diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sqliteInt.h | 10 | ||||
-rw-r--r-- | src/status.c | 2 | ||||
-rw-r--r-- | src/util.c | 10 |
3 files changed, 15 insertions, 7 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h index c034d6841..e57453e67 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -110,6 +110,14 @@ # define GCC_VERSION 0 #endif +/* What version of CLANG is being used. 0 means GCC is not being used */ +#ifdef __clang__ +# define CLANG_VERSION \ + (__clang_major__*1000000+__clang_minor__*1000+__clang_patchlevel__) +#else +# define CLANG_VERSION 0 +#endif + /* Needed for various definitions... */ #if defined(__GNUC__) && !defined(_GNU_SOURCE) # define _GNU_SOURCE @@ -233,7 +241,7 @@ ** the sqlite3StatusDown() function is threadsafe. */ #if !defined(SQLITE_DISABLE_INTRINSIC) \ - && defined(__GNUC__) && GCC_VERSION>=4004000 + && (GCC_VERSION>=4004000 || CLANG_VERSION>=3000000) # define SQLITE_ATOMIC_STATUS_DOWN 1 #endif diff --git a/src/status.c b/src/status.c index 5e8fbc2ee..f36f36724 100644 --- a/src/status.c +++ b/src/status.c @@ -102,7 +102,7 @@ void sqlite3StatusDown(int op, int N){ assert( N>=0 ); assert( op>=0 && op<ArraySize(wsdStat.nowValue) ); #if !defined(SQLITE_DISABLE_INTRINSIC) \ - && defined(__GNUC__) && GCC_VERSION>=4004000 + && (GCC_VERSION>=4004000 || CLANG_VERSION>=3000000) (void)__sync_fetch_and_sub(&wsdStat.nowValue[op], N); #else assert( op>=0 && op<ArraySize(statMutex) ); diff --git a/src/util.c b/src/util.c index 4a2266ee6..ca14ab852 100644 --- a/src/util.c +++ b/src/util.c @@ -1141,7 +1141,7 @@ u32 sqlite3Get4byte(const u8 *p){ memcpy(&x,p,4); return x; #elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \ - && defined(__GNUC__) && GCC_VERSION>=4003000 + && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000) u32 x; memcpy(&x,p,4); return __builtin_bswap32(x); @@ -1159,7 +1159,7 @@ void sqlite3Put4byte(unsigned char *p, u32 v){ #if SQLITE_BYTEORDER==4321 memcpy(p,&v,4); #elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \ - && defined(__GNUC__) && GCC_VERSION>=4003000 + && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000) u32 x = __builtin_bswap32(v); memcpy(p,&x,4); #elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \ @@ -1280,7 +1280,7 @@ int sqlite3SafetyCheckSickOrOk(sqlite3 *db){ */ int sqlite3AddInt64(i64 *pA, i64 iB){ #if !defined(SQLITE_DISABLE_INTRINSIC) \ - && defined(__GNUC__) && GCC_VERSION>=5004000 + && (GCC_VERSION>=5004000 || CLANG_VERSION>=4000000) return __builtin_add_overflow(*pA, iB, pA); #else i64 iA = *pA; @@ -1301,7 +1301,7 @@ int sqlite3AddInt64(i64 *pA, i64 iB){ } int sqlite3SubInt64(i64 *pA, i64 iB){ #if !defined(SQLITE_DISABLE_INTRINSIC) \ - && defined(__GNUC__) && GCC_VERSION>=5004000 + && (GCC_VERSION>=5004000 || CLANG_VERSION>=4000000) return __builtin_sub_overflow(*pA, iB, pA); #else testcase( iB==SMALLEST_INT64+1 ); @@ -1317,7 +1317,7 @@ int sqlite3SubInt64(i64 *pA, i64 iB){ } int sqlite3MulInt64(i64 *pA, i64 iB){ #if !defined(SQLITE_DISABLE_INTRINSIC) \ - && defined(__GNUC__) && GCC_VERSION>=5004000 + && (GCC_VERSION>=5004000 || CLANG_VERSION>=4000000) return __builtin_mul_overflow(*pA, iB, pA); #else i64 iA = *pA; |