Remove K&R compatibility.
[kopensolaris-gnu/glibc.git] / linuxthreads / README.Xfree3.2
1 This file describes how to make a threaded X11R6.
2
3 You need the source-code of XFree-3.2. I used the sources of X11R6.1
4 (files: xc-1.tar.gz xc-2.tar.gz xc-3.tar.gz) and the patches to
5 XFree-3.2 (files: README.X11.patch R6.1pl1-3.2.diff.gz cfont32.tgz).
6
7 Untar the xc-?.tar.gz files in a directory called XF3.2 and apply
8 the XFree-3.2 patches as described in README.X11.patch or use the
9 whole XFree86 source.
10
11 Now apply the thread patch with
12
13 patch -p0 < XF3.2.xc.diff
14
15 Go to the XF3.2/xc directory and make the whole thing:
16 nice make World >& world.log &
17 tail -f world.log
18
19 Wait a few hours or interrupt the process after the shared libs
20 are made. The shared libs are:
21
22 XF3.2/xc/lib/ICE/libICE.so.6.0*
23 XF3.2/xc/lib/PEX5/libPEX5.so.6.0*
24 XF3.2/xc/lib/SM/libSM.so.6.0*
25 XF3.2/xc/lib/X11/libX11.so.6.1*
26 XF3.2/xc/lib/XIE/libXIE.so.6.0*
27 XF3.2/xc/lib/XThrStub/libXThrStub.so.6.0*
28 XF3.2/xc/lib/Xaw/libXaw.so.6.1*
29 XF3.2/xc/lib/Xext/libXext.so.6.1*
30 XF3.2/xc/lib/Xi/libXi.so.6.0*
31 XF3.2/xc/lib/Xmu/libXmu.so.6.0*
32 XF3.2/xc/lib/Xt/libXt.so.6.0*
33 XF3.2/xc/lib/Xtst/libXtst.so.6.1*
34
35 (The Program dga didn't compile, but I have not check out why.)
36
37 Now you can copy the resulting libs   
38
39 cp XF3.2/xc/lib/*/*.so.?.? /usr/X11R6/lib/
40
41 and create some links
42
43 cd /usr/X11R6/lib/
44 ln -s libXThrStub.so.6.0 libXThrStub.so.6
45 ln -s libXThrStub.so.6 libXThrStub.so
46
47 or use make install (not tested, and needs new configuration).
48
49 It is possible with the libXThrSub to compile X11 programs without linking
50 libpthread to them and not necessary to recompile already installed
51 unthreaded X11 programs, because libXThrSub keeps the dynamic linker quit.
52 On the other hand you can link libpthread to a X11 program to use threads.
53
54 I used linux 2.0.23 and libc 5.4.7 .
55
56 Hans-Helmut B├╝hmann     hans@expmech.ing.tu-bs.de
57
58 ----------------------------------------------------------------------------
59
60 XF3.2.xc.diff:
61 -----------------------------------------------------------------------------
62 diff -u --recursive XF3.2.orig/xc/config/cf/linux.cf XF3.2/xc/config/cf/linux.cf
63 --- XF3.2.orig/xc/config/cf/linux.cf    Sun Nov 10 17:05:30 1996
64 +++ XF3.2/xc/config/cf/linux.cf Sun Nov 10 16:30:55 1996
65 @@ -61,6 +61,14 @@
66  #define HasSnprintf            YES
67  #endif
68  
69 +#define HasPosixThreads         YES
70 +#define ThreadedX               YES
71 +#define BuildThreadStubLibrary YES
72 +#define NeedUIThrStubs         YES
73 +#define HasThreadSafeAPI        NO
74 +#define SystemMTDefines         -D_REENTRANT
75 +#define ThreadsLibraries        -lpthread
76 +
77  #define AvoidNullMakeCommand   YES
78  #define StripInstalledPrograms YES
79  #define CompressAllFonts       YES
80 @@ -158,7 +166,7 @@
81  #define LdPostLib              /* Never needed */
82  
83  #ifdef i386Architecture
84 -#define OptimizedCDebugFlags   DefaultGcc2i386Opt -m486
85 +#define OptimizedCDebugFlags   DefaultGcc2i386Opt -m486 -pipe
86  #define StandardDefines                -Dlinux -D__i386__ -D_POSIX_SOURCE \
87                                 -D_BSD_SOURCE -D_SVID_SOURCE -DX_LOCALE
88  #define XawI18nDefines         -DUSE_XWCHAR_STRING -DUSE_XMBTOWC
89 diff -u --recursive XF3.2.orig/xc/config/cf/lnxLib.tmpl XF3.2/xc/config/cf/lnxLib.tmpl
90 --- XF3.2.orig/xc/config/cf/lnxLib.tmpl Sun Nov 10 17:05:30 1996
91 +++ XF3.2/xc/config/cf/lnxLib.tmpl      Sat Nov  9 14:52:39 1996
92 @@ -19,7 +19,7 @@
93  
94  #define CplusplusLibC
95  
96 -#define SharedX11Reqs
97 +#define SharedX11Reqs          -L$(BUILDLIBDIR) -lXThrStub 
98  #define SharedOldXReqs $(LDPRELIB) $(XLIBONLY)
99  #define SharedXtReqs   $(LDPRELIB) $(XLIBONLY) $(SMLIB) $(ICELIB)
100  #define SharedXawReqs  $(LDPRELIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
101 diff -u --recursive XF3.2.orig/xc/include/Xthreads.h XF3.2/xc/include/Xthreads.h
102 --- XF3.2.orig/xc/include/Xthreads.h    Thu Dec  7 02:19:09 1995
103 +++ XF3.2/xc/include/Xthreads.h Sat Nov  9 01:04:55 1996
104 @@ -229,12 +229,12 @@
105  #define xcondition_wait(c,m) pthread_cond_wait(c,m)
106  #define xcondition_signal(c) pthread_cond_signal(c)
107  #define xcondition_broadcast(c) pthread_cond_broadcast(c)
108 -#ifdef _DECTHREADS_
109 +#if defined(_DECTHREADS_) || defined(linux)
110  static xthread_t _X_no_thread_id;
111  #define xthread_have_id(id) !pthread_equal(id, _X_no_thread_id)
112  #define xthread_clear_id(id) id = _X_no_thread_id
113  #define xthread_equal(id1,id2) pthread_equal(id1, id2)
114 -#endif /* _DECTHREADS_ */
115 +#endif /* _DECTHREADS_ || linux */
116  #if _CMA_VENDOR_ == _CMA__IBM
117  #ifdef DEBUG                   /* too much of a hack to enable normally */
118  /* see also cma__obj_set_name() */
119 diff -u --recursive XF3.2.orig/xc/lib/X11/util/makekeys.c XF3.2/xc/lib/X11/util/makekeys.c
120 --- XF3.2.orig/xc/lib/X11/util/makekeys.c       Mon Apr 18 02:22:22 1994
121 +++ XF3.2/xc/lib/X11/util/makekeys.c    Sat Nov  9 00:44:14 1996
122 @@ -73,7 +73,7 @@
123      register char c;
124      int first;
125      int best_max_rehash;
126 -    int best_z;
127 +    int best_z = 0;
128      int num_found;
129      KeySym val;
130  
131 diff -u --recursive XF3.2.orig/xc/lib/XThrStub/Imakefile XF3.2/xc/lib/XThrStub/Imakefile
132 --- XF3.2.orig/xc/lib/XThrStub/Imakefile        Sun Nov 10 17:08:12 1996
133 +++ XF3.2/xc/lib/XThrStub/Imakefile     Sat Nov  9 19:04:51 1996
134 @@ -25,7 +25,7 @@
135        DEFINES = $(ALLOC_DEFINES)
136       INCLUDES = 
137           SRCS = $(STUBSRCS)
138 -         OBJS = $(STUBOBJS
139 +         OBJS = $(STUBOBJS)
140       LINTLIBS = $(LINTXLIB)
141  
142  #include <Library.tmpl>
143 diff -u --recursive XF3.2.orig/xc/lib/XThrStub/UIThrStubs.c XF3.2/xc/lib/XThrStub/UIThrStubs.c
144 --- XF3.2.orig/xc/lib/XThrStub/UIThrStubs.c     Sun Nov 10 17:08:12 1996
145 +++ XF3.2/xc/lib/XThrStub/UIThrStubs.c  Sun Nov 10 15:14:55 1996
146 @@ -37,16 +37,43 @@
147   * specificies the thread library on the link line.
148   */
149  
150 +#if defined(linux)
151 +#include <pthread.h>
152 +#else
153  #include <thread.h>
154  #include <synch.h>
155 +#endif
156  
157 +#if defined(linux)
158 +static pthread_t no_thread_id;
159 +#endif /* defined(linux) */
160 +
161 +#if defined(linux)
162 +#pragma weak pthread_self = _Xthr_self_stub_
163 +pthread_t 
164 +_Xthr_self_stub_()
165 +{
166 +    return(no_thread_id);
167 +}
168 +#else /* defined(linux) */
169  #pragma weak thr_self = _Xthr_self_stub_
170  thread_t 
171  _Xthr_self_stub_()
172  {
173      return((thread_t)0);
174  }
175 +#endif /* defined(linux) */
176  
177 +#if defined(linux)
178 +#pragma weak pthread_mutex_init = _Xmutex_init_stub_
179 +int 
180 +_Xmutex_init_stub_(m, a)
181 +    pthread_mutex_t *m;
182 +    __const pthread_mutexattr_t *a;
183 +{
184 +    return(0);
185 +}
186 +#else /* defined(linux) */
187  #pragma weak mutex_init = _Xmutex_init_stub_
188  int 
189  _Xmutex_init_stub_(m, t, a)
190 @@ -56,7 +83,17 @@
191  {
192      return(0);
193  }
194 +#endif /* defined(linux) */
195  
196 +#if defined(linux)
197 +#pragma weak pthread_mutex_destroy = _Xmutex_destroy_stub_
198 +int
199 +_Xmutex_destroy_stub_(m)
200 +    pthread_mutex_t *m;
201 +{
202 +    return(0);
203 +}
204 +#else /* defined(linux) */
205  #pragma weak mutex_destroy = _Xmutex_destroy_stub_
206  int
207  _Xmutex_destroy_stub_(m)
208 @@ -64,7 +101,17 @@
209  {
210      return(0);
211  }
212 +#endif /* defined(linux) */
213  
214 +#if defined(linux)
215 +#pragma weak pthread_mutex_lock = _Xmutex_lock_stub_
216 +int
217 +_Xmutex_lock_stub_(m)
218 +    pthread_mutex_t *m;
219 +{
220 +    return(0);
221 +}
222 +#else /* defined(linux) */
223  #pragma weak mutex_lock = _Xmutex_lock_stub_
224  int
225  _Xmutex_lock_stub_(m)
226 @@ -72,7 +119,17 @@
227  {
228      return(0);
229  }
230 +#endif /* defined(linux) */
231  
232 +#if defined(linux)
233 +#pragma weak pthread_mutex_unlock = _Xmutex_unlock_stub_
234 +int
235 +_Xmutex_unlock_stub_(m)
236 +    pthread_mutex_t *m;
237 +{
238 +    return(0);
239 +}
240 +#else /* defined(linux) */
241  #pragma weak mutex_unlock = _Xmutex_unlock_stub_
242  int
243  _Xmutex_unlock_stub_(m)
244 @@ -80,7 +137,18 @@
245  {
246      return(0);
247  }
248 +#endif /* defined(linux) */
249  
250 +#if defined(linux)
251 +#pragma weak  pthread_cond_init = _Xcond_init_stub_
252 +int 
253 +_Xcond_init_stub_(c, a)
254 +    pthread_cond_t *c;
255 +    __const pthread_condattr_t *a;
256 +{
257 +    return(0);
258 +}
259 +#else /* defined(linux) */
260  #pragma weak cond_init = _Xcond_init_stub_
261  int 
262  _Xcond_init_stub_(c, t, a)
263 @@ -90,7 +158,17 @@
264  {
265      return(0);
266  }
267 +#endif /* defined(linux) */
268  
269 +#if defined(linux)
270 +#pragma weak pthread_cond_destroy = _Xcond_destroy_stub_
271 +int
272 +_Xcond_destroy_stub_(c)
273 +    pthread_cond_t *c;
274 +{
275 +    return(0);
276 +}
277 +#else /* defined(linux) */
278  #pragma weak cond_destroy = _Xcond_destroy_stub_
279  int
280  _Xcond_destroy_stub_(c)
281 @@ -98,7 +176,18 @@
282  {
283      return(0);
284  }
285 +#endif /* defined(linux) */
286  
287 +#if defined(linux)
288 +#pragma weak pthread_cond_wait = _Xcond_wait_stub_
289 +int
290 +_Xcond_wait_stub_(c,m)
291 +    pthread_cond_t *c;
292 +    pthread_mutex_t *m;
293 +{
294 +    return(0);
295 +}
296 +#else /* defined(linux) */
297  #pragma weak cond_wait = _Xcond_wait_stub_
298  int
299  _Xcond_wait_stub_(c,m)
300 @@ -107,7 +196,17 @@
301  {
302      return(0);
303  }
304 +#endif /* defined(linux) */
305  
306 +#if defined(linux)
307 +#pragma weak pthread_cond_signal = _Xcond_signal_stub_
308 +int
309 +_Xcond_signal_stub_(c)
310 +    pthread_cond_t *c;
311 +{
312 +    return(0);
313 +}
314 +#else /* defined(linux) */
315  #pragma weak cond_signal = _Xcond_signal_stub_
316  int
317  _Xcond_signal_stub_(c)
318 @@ -115,7 +214,17 @@
319  {
320      return(0);
321  }
322 +#endif /* defined(linux) */
323  
324 +#if defined(linux)
325 +#pragma weak pthread_cond_broadcast = _Xcond_broadcast_stub_
326 +int
327 +_Xcond_broadcast_stub_(c)
328 +    pthread_cond_t *c;
329 +{
330 +    return(0);
331 +}
332 +#else /* defined(linux) */
333  #pragma weak cond_broadcast = _Xcond_broadcast_stub_
334  int
335  _Xcond_broadcast_stub_(c)
336 @@ -123,3 +232,15 @@
337  {
338      return(0);
339  }
340 +#endif /* defined(linux) */
341 +
342 +#if defined(linux)
343 +#pragma weak pthread_equal = _Xthr_equal_stub_
344 +int
345 +_Xthr_equal_stub_(t1, t2)
346 +    pthread_t t1;
347 +    pthread_t t2;
348 +{
349 +    return(1);
350 +}
351 +#endif /* defined(linux) */
352 -------------------------------------------------------------------------