xref: /aoo41x/main/sal/osl/unx/system.h (revision 9eab2a37)
1*9eab2a37SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9eab2a37SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9eab2a37SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9eab2a37SAndrew Rist  * distributed with this work for additional information
6*9eab2a37SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9eab2a37SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9eab2a37SAndrew Rist  * "License"); you may not use this file except in compliance
9*9eab2a37SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9eab2a37SAndrew Rist  *
11*9eab2a37SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9eab2a37SAndrew Rist  *
13*9eab2a37SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9eab2a37SAndrew Rist  * software distributed under the License is distributed on an
15*9eab2a37SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9eab2a37SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9eab2a37SAndrew Rist  * specific language governing permissions and limitations
18*9eab2a37SAndrew Rist  * under the License.
19*9eab2a37SAndrew Rist  *
20*9eab2a37SAndrew Rist  *************************************************************/
21*9eab2a37SAndrew Rist 
22*9eab2a37SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __OSL_SYSTEM_H__
25cdf0e10cSrcweir #define __OSL_SYSTEM_H__
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <stdio.h>
28cdf0e10cSrcweir #include <stdlib.h>
29cdf0e10cSrcweir #include <limits.h>
30cdf0e10cSrcweir #include <string.h>
31cdf0e10cSrcweir #include <errno.h>
32cdf0e10cSrcweir #include <stdarg.h>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <unistd.h>
35cdf0e10cSrcweir #include <fcntl.h>
36cdf0e10cSrcweir #include <dirent.h>
37cdf0e10cSrcweir #include <signal.h>
38cdf0e10cSrcweir #include <utime.h>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <pwd.h>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include <netdb.h>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include <sys/stat.h>
45cdf0e10cSrcweir #include <sys/wait.h>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include <sys/types.h>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir /* Make sockets of type AF_UNIX use underlying FS rights */
50cdf0e10cSrcweir #ifdef SOLARIS
51cdf0e10cSrcweir #	define _XOPEN_SOURCE 500
52cdf0e10cSrcweir #	include <sys/socket.h>
53cdf0e10cSrcweir #	undef _XOPEN_SOURCE
54cdf0e10cSrcweir #else
55cdf0e10cSrcweir #	include <sys/socket.h>
56cdf0e10cSrcweir #endif
57cdf0e10cSrcweir 
58cdf0e10cSrcweir #include <netinet/in.h>
59cdf0e10cSrcweir #include <arpa/inet.h>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #ifdef SYSV
62cdf0e10cSrcweir #   include <sys/utsname.h>
63cdf0e10cSrcweir #endif
64cdf0e10cSrcweir 
65cdf0e10cSrcweir #ifdef LINUX
66cdf0e10cSrcweir #   ifndef __USE_GNU
67cdf0e10cSrcweir #   define __USE_GNU
68cdf0e10cSrcweir #   endif
69cdf0e10cSrcweir 
70cdf0e10cSrcweir #if GLIBC >= 2
71cdf0e10cSrcweir #   include <shadow.h>
72cdf0e10cSrcweir #   include <pthread.h>
73cdf0e10cSrcweir #   include <sys/file.h>
74cdf0e10cSrcweir #   include <sys/ioctl.h>
75cdf0e10cSrcweir #	include <sys/uio.h>
76cdf0e10cSrcweir #	include <sys/un.h>
77cdf0e10cSrcweir #   include <netinet/tcp.h>
78cdf0e10cSrcweir #   include <dlfcn.h>
79cdf0e10cSrcweir #	include <endian.h>
80cdf0e10cSrcweir #	include <sys/time.h>
81cdf0e10cSrcweir #	include <semaphore.h>
82cdf0e10cSrcweir #	if __BYTE_ORDER == __LITTLE_ENDIAN
83cdf0e10cSrcweir #		define _LITTLE_ENDIAN
84cdf0e10cSrcweir #	elif __BYTE_ORDER == __BIG_ENDIAN
85cdf0e10cSrcweir #               ifndef _BIG_ENDIAN
86cdf0e10cSrcweir #               define _BIG_ENDIAN
87cdf0e10cSrcweir #               endif
88cdf0e10cSrcweir #	elif __BYTE_ORDER == __PDP_ENDIAN
89cdf0e10cSrcweir #		define _PDP_ENDIAN
90cdf0e10cSrcweir #	endif
91cdf0e10cSrcweir #	define 	IORESOURCE_TRANSFER_BSD
92cdf0e10cSrcweir #	define 	IOCHANNEL_TRANSFER_BSD_RENO
93cdf0e10cSrcweir #	define	pthread_testcancel()
94cdf0e10cSrcweir #	define  NO_PTHREAD_PRIORITY
95cdf0e10cSrcweir #	define  PTHREAD_SIGACTION 			pthread_sigaction
96cdf0e10cSrcweir #else
97cdf0e10cSrcweir #   include <shadow.h>
98cdf0e10cSrcweir #   include <asm/sigcontext.h>
99cdf0e10cSrcweir #   include <pthread.h>
100cdf0e10cSrcweir #   include <sys/file.h>
101cdf0e10cSrcweir #   include <sys/ioctl.h>
102cdf0e10cSrcweir #   include <linux/net.h>
103cdf0e10cSrcweir #	include <sys/un.h>
104cdf0e10cSrcweir #   include <netinet/tcp.h>
105cdf0e10cSrcweir #   include <linux/elfcore.h>
106cdf0e10cSrcweir #   include <dlfcn.h>
107cdf0e10cSrcweir #	include <endian.h>
108cdf0e10cSrcweir #	if __BYTE_ORDER == __LITTLE_ENDIAN
109cdf0e10cSrcweir #		define _LITTLE_ENDIAN
110cdf0e10cSrcweir #	elif __BYTE_ORDER == __BIG_ENDIAN
111cdf0e10cSrcweir #		define _BIG_ENDIAN
112cdf0e10cSrcweir #	elif __BYTE_ORDER == __PDP_ENDIAN
113cdf0e10cSrcweir #		define _PDP_ENDIAN
114cdf0e10cSrcweir #	endif
115cdf0e10cSrcweir #	define 	IORESOURCE_TRANSFER_BSD
116cdf0e10cSrcweir #	define 	IOCHANNEL_TRANSFER_BSD_RENO
117cdf0e10cSrcweir #	define	pthread_testcancel()
118cdf0e10cSrcweir #	define  NO_PTHREAD_RTL
119cdf0e10cSrcweir #	define  NO_PTHREAD_PRIORITY
120cdf0e10cSrcweir #	define  PTHREAD_SIGACTION 			pthread_sigaction
121cdf0e10cSrcweir #endif
122cdf0e10cSrcweir 
123cdf0e10cSrcweir #   ifndef ETIME
124cdf0e10cSrcweir #       define ETIME ETIMEDOUT
125cdf0e10cSrcweir #   endif
126cdf0e10cSrcweir 
127cdf0e10cSrcweir #endif
128cdf0e10cSrcweir 
129cdf0e10cSrcweir #ifdef NETBSD
130cdf0e10cSrcweir #	define  ETIME ETIMEDOUT
131cdf0e10cSrcweir #	define _POSIX_THREAD_SYSCALL_SOFT 1
132cdf0e10cSrcweir #	include <pthread.h>
133cdf0e10cSrcweir #	include <netdb.h>
134cdf0e10cSrcweir #	include <sys/sem.h>
135cdf0e10cSrcweir #	include <sys/exec.h>
136cdf0e10cSrcweir #	include <sys/filio.h>
137cdf0e10cSrcweir #	include <sys/ioctl.h>
138cdf0e10cSrcweir #	include <sys/time.h>
139cdf0e10cSrcweir #	include <sys/un.h>
140cdf0e10cSrcweir #	include <netinet/tcp.h>
141cdf0e10cSrcweir #	include <dlfcn.h>
142cdf0e10cSrcweir #   include <machine/endian.h>
143cdf0e10cSrcweir #   if BYTE_ORDER == LITTLE_ENDIAN
144cdf0e10cSrcweir #   	define _LITTLE_ENDIAN_OO
145cdf0e10cSrcweir #   elif BYTE_ORDER == BIG_ENDIAN
146cdf0e10cSrcweir #   	define _BIG_ENDIAN_OO
147cdf0e10cSrcweir #   elif BYTE_ORDER == PDP_ENDIAN
148cdf0e10cSrcweir #   	define _PDP_ENDIAN_OO
149cdf0e10cSrcweir #   endif
150cdf0e10cSrcweir #	define 	IORESOURCE_TRANSFER_BSD
151cdf0e10cSrcweir #	define 	IOCHANNEL_TRANSFER_BSD_RENO
152cdf0e10cSrcweir #	define	pthread_testcancel()
153cdf0e10cSrcweir #	define  NO_PTHREAD_PRIORITY
154cdf0e10cSrcweir #     define  NO_PTHREAD_SEMAPHORES
155cdf0e10cSrcweir #	define  NO_PTHREAD_RTL
156cdf0e10cSrcweir #	define  PTHREAD_SIGACTION 			pthread_sigaction
157cdf0e10cSrcweir #endif
158cdf0e10cSrcweir 
159cdf0e10cSrcweir #ifdef FREEBSD
160cdf0e10cSrcweir #   define  ETIME ETIMEDOUT
161cdf0e10cSrcweir #   include <pthread.h>
162cdf0e10cSrcweir #   include <sys/sem.h>
163cdf0e10cSrcweir #   include <semaphore.h>
164cdf0e10cSrcweir #   include <dlfcn.h>
165cdf0e10cSrcweir #   include <sys/filio.h>
166cdf0e10cSrcweir #   include <sys/ioctl.h>
167cdf0e10cSrcweir #   include <sys/param.h>
168cdf0e10cSrcweir #   include <sys/time.h>
169cdf0e10cSrcweir #   include <sys/uio.h>
170cdf0e10cSrcweir #   include <sys/exec.h>
171cdf0e10cSrcweir #   include <vm/vm.h>
172cdf0e10cSrcweir #   include <vm/vm_param.h>
173cdf0e10cSrcweir #   include <vm/pmap.h>
174cdf0e10cSrcweir #   include <vm/swap_pager.h>
175cdf0e10cSrcweir #	include <sys/un.h>
176cdf0e10cSrcweir #   include <netinet/tcp.h>
177cdf0e10cSrcweir #	define 	IORESOURCE_TRANSFER_BSD
178cdf0e10cSrcweir #   include <machine/endian.h>
179cdf0e10cSrcweir #if __FreeBSD_version < 500000
180cdf0e10cSrcweir #   if BYTE_ORDER == LITTLE_ENDIAN
181cdf0e10cSrcweir #   	define _LITTLE_ENDIAN
182cdf0e10cSrcweir #   elif BYTE_ORDER == BIG_ENDIAN
183cdf0e10cSrcweir #   	define _BIG_ENDIAN
184cdf0e10cSrcweir #   elif BYTE_ORDER == PDP_ENDIAN
185cdf0e10cSrcweir #   	define _PDP_ENDIAN
186cdf0e10cSrcweir #   endif
187cdf0e10cSrcweir #endif
188cdf0e10cSrcweir #	define  NO_PTHREAD_RTL
189cdf0e10cSrcweir #endif
190cdf0e10cSrcweir 
191cdf0e10cSrcweir #ifdef SCO
192cdf0e10cSrcweir #   define AF_IPX -1
193cdf0e10cSrcweir #	include <strings.h>
194cdf0e10cSrcweir #	include <pthread.h>
195cdf0e10cSrcweir #	include <shadow.h>
196cdf0e10cSrcweir #	include <netdb.h>
197cdf0e10cSrcweir #	include <sys/un.h>
198cdf0e10cSrcweir #	include <sys/netinet/tcp.h>
199cdf0e10cSrcweir #   include <sys/types.h>
200cdf0e10cSrcweir #   include <sys/byteorder.h>
201cdf0e10cSrcweir #   include <dlfcn.h>
202cdf0e10cSrcweir #   if BYTE_ORDER == LITTLE_ENDIAN
203cdf0e10cSrcweir #   	define _LITTLE_ENDIAN
204cdf0e10cSrcweir #   elif BYTE_ORDER == BIG_ENDIAN
205cdf0e10cSrcweir #   	define _BIG_ENDIAN
206cdf0e10cSrcweir #   elif BYTE_ORDER == PDP_ENDIAN
207cdf0e10cSrcweir #   	define _PDP_ENDIAN
208cdf0e10cSrcweir #   endif
209cdf0e10cSrcweir #	define  sched_yield() 				pthread_yield()
210cdf0e10cSrcweir #	define	pthread_testcancel()
211cdf0e10cSrcweir #	define  NO_PTHREAD_RTL
212cdf0e10cSrcweir #	define  NO_PTHREAD_PRIORITY
213cdf0e10cSrcweir extern int pthread_cancel(pthread_t);
214cdf0e10cSrcweir extern unsigned int nanosleep(unsigned int);
215cdf0e10cSrcweir #	define  SLEEP_TIMESPEC(timespec)  	(timespec .tv_sec > 0) ? sleep(timespec .tv_sec), nanosleep(timespec .tv_nsec) : nanosleep(timespec .tv_nsec)
216cdf0e10cSrcweir #	define  PATH_MAX 					_POSIX_PATH_MAX
217cdf0e10cSrcweir #	define	S_ISSOCK					S_ISFIFO
218cdf0e10cSrcweir #	define	PTHREAD_SIGACTION 			pthread_sigaction
219cdf0e10cSrcweir #	define	STAT_PARENT					stat
220cdf0e10cSrcweir #endif
221cdf0e10cSrcweir 
222cdf0e10cSrcweir #ifdef AIX
223cdf0e10cSrcweir #   define AF_IPX -1
224cdf0e10cSrcweir #	include <strings.h>
225cdf0e10cSrcweir #	include <pthread.h>
226cdf0e10cSrcweir #	include <sys/time.h>
227cdf0e10cSrcweir #	include <sys/un.h>
228cdf0e10cSrcweir #	include <netinet/tcp.h>
229cdf0e10cSrcweir #	include <sys/machine.h>
230cdf0e10cSrcweir #   if BYTE_ORDER == LITTLE_ENDIAN
231cdf0e10cSrcweir #   	define _LITTLE_ENDIAN
232cdf0e10cSrcweir #   elif BYTE_ORDER == BIG_ENDIAN
233cdf0e10cSrcweir #   	define _BIG_ENDIAN
234cdf0e10cSrcweir #   elif BYTE_ORDER == PDP_ENDIAN
235cdf0e10cSrcweir #   	define _PDP_ENDIAN
236cdf0e10cSrcweir #   endif
237cdf0e10cSrcweir #	define  sched_yield() 				pthread_yield()
238cdf0e10cSrcweir #	define  SLEEP_TIMESPEC(timespec)  	nsleep(&timespec, 0)
239cdf0e10cSrcweir #	define  LIBPATH "LIBPATH"
240cdf0e10cSrcweir #	define  NO_PTHREAD_SEMAPHORES
241cdf0e10cSrcweir #   define  NO_DL_FUNCTIONS
242cdf0e10cSrcweir #endif
243cdf0e10cSrcweir 
244cdf0e10cSrcweir #ifdef HPUX
245cdf0e10cSrcweir #   define  AF_IPX -1
246cdf0e10cSrcweir #   undef	howmany
247cdf0e10cSrcweir #   undef	MAXINT
248cdf0e10cSrcweir #	include <pthread.h>
249cdf0e10cSrcweir #	include <sys/un.h>
250cdf0e10cSrcweir #	include <sys/sched.h>
251cdf0e10cSrcweir #	include <sys/xti.h>
252cdf0e10cSrcweir #	include <sys/pstat.h>
253cdf0e10cSrcweir #	include <shadow.h>
254cdf0e10cSrcweir #	include <crypt.h>
255cdf0e10cSrcweir #	include <machine/param.h>
256cdf0e10cSrcweir #	define  LIBPATH "SHLIB_PATH"
257cdf0e10cSrcweir #	define  PTR_FD_SET(s)				((int *)&(s))
258cdf0e10cSrcweir #	define  PTHREAD_VALUE(t)			((t).field2)
259cdf0e10cSrcweir # 	define  PTHREAD_NONE_INIT			{ 0, -1 }
260cdf0e10cSrcweir #	define  PTHREAD_ATTR_DEFAULT		pthread_attr_default
261cdf0e10cSrcweir #	define  PTHREAD_MUTEXATTR_DEFAULT	pthread_mutexattr_default
262cdf0e10cSrcweir #	define  PTHREAD_CONDATTR_DEFAULT	pthread_condattr_default
263cdf0e10cSrcweir #	define  pthread_detach(t)			pthread_detach(&(t))
264cdf0e10cSrcweir #	define  NO_PTHREAD_PRIORITY
265cdf0e10cSrcweir #	define  NO_PTHREAD_SEMAPHORES
266cdf0e10cSrcweir #   define  NO_DL_FUNCTIONS
267cdf0e10cSrcweir #	undef	sigaction
268cdf0e10cSrcweir #	define  PTHREAD_SIGACTION 			cma_sigaction
269cdf0e10cSrcweir #endif
270cdf0e10cSrcweir 
271cdf0e10cSrcweir #ifdef SOLARIS
272cdf0e10cSrcweir #	include <shadow.h>
273cdf0e10cSrcweir #	include <sys/un.h>
274cdf0e10cSrcweir #	include <stropts.h>
275cdf0e10cSrcweir #	include <pthread.h>
276cdf0e10cSrcweir #	include <semaphore.h>
277cdf0e10cSrcweir #	include <netinet/tcp.h>
278cdf0e10cSrcweir #	include <sys/filio.h>
279cdf0e10cSrcweir #	include <dlfcn.h>
280cdf0e10cSrcweir #	include <sys/isa_defs.h>
281cdf0e10cSrcweir #	define 	IORESOURCE_TRANSFER_SYSV
282cdf0e10cSrcweir #	define 	IOCHANNEL_TRANSFER_BSD
283cdf0e10cSrcweir #	define  LIBPATH "LD_LIBRARY_PATH"
284cdf0e10cSrcweir #endif
285cdf0e10cSrcweir 
286cdf0e10cSrcweir #ifdef MACOSX
287cdf0e10cSrcweir #define __OPENTRANSPORTPROVIDERS__ // these are already defined
288cdf0e10cSrcweir #define TimeValue CFTimeValue      // Do not conflict with TimeValue in sal/inc/osl/time.h
289cdf0e10cSrcweir #include <Carbon/Carbon.h>
290cdf0e10cSrcweir #undef TimeValue
291cdf0e10cSrcweir #	ifndef ETIME
292cdf0e10cSrcweir #		define  ETIME ETIMEDOUT
293cdf0e10cSrcweir #	endif
294cdf0e10cSrcweir #	include <dlfcn.h>
295cdf0e10cSrcweir #	include <pthread.h>
296cdf0e10cSrcweir #	include <sys/file.h>
297cdf0e10cSrcweir #	include <sys/ioctl.h>
298cdf0e10cSrcweir #	include <sys/uio.h>
299cdf0e10cSrcweir #	include <sys/un.h>
300cdf0e10cSrcweir #	include <netinet/tcp.h>
301cdf0e10cSrcweir #	include <machine/endian.h>
302cdf0e10cSrcweir #	include <sys/time.h>
303cdf0e10cSrcweir #	include <sys/semaphore.h>
304cdf0e10cSrcweir /* fixme are premac and postmac still needed here? */
305cdf0e10cSrcweir #	include <premac.h>
306cdf0e10cSrcweir #	include <mach-o/dyld.h>
307cdf0e10cSrcweir #	include <postmac.h>
308cdf0e10cSrcweir #	if BYTE_ORDER == LITTLE_ENDIAN
309cdf0e10cSrcweir #		ifndef _LITTLE_ENDIAN
310cdf0e10cSrcweir #		define _LITTLE_ENDIAN
311cdf0e10cSrcweir #		endif
312cdf0e10cSrcweir #	elif BYTE_ORDER == BIG_ENDIAN
313cdf0e10cSrcweir #		ifndef _BIG_ENDIAN
314cdf0e10cSrcweir #		define _BIG_ENDIAN
315cdf0e10cSrcweir #		endif
316cdf0e10cSrcweir #	elif BYTE_ORDER == PDP_ENDIAN
317cdf0e10cSrcweir #		ifndef _PDP_ENDIAN
318cdf0e10cSrcweir #		define _PDP_ENDIAN
319cdf0e10cSrcweir #		endif
320cdf0e10cSrcweir #	endif
321cdf0e10cSrcweir #	define 	IOCHANNEL_TRANSFER_BSD_RENO
322cdf0e10cSrcweir #	define  NO_PTHREAD_RTL
323cdf0e10cSrcweir /* for NSGetArgc/Argv/Environ */
324cdf0e10cSrcweir #       include <crt_externs.h>
325cdf0e10cSrcweir #ifdef __cplusplus
326cdf0e10cSrcweir extern "C" {
327cdf0e10cSrcweir #endif
328cdf0e10cSrcweir int macxp_resolveAlias(char *path, int buflen);
329cdf0e10cSrcweir #ifdef __cplusplus
330cdf0e10cSrcweir }
331cdf0e10cSrcweir #endif
332cdf0e10cSrcweir #endif
333cdf0e10cSrcweir 
334cdf0e10cSrcweir #if !defined(_WIN32)  && !defined(_WIN16) && !defined(OS2)  && \
335cdf0e10cSrcweir     !defined(LINUX)   && !defined(NETBSD) && !defined(FREEBSD) && !defined(SCO)  && \
336cdf0e10cSrcweir 	!defined(AIX)     && !defined(HPUX)   && \
337cdf0e10cSrcweir 	!defined(SOLARIS) && !defined(MACOSX)
338cdf0e10cSrcweir #	error "Target platform not specified!"
339cdf0e10cSrcweir #endif
340cdf0e10cSrcweir 
341cdf0e10cSrcweir #if defined(NETBSD)
342cdf0e10cSrcweir #if defined _LITTLE_ENDIAN_OO
343cdf0e10cSrcweir #	define _OSL_BIGENDIAN
344cdf0e10cSrcweir #elif defined _BIG_ENDIAN_OO
345cdf0e10cSrcweir #	define _OSL_LITENDIAN
346cdf0e10cSrcweir #else
347cdf0e10cSrcweir #	error undetermined endianess
348cdf0e10cSrcweir #endif
349cdf0e10cSrcweir #else
350cdf0e10cSrcweir #if defined _LITTLE_ENDIAN
351cdf0e10cSrcweir #	define _OSL_BIGENDIAN
352cdf0e10cSrcweir #elif defined _BIG_ENDIAN
353cdf0e10cSrcweir #	define _OSL_LITENDIAN
354cdf0e10cSrcweir #else
355cdf0e10cSrcweir #	error undetermined endianess
356cdf0e10cSrcweir #endif
357cdf0e10cSrcweir #endif
358cdf0e10cSrcweir 
359cdf0e10cSrcweir #ifndef PTR_FD_SET
360cdf0e10cSrcweir #	define PTR_FD_SET(s)				(&(s))
361cdf0e10cSrcweir #endif
362cdf0e10cSrcweir 
363cdf0e10cSrcweir #ifndef NORMALIZE_TIMESPEC
364cdf0e10cSrcweir #	define NORMALIZE_TIMESPEC(timespec) \
365cdf0e10cSrcweir   		timespec . tv_sec  += timespec . tv_nsec / 1000000000; \
366cdf0e10cSrcweir   		timespec . tv_nsec %= 1000000000;
367cdf0e10cSrcweir #endif
368cdf0e10cSrcweir 
369cdf0e10cSrcweir #ifndef SET_TIMESPEC
370cdf0e10cSrcweir #	define SET_TIMESPEC(timespec, sec, nsec) \
371cdf0e10cSrcweir   		timespec . tv_sec  = (sec);  \
372cdf0e10cSrcweir   		timespec . tv_nsec = (nsec); \
373cdf0e10cSrcweir 		NORMALIZE_TIMESPEC(timespec);
374cdf0e10cSrcweir #endif
375cdf0e10cSrcweir 
376cdf0e10cSrcweir #ifndef SLEEP_TIMESPEC
377cdf0e10cSrcweir #	define SLEEP_TIMESPEC(timespec) nanosleep(&timespec, 0)
378cdf0e10cSrcweir #endif
379cdf0e10cSrcweir 
380cdf0e10cSrcweir #ifndef INIT_GROUPS
381cdf0e10cSrcweir #	define  INIT_GROUPS(name, gid)	((setgid((gid)) == 0) && (initgroups((name), (gid)) == 0))
382cdf0e10cSrcweir #endif
383cdf0e10cSrcweir 
384cdf0e10cSrcweir #ifndef PTHREAD_VALUE
385cdf0e10cSrcweir #	define PTHREAD_VALUE(t) 			(t)
386cdf0e10cSrcweir #endif
387cdf0e10cSrcweir #ifndef PTHREAD_NONE
388cdf0e10cSrcweir # if (__GNUC__ < 4) && !defined(MACOSX)
389cdf0e10cSrcweir extern pthread_t _pthread_none_;
390cdf0e10cSrcweir # endif
391cdf0e10cSrcweir #	define PTHREAD_NONE					_pthread_none_
392cdf0e10cSrcweir #   ifndef PTHREAD_NONE_INIT
393cdf0e10cSrcweir #		define PTHREAD_NONE_INIT		((pthread_t)-1)
394cdf0e10cSrcweir #	endif
395cdf0e10cSrcweir #endif
396cdf0e10cSrcweir 
397cdf0e10cSrcweir #ifndef PTHREAD_ATTR_DEFAULT
398cdf0e10cSrcweir #	define PTHREAD_ATTR_DEFAULT 		NULL
399cdf0e10cSrcweir #endif
400cdf0e10cSrcweir #ifndef PTHREAD_MUTEXATTR_DEFAULT
401cdf0e10cSrcweir #	define PTHREAD_MUTEXATTR_DEFAULT 	NULL
402cdf0e10cSrcweir #endif
403cdf0e10cSrcweir #ifndef PTHREAD_CONDATTR_DEFAULT
404cdf0e10cSrcweir #	define PTHREAD_CONDATTR_DEFAULT 	NULL
405cdf0e10cSrcweir #endif
406cdf0e10cSrcweir 
407cdf0e10cSrcweir #ifndef PTHREAD_SIGACTION
408cdf0e10cSrcweir #	define PTHREAD_SIGACTION sigaction
409cdf0e10cSrcweir #endif
410cdf0e10cSrcweir 
411cdf0e10cSrcweir #ifndef STAT_PARENT
412cdf0e10cSrcweir #	define STAT_PARENT					lstat
413cdf0e10cSrcweir #endif
414cdf0e10cSrcweir 
415cdf0e10cSrcweir /* socket options which might not be defined on all unx flavors */
416cdf0e10cSrcweir #ifndef SO_ACCEPTCONN
417cdf0e10cSrcweir #	define SO_ACCEPTCONN 	0
418cdf0e10cSrcweir #endif
419cdf0e10cSrcweir #ifndef SO_SNDLOWAT
420cdf0e10cSrcweir #	define SO_SNDLOWAT 		0
421cdf0e10cSrcweir #endif
422cdf0e10cSrcweir #ifndef SO_RCVLOWAT
423cdf0e10cSrcweir #	define SO_RCVLOWAT 		0
424cdf0e10cSrcweir #endif
425cdf0e10cSrcweir #ifndef SO_SNDTIMEO
426cdf0e10cSrcweir #	define	SO_SNDTIMEO 	0
427cdf0e10cSrcweir #endif
428cdf0e10cSrcweir #ifndef SO_RCVTIMEO
429cdf0e10cSrcweir #	define SO_RCVTIMEO 		0
430cdf0e10cSrcweir #endif
431cdf0e10cSrcweir #ifndef SO_USELOOPBACK
432cdf0e10cSrcweir #	define SO_USELOOPBACK 	0
433cdf0e10cSrcweir #endif
434cdf0e10cSrcweir #ifndef MSG_MAXIOVLEN
435cdf0e10cSrcweir #	define MSG_MAXIOVLEN 	0
436cdf0e10cSrcweir #endif
437cdf0e10cSrcweir 
438cdf0e10cSrcweir /* BEGIN HACK */
439cdf0e10cSrcweir /* dummy define and declarations for IPX should be replaced by */
440cdf0e10cSrcweir /* original ipx headers when these are available for this platform */
441cdf0e10cSrcweir 
442cdf0e10cSrcweir #ifndef SA_FAMILY_DECL
443cdf0e10cSrcweir #	define SA_FAMILY_DECL short sa_family
444cdf0e10cSrcweir #endif
445cdf0e10cSrcweir 
446cdf0e10cSrcweir typedef struct sockaddr_ipx {
447cdf0e10cSrcweir     SA_FAMILY_DECL;
448cdf0e10cSrcweir     char  sa_netnum[4];
449cdf0e10cSrcweir     char  sa_nodenum[6];
450cdf0e10cSrcweir     unsigned short sa_socket;
451cdf0e10cSrcweir } SOCKADDR_IPX;
452cdf0e10cSrcweir 
453cdf0e10cSrcweir #define NSPROTO_IPX      1000
454cdf0e10cSrcweir #define NSPROTO_SPX      1256
455cdf0e10cSrcweir #define NSPROTO_SPXII    1257
456cdf0e10cSrcweir 
457cdf0e10cSrcweir /* END HACK */
458cdf0e10cSrcweir 
459cdf0e10cSrcweir #ifdef NO_PTHREAD_SEMAPHORES
460cdf0e10cSrcweir 
461cdf0e10cSrcweir typedef struct
462cdf0e10cSrcweir {
463cdf0e10cSrcweir 	pthread_mutex_t	mutex;
464cdf0e10cSrcweir 	pthread_cond_t	increased;
465cdf0e10cSrcweir 	int			    value;
466cdf0e10cSrcweir } sem_t;
467cdf0e10cSrcweir extern int sem_init(sem_t* sem, int pshared, unsigned int value);
468cdf0e10cSrcweir extern int sem_destroy(sem_t* sem);
469cdf0e10cSrcweir extern int sem_wait(sem_t* sem);
470cdf0e10cSrcweir extern int sem_trywait(sem_t* sem);
471cdf0e10cSrcweir extern int sem_post(sem_t* sem);
472cdf0e10cSrcweir 
473cdf0e10cSrcweir #endif
474cdf0e10cSrcweir 
475cdf0e10cSrcweir #ifdef NO_PTHREAD_RTL
476cdf0e10cSrcweir #if !defined FREEBSD || (__FreeBSD_version < 500112)
477cdf0e10cSrcweir struct passwd *getpwent_r(struct passwd *pwd, char *buffer,  int buflen);
478cdf0e10cSrcweir extern struct spwd *getspnam_r(const char *name, struct spwd *result,
479cdf0e10cSrcweir 							   char *buffer, int buflen);
480cdf0e10cSrcweir 
481cdf0e10cSrcweir struct tm *localtime_r(const time_t *timep, struct tm *buffer);
482cdf0e10cSrcweir struct tm *gmtime_r(const time_t *timep, struct tm *buffer);
483cdf0e10cSrcweir #endif /* !defined FREEBSD || (__FreeBSD_version < 500112) */
484cdf0e10cSrcweir #if !defined(FREEBSD) || (__FreeBSD_version < 601103)
485cdf0e10cSrcweir struct hostent *gethostbyname_r(const char *name, struct hostent *result,
486cdf0e10cSrcweir 								char *buffer, int buflen, int *h_errnop);
487cdf0e10cSrcweir #endif /* !defined(FREEBSD) || (__FreeBSD_version < 601103) */
488cdf0e10cSrcweir #endif
489cdf0e10cSrcweir 
490cdf0e10cSrcweir #endif /* __OSL_SYSTEM_H__ */
491cdf0e10cSrcweir 
492