commit ba7891b363b313a41bab4859efa5bf15ed4fa077
parent 8b14c940874cad6b6538e5850f8c6d131e032f97
Author: Michael Savage <mikejsavage@gmail.com>
Date: Tue, 23 Dec 2014 17:41:49 +0000
Update safebfuns
Diffstat:
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/compat/safebfuns.c b/compat/safebfuns.c
@@ -5,13 +5,13 @@
#if __clang__
/*
* http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
- * https://www.mail-archive.com/cfe-commits@cs.uiuc.edu/msg97459.html
+ * http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-December/040627.html
*/
- #if __clang_major__ > 3 || ( __clang_major__ == 3 && __clang_minor__ >= 5 )
- #pragma clang optimize off
+ #if __has_attribute( noinline ) && __has_attribute( optnone )
+ #define NOOPT __attribute__ (( optnone ))
#define NOINLINE __attribute__ (( noinline ))
#else
- #error "require clang >= 3.5"
+ #error "require clang with noinline and optnone attributes"
#endif
#elif __GNUC__
/*
@@ -19,17 +19,17 @@
* http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
*/
#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )
- #pragma GCC push_options
- #pragma GCC optimize ( "-O0" )
+ #define NOOPT __attribute__ (( optimize( 0 ) ))
#define NOINLINE __attribute__ (( noinline ))
#else
#error "require gcc >= 4.4"
#endif
#else
#error "unrecognised compiler"
+ explode
#endif
-NOINLINE void explicit_bzero( void * const buf, const size_t n ) {
+NOOPT NOINLINE void explicit_bzero( void * const buf, const size_t n ) {
size_t i;
unsigned char * p = buf;
@@ -38,7 +38,7 @@ NOINLINE void explicit_bzero( void * const buf, const size_t n ) {
}
}
-NOINLINE int timingsafe_bcmp( const void * const b1, const void * const b2, const size_t n ) {
+NOOPT NOINLINE int timingsafe_bcmp( const void * const b1, const void * const b2, const size_t n ) {
size_t i;
const unsigned char * const p1 = b1;
const unsigned char * const p2 = b2;
@@ -71,7 +71,7 @@ NOINLINE int timingsafe_bcmp( const void * const b1, const void * const b2, cons
#include <limits.h>
#include <string.h>
-NOINLINE int timingsafe_memcmp( const void * const b1, const void * const b2, const size_t len ) {
+NOOPT NOINLINE int timingsafe_memcmp( const void * const b1, const void * const b2, const size_t len ) {
const unsigned char * p1 = b1;
const unsigned char * p2 = b2;
size_t i;
@@ -96,11 +96,3 @@ NOINLINE int timingsafe_memcmp( const void * const b1, const void * const b2, co
return res;
}
-
-/* Public domain */
-
-#ifdef __clang__
- #pragma clang optimize on
-#else
- #pragma GCC pop_options
-#endif