1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Make use of the _byteswap_ushort() and _byteswap_ulong() compiler intrinsics for MSVC, when available.

FossilOrigin-Name: fe144dd73f7097a17c24c7812c2a1cc40466e6da
This commit is contained in:
mistachkin
2015-06-30 17:28:40 +00:00
parent da6d3e2117
commit 647ca46fc5
5 changed files with 29 additions and 11 deletions

View File

@@ -1086,6 +1086,10 @@ u32 sqlite3Get4byte(const u8 *p){
u32 x;
memcpy(&x,p,4);
return __builtin_bswap32(x);
#elif SQLITE_BYTEORDER==1234 && defined(_MSC_VER) && _MSC_VER>=1300
u32 x;
memcpy(&x,p,4);
return _byteswap_ulong(x);
#else
testcase( p[0]&0x80 );
return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
@@ -1097,6 +1101,9 @@ void sqlite3Put4byte(unsigned char *p, u32 v){
#elif SQLITE_BYTEORDER==1234 && defined(__GNUC__)
u32 x = __builtin_bswap32(v);
memcpy(p,&x,4);
#elif SQLITE_BYTEORDER==1234 && defined(_MSC_VER) && _MSC_VER>=1300
u32 x = _byteswap_ulong(v);
memcpy(p,&x,4);
#else
p[0] = (u8)(v>>24);
p[1] = (u8)(v>>16);