1:
2:
3:
4:
5: #ifndef _THREAD_PRIVATE_H_
6: #define _THREAD_PRIVATE_H_
7:
8: 9: 10: 11: 12: 13:
14:
15: 16: 17:
18: #if 1
19: #define _THREAD_PRIVATE_MUTEX(name)
20: #define _THREAD_PRIVATE_MUTEX_LOCK(t) __libc_lock_findfp()
21: extern void __libc_lock_findfp(void);
22: #define _THREAD_PRIVATE_MUTEX_UNLOCK(t) __libc_unlock_findfp()
23: extern void __libc_unlock_findfp(void);
24: #else
25: extern int __isthreaded;
26:
27: 28: 29: 30: 31: 32: 33: 34:
35: #define WEAK_NAME(name) __CONCAT(_weak_,name)
36: #define WEAK_ALIAS(name) __weak_alias(name, WEAK_NAME(name))
37: #ifdef __GNUC__
38: #define WEAK_PROTOTYPE(name) __typeof__(name) WEAK_NAME(name)
39: #else
40: #define WEAK_PROTOTYPE(name)
41: #endif
42:
43: 44: 45: 46: 47: 48: 49:
50: #define STUB_NAME(name) __CONCAT(_thread_sys_,name)
51: #define STUB_ALIAS(name) __weak_alias(name, STUB_NAME(name))
52: #ifdef __GNUC__
53: #define STUB_PROTOTYPE(name) __typeof__(name) STUB_NAME(name)
54: #else
55: #define STUB_PROTOTYPE(name)
56: #endif
57:
58: 59: 60:
61: #define __THREAD_NAME(name) __CONCAT(_thread_tagname_,name)
62:
63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90:
91: void _thread_tag_lock(void **);
92: void _thread_tag_unlock(void **);
93: void *_thread_tag_storage(void **, void *, size_t, void *);
94: void _thread_mutex_lock(void **);
95: void _thread_mutex_unlock(void **);
96: void _thread_mutex_destroy(void **);
97:
98: 99: 100: 101: 102: 103: 104:
105: #define _THREAD_PRIVATE_KEY(name) \
106: static void *__THREAD_NAME(name)
107: #define _THREAD_PRIVATE_MUTEX(name) \
108: static void *__THREAD_NAME(name)
109: #define _THREAD_PRIVATE_MUTEX_LOCK(name) \
110: _thread_tag_lock(&(__THREAD_NAME(name)))
111: #define _THREAD_PRIVATE_MUTEX_UNLOCK(name) \
112: _thread_tag_unlock(&(__THREAD_NAME(name)))
113: #define _THREAD_PRIVATE(keyname, storage, error) \
114: _thread_tag_storage(&(__THREAD_NAME(keyname)), &(storage), \
115: sizeof (storage), error)
116:
117: 118: 119:
120: #define _MUTEX_LOCK(mutex) \
121: do { \
122: if (__isthreaded) \
123: _thread_mutex_lock(mutex); \
124: } while (0)
125: #define _MUTEX_UNLOCK(mutex) \
126: do { \
127: if (__isthreaded) \
128: _thread_mutex_unlock(mutex); \
129: } while (0)
130: #define _MUTEX_DESTROY(mutex) \
131: do { \
132: if (__isthreaded) \
133: _thread_mutex_destroy(mutex); \
134: } while (0)
135:
136: 137: 138:
139: extern void *__THREAD_NAME(_res);
140: extern void *__THREAD_NAME(_res_ext);
141: extern void *__THREAD_NAME(serv_mutex);
142:
143: 144: 145:
146: void _thread_malloc_lock(void);
147: void _thread_malloc_unlock(void);
148:
149: #define _MALLOC_LOCK() do { \
150: if (__isthreaded) \
151: _thread_malloc_lock(); \
152: } while (0)
153: #define _MALLOC_UNLOCK() do { \
154: if (__isthreaded) \
155: _thread_malloc_unlock();\
156: } while (0)
157:
158: void _thread_atexit_lock(void);
159: void _thread_atexit_unlock(void);
160:
161: #define _ATEXIT_LOCK() do { \
162: if (__isthreaded) \
163: _thread_atexit_lock(); \
164: } while (0)
165: #define _ATEXIT_UNLOCK() do { \
166: if (__isthreaded) \
167: _thread_atexit_unlock();\
168: } while (0)
169:
170: void _thread_arc4_lock(void);
171: void _thread_arc4_unlock(void);
172:
173: #define _ARC4_LOCK() do { \
174: if (__isthreaded) \
175: _thread_arc4_lock(); \
176: } while (0)
177: #define _ARC4_UNLOCK() do { \
178: if (__isthreaded) \
179: _thread_arc4_unlock();\
180: } while (0)
181:
182: #endif
183: #endif