Skip to content

Commit

Permalink
Do not prohibit threaded builds with malloc redirection on non-Linux
Browse files Browse the repository at this point in the history
Issue #478 (bdwgc).

The malloc (and friends) redirection in a multi-threaded client may
work even on platforms other than Linux (as confirmed on MacOS)
provided the client ensures all the client threads are registered with
the collector, e.g. by using the preprocessor-based interception of
the thread primitives (i.e., define GC_THREADS and include gc.h from
all the client files those are using pthread_create and friends).

* include/private/gcconfig.h [!CPPCHECK && REDIRECT_MALLOC && THREADS
&& !LINUX && !REDIRECT_MALLOC_IN_HEADER]: Remove error preprocessor
directive; add comment.
  • Loading branch information
plajjan authored and ivmai committed Nov 17, 2022
1 parent 542295d commit daea2f1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/private/gcconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -3176,7 +3176,11 @@ EXTERN_C_BEGIN
# endif
# if defined(REDIRECT_MALLOC) && defined(THREADS) && !defined(LINUX) \
&& !defined(REDIRECT_MALLOC_IN_HEADER)
# error REDIRECT_MALLOC with THREADS works at most on Linux
/* May work on other platforms (e.g. Darwin) provided the client */
/* ensures all the client threads are registered with the GC, */
/* e.g. by using the preprocessor-based interception of the thread */
/* primitives (i.e., define GC_THREADS and include gc.h from all */
/* the client files those are using pthread_create and friends). */
# endif
#endif /* !CPPCHECK */

Expand Down

0 comments on commit daea2f1

Please sign in to comment.