aboutsummaryrefslogtreecommitdiffstats
path: root/common.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-01-19 20:28:55 +0100
committerMattias Andrée <maandree@kth.se>2022-01-19 20:28:55 +0100
commit5d77a0178349ecac6536e0374cf689500efa22bc (patch)
treef6fcb38cd39e8f4240537233a08fdbb5c0284798 /common.h
parentImprove portability (diff)
downloadlibblake-5d77a0178349ecac6536e0374cf689500efa22bc.tar.gz
libblake-5d77a0178349ecac6536e0374cf689500efa22bc.tar.bz2
libblake-5d77a0178349ecac6536e0374cf689500efa22bc.tar.xz
Optimisation for amd64
Increased major number as the ABI was broken by insertion of padding into the BLAKE2 parameter structures (except for BLAKE2Xs) Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'common.h')
-rw-r--r--common.h31
1 files changed, 30 insertions, 1 deletions
diff --git a/common.h b/common.h
index b1920dc..3f9dce0 100644
--- a/common.h
+++ b/common.h
@@ -24,9 +24,38 @@
#endif
#if defined(__GNUC__)
-# define HIDDEN __attribute__((__visibility__("hidden")))
+# define HIDDEN __attribute__((visibility("hidden")))
+# define LIKELY(X) __builtin_expect(!!(X), 1)
+# define UNLIKELY(X) __builtin_expect(!!(X), 0)
+# define ASSUMING_CONSTANT(X) (__builtin_constant_p(X) && (X))
#else
# define HIDDEN
+# define LIKELY(X) X
+# define UNLIKELY(X) X
+# define ASSUMING_CONSTANT(X) 0
+# if defined(__has_builtin)
+# if __has_builtin(__builtin_expect)
+# undef LIKELY
+# undef UNLIKELY
+# define LIKELY(X) __builtin_expect(!!(X), 1)
+# define UNLIKELY(X) __builtin_expect(!!(X), 0)
+# endif
+# if __has_builtin(__builtin_constant_p)
+# undef ASSUMING_CONSTANT
+# define ASSUMING_CONSTANT(X) (__builtin_constant_p(X) && (X))
+# endif
+# endif
+#endif
+#if defined(__has_builtin)
+# define HAS_BUILTIN(X) __has_builtin(X)
+#else
+# define HAS_BUILTIN(X) 0
+#endif
+
+#if defined(__x86_64__) || defined(__i386__)
+# define LITTLE_ENDIAN
+#else
+# error Endian is unknown
#endif
#define A 10