summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Gran <spk121@yahoo.com>2022-11-10 14:45:31 -0800
committerMichael Gran <spk121@yahoo.com>2022-11-10 14:45:31 -0800
commit591e10a121bae5851a796dead0b2df97d08b628f (patch)
tree65ac7ad3fc4c045cc562b093f890fcd4f4675a36
parentbb646c42f7e9a3ad350ccb78168087dfda6228a7 (diff)
downloadguile-591e10a121bae5851a796dead0b2df97d08b628f.tar.gz
Avoids sign extension error in bytevector construction
Without this, negative numbers may change signedness * libguile/bytevectors (is_signed_int8, is_unsigned_int8) (is_signed_int16, is_unsigned_int16)[__MINGW32__ __x86_64__]: use long long type.
-rw-r--r--libguile/bytevectors.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c
index 58e398b61..4e697318a 100644
--- a/libguile/bytevectors.c
+++ b/libguile/bytevectors.c
@@ -71,14 +71,18 @@
#define INT16_T_unsigned uint16_t
#define INT32_T_signed int32_t
#define INT32_T_unsigned uint32_t
+#if !(__MINGW32__ && __x86_64__)
#define is_signed_int8(_x) (((_x) >= -128L) && ((_x) <= 127L))
#define is_unsigned_int8(_x) ((_x) <= 255UL)
#define is_signed_int16(_x) (((_x) >= -32768L) && ((_x) <= 32767L))
#define is_unsigned_int16(_x) ((_x) <= 65535UL)
-#if !(__MINGW32__ && __x86_64__)
#define is_signed_int32(_x) (((_x) >= -2147483648L) && ((_x) <= 2147483647L))
#define is_unsigned_int32(_x) ((_x) <= 4294967295UL)
#else /* (__MINGW32__ && __x86_64__) */
+#define is_signed_int8(_x) (((_x) >= -128LL) && ((_x) <= 127LL))
+#define is_unsigned_int8(_x) ((_x) <= 255ULL)
+#define is_signed_int16(_x) (((_x) >= -32768LL) && ((_x) <= 32767LL))
+#define is_unsigned_int16(_x) ((_x) <= 65535ULL)
#define is_signed_int32(_x) (((_x) >= -2147483648LL) && ((_x) <= 2147483647LL))
#define is_unsigned_int32(_x) ((_x) <= 4294967295ULL)
#endif /* (__MINGW32__ && __x86_64__) */