diff options
author | drh <drh@noemail.net> | 2014-04-18 00:06:02 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2014-04-18 00:06:02 +0000 |
commit | 2cf4acbd9f774e1c7bbaa232edbbdf93cff553ee (patch) | |
tree | 170d5be2943980d96eaa4c4eb15d612d03df3ccd /src | |
parent | 65b9ac522430cdc55855b24de406c54d12199346 (diff) | |
download | sqlite-2cf4acbd9f774e1c7bbaa232edbbdf93cff553ee.tar.gz sqlite-2cf4acbd9f774e1c7bbaa232edbbdf93cff553ee.zip |
Add the SQLITE_TESTCTRL_BYTEORDER test control to interrogate SQLite's notion
of the processor byte order and whether the byte order is known at compile-time
or determined at run-time.
FossilOrigin-Name: 9c6961967ae00e563ebe2859eaf2639a79f2cb01
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 16 | ||||
-rw-r--r-- | src/shell.c | 6 | ||||
-rw-r--r-- | src/sqlite.h.in | 3 | ||||
-rw-r--r-- | src/sqliteInt.h | 9 |
4 files changed, 28 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c index 9e83d4963..65521f446 100644 --- a/src/main.c +++ b/src/main.c @@ -3205,6 +3205,22 @@ int sqlite3_test_control(int op, ...){ break; } + /* + ** sqlite3_test_control(SQLITE_TESTCTRL_BYTEORDER); + ** + ** The integer returned reveals the byte-order of the computer on which + ** SQLite is running: + ** + ** 1 big-endian, determined at run-time + ** 10 little-endian, determined at run-time + ** 432101 big-endian, determined at compile-time + ** 123410 little-endian, determined at compile-time + */ + case SQLITE_TESTCTRL_BYTEORDER: { + rc = SQLITE_BYTEORDER*100 + SQLITE_LITTLEENDIAN*10 + SQLITE_BIGENDIAN; + break; + } + /* sqlite3_test_control(SQLITE_TESTCTRL_RESERVE, sqlite3 *db, int N) ** ** Set the nReserve size to N for the main database on the database diff --git a/src/shell.c b/src/shell.c index f380962a8..61965d2d3 100644 --- a/src/shell.c +++ b/src/shell.c @@ -3027,6 +3027,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ { "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS }, { "iskeyword", SQLITE_TESTCTRL_ISKEYWORD }, { "scratchmalloc", SQLITE_TESTCTRL_SCRATCHMALLOC }, + { "byteorder", SQLITE_TESTCTRL_BYTEORDER }, }; int testctrl = -1; int rc = 0; @@ -3067,9 +3068,10 @@ static int do_meta_command(char *zLine, struct callback_data *p){ break; /* sqlite3_test_control(int) */ - case SQLITE_TESTCTRL_PRNG_SAVE: - case SQLITE_TESTCTRL_PRNG_RESTORE: + case SQLITE_TESTCTRL_PRNG_SAVE: + case SQLITE_TESTCTRL_PRNG_RESTORE: case SQLITE_TESTCTRL_PRNG_RESET: + case SQLITE_TESTCTRL_BYTEORDER: if( nArg==2 ){ rc = sqlite3_test_control(testctrl); fprintf(p->out, "%d (0x%08x)\n", rc, rc); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 5d2c87552..e8dddc468 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -6118,7 +6118,8 @@ int sqlite3_test_control(int op, ...); #define SQLITE_TESTCTRL_EXPLAIN_STMT 19 #define SQLITE_TESTCTRL_NEVER_CORRUPT 20 #define SQLITE_TESTCTRL_VDBE_COVERAGE 21 -#define SQLITE_TESTCTRL_LAST 21 +#define SQLITE_TESTCTRL_BYTEORDER 22 +#define SQLITE_TESTCTRL_LAST 22 /* ** CAPI3REF: SQLite Runtime Status diff --git a/src/sqliteInt.h b/src/sqliteInt.h index da46676ad..2a12466a4 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -553,15 +553,18 @@ const int sqlite3one = 1; #else extern const int sqlite3one; #endif -#if defined(i386) || defined(__i386__) || defined(_M_IX86)\ - || defined(__x86_64) || defined(__x86_64__) +#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) +# define SQLITE_BYTEORDER 1234 # define SQLITE_BIGENDIAN 0 # define SQLITE_LITTLEENDIAN 1 # define SQLITE_UTF16NATIVE SQLITE_UTF16LE #else +# define SQLITE_BYTEORDER 0 /* 0 means "unknown at compile-time" */ # define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0) # define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1) -# define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) +# define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) #endif /* |