diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-03-20 09:46:33 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-03-20 09:47:58 +0300 |
commit | 2b10620b1213fb35a6704d2133be561dffd4c54e (patch) | |
tree | 9d01a2561717f5e978705f94d98210dfb0567548 /tests | |
parent | 80e3fa6499c9c76982d36ab0282ae05e7169144c (diff) | |
download | bdwgc-2b10620b1213fb35a6704d2133be561dffd4c54e.tar.gz |
Use AO primitives in GC_RAND_NEXT instead of no_sanitize attribute
* include/private/gc_priv.h [THREAD_SANITIZER] (GC_RAND_STATE_T):
Define to volatile AO_t (instead of unsigned).
* include/private/gc_priv.h [THREAD_SANITIZER] (GC_RAND_NEXT): Define
to GC_rand_next.
* include/private/gc_priv.h [THREAD_SANITIZER] (GC_rand_next): Define
inline function (using AO_load/store to update the state).
* tests/disclaim.c [GC_PTHREADS || LINT2] (GC_rand): Remove function
(with GC_ATTR_NO_SANITIZE_THREAD attribute).
* tests/weakmap.c [GC_PTHREADS || LINT2] (GC_rand): Likewise.
* tests/disclaim.c [GC_PTHREADS || LINT2] (seed): Move static variable
definition out of GC_rand.
* tests/weakmap.c [GC_PTHREADS || LINT2] (seed): Likewise.
* tests/disclaim.c [GC_PTHREADS || LINT2] (rand): Define to
GC_RAND_NEXT(&seed).
* tests/weakmap.c [GC_PTHREADS || LINT2] (rand): Likewise.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/disclaim.c | 11 | ||||
-rw-r--r-- | tests/weakmap.c | 11 |
2 files changed, 4 insertions, 18 deletions
diff --git a/tests/disclaim.c b/tests/disclaim.c index 50f9e4da..cd777381 100644 --- a/tests/disclaim.c +++ b/tests/disclaim.c @@ -31,20 +31,13 @@ #if defined(GC_PTHREADS) || defined(LINT2) # define NOT_GCBUILD # include "private/gc_priv.h" - - GC_ATTR_NO_SANITIZE_THREAD - static int GC_rand(void) - { - static GC_RAND_STATE_T seed; /* concurrent update does not hurt the test */ - return GC_RAND_NEXT(&seed); - } - /* Redefine the standard rand() with a trivial (yet sufficient for */ /* the test purpose) implementation to avoid crashes inside rand() */ /* on some targets (e.g. FreeBSD 13.0) when used concurrently. */ /* The standard specifies rand() as not a thread-safe API function. */ # undef rand -# define rand() GC_rand() + static GC_RAND_STATE_T seed; /* concurrent update does not hurt the test */ +# define rand() GC_RAND_NEXT(&seed) #endif /* GC_PTHREADS || LINT2 */ #define my_assert(e) \ diff --git a/tests/weakmap.c b/tests/weakmap.c index b8e4edff..a13e3da8 100644 --- a/tests/weakmap.c +++ b/tests/weakmap.c @@ -29,16 +29,9 @@ #if defined(GC_PTHREADS) || defined(LINT2) # define NOT_GCBUILD # include "private/gc_priv.h" - - GC_ATTR_NO_SANITIZE_THREAD - static int GC_rand(void) /* same as in disclaim.c */ - { - static GC_RAND_STATE_T seed; /* concurrent update does not hurt the test */ - return GC_RAND_NEXT(&seed); - } - # undef rand -# define rand() GC_rand() + static GC_RAND_STATE_T seed; /* concurrent update does not hurt the test */ +# define rand() GC_RAND_NEXT(&seed) #endif /* GC_PTHREADS || LINT2 */ #include "gc/gc_mark.h" /* should not precede include gc_priv.h */ |