--- sqlite3.orig/sqlite3.c 2024-02-12 21:32:10.804005193 +0100 +++ sqlite3/sqlite3.c 2025-01-30 17:42:00.624509041 +0100 @@ -13915,7 +13915,7 @@ ** Macros to hint to the compiler that a function should or should not be ** inlined. */ -#if defined(__GNUC__) +#if defined(__GNUC__) && (__GNUC__>=4 || (__GNUC__==3 && __GNUC_MINOR__>=1)) # define SQLITE_NOINLINE __attribute__((noinline)) # define SQLITE_INLINE __attribute__((always_inline)) inline #elif defined(_MSC_VER) && _MSC_VER>=1310 @@ -34853,6 +34853,17 @@ return h; } +#if defined( __BORLANDC__ ) +# if __BORLANDC__ >= 0x530 +# define _LL( num ) num##i64 +# else +# define _LL( num ) num +# endif +#elif defined( _MSC_VER ) +# define _LL( num ) num +#else +# define _LL( num ) num##LL +#endif /* Double-Double multiplication. (x[0],x[1]) *= (y,yy) ** ** Reference: @@ -34872,11 +34883,11 @@ double hx, hy; u64 m; memcpy(&m, (void*)&x[0], 8); - m &= 0xfffffffffc000000LL; + m &= _LL(0xfffffffffc000000); memcpy(&hx, &m, 8); tx = x[0] - hx; memcpy(&m, &y, 8); - m &= 0xfffffffffc000000LL; + m &= _LL(0xfffffffffc000000); memcpy(&hy, &m, 8); ty = y - hy; p = hx*hy; @@ -35441,7 +35452,7 @@ memcpy(&v,&r,8); e = v>>52; if( (e&0x7ff)==0x7ff ){ - p->isSpecial = 1 + (v!=0x7ff0000000000000LL); + p->isSpecial = 1 + (v!=_LL(0x7ff0000000000000)); p->n = 0; p->iDP = 0; return; @@ -35561,7 +35572,7 @@ int i; for(i=0; sqlite3Isdigit(z[i]); i++){ v = v*10 + z[i] - '0'; - if( v>4294967296LL ){ *pI = 0; return 0; } + if( v>_LL(4294967296) ){ *pI = 0; return 0; } } if( i==0 || z[i]!=0 ){ *pI = 0; return 0; } *pI = (u32)v; @@ -41770,7 +41781,11 @@ ** This is a similar technique to that used by glibc on systems ** that do not have a real fallocate() call. */ +#if __minix + int nBlk = 4096; /* MFS default; good enough for now */ +#else int nBlk = buf.st_blksize; /* File-system block size */ +#endif int nWrite = 0; /* Number of bytes written by seekAndWrite */ i64 iWrite; /* Next offset to write to */ @@ -48194,7 +48209,7 @@ SYSTEMTIME pTm; sqlite3_int64 t64; t64 = *t; - t64 = (t64 + 11644473600)*10000000; + t64 = (t64 + _LL(11644473600))*10000000; uTm.dwLowDateTime = (DWORD)(t64 & 0xFFFFFFFF); uTm.dwHighDateTime= (DWORD)(t64 >> 32); osFileTimeToLocalFileTime(&uTm,&lTm); @@ -82701,7 +82716,7 @@ double r2 = (double)i; return r1==0.0 || (memcmp(&r1, &r2, sizeof(r1))==0 - && i >= -2251799813685248LL && i < 2251799813685248LL); + && i >= _LL(-2251799813685248) && i < _LL(2251799813685248)); } /* Convert a floating point value to its closest integer. Do so in @@ -95469,7 +95484,7 @@ testcase( pIn1->u.i==140737488355327LL ); testcase( pIn1->u.i==-140737488355328LL ); testcase( pIn1->u.i==-140737488355329LL ); - if( pIn1->u.i<=140737488355327LL && pIn1->u.i>=-140737488355328LL){ + if( pIn1->u.i<=_LL(140737488355327) && pIn1->u.i>=_LL(-140737488355328)){ pIn1->flags |= MEM_IntReal; pIn1->flags &= ~MEM_Int; }else{ @@ -95532,7 +95547,7 @@ testcase( pIn1->u.i==140737488355327LL ); testcase( pIn1->u.i==-140737488355328LL ); testcase( pIn1->u.i==-140737488355329LL ); - if( pIn1->u.i<=140737488355327LL && pIn1->u.i>=-140737488355328LL ){ + if( pIn1->u.i<=_LL(140737488355327) && pIn1->u.i>=_LL(-140737488355328) ){ pIn1->flags |= MEM_IntReal; pIn1->flags &= ~MEM_Int; }else{ @@ -95732,7 +95747,7 @@ }else if( uu<=2147483647 ){ nData += 4; pRec->uTemp = 4; - }else if( uu<=140737488355327LL ){ + }else if( uu<=_LL(140737488355327) ){ nData += 6; pRec->uTemp = 5; }else{ @@ -102360,7 +102375,8 @@ /* Copy as much data as is available in the buffer into the start of ** p->aAlloc[]. */ - memcpy(p->aAlloc, &p->aBuffer[iBuf], nAvail); + if( nAvail > 0 ) + memcpy(p->aAlloc, &p->aBuffer[iBuf], nAvail); p->iReadOff += nAvail; nRem = nByte - nAvail; @@ -120162,6 +120178,10 @@ */ /* #include "sqliteInt.h" */ +#if defined( __GNUC__ ) && __GNUC__ >= 14 +# pragma GCC diagnostic ignored "-Wstringop-overread" +#endif + #ifndef SQLITE_OMIT_SHARED_CACHE /* ** The TableLock structure is only used by the sqlite3TableLock() and @@ -129191,7 +129211,7 @@ ** Add a (possibly large) integer to the running sum. */ static void kahanBabuskaNeumaierStepInt64(volatile SumCtx *pSum, i64 iVal){ - if( iVal<=-4503599627370496LL || iVal>=+4503599627370496LL ){ + if( iVal<=_LL(-4503599627370496) || iVal>=_LL(+4503599627370496) ){ i64 iBig, iSm; iSm = iVal % 16384; iBig = iVal - iSm; @@ -129209,7 +129229,7 @@ volatile SumCtx *p, i64 iVal ){ - if( iVal<=-4503599627370496LL || iVal>=+4503599627370496LL ){ + if( iVal<=_LL(-4503599627370496) || iVal>=_LL(+4503599627370496) ){ i64 iSm = iVal % 16384; p->rSum = (double)(iVal - iSm); p->rErr = (double)iSm; @@ -203696,7 +203716,7 @@ ** A macro to hint to the compiler that a function should not be ** inlined. */ -#if defined(__GNUC__) +#if defined(__GNUC__) && (__GNUC__>=4 || (__GNUC__==3 && __GNUC_MINOR__>=1)) # define JSON_NOINLINE __attribute__((noinline)) #elif defined(_MSC_VER) && _MSC_VER>=1310 # define JSON_NOINLINE __declspec(noinline)