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