gthr_supp_vxw_5x.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Kernel-side additional module for the VxWorks threading support
  2. logic for GCC. Written 2002 by Zack Weinberg.
  3. This file is distributed with GCC, but it is not part of GCC.
  4. The contents of this file are in the public domain. */
  5. /* If you are using the Tornado IDE, copy this file to
  6. $WIND_BASE/target/config/comps/src/gthread_supp.c. Then create a
  7. file named 10comp_gthread_supp.cdf in target/config/comps/vxWorks
  8. with the following contents:
  9. Component INCLUDE_GCC_GTHREAD {
  10. NAME GCC 3.x gthread support (required by C++)
  11. CONFIGLETTES gthread_supp.c
  12. REQUIRES INCLUDE_CPLUS
  13. INCLUDE_WHEN INCLUDE_CPLUS
  14. _FOLDER FOLDER_CPLUS
  15. }
  16. If you are using command line builds, instead copy this file to
  17. $WIND_BASE/target/src/config/gthread_supp.c, and add the following
  18. block to target/src/config/usrExtra.c:
  19. #ifdef INCLUDE_CPLUS
  20. #include "../../src/config/gthread_supp.c"
  21. #endif
  22. You should now be able to rebuild your application using GCC 3.x. */
  23. #include <vxWorks.h>
  24. #include <taskLib.h>
  25. /* This file provides these routines: */
  26. extern void *__gthread_get_tsd_data (WIND_TCB *tcb);
  27. extern void __gthread_set_tsd_data (WIND_TCB *tcb, void *data);
  28. extern void __gthread_enter_tsd_dtor_context (WIND_TCB *tcb);
  29. extern void __gthread_leave_tsd_dtor_context (WIND_TCB *tcb);
  30. /* Set and retrieve the TSD data block for the task TCB.
  31. Possible choices for TSD_SLOT are:
  32. reserved1
  33. reserved2
  34. spare1
  35. spare2
  36. spare3
  37. spare4
  38. (these are all fields of the TCB structure; all have type 'int').
  39. If you find that the slot chosen by default is already used for
  40. something else, simply change the #define below and recompile this
  41. file. No other file should reference TSD_SLOT directly. */
  42. /* WARNING: This code is not 64-bit clean (it assumes that a pointer
  43. can be held in an 'int' without truncation). As much of the rest
  44. of VxWorks also makes this assumption, we can't really avoid it. */
  45. #define TSD_SLOT reserved1
  46. void *
  47. __gthread_get_tsd_data (WIND_TCB *tcb)
  48. {
  49. return (void *) (tcb->TSD_SLOT);
  50. }
  51. void
  52. __gthread_set_tsd_data (WIND_TCB *tcb, void *data)
  53. {
  54. tcb->TSD_SLOT = (int) data;
  55. }
  56. /* Enter and leave "TSD destructor context". This is defined as a
  57. state in which it is safe to call free() from a task delete hook
  58. on a memory block allocated by the task being deleted.
  59. For VxWorks 5.x, nothing needs to be done. */
  60. #if __GNUC__ >= 2
  61. #define UNUSED __attribute__((unused))
  62. #else
  63. #define UNUSED
  64. #endif
  65. void
  66. __gthread_enter_tsd_dtor_context (WIND_TCB *tcb UNUSED)
  67. {
  68. }
  69. void
  70. __gthread_leave_tsd_dtor_context (WIND_TCB *tcb UNUSED)
  71. {
  72. }