From 23f269562b7537b2f6f5014e50a25e5dcc55a837 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 3 Sep 2014 05:33:25 +1000 Subject: [PATCH] - (djm) [defines.h sshbuf.c] Move __predict_true|false to defines.h and conditionalise to avoid duplicate definition. --- ChangeLog | 4 ++++ defines.h | 13 ++++++++++++- sshbuf.c | 10 ---------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 97eb0a8c2..128368da4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +20140903 + - (djm) [defines.h sshbuf.c] Move __predict_true|false to defines.h and + conditionalise to avoid duplicate definition. + 20140830 - (djm) [openbsd-compat/openssl-compat.h] add OPENSSL_[RD]SA_MAX_MODULUS_BITS defines for OpenSSL that lacks them diff --git a/defines.h b/defines.h index f1deafa61..3ac8be987 100644 --- a/defines.h +++ b/defines.h @@ -25,7 +25,7 @@ #ifndef _DEFINES_H #define _DEFINES_H -/* $Id: defines.h,v 1.182 2014/06/16 12:50:56 dtucker Exp $ */ +/* $Id: defines.h,v 1.183 2014/09/02 19:33:26 djm Exp $ */ /* Constants */ @@ -830,4 +830,15 @@ struct winsize { # endif #endif +#ifndef __predict_true +# if defined(__GNUC__) && \ + ((__GNUC__ > (2)) || (__GNUC__ == (2) && __GNUC_MINOR__ >= (96))) +# define __predict_true(exp) __builtin_expect(((exp) != 0), 1) +# define __predict_false(exp) __builtin_expect(((exp) != 0), 0) +# else +# define __predict_true(exp) ((exp) != 0) +# define __predict_false(exp) ((exp) != 0) +# endif /* gcc version */ +#endif /* __predict_true */ + #endif /* _DEFINES_H */ diff --git a/sshbuf.c b/sshbuf.c index 5df7c9f46..78f5340a1 100644 --- a/sshbuf.c +++ b/sshbuf.c @@ -28,16 +28,6 @@ #include "ssherr.h" #include "sshbuf.h" -/* XXX move to defines.h? */ -#if defined(__GNUC__) && \ - ((__GNUC__ > (2)) || (__GNUC__ == (2) && __GNUC_MINOR__ >= (96))) -#define __predict_true(exp) __builtin_expect(((exp) != 0), 1) -#define __predict_false(exp) __builtin_expect(((exp) != 0), 0) -#else -#define __predict_true(exp) ((exp) != 0) -#define __predict_false(exp) ((exp) != 0) -#endif - static inline int sshbuf_check_sanity(const struct sshbuf *buf) {