From dd7e62d18a06b7b12084e5db795ac9d43a366341 Mon Sep 17 00:00:00 2001 From: ivmai Date: Tue, 8 Mar 2011 08:45:31 +0000 Subject: [PATCH] 2011-03-08 Ivan Maidanski * include/gc_pthread_redirects.h (GC_NO_DLOPEN, GC_NO_PTHREAD_SIGMASK, GC_PTHREAD_CREATE_CONST, GC_PTHREAD_EXIT_ATTRIBUTE, GC_NO_PTHREAD_CANCEL): Move the definition to gc_config_macros. --- ChangeLog | 7 ++++++ include/gc_config_macros.h | 53 +++++++++++++++++++++++++++++++++++++++--- include/gc_pthread_redirects.h | 43 ---------------------------------- 3 files changed, 57 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7a1ee2..3af29f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2011-03-08 Ivan Maidanski + * include/gc_pthread_redirects.h (GC_NO_DLOPEN, + GC_NO_PTHREAD_SIGMASK, GC_PTHREAD_CREATE_CONST, + GC_PTHREAD_EXIT_ATTRIBUTE, GC_NO_PTHREAD_CANCEL): Move the + definition to gc_config_macros. + +2011-03-08 Ivan Maidanski + * pthread_support.c (pthread_cancel, GC_pthread_cancel_t, GC_pthread_cancel): Test GC_NO_PTHREAD_CANCEL (instead of NACL and GC_PTHREAD_EXIT_ATTRIBUTE). diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h index e08b9f7..030218e 100644 --- a/include/gc_config_macros.h +++ b/include/gc_config_macros.h @@ -277,13 +277,60 @@ && !defined(GC_CAN_SAVE_CALL_STACKS) # define GC_ADD_CALLER # if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) - /* gcc knows how to retrieve return address, but we don't know */ - /* how to generate call stacks. */ + /* gcc knows how to retrieve return address, but we don't know */ + /* how to generate call stacks. */ # define GC_RETURN_ADDR (GC_word)__builtin_return_address(0) # else - /* Just pass 0 for gcc compatibility. */ + /* Just pass 0 for gcc compatibility. */ # define GC_RETURN_ADDR 0 # endif #endif /* !GC_CAN_SAVE_CALL_STACKS */ +#ifdef GC_PTHREADS + +# if (defined(GC_DARWIN_THREADS) || defined(GC_WIN32_PTHREADS) \ + || defined(__native_client__)) && !defined(GC_NO_DLOPEN) + /* Either there is no dlopen() or we do not need to intercept it. */ +# define GC_NO_DLOPEN +# endif + +# if (defined(GC_DARWIN_THREADS) || defined(GC_WIN32_PTHREADS) \ + || defined(GC_OPENBSD_THREADS) || defined(__native_client__)) \ + && !defined(GC_NO_PTHREAD_SIGMASK) + /* Either there is no pthread_sigmask() or no need to intercept it. */ +# define GC_NO_PTHREAD_SIGMASK +# endif + +# if defined(__native_client__) + /* At present, NaCl pthread_create() prototype does not have */ + /* "const" for its "attr" argument; also, NaCl pthread_exit() one */ + /* does not have "noreturn" attribute. */ +# ifndef GC_PTHREAD_CREATE_CONST +# define GC_PTHREAD_CREATE_CONST /* empty */ +# endif +# ifndef GC_PTHREAD_EXIT_ATTRIBUTE +# define GC_PTHREAD_EXIT_ATTRIBUTE /* empty */ +# endif +# endif + +# if !defined(GC_PTHREAD_EXIT_ATTRIBUTE) && !defined(PLATFORM_ANDROID) \ + && (defined(GC_LINUX_THREADS) || defined(GC_SOLARIS_THREADS)) + /* Intercept pthread_exit on Linux and Solaris. */ +# if defined(__GNUC__) /* since GCC v2.7 */ +# define GC_PTHREAD_EXIT_ATTRIBUTE __attribute__((__noreturn__)) +# elif defined(__NORETURN) /* used in Solaris */ +# define GC_PTHREAD_EXIT_ATTRIBUTE __NORETURN +# else +# define GC_PTHREAD_EXIT_ATTRIBUTE /* empty */ +# endif +# endif + +# if (!defined(GC_PTHREAD_EXIT_ATTRIBUTE) || defined(__native_client__)) \ + && !defined(GC_NO_PTHREAD_CANCEL) + /* Either there is no pthread_cancel() or no need to intercept it. */ +# define GC_NO_PTHREAD_CANCEL +# endif + +#endif /* GC_PTHREADS */ + #endif diff --git a/include/gc_pthread_redirects.h b/include/gc_pthread_redirects.h index 82de3ee..b4b2b13 100644 --- a/include/gc_pthread_redirects.h +++ b/include/gc_pthread_redirects.h @@ -32,31 +32,6 @@ #include -#if (defined(GC_DARWIN_THREADS) || defined(GC_WIN32_PTHREADS) \ - || defined(__native_client__)) && !defined(GC_NO_DLOPEN) - /* Either there is no dlopen() or we do not need to intercept it. */ -# define GC_NO_DLOPEN -#endif - -#if (defined(GC_DARWIN_THREADS) || defined(GC_WIN32_PTHREADS) \ - || defined(GC_OPENBSD_THREADS) || defined(__native_client__)) \ - && !defined(GC_NO_PTHREAD_SIGMASK) - /* Either there is no pthread_sigmask() or no need to intercept it. */ -# define GC_NO_PTHREAD_SIGMASK -#endif - -#if defined(__native_client__) - /* At present, NaCl pthread_create() prototype does not have "const" */ - /* for its "attr" argument; also, NaCl pthread_exit() one does not */ - /* have "noreturn" attribute. */ -# ifndef GC_PTHREAD_CREATE_CONST -# define GC_PTHREAD_CREATE_CONST /* empty */ -# endif -# ifndef GC_PTHREAD_EXIT_ATTRIBUTE -# define GC_PTHREAD_EXIT_ATTRIBUTE /* empty */ -# endif -#endif - #ifndef GC_NO_DLOPEN # include GC_API void *GC_dlopen(const char * /* path */, int /* mode */); @@ -79,24 +54,6 @@ GC_API int GC_pthread_create(pthread_t *, GC_API int GC_pthread_join(pthread_t, void ** /* retval */); GC_API int GC_pthread_detach(pthread_t); -#if !defined(GC_PTHREAD_EXIT_ATTRIBUTE) && !defined(PLATFORM_ANDROID) \ - && (defined(GC_LINUX_THREADS) || defined(GC_SOLARIS_THREADS)) - /* Intercept pthread_exit on Linux and Solaris. */ -# if defined(__GNUC__) /* since GCC v2.7 */ -# define GC_PTHREAD_EXIT_ATTRIBUTE __attribute__((__noreturn__)) -# elif defined(__NORETURN) /* used in Solaris */ -# define GC_PTHREAD_EXIT_ATTRIBUTE __NORETURN -# else -# define GC_PTHREAD_EXIT_ATTRIBUTE /* empty */ -# endif -#endif - -#if (!defined(GC_PTHREAD_EXIT_ATTRIBUTE) || defined(__native_client__)) \ - && !defined(GC_NO_PTHREAD_CANCEL) - /* Either there is no pthread_cancel() or no need to intercept it. */ -# define GC_NO_PTHREAD_CANCEL -#endif - #ifndef GC_NO_PTHREAD_CANCEL GC_API int GC_pthread_cancel(pthread_t); #endif -- 2.7.4