upload tizen2.0 source
[framework/uifw/xorg/xcb/libpthread-stubs.git] / stubs.c
1 /* Copyright (C) 2006 Diego Pettenò
2  * Inspired by libX11 code copyright (c) 1995 David E. Wexelblat.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  * 
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  * 
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20  * 
21  * Except as contained in this notice, the names of the authors or their
22  * institutions shall not be used in advertising or otherwise to promote the
23  * sale, use or other dealings in this Software without prior written
24  * authorization from the authors.
25  */
26
27 #include <pthread.h>
28 #include <stdlib.h>
29 #include "config.h"
30
31 #ifndef HAVE_PTHREAD_SELF
32 #define NEED_ZERO_STUB
33 # ifdef SUPPORT_ATTRIBUTE_ALIAS
34 int pthread_self() __attribute__ ((weak, alias ("__pthread_zero_stub")));
35 # else
36 #  pragma weak pthread_self = __pthread_zero_stub
37 # endif
38 #endif
39
40 #ifndef HAVE_PTHREAD_MUTEX_INIT
41 #define NEED_ZERO_STUB
42 # ifdef SUPPORT_ATTRIBUTE_ALIAS
43 int pthread_mutex_init() __attribute__ ((weak, alias ("__pthread_zero_stub")));
44 # else
45 #  pragma weak pthread_mutex_init = __pthread_zero_stub
46 # endif
47 #endif
48
49 #ifndef HAVE_PTHREAD_MUTEX_DESTROY
50 #define NEED_ZERO_STUB
51 # ifdef SUPPORT_ATTRIBUTE_ALIAS
52 int pthread_mutex_destroy() __attribute__ ((weak, alias ("__pthread_zero_stub")));
53 # else
54 #  pragma weak pthread_mutex_destroy = __pthread_zero_stub
55 # endif
56 #endif
57
58 #ifndef HAVE_PTHREAD_MUTEX_LOCK
59 #define NEED_ZERO_STUB
60 # ifdef SUPPORT_ATTRIBUTE_ALIAS
61 int pthread_mutex_lock() __attribute__ ((weak, alias ("__pthread_zero_stub")));
62 # else
63 #  pragma weak pthread_mutex_lock = __pthread_zero_stub
64 # endif
65 #endif
66
67 #ifndef HAVE_PTHREAD_MUTEX_UNLOCK
68 #define NEED_ZERO_STUB
69 # ifdef SUPPORT_ATTRIBUTE_ALIAS
70 int pthread_mutex_unlock() __attribute__ ((weak, alias ("__pthread_zero_stub")));
71 # else
72 #  pragma weak pthread_mutex_unlock = __pthread_zero_stub
73 # endif
74 #endif
75
76 #ifndef HAVE_PTHREAD_COND_INIT
77 #define NEED_ZERO_STUB
78 # ifdef SUPPORT_ATTRIBUTE_ALIAS
79 int pthread_cond_init() __attribute__ ((weak, alias ("__pthread_zero_stub")));
80 # else
81 #  pragma weak pthread_cond_init = __pthread_zero_stub
82 # endif
83 #endif
84
85 #ifndef HAVE_PTHREAD_COND_DESTROY
86 #define NEED_ZERO_STUB
87 # ifdef SUPPORT_ATTRIBUTE_ALIAS
88 int pthread_cond_destroy() __attribute__ ((weak, alias ("__pthread_zero_stub")));
89 # else
90 #  pragma weak pthread_cond_destroy = __pthread_zero_stub
91 # endif
92 #endif
93
94 #ifndef HAVE_PTHREAD_CONDATTR_INIT
95 #define NEED_ZERO_STUB
96 # ifdef SUPPORT_ATTRIBUTE_ALIAS
97 int pthread_condattr_init() __attribute__ ((weak, alias ("__pthread_zero_stub")));
98 # else
99 #  pragma weak pthread_condattr_init = __pthread_zero_stub
100 # endif
101 #endif
102
103 #ifndef HAVE_PTHREAD_CONDATTR_DESTROY
104 #define NEED_ZERO_STUB
105 # ifdef SUPPORT_ATTRIBUTE_ALIAS
106 int pthread_condattr_destroy() __attribute__ ((weak, alias ("__pthread_zero_stub")));
107 # else
108 #  pragma weak pthread_condattr_destroy = __pthread_zero_stub
109 # endif
110 #endif
111
112 #ifndef HAVE_PTHREAD_COND_WAIT
113 #define NEED_ABORT_STUB
114 # ifdef SUPPORT_ATTRIBUTE_ALIAS
115 int pthread_cond_wait() __attribute__ ((weak, alias ("__pthread_abort_stub")));
116 # else
117 #  pragma weak pthread_cond_wait = __pthread_abort_stub
118 # endif
119 #endif
120
121 #ifndef HAVE_PTHREAD_COND_TIMEDWAIT
122 #define NEED_ABORT_STUB
123 # ifdef SUPPORT_ATTRIBUTE_ALIAS
124 int pthread_cond_timedwait() __attribute__ ((weak, alias ("__pthread_abort_stub")));
125 # else
126 #  pragma weak pthread_cond_timedwait = __pthread_abort_stub
127 # endif
128 #endif
129
130 #ifndef HAVE_PTHREAD_COND_SIGNAL
131 #define NEED_ZERO_STUB
132 # ifdef SUPPORT_ATTRIBUTE_ALIAS
133 int pthread_cond_signal() __attribute__ ((weak, alias ("__pthread_zero_stub")));
134 # else
135 #  pragma weak pthread_cond_signal = __pthread_zero_stub
136 # endif
137 #endif
138
139 #ifndef HAVE_PTHREAD_COND_BROADCAST
140 #define NEED_ZERO_STUB
141 # ifdef SUPPORT_ATTRIBUTE_ALIAS
142 int pthread_cond_broadcast() __attribute__ ((weak, alias ("__pthread_zero_stub")));
143 # else
144 #  pragma weak pthread_cond_broadcast = __pthread_zero_stub
145 # endif
146 #endif
147
148 #ifndef HAVE_PTHREAD_EQUAL
149 #define NEED_EQUAL_STUB
150 # ifdef SUPPORT_ATTRIBUTE_ALIAS
151 int pthread_equal() __attribute__ ((weak, alias ("__pthread_equal_stub")));
152 # else
153 #  pragma weak pthread_equal = __pthread_equal_stub
154 # endif
155 #endif
156
157 #ifndef HAVE_PTHREAD_EXIT
158 #define NEED_EXIT_STUB
159 # ifdef SUPPORT_ATTRIBUTE_ALIAS
160 int pthread_exit() __attribute__ ((weak, alias ("__pthread_exit_stub")));
161 # else
162 #  pragma weak pthread_exit = __pthread_exit_stub
163 # endif
164 #endif
165
166 #ifdef NEED_ZERO_STUB
167 static int __pthread_zero_stub()
168 {
169     return 0;
170 }
171 #endif
172
173 #ifdef NEED_ABORT_STUB
174 static int __pthread_abort_stub()
175 {
176     abort();
177 }
178 #endif
179
180 #ifdef NEED_EQUAL_STUB
181 static int __pthread_equal_stub(pthread_t t1, pthread_t t2)
182 {
183     return (t1 == t2);
184 }
185 #endif
186
187 #ifdef NEED_EXIT_STUB
188 static void __pthread_exit_stub(void *ret)
189 {
190     exit(EXIT_SUCCESS);
191 }
192 #endif