#include <crypt.h>
#endif
+#ifdef __GNUC__
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#define likely(x) __builtin_expect(!!(x), 1)
+#else
+#define unlikely(x) x
+#define likely(x) x
+#endif
+
#ifdef CASSERT
-#define Assert(e) do { if (!(e)) { \
+#define Assert(e) do { if (unlikely(!(e))) { \
fatal_noexit("Assert(%s) failed", #e); abort(); } } while (0)
#else
#define Assert(e)
#define log_warning(args...) log_level("WARNING", ## args)
#define log_info(args...) log_level("LOG", ## args)
#define log_debug(args...) do { \
- if (cf_verbose > 0) log_level("DEBUG", ## args); \
+ if (unlikely(cf_verbose > 0)) \
+ log_level("DEBUG", ## args); \
} while (0)
#define log_noise(args...) do { \
- if (cf_verbose > 1) log_level("NOISE", ## args); \
+ if (unlikely(cf_verbose > 1)) \
+ log_level("NOISE", ## args); \
} while (0)
void close_logfile(void);
#define slog_warning(sk, args...) slog_level("WARNING", sk, ## args)
#define slog_info(sk, args...) slog_level("LOG", sk, ## args)
#define slog_debug(sk, args...) do { \
- if (cf_verbose > 0) slog_level("DEBUG", sk, ## args); \
+ if (unlikely(cf_verbose > 0)) \
+ slog_level("DEBUG", sk, ## args); \
} while (0)
#define slog_noise(sk, args...) do { \
- if (cf_verbose > 1) slog_level("NOISE", sk, ## args); \
+ if (unlikely(cf_verbose > 1)) \
+ slog_level("NOISE", sk, ## args); \
} while (0)
/*