/libs/headers/gc/gc_pthread_redirects.h

http://github.com/nddrylliog/ooc · C++ Header · 54 lines · 31 code · 10 blank · 13 comment · 3 complexity · 5cf9535ac8a8e4b27fdc322172f7ac21 MD5 · raw file

  1. /* Our pthread support normally needs to intercept a number of thread */
  2. /* calls. We arrange to do that here, if appropriate. */
  3. #ifndef GC_PTHREAD_REDIRECTS_H
  4. #define GC_PTHREAD_REDIRECTS_H
  5. #if !defined(GC_USE_LD_WRAP) && defined(GC_PTHREADS)
  6. /* We need to intercept calls to many of the threads primitives, so */
  7. /* that we can locate thread stacks and stop the world. */
  8. /* Note also that the collector cannot always see thread specific data. */
  9. /* Thread specific data should generally consist of pointers to */
  10. /* uncollectable objects (allocated with GC_malloc_uncollectable, */
  11. /* not the system malloc), which are deallocated using the destructor */
  12. /* facility in thr_keycreate. Alternatively, keep a redundant pointer */
  13. /* to thread specific data on the thread stack. */
  14. # include <pthread.h>
  15. # include <signal.h>
  16. int GC_pthread_create(pthread_t *new_thread,
  17. const pthread_attr_t *attr,
  18. void *(*start_routine)(void *), void *arg);
  19. #ifndef GC_DARWIN_THREADS
  20. int GC_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset);
  21. #endif
  22. int GC_pthread_join(pthread_t thread, void **retval);
  23. int GC_pthread_detach(pthread_t thread);
  24. #if defined(GC_OSF1_THREADS) \
  25. && defined(_PTHREAD_USE_MANGLED_NAMES_) && !defined(_PTHREAD_USE_PTDNAM_)
  26. /* Unless the compiler supports #pragma extern_prefix, the Tru64 UNIX
  27. <pthread.h> redefines some POSIX thread functions to use mangled names.
  28. If so, undef them before redefining. */
  29. # undef pthread_create
  30. # undef pthread_join
  31. # undef pthread_detach
  32. #endif
  33. # define pthread_create GC_pthread_create
  34. # define pthread_join GC_pthread_join
  35. # define pthread_detach GC_pthread_detach
  36. #ifndef GC_DARWIN_THREADS
  37. # ifdef pthread_sigmask
  38. # undef pthread_sigmask
  39. # endif /* pthread_sigmask */
  40. # define pthread_sigmask GC_pthread_sigmask
  41. # define dlopen GC_dlopen
  42. #endif
  43. #endif /* GC_xxxxx_THREADS */
  44. #endif /* GC_PTHREAD_REDIRECTS_H */