diff options
author | drh <drh@noemail.net> | 2014-04-18 00:49:29 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2014-04-18 00:49:29 +0000 |
commit | 71794dbaeb73f594ef704fa265715b207f98edc7 (patch) | |
tree | 1d6f19502f186c633c22a4acccc3f29df91b66af /src/sqliteInt.h | |
parent | 2cf4acbd9f774e1c7bbaa232edbbdf93cff553ee (diff) | |
download | sqlite-71794dbaeb73f594ef704fa265715b207f98edc7.tar.gz sqlite-71794dbaeb73f594ef704fa265715b207f98edc7.zip |
Add the SQLITE_RUNTIME_BYTEORDER compile-time option to force SQLite to check
the processor byte-order at run-time. Add additional compile-time byte order
checks for ARM, PPC, and SPARC.
FossilOrigin-Name: 2c5363873a6f990a0abaacac6303acd46b48befc
Diffstat (limited to 'src/sqliteInt.h')
-rw-r--r-- | src/sqliteInt.h | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 2a12466a4..8197a61eb 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -546,21 +546,35 @@ typedef INT16_TYPE LogEst; /* ** Macros to determine whether the machine is big or little endian, -** evaluated at runtime. +** and whether or not that determination is run-time or compile-time. +** +** For best performance, an attempt is made to guess at the byte-order +** using C-preprocessor macros. If that is unsuccessful, or if +** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined +** at run-time. */ #ifdef SQLITE_AMALGAMATION const int sqlite3one = 1; #else extern const int sqlite3one; #endif -#if defined(i386) || defined(__i386__) || defined(_M_IX86) \ - || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) \ - || defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) +#if (defined(i386) || defined(__i386__) || defined(_M_IX86) || \ + defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ + defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ + defined(__arm__)) && !defined(SQLITE_RUNTIME_BYTEORDER) # define SQLITE_BYTEORDER 1234 # define SQLITE_BIGENDIAN 0 # define SQLITE_LITTLEENDIAN 1 # define SQLITE_UTF16NATIVE SQLITE_UTF16LE -#else +#endif +#if (defined(sparc) || defined(__ppc__)) \ + && !defined(SQLITE_RUNTIME_BYTEORDER) +# define SQLITE_BYTEORDER 4321 +# define SQLITE_BIGENDIAN 1 +# define SQLITE_LITTLEENDIAN 0 +# define SQLITE_UTF16NATIVE SQLITE_UTF16BE +#endif +#if !defined(SQLITE_BYTEORDER) # define SQLITE_BYTEORDER 0 /* 0 means "unknown at compile-time" */ # define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0) # define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1) |