Debian Codegraph @

nx-X11/lib/src/UIThrStubs.c

raw
1 /*
2 *
3 * Copyright (c) 1995 David E. Wexelblat. All rights reserved
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL DAVID E. WEXELBLAT BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Except as contained in this notice, the name of David E. Wexelblat shall
25 * not be used in advertising or otherwise to promote the sale, use or
26 * other dealings in this Software without prior written authorization
27 * from David E. Wexelblat.
28 *
29 */
30
31 /*
32 * Stubs for thread functions needed by the X library. Supports
33 * UnixWare 2.x threads; may support Solaris 2 threads as well, but not
34 * tested. Defining things this way removes the dependency of the X
35 * library on the threads library, but still supports threads if the user
36 * specificies the thread library on the link line.
37 */
38
39 /*
40 * Modifications by Carlos A M dos Santos, XFree86 Project, November 1999.
41 *
42 * Explanation from <X11/Xos_r.h>:
43 * The structure below is complicated, mostly because P1003.1c (the
44 * IEEE POSIX Threads spec) went through lots of drafts, and some
45 * vendors shipped systems based on draft API that were changed later.
46 * Unfortunately POSIX did not provide a feature-test macro for
47 * distinguishing each of the drafts.
48 */
49
50 #ifdef CTHREADS
51 #ifdef HAVE_CONFIG_H
52 #include <config.h>
53 #endif
54 #include <cthreads.h>
55 typedef cthread_t xthread_t;
56 #define xthread_self cthread_self
57 #pragma weak cthread_self = _Xthr_self_stub_
58 #define xmutex_init mutex_init
59 #pragma weak mutex_init = _Xthr_zero_stub_
60 #pragma weak mutex_clear = _Xthr_zero_stub_
61 #pragma weak mutex_lock = _Xthr_zero_stub_
62 #pragma weak mutex_unlock = _Xthr_zero_stub_
63 #pragma weak condition_init = _Xthr_zero_stub_
64 #pragma weak condition_clear = _Xthr_zero_stub_
65 #pragma weak condition_wait = _Xthr_zero_stub_
66 #pragma weak condition_signal = _Xthr_zero_stub_
67 #pragma weak condition_broadcast = _Xthr_zero_stub_
68 #else /* !CTHREADS */
69 #if defined(SVR4)
70 #include <thread.h>
71 typedef thread_t xthread_t;
72 #pragma weak thr_self = _Xthr_self_stub_
73 #pragma weak mutex_init = _Xthr_zero_stub_
74 #pragma weak mutex_destroy = _Xthr_zero_stub_
75 #pragma weak mutex_lock = _Xthr_zero_stub_
76 #pragma weak mutex_unlock = _Xthr_zero_stub_
77 #pragma weak cond_init = _Xthr_zero_stub_
78 #pragma weak cond_destroy = _Xthr_zero_stub_
79 #pragma weak cond_wait = _Xthr_zero_stub_
80 #pragma weak cond_signal = _Xthr_zero_stub_
81 #pragma weak cond_broadcast = _Xthr_zero_stub_
82 #else /* !SVR4 */
83 #ifdef WIN32
84 #include <nx-X11/Xthreads.h>
85 #else /* !WIN32 */
86 #ifdef USE_TIS_SUPPORT
87 #include <tis.h>
88 typedef pthread_t xthread_t;
89 #pragma weak tis_self = _Xthr_self_stub_
90 #pragma weak tis_mutex_init = _Xthr_zero_stub_
91 #pragma weak tis_mutex_destroy = _Xthr_zero_stub_
92 #pragma weak tis_mutex_lock = _Xthr_zero_stub_
93 #pragma weak tis_mutex_unlock = _Xthr_zero_stub_
94 #pragma weak tis_cond_init = _Xthr_zero_stub_
95 #pragma weak tis_cond_destroy = _Xthr_zero_stub_
96 #pragma weak tis_cond_wait = _Xthr_zero_stub_
97 #pragma weak tis_cond_signal = _Xthr_zero_stub_
98 #pragma weak tis_cond_broadcast = _Xthr_zero_stub_
99 #else
100 #include <pthread.h>
101 typedef pthread_t xthread_t;
102 #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
103 xthread_t pthread_self() __attribute__ ((weak, alias ("_Xthr_self_stub_")));
104 int pthread_mutex_init() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
105 int pthread_mutex_destroy() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
106 int pthread_mutex_lock() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
107 int pthread_mutex_unlock() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
108 int pthread_cond_init() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
109 int pthread_cond_destroy() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
110 int pthread_cond_wait() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
111 int pthread_cond_signal() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
112 int pthread_cond_broadcast() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
113 int pthread_key_create() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
114 void *pthread_getspecific() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
115 int pthread_setspecific() __attribute__ ((weak, alias ("_Xthr_zero_stub_")));
116 #else /* __GNUC__ */
117 #pragma weak pthread_self = _Xthr_self_stub_
118 #pragma weak pthread_mutex_init = _Xthr_zero_stub_
119 #pragma weak pthread_mutex_destroy = _Xthr_zero_stub_
120 #pragma weak pthread_mutex_lock = _Xthr_zero_stub_
121 #pragma weak pthread_mutex_unlock = _Xthr_zero_stub_
122 #pragma weak pthread_cond_init = _Xthr_zero_stub_
123 #pragma weak pthread_cond_destroy = _Xthr_zero_stub_
124 #pragma weak pthread_cond_wait = _Xthr_zero_stub_
125 #pragma weak pthread_cond_signal = _Xthr_zero_stub_
126 #pragma weak pthread_cond_broadcast = _Xthr_zero_stub_
127 /* These are added for libGL */
128 #pragma weak pthread_key_create = _Xthr_zero_stub_
129 #pragma weak pthread_getspecific = _Xthr_zero_stub_
130 #pragma weak pthread_setspecific = _Xthr_zero_stub_
131 #endif /* __GNUC__ */
132 #if defined(_DECTHREADS_) || defined(linux)
133 #pragma weak pthread_equal = _Xthr_equal_stub_ /* See Xthreads.h! */
134 int
135 _Xthr_equal_stub_()
136 {
137 return(1);
138 }
139 #endif /* _DECTHREADS_ || linux */
140 #endif /* USE_TIS_SUPPORT */
141 #endif /* WIN32 */
142 #endif /* SVR4 */
143 #endif /* CTHREADS */
144
145 static xthread_t
146 _Xthr_self_stub_()
147 {
148 static xthread_t _X_no_thread_id;
149
150 return(_X_no_thread_id); /* defined by <X11/Xthreads.h> */
151 }
152
153 static int
154 _Xthr_zero_stub_()
155 {
156 return(0);
157 }