aboutsummaryrefslogtreecommitdiff
path: root/ext/misc/series.c
diff options
context:
space:
mode:
authordrh <>2024-01-16 14:54:54 +0000
committerdrh <>2024-01-16 14:54:54 +0000
commit9239fb59ad74b1fee03ea99e86dddf3726dd7bf4 (patch)
tree80de6d3cd16f6facd48baf5002b5ac768d335297 /ext/misc/series.c
parent6f30cac209728dc733502794db4508c40bca390d (diff)
downloadsqlite-9239fb59ad74b1fee03ea99e86dddf3726dd7bf4.tar.gz
sqlite-9239fb59ad74b1fee03ea99e86dddf3726dd7bf4.zip
Remove the LLONG_MAX preprocessor macro from the series.c extension as it
is apparently only C99 and later. [forum:/forumpost/4af649419b|Forum post 4af649419b]. FossilOrigin-Name: f106bc0d21b7a815f0d23a97b6fd63c54d3f5353e965dfa550fa715e698ec6e3
Diffstat (limited to 'ext/misc/series.c')
-rw-r--r--ext/misc/series.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/ext/misc/series.c b/ext/misc/series.c
index abd6af7ad..3e859a8f2 100644
--- a/ext/misc/series.c
+++ b/ext/misc/series.c
@@ -103,16 +103,20 @@ SQLITE_EXTENSION_INIT1
** index is ix. The 0th member is given by smBase. The sequence members
** progress per ix increment by smStep.
*/
-static sqlite3_int64 genSeqMember(sqlite3_int64 smBase,
- sqlite3_int64 smStep,
- sqlite3_uint64 ix){
- if( ix>=(sqlite3_uint64)LLONG_MAX ){
+static sqlite3_int64 genSeqMember(
+ sqlite3_int64 smBase,
+ sqlite3_int64 smStep,
+ sqlite3_uint64 ix
+){
+ static const sqlite3_uint64 mxI64 =
+ ((sqlite3_uint64)0x7fffffff)<<32 | 0xffffffff;
+ if( ix>=mxI64 ){
/* Get ix into signed i64 range. */
- ix -= (sqlite3_uint64)LLONG_MAX;
+ ix -= mxI64;
/* With 2's complement ALU, this next can be 1 step, but is split into
* 2 for UBSAN's satisfaction (and hypothetical 1's complement ALUs.) */
- smBase += (LLONG_MAX/2) * smStep;
- smBase += (LLONG_MAX - LLONG_MAX/2) * smStep;
+ smBase += (mxI64/2) * smStep;
+ smBase += (mxI64 - mxI64/2) * smStep;
}
/* Under UBSAN (or on 1's complement machines), must do this last term
* in steps to avoid the dreaded (and harmless) signed multiply overlow. */