]> granicus.if.org Git - gc/commitdiff
Use standalone private macro to guard against ptr_t redefinition
authorIvan Maidanski <ivmai@mail.ru>
Wed, 14 Nov 2018 07:49:27 +0000 (10:49 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 26 Nov 2018 06:43:01 +0000 (09:43 +0300)
(code refactoring)

* include/private/gc_priv.h (ptr_t): Define only if PTR_T_DEFINED is
not defined (previously).
* include/private/gcconfig.h (ptr_t): Likewise.
* include/private/gc_priv.h (PTR_T_DEFINED): Define macro.
* include/private/gcconfig.h (PTR_T_DEFINED): Likewise.
* include/private/gcconfig.h (ptr_t): Change type to char*; remove
void comments.
* include/private/gcconfig.h: Include stddef.h only if sony_news is
not defined (like in gc_priv.h).

include/private/gc_priv.h
include/private/gcconfig.h

index e4e07181715483eb1b13e3b64bb0f96bb3f187c3..1eb3aa6c1eda634b5096d36e8081cd40ac9c2aa4 100644 (file)
@@ -91,9 +91,12 @@ typedef int GC_bool;
 #define TRUE 1
 #define FALSE 0
 
-typedef char * ptr_t;   /* A generic pointer to which we can add        */
+#ifndef PTR_T_DEFINED
+  typedef char * ptr_t; /* A generic pointer to which we can add        */
                         /* byte displacements and which can be used     */
                         /* for address comparisons.                     */
+# define PTR_T_DEFINED
+#endif
 
 #ifndef SIZE_MAX
 # include <limits.h>
index 5caa29766619df5fd8848695942e0019f2a7e37f..8ee2536970085689c1b3af4f959e11e639fb4270 100644 (file)
 #ifndef GCCONFIG_H
 #define GCCONFIG_H
 
-# ifndef GC_PRIVATE_H
-    /* Fake ptr_t declaration, just to avoid compilation errors.        */
-    /* This avoids many instances if "ifndef GC_PRIVATE_H" below.       */
-    typedef struct GC_undefined_struct * ptr_t;
-#   include <stddef.h>  /* For size_t etc. */
-# endif
+#ifndef PTR_T_DEFINED
+  typedef char * ptr_t;
+# define PTR_T_DEFINED
+#endif
+
+#if !defined(sony_news)
+# include <stddef.h> /* For size_t, etc. */
+#endif
 
 /* Note: Only wrap our own declarations, and not the included headers.  */
 /* In this case, wrap our entire file, but temporarily unwrap/rewrap    */