]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
define likely() and unlikely() and use them to prevent debugging code from being...
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 11 Nov 2011 12:52:45 +0000 (13:52 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 11 Nov 2011 12:52:45 +0000 (13:52 +0100)
lib/gnutls_errors.h
lib/gnutls_int.h

index 8f1c05d9edae572ffaf633afefef8e319ae2a1b2..9907c63a62dd04fef348773ba282772dffa8549b 100644 (file)
@@ -58,10 +58,10 @@ _gnutls_audit_log (gnutls_session_t, const char *fmt, ...)
 void _gnutls_mpi_log (const char *prefix, bigint_t a);
 
 #ifdef C99_MACROS
-#define LEVEL(l, ...) do { if (_gnutls_log_level >= l || _gnutls_log_level > 9) \
+#define LEVEL(l, ...) do { if (unlikely(_gnutls_log_level >= l || _gnutls_log_level > 9)) \
       _gnutls_log( l, __VA_ARGS__); } while(0)
 
-#define LEVEL_EQ(l, ...) do { if (_gnutls_log_level == l || _gnutls_log_level > 9) \
+#define LEVEL_EQ(l, ...) do { if (unlikely(_gnutls_log_level == l || _gnutls_log_level > 9)) \
       _gnutls_log( l, __VA_ARGS__); } while(0)
 
 #define _gnutls_debug_log(...) LEVEL(2, __VA_ARGS__)
index 4818eebaebe5795f270f49f5e3426fe026692aa2..92acdd26c6284b58e1d41a906a70d069c955e631 100644 (file)
@@ -58,6 +58,21 @@ typedef int ssize_t;
 # define memxor gl_memxor
 #endif
 
+#ifdef __GNUC__
+# ifndef _GNUTLS_GCC_VERSION
+#  define _GNUTLS_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+# endif
+# if _GNUTLS_GCC_VERSION >= 30100
+#  define likely(x)      __builtin_expect((x), 1)
+#  define unlikely(x)    __builtin_expect((x), 0)
+# endif
+#endif
+
+#ifndef likely
+# define likely
+# define unlikely
+#endif
+
 /* some systems had problems with long long int, thus,
  * it is not used.
  */