Changeset: ff4d4a77e4a0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ff4d4a77e4a0
Modified Files:
        common/stream/stream.h
        common/utils/matomic.h
        common/utils/mstring.h
        gdk/gdk.h
        gdk/gdk_system.h
        monetdb_config.h.in
Branch: default
Log Message:

Move some includes and defines around.
Everything __attribute__ related is now defined in monetdb_config.h
which is now automatically included if gdk.h or one of the common
include files is included.


diffs (truncated from 343 to 300 lines):

diff --git a/common/stream/stream.h b/common/stream/stream.h
--- a/common/stream/stream.h
+++ b/common/stream/stream.h
@@ -23,6 +23,8 @@
  * required for proper conversion on different byte order platforms.
  */
 
+#include "monetdb_config.h"
+
 #include <unistd.h>
 #include <ctype.h>
 #include <stdio.h>
@@ -47,21 +49,6 @@
 # define stream_export extern
 #endif
 
-/* Does your compiler support `__attribute__' extension? */
-#if !defined(__has_attribute)
-#ifndef __attribute__
-#define __attribute__(...)
-#endif
-#endif
-
-/* Defines to help the compiler check printf-style format arguments.
- * These defines are also in our config.h, but we repeat them here so
- * that we don't need that for this file.*/
-#if !defined(_MSC_VER) && !defined(_In_z_)
-# define _In_z_
-# define _Printf_format_string_
-#endif
-
 #define EOT 4
 
 /* fwf gets turned into a csv with these parameters */
diff --git a/common/utils/matomic.h b/common/utils/matomic.h
--- a/common/utils/matomic.h
+++ b/common/utils/matomic.h
@@ -53,6 +53,8 @@
 #ifndef _MATOMIC_H_
 #define _MATOMIC_H_
 
+#include "monetdb_config.h"
+
 /* the atomic type we export is always a 64 bit unsigned integer */
 
 /* ignore __STDC_NO_ATOMICS__ if compiling using Intel compiler on
diff --git a/common/utils/mstring.h b/common/utils/mstring.h
--- a/common/utils/mstring.h
+++ b/common/utils/mstring.h
@@ -11,6 +11,8 @@
 #ifndef _MSTRING_H_
 #define _MSTRING_H_
 
+#include "monetdb_config.h"
+
 #include <string.h>
 
 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 
4))
@@ -20,30 +22,6 @@
 #define GCC_Pragma(pragma)
 #endif
 
-/* if __has_attribute is not known to the preprocessor, we ignore
- * attributes completely (see monetdb_config.h); if it is known, use it
- * to find out whether specific attributes that we use are known */
-#if defined(__has_attribute)
-#if !__has_attribute(__access__)
-#define __access__(...)
-#endif
-#if !__has_attribute(__format__)
-#define __format__(...)
-#endif
-#if !__has_attribute(__nonnull__)
-#define __nonnull__(...)
-#endif
-#if !__has_attribute(__nonnull_if_nonzero__)
-#define __nonnull_if_nonzero__(...)
-#endif
-#if !__has_attribute(__pure__)
-#define __pure__
-#endif
-#if !__has_attribute(__sentinel__)
-#define __sentinel__
-#endif
-#endif
-
 #ifndef mutils_export
 #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__)
 #ifndef LIBMUTILS
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -23,6 +23,23 @@
 
 #include "monetdb_config.h"
 
+/* standard C-99 include files */
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <float.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <setjmp.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
 /* standard includes upon which all configure tests depend */
 #ifdef HAVE_SYS_STAT_H
 # include <sys/stat.h>
@@ -39,6 +56,10 @@
 # include <dirent.h>
 #endif
 
+#include "stream.h"
+#include "mstring.h"
+#include "matomic.h"
+
 #ifndef PATH_MAX
 #define PATH_MAX       1024
 #endif
@@ -53,6 +74,20 @@
 #define gdk_export extern
 #endif
 
+/* unreachable code */
+#ifdef __has_builtin
+#if __has_builtin(__builtin_unreachable)
+#define MT_UNREACHABLE()       do { assert(0); __builtin_unreachable(); } 
while (0)
+#endif
+#endif
+#ifndef MT_UNREACHABLE
+#if defined(_MSC_VER)
+#define MT_UNREACHABLE()       do { assert(0); __assume(0); } while (0)
+#else
+#define MT_UNREACHABLE()       do { assert(0); GDKfatal("Unreachable C code 
path reached"); } while (0)
+#endif
+#endif
+
 /* Only ever compare with GDK_SUCCEED, never with GDK_FAIL, and do not
  * use as a Boolean. */
 typedef enum gdk_return { GDK_FAIL, GDK_SUCCEED } gdk_return;
@@ -81,10 +116,9 @@ typedef struct allocator_state {
        allocator *ma;
 } allocator_state;
 
+#include "gdk_tracer.h"
 #include "gdk_system.h"
 #include "gdk_posix.h"
-#include "stream.h"
-#include "mstring.h"
 
 gdk_export _Noreturn void GDKfatal(_In_z_ _Printf_format_string_ const char 
*format, ...)
        __attribute__((__format__(__printf__, 1, 2)));
@@ -1193,10 +1227,6 @@ BATnegateprops(BAT *b)
 #define GDKERROR       "!ERROR: "
 #define GDKFATAL       "!FATAL: "
 
-/* Data Distilleries uses ICU for internationalization of some MonetDB error 
messages */
-
-#include "gdk_tracer.h"
-
 gdk_export gdk_return GDKtracer_fill_comp_info(BAT *id, BAT *component, BAT 
*log_level);
 
 #define GDKerror(...)          TRC_ERROR(GDK, __VA_ARGS__)
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -11,87 +11,6 @@
 #ifndef _GDK_SYSTEM_H_
 #define _GDK_SYSTEM_H_
 
-/* if __has_attribute is not known to the preprocessor, we ignore
- * attributes completely (see monetdb_config.h); if it is known, use it
- * to find out whether specific attributes that we use are known */
-#if defined(__has_attribute)
-#if !__has_attribute(__access__)
-#define __access__(...)
-#endif
-#if !__has_attribute(__aligned__)
-#define __aligned__(...)
-#endif
-#if !__has_attribute(__alloc_size__)
-#define __alloc_size__(...)
-#endif
-#if !__has_attribute(__cold__)
-#define __cold__
-#endif
-#if !__has_attribute(__const__)
-#define __const__
-#endif
-#if !__has_attribute(__constructor__)
-#define __constructor__
-#endif
-#if !__has_attribute(__counted_by__)
-#define __counted_by__(...)
-#endif
-#if !__has_attribute(__designated_init__)
-#define __designated_init__
-#endif
-#if !__has_attribute(__format__)
-#define __format__(...)
-#endif
-#if !__has_attribute(__malloc__)
-#define __malloc__
-#define __malloc__(...)
-#elif !defined(__GNUC__) || __GNUC__ < 13
-/* attribute malloc with argument seems to have been introduced in gcc 13 */
-#define __malloc__(...)
-#endif
-#if !__has_attribute(__noinline__)
-#define __noinline__
-#endif
-#if !__has_attribute(__nonnull__)
-#define __nonnull__(...)
-#endif
-#if !__has_attribute(__nonnull_if_nonzero__)
-#define __nonnull_if_nonzero__(...)
-#endif
-#if !__has_attribute(__nonstring__)
-#define __nonstring__
-#endif
-#if !__has_attribute(__pure__)
-#define __pure__
-#endif
-#if !__has_attribute(__returns_nonnull__)
-#define __returns_nonnull__
-#endif
-#if !__has_attribute(__sentinel__)
-#define __sentinel__
-#endif
-#if !__has_attribute(__visibility__)
-#define __visibility__(...)
-#endif
-#if !__has_attribute(__warn_unused_result__)
-#define __warn_unused_result__
-#endif
-#endif
-
-/* unreachable code */
-#ifdef __has_builtin
-#if __has_builtin(__builtin_unreachable)
-#define MT_UNREACHABLE()       do { assert(0); __builtin_unreachable(); } 
while (0)
-#endif
-#endif
-#ifndef MT_UNREACHABLE
-#if defined(_MSC_VER)
-#define MT_UNREACHABLE()       do { assert(0); __assume(0); } while (0)
-#else
-#define MT_UNREACHABLE()       do { assert(0); GDKfatal("Unreachable C code 
path reached"); } while (0)
-#endif
-#endif
-
 /*
  * @- pthreads Includes and Definitions
  */
diff --git a/monetdb_config.h.in b/monetdb_config.h.in
--- a/monetdb_config.h.in
+++ b/monetdb_config.h.in
@@ -363,10 +363,77 @@ typedef __uint128_t uint128_t;
 
 /* Does your compiler support `__attribute__' extension? */
 #if !defined(__has_attribute)
+/* if __has_attribute is not known to the preprocessor, we ignore
+ * attributes completely */
 #ifndef __attribute__
 #define __attribute__(...)
 #endif
+#else
+/* if it is known, use it to find out whether specific attributes that
+ * we use are known */
+#if !__has_attribute(__access__)
+#define __access__(...)
 #endif
+#if !__has_attribute(__aligned__)
+#define __aligned__(...)
+#endif
+#if !__has_attribute(__alloc_size__)
+#define __alloc_size__(...)
+#endif
+#if !__has_attribute(__cold__)
+#define __cold__
+#endif
+#if !__has_attribute(__const__)
+#define __const__
+#endif
+#if !__has_attribute(__constructor__)
+#define __constructor__
+#endif
+#if !__has_attribute(__counted_by__)
+#define __counted_by__(...)
+#endif
+#if !__has_attribute(__designated_init__)
+#define __designated_init__
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to