OLD | NEW |
1 /* Threads compatibility routines for libgcc2 and libobjc for VxWorks. */ | 1 /* Threads compatibility routines for libgcc2 and libobjc for VxWorks. */ |
2 /* Compile this one with gcc. */ | 2 /* Compile this one with gcc. */ |
3 /* Copyright (C) 1997, 1999, 2000, 2008, 2009 Free Software Foundation, Inc. | 3 /* Copyright (C) 1997, 1999, 2000, 2008, 2009 Free Software Foundation, Inc. |
4 Contributed by Mike Stump <mrs@wrs.com>. | 4 Contributed by Mike Stump <mrs@wrs.com>. |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
8 GCC is free software; you can redistribute it and/or modify it under | 8 GCC is free software; you can redistribute it and/or modify it under |
9 the terms of the GNU General Public License as published by the Free | 9 the terms of the GNU General Public License as published by the Free |
10 Software Foundation; either version 3, or (at your option) any later | 10 Software Foundation; either version 3, or (at your option) any later |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex) | 108 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex) |
109 { | 109 { |
110 return __gthread_mutex_unlock (mutex); | 110 return __gthread_mutex_unlock (mutex); |
111 } | 111 } |
112 | 112 |
113 /* pthread_once is complicated enough that it's implemented | 113 /* pthread_once is complicated enough that it's implemented |
114 out-of-line. See config/vxlib.c. */ | 114 out-of-line. See config/vxlib.c. */ |
115 | 115 |
116 typedef struct | 116 typedef struct |
117 { | 117 { |
118 #ifndef __RTP__ | 118 #if !defined(__RTP__) |
| 119 #if defined(__PPC__) |
| 120 __attribute ((aligned (__alignof (unsigned)))) |
| 121 #endif |
119 volatile unsigned char busy; | 122 volatile unsigned char busy; |
120 #endif | 123 #endif |
121 volatile unsigned char done; | 124 volatile unsigned char done; |
| 125 #if !defined(__RTP__) && defined(__PPC__) |
| 126 /* PPC's test-and-set implementation requires a 4 byte aligned |
| 127 object, of which it only sets the first byte. We use padding |
| 128 here, in order to maintain some amount of backwards |
| 129 compatibility. Without this padding, gthread_once objects worked |
| 130 by accident because they happen to be static objects and the ppc |
| 131 port automatically increased their alignment to 4 bytes. */ |
| 132 unsigned char pad1; |
| 133 unsigned char pad2; |
| 134 #endif |
122 } | 135 } |
123 __gthread_once_t; | 136 __gthread_once_t; |
124 | 137 |
125 #ifndef __RTP__ | 138 #if defined (__RTP__) |
| 139 # define __GTHREAD_ONCE_INIT { 0 } |
| 140 #elif defined (__PPC__) |
| 141 # define __GTHREAD_ONCE_INIT { 0, 0, 0, 0 } |
| 142 #else |
126 # define __GTHREAD_ONCE_INIT { 0, 0 } | 143 # define __GTHREAD_ONCE_INIT { 0, 0 } |
127 #else | |
128 # define __GTHREAD_ONCE_INIT { 0 } | |
129 #endif | 144 #endif |
130 | 145 |
131 extern int __gthread_once (__gthread_once_t *__once, void (*__func)(void)); | 146 extern int __gthread_once (__gthread_once_t *__once, void (*__func)(void)); |
132 | 147 |
133 /* Thread-specific data requires a great deal of effort, since VxWorks | 148 /* Thread-specific data requires a great deal of effort, since VxWorks |
134 is not really set up for it. See config/vxlib.c for the gory | 149 is not really set up for it. See config/vxlib.c for the gory |
135 details. All the TSD routines are sufficiently complex that they | 150 details. All the TSD routines are sufficiently complex that they |
136 need to be implemented out of line. */ | 151 need to be implemented out of line. */ |
137 | 152 |
138 typedef unsigned int __gthread_key_t; | 153 typedef unsigned int __gthread_key_t; |
139 | 154 |
140 extern int __gthread_key_create (__gthread_key_t *__keyp, void (*__dtor)(void *)
); | 155 extern int __gthread_key_create (__gthread_key_t *__keyp, void (*__dtor)(void *)
); |
141 extern int __gthread_key_delete (__gthread_key_t __key); | 156 extern int __gthread_key_delete (__gthread_key_t __key); |
142 | 157 |
143 extern void *__gthread_getspecific (__gthread_key_t __key); | 158 extern void *__gthread_getspecific (__gthread_key_t __key); |
144 extern int __gthread_setspecific (__gthread_key_t __key, void *__ptr); | 159 extern int __gthread_setspecific (__gthread_key_t __key, void *__ptr); |
145 | 160 |
146 #undef UNUSED | 161 #undef UNUSED |
147 | 162 |
148 #ifdef __cplusplus | 163 #ifdef __cplusplus |
149 } | 164 } |
150 #endif | 165 #endif |
151 | 166 |
152 #endif /* not _LIBOBJC */ | 167 #endif /* not _LIBOBJC */ |
153 | 168 |
154 #endif /* gthr-vxworks.h */ | 169 #endif /* gthr-vxworks.h */ |
OLD | NEW |