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