From f028460d0b2e5a584355321015cde69bf6fd933e Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Thu, 1 May 2014 02:24:35 +1000 Subject: [PATCH] - (dtucker) [defines.h] Define __GNUC_PREREQ__ macro if we don't already have it. Only attempt to use __attribute__(__bounded__) for gcc. --- ChangeLog | 4 ++++ defines.h | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 541db38c4..7bff5fba7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +20140430 + - (dtucker) [defines.h] Define __GNUC_PREREQ__ macro if we don't already + have it. Only attempt to use __attribute__(__bounded__) for gcc. + 20140420 - OpenBSD CVS Sync - djm@cvs.openbsd.org 2014/03/03 22:22:30 diff --git a/defines.h b/defines.h index 41861fbba..928bd9b01 100644 --- a/defines.h +++ b/defines.h @@ -25,7 +25,7 @@ #ifndef _DEFINES_H #define _DEFINES_H -/* $Id: defines.h,v 1.177 2014/04/20 03:21:23 djm Exp $ */ +/* $Id: defines.h,v 1.178 2014/04/30 16:24:35 dtucker Exp $ */ /* Constants */ @@ -826,9 +826,17 @@ struct winsize { # define arc4random_stir() #endif +/* Macro to test if we're using a specific version of gcc or later. */ +#if defined(__GNUC__) && !defined(__GNUC_PREREQ__) +#define __GNUC_PREREQ__(ma, mi) \ + ((__GNUC__ > (ma)) || (__GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))) +#else +#define __GNUC_PREREQ__(ma, mi) 0 +#endif + /* __bounded macro */ #ifndef __bounded -# if __GNUC_PREREQ__(3,3) && !defined(__clang__) +# if defined(__GNUC__) && __GNUC_PREREQ__(3,3) && !defined(__clang__) # define __bounded(args) __attribute__ ((__bounded__ args )) # else # define __bounded(args) /* delete */