From: Ivan Maidanski Date: Thu, 30 Mar 2017 19:06:09 +0000 (+0300) Subject: Fix mixed include of GC public header and gc_priv.h in disclaim bench/test X-Git-Tag: v8.0.0~799 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b15c34355fb42d785b8aa1cc5c6e337a99b50645;p=gc Fix mixed include of GC public header and gc_priv.h in disclaim bench/test Include gc_priv.h should be avoided in tests (if possible) or, at least, this include should not precede include of the public GC headers (because, e.g., gc_priv.h define GC_BUILD which influences declspec of the GC public symbols in case of a shared library). * tests/disclaim_bench.c: Move include gc_priv.h to be after gc_disclaim.h; add comment . * tests/disclaim_bench.c [HAVE_CONFIG_H]: Include "config.h" (before include gc_disclaim.h). * tests/disclaim_test.c [LINT2]: Do not include gc_priv.h; include config.h instead. * tests/disclaim_test.c [LINT2] (GC_API_PRIV): Define. * tests/disclaim_test.c [LINT2] (GC_random): Declare the function (instead of including gc_priv.h to get the prototype). --- diff --git a/tests/disclaim_bench.c b/tests/disclaim_bench.c index 298bac68..7ae1f3e5 100644 --- a/tests/disclaim_bench.c +++ b/tests/disclaim_bench.c @@ -16,10 +16,16 @@ #include #include -#include "private/gc_priv.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include "gc_disclaim.h" +/* Include gc_priv.h is done after including GC public headers, so */ +/* that GC_BUILD has no effect on the public prototypes. */ +#include "private/gc_priv.h" /* for CLOCK_TYPE and GC_random */ + #ifdef LINT2 # undef rand # define rand() (int)GC_random() diff --git a/tests/disclaim_test.c b/tests/disclaim_test.c index 73f82c5f..b7c92010 100644 --- a/tests/disclaim_test.c +++ b/tests/disclaim_test.c @@ -20,12 +20,7 @@ #include #include -#ifdef LINT2 - /* For GC_random() */ -# include "private/gc_priv.h" -# undef rand -# define rand() (int)GC_random() -#elif defined(HAVE_CONFIG_H) +#ifdef HAVE_CONFIG_H /* For GC_[P]THREADS */ # include "config.h" #endif @@ -33,6 +28,16 @@ #undef GC_NO_THREAD_REDIRECTS #include "gc_disclaim.h" +#ifdef LINT2 + /* Avoid include gc_priv.h. */ +# ifndef GC_API_PRIV +# define GC_API_PRIV GC_API +# endif + GC_API_PRIV long GC_random(void); +# undef rand +# define rand() (int)GC_random() +#endif /* LINT2 */ + #define my_assert(e) \ if (!(e)) { \ fflush(stdout); \