Changeset: fee673acaacf for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fee673acaacf
Modified Files:
        NT/monetdb_config.h.in
        configure.ag
        gdk/gdk.h
        gdk/gdk_atoms.c
Branch: default
Log Message:

Define lng as int64_t: let the compiler writer figure it out, we don't have to.
Also, sht is int16_t and bit and bte are int8_t.


diffs (229 lines):

diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in
--- a/NT/monetdb_config.h.in
+++ b/NT/monetdb_config.h.in
@@ -51,6 +51,32 @@
 #include <stdio.h>             /* NULL, printf etc. */
 #include <errno.h>
 #include <stdarg.h>            /* va_alist.. */
+#if !defined(_MSC_VER) || _MSC_VER >= 1800
+#include <inttypes.h>
+#include <stdbool.h>
+#else
+#error old versions of Visual Studio are no longer supported
+/* ... but this is how you might be able to do it (untested) */
+#if !defined(_MSC_VER) || _MSC_VER >= 1600
+/* old Visual Studio */
+#include <stdint.h>
+#else
+/* ancient Visual Studio */
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned __int64 uint64_t;
+typedef int64_t __int64;
+typedef uint64_t unsigned __int64;
+#endif
+/* normally defined in inttypes.h */
+#define PRId64 "I64d"
+#define PRIu64 "I64u"
+/* normally defined in stdbool.h */
+#define true 1
+#define false 0
+#define __bool_true_false_are_defined 1
+#endif
 
 #include <assert.h>
 
@@ -218,11 +244,6 @@
 /* Define to 1 if you have the <ieeefp.h> header file. */
 /* #undef HAVE_IEEEFP_H */
 
-/* Define to 1 if you have the <inttypes.h> header file. */
-#if !defined(_MSC_VER) || _MSC_VER >= 1800
-#define HAVE_INTTYPES_H 1
-#endif
-
 /* Define to 1 if you have the <io.h> header file. */
 #define HAVE_IO_H 1
 
@@ -987,29 +1008,13 @@ c99_snprintf(char *outBuf, size_t size, 
 #define va_copy(x,y) ((x) = (y))
 #endif
 
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned int uint32_t;
-typedef unsigned __int64 uint64_t;
-
-/* normally defined in stdbool.h, but that doesn't exist on Windows */
-#define true 1
-#define false 0
-#define __bool_true_false_are_defined 1
-
 /* normally defined in fcntl.h, but not on Windows */
 #define O_CLOEXEC 0
 
 
-#ifdef HAVE_LONG_LONG
-typedef long long lng;
-typedef unsigned long long ulng;
-# define SIZEOF_LNG SIZEOF_LONG_LONG
-#else
-typedef __int64 lng;
-typedef unsigned __int64 ulng;
-# define SIZEOF_LNG SIZEOF___INT64
-#endif
+typedef int64_t lng;
+typedef uint64_t ulng;
+#define SIZEOF_LNG 8
 
 #ifdef HAVE___INT128
 typedef __int128 hge;
@@ -1026,10 +1031,10 @@ typedef __uint128_t uhge;
 #endif
 
 /* Format to print 64 bit signed integers. */
-#define LLFMT "%I64d"
+#define LLFMT "%" PRId64
 
 /* Format to print 64 bit unsigned integers. */
-#define ULLFMT "%I64u"
+#define ULLFMT "%" PRIu64
 
 /* define printf formats for printing size_t and ssize_t variables */
 #if SIZEOF_SIZE_T == SIZEOF_INT
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2669,9 +2669,6 @@ AC_CHECK_SIZEOF([__int128])
 AC_CHECK_SIZEOF([__int128_t])
 AC_C_CHAR_UNSIGNED
 
-AC_DEFINE([LLFMT], ["%lld"], [Format to print 64 bit signed integers.])
-AC_DEFINE([ULLFMT], ["%llu"], [Format to print 64 bit unsigned integers.])
-
 #    checks for structures
 #    checks for compiler characteristics
 AC_C_CONST
@@ -2999,9 +2996,7 @@ AH_BOTTOM([
 @%:@include <stdlib.h>
 @%:@include <errno.h>
 @%:@include <stdarg.h>         /* va_alist.. */
-@%:@ifdef HAVE_STDINT_H
-@%:@include <stdint.h>
-@%:@endif
+@%:@include <inttypes.h>
 @%:@ifndef HAVE_INTPTR_T
 typedef ssize_t intptr_t;
 @%:@endif
@@ -3022,17 +3017,12 @@ typedef size_t uintptr_t;
 @%:@define SLASH_2_DIR_SEP(s) {char *t; for(t=strchr(s, '/'    ); t; 
t=strchr(t+1, '/'    )) *t=DIR_SEP;}
 @%:@define DIR_SEP_2_SLASH(s) {char *t; for(t=strchr(s, DIR_SEP); t; 
t=strchr(t+1, DIR_SEP)) *t='/'    ;}
 
-@%:@ifdef HAVE_LONG_LONG
-typedef long long lng;
-typedef unsigned long long ulng;
-@%:@ define SIZEOF_LNG SIZEOF_LONG_LONG
-@%:@else
-@%:@ ifdef HAVE___INT64
-typedef __int64 lng;
-typedef unsigned __int64 ulng;
-@%:@  define SIZEOF_LNG SIZEOF___INT64
-@%:@ endif
-@%:@endif
+typedef int64_t lng;
+typedef uint64_t ulng;
+@%:@ define SIZEOF_LNG 8
+@%:@ define LLFMT "%" PRId64
+@%:@ define ULLFMT "%" PRIu64
+
 
 @%:@ifdef HAVE___INT128
 typedef __int128 hge;
@@ -3093,16 +3083,13 @@ typedef lng ptrdiff_t;
 @%:@define PTRFMTCAST          /* no cast needed */
 @%:@elif defined(_MSC_VER)
 @%:@define PTRFMT              "%p"
-@%:@define PTRFMTCAST
-@%:@elif SIZEOF_VOID_P == SIZEOF_INT
-@%:@define PTRFMT              "%x"
-@%:@define PTRFMTCAST  (unsigned int)
-@%:@elif SIZEOF_VOID_P == SIZEOF_LONG
-@%:@define PTRFMT              "%lx"
-@%:@define PTRFMTCAST  (unsigned long)
-@%:@elif SIZEOF_VOID_P == SIZEOF_LONG_LONG
-@%:@define PTRFMT              "%llx"
-@%:@define PTRFMTCAST  (unsigned long long)
+@%:@define PTRFMTCAST          /* no cast needed */
+@%:@elif SIZEOF_VOID_P == 4
+@%:@define PTRFMT              "%" PRIx32
+@%:@define PTRFMTCAST  (uint32_t)
+@%:@elif SIZEOF_VOID_P == 8
+@%:@define PTRFMT              "%" PRIx64
+@%:@define PTRFMTCAST  (uint64_t)
 @%:@else
 @%:@error no definition for PTRFMT
 @%:@endif
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -517,9 +517,9 @@
 #endif
 #define TYPE_any       255     /* limit types to <255! */
 
-typedef signed char bit;
-typedef signed char bte;
-typedef short sht;
+typedef int8_t bit;
+typedef int8_t bte;
+typedef int16_t sht;
 
 #define SIZEOF_OID     SIZEOF_SIZE_T
 typedef size_t oid;
@@ -533,15 +533,7 @@ typedef float flt;
 typedef double dbl;
 typedef char *str;
 
-#if SIZEOF_INT==8
-#      define LL_CONSTANT(val) (val)
-#elif SIZEOF_LONG==8
-#      define LL_CONSTANT(val) (val##L)
-#elif defined(HAVE_LONG_LONG)
-#      define LL_CONSTANT(val) (val##LL)
-#elif defined(HAVE___INT64)
-#      define LL_CONSTANT(val) (val##i64)
-#endif
+#define LL_CONSTANT(val)       INT64_C(val)
 
 typedef oid var_t;             /* type used for heap index of var-sized BAT */
 #define SIZEOF_VAR_T   SIZEOF_OID
@@ -578,10 +570,10 @@ typedef uint32_t BUN4type;
 #if SIZEOF_BUN > 4
 typedef uint64_t BUN8type;
 #endif
-#define BUN2_NONE ((BUN2type) 0xFFFF)
-#define BUN4_NONE ((BUN4type) 0xFFFFFFFF)
+#define BUN2_NONE ((BUN2type) UINT16_C(0xFFFF))
+#define BUN4_NONE ((BUN4type) UINT32_C(0xFFFFFFFF))
 #if SIZEOF_BUN > 4
-#define BUN8_NONE ((BUN8type) LL_CONSTANT(0xFFFFFFFFFFFFFFFF))
+#define BUN8_NONE ((BUN8type) UINT64_C(0xFFFFFFFFFFFFFFFF))
 #endif
 
 
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -841,11 +841,7 @@ atomtostr(lng, LLFMT, )
 atom_io(lng, Lng, lng)
 
 #ifdef HAVE_HGE
-#ifdef WIN32
-#define HGE_LL018FMT "%018I64d"
-#else
-#define HGE_LL018FMT "%018lld"
-#endif
+#define HGE_LL018FMT "%018" PRId64
 #define HGE_LL18DIGITS LL_CONSTANT(1000000000000000000)
 #define HGE_ABS(a) (((a) < 0) ? -(a) : (a))
 ssize_t
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to