From 208846413a70a2a92979e8a87de28b6ac93b806a Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 14 Nov 2018 10:49:27 +0300 Subject: [PATCH] Use standalone private macro to guard against ptr_t redefinition (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 | 5 ++++- include/private/gcconfig.h | 14 ++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index ed45dcd..8f2222c 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -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 diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 320e7d6..541780f 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -25,12 +25,14 @@ #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 /* For size_t etc. */ -# endif +#ifndef PTR_T_DEFINED + typedef char * ptr_t; +# define PTR_T_DEFINED +#endif + +#if !defined(sony_news) +# include /* 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 */ -- 2.7.4