/ Check-in [9c696196]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9c6961967ae00e563ebe2859eaf2639a79f2cb01
User & Date: drh 2014-04-18 00:06:02
Context
2014-04-18
00:49
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. check-in: 2c536387 user: drh tags: trunk
00:08
Preliminary changes to support building VSIX packages for Windows Phone 8.1. check-in: a1b2f28b user: mistachkin tags: vsixWinPhone81
00:06
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. check-in: 9c696196 user: drh tags: trunk
2014-04-14
19:48
Make sure the undocumented sqlite_rename_parent() function does not crash even if it is invoked with NULL arguments. Ticket [264b970c4379fd4b94] check-in: c6fa8d0d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

  3200   3200       **    }
  3201   3201       */
  3202   3202       case SQLITE_TESTCTRL_ALWAYS: {
  3203   3203         int x = va_arg(ap,int);
  3204   3204         rc = ALWAYS(x);
  3205   3205         break;
  3206   3206       }
         3207  +
         3208  +    /*
         3209  +    **   sqlite3_test_control(SQLITE_TESTCTRL_BYTEORDER);
         3210  +    **
         3211  +    ** The integer returned reveals the byte-order of the computer on which
         3212  +    ** SQLite is running:
         3213  +    **
         3214  +    **       1     big-endian,    determined at run-time
         3215  +    **      10     little-endian, determined at run-time
         3216  +    **  432101     big-endian,    determined at compile-time
         3217  +    **  123410     little-endian, determined at compile-time
         3218  +    */ 
         3219  +    case SQLITE_TESTCTRL_BYTEORDER: {
         3220  +      rc = SQLITE_BYTEORDER*100 + SQLITE_LITTLEENDIAN*10 + SQLITE_BIGENDIAN;
         3221  +      break;
         3222  +    }
  3207   3223   
  3208   3224       /*   sqlite3_test_control(SQLITE_TESTCTRL_RESERVE, sqlite3 *db, int N)
  3209   3225       **
  3210   3226       ** Set the nReserve size to N for the main database on the database
  3211   3227       ** connection db.
  3212   3228       */
  3213   3229       case SQLITE_TESTCTRL_RESERVE: {

Changes to src/shell.c.

  3023   3023         { "pending_byte",          SQLITE_TESTCTRL_PENDING_BYTE           },
  3024   3024         { "assert",                SQLITE_TESTCTRL_ASSERT                 },
  3025   3025         { "always",                SQLITE_TESTCTRL_ALWAYS                 },
  3026   3026         { "reserve",               SQLITE_TESTCTRL_RESERVE                },
  3027   3027         { "optimizations",         SQLITE_TESTCTRL_OPTIMIZATIONS          },
  3028   3028         { "iskeyword",             SQLITE_TESTCTRL_ISKEYWORD              },
  3029   3029         { "scratchmalloc",         SQLITE_TESTCTRL_SCRATCHMALLOC          },
         3030  +      { "byteorder",             SQLITE_TESTCTRL_BYTEORDER              },
  3030   3031       };
  3031   3032       int testctrl = -1;
  3032   3033       int rc = 0;
  3033   3034       int i, n;
  3034   3035       open_db(p, 0);
  3035   3036   
  3036   3037       /* convert testctrl text option to value. allow any unique prefix
................................................................................
  3063   3064             } else {
  3064   3065               fprintf(stderr,"Error: testctrl %s takes a single int option\n",
  3065   3066                       azArg[1]);
  3066   3067             }
  3067   3068             break;
  3068   3069   
  3069   3070           /* sqlite3_test_control(int) */
  3070         -        case SQLITE_TESTCTRL_PRNG_SAVE:           
  3071         -        case SQLITE_TESTCTRL_PRNG_RESTORE:        
         3071  +        case SQLITE_TESTCTRL_PRNG_SAVE:
         3072  +        case SQLITE_TESTCTRL_PRNG_RESTORE:
  3072   3073           case SQLITE_TESTCTRL_PRNG_RESET:
         3074  +        case SQLITE_TESTCTRL_BYTEORDER:
  3073   3075             if( nArg==2 ){
  3074   3076               rc = sqlite3_test_control(testctrl);
  3075   3077               fprintf(p->out, "%d (0x%08x)\n", rc, rc);
  3076   3078             } else {
  3077   3079               fprintf(stderr,"Error: testctrl %s takes no options\n", azArg[1]);
  3078   3080             }
  3079   3081             break;

Changes to src/sqlite.h.in.

  6114   6114   #define SQLITE_TESTCTRL_OPTIMIZATIONS           15
  6115   6115   #define SQLITE_TESTCTRL_ISKEYWORD               16
  6116   6116   #define SQLITE_TESTCTRL_SCRATCHMALLOC           17
  6117   6117   #define SQLITE_TESTCTRL_LOCALTIME_FAULT         18
  6118   6118   #define SQLITE_TESTCTRL_EXPLAIN_STMT            19
  6119   6119   #define SQLITE_TESTCTRL_NEVER_CORRUPT           20
  6120   6120   #define SQLITE_TESTCTRL_VDBE_COVERAGE           21
  6121         -#define SQLITE_TESTCTRL_LAST                    21
         6121  +#define SQLITE_TESTCTRL_BYTEORDER               22
         6122  +#define SQLITE_TESTCTRL_LAST                    22
  6122   6123   
  6123   6124   /*
  6124   6125   ** CAPI3REF: SQLite Runtime Status
  6125   6126   **
  6126   6127   ** ^This interface is used to retrieve runtime status information
  6127   6128   ** about the performance of SQLite, and optionally to reset various
  6128   6129   ** highwater marks.  ^The first argument is an integer code for

Changes to src/sqliteInt.h.

   549    549   ** evaluated at runtime.
   550    550   */
   551    551   #ifdef SQLITE_AMALGAMATION
   552    552   const int sqlite3one = 1;
   553    553   #else
   554    554   extern const int sqlite3one;
   555    555   #endif
   556         -#if defined(i386) || defined(__i386__) || defined(_M_IX86)\
   557         -                             || defined(__x86_64) || defined(__x86_64__)
          556  +#if   defined(i386)     || defined(__i386__)   || defined(_M_IX86)     \
          557  +   || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)      \
          558  +   || defined(_M_AMD64) || defined(_M_ARM)     || defined(__x86)
          559  +# define SQLITE_BYTEORDER    1234
   558    560   # define SQLITE_BIGENDIAN    0
   559    561   # define SQLITE_LITTLEENDIAN 1
   560    562   # define SQLITE_UTF16NATIVE  SQLITE_UTF16LE
   561    563   #else
          564  +# define SQLITE_BYTEORDER    0     /* 0 means "unknown at compile-time" */
   562    565   # define SQLITE_BIGENDIAN    (*(char *)(&sqlite3one)==0)
   563    566   # define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)
   564         -# define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)
          567  +# define SQLITE_UTF16NATIVE  (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)
   565    568   #endif
   566    569   
   567    570   /*
   568    571   ** Constants for the largest and smallest possible 64-bit signed integers.
   569    572   ** These macros are designed to work correctly on both 32-bit and 64-bit
   570    573   ** compilers.
   571    574   */