1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef __OSL_SYSTEM_H__
29 #define __OSL_SYSTEM_H__
51 #include <sys/types.h>
53 /* Make sockets of type AF_UNIX use underlying FS rights */
55 # define _XOPEN_SOURCE 500
56 # include <sys/socket.h>
59 # include <sys/socket.h>
62 #include <netinet/in.h>
63 #include <arpa/inet.h>
66 # include <sys/utsname.h>
77 # include <sys/file.h>
78 # include <sys/ioctl.h>
81 # include <netinet/tcp.h>
84 # include <sys/time.h>
85 # include <semaphore.h>
86 # if __BYTE_ORDER == __LITTLE_ENDIAN
87 # define _LITTLE_ENDIAN
88 # elif __BYTE_ORDER == __BIG_ENDIAN
92 # elif __BYTE_ORDER == __PDP_ENDIAN
95 # define IORESOURCE_TRANSFER_BSD
96 # define IOCHANNEL_TRANSFER_BSD_RENO
97 # define pthread_testcancel()
98 # define NO_PTHREAD_PRIORITY
99 # define PTHREAD_SIGACTION pthread_sigaction
102 # include <asm/sigcontext.h>
103 # include <pthread.h>
104 # include <sys/file.h>
105 # include <sys/ioctl.h>
106 # include <linux/net.h>
108 # include <netinet/tcp.h>
109 # include <linux/elfcore.h>
112 # if __BYTE_ORDER == __LITTLE_ENDIAN
113 # define _LITTLE_ENDIAN
114 # elif __BYTE_ORDER == __BIG_ENDIAN
116 # elif __BYTE_ORDER == __PDP_ENDIAN
119 # define IORESOURCE_TRANSFER_BSD
120 # define IOCHANNEL_TRANSFER_BSD_RENO
121 # define pthread_testcancel()
122 # define NO_PTHREAD_RTL
123 # define NO_PTHREAD_PRIORITY
124 # define PTHREAD_SIGACTION pthread_sigaction
128 # define ETIME ETIMEDOUT
134 # define ETIME ETIMEDOUT
135 # define _POSIX_THREAD_SYSCALL_SOFT 1
136 # include <pthread.h>
138 # include <sys/sem.h>
139 # include <sys/exec.h>
140 # include <sys/filio.h>
141 # include <sys/ioctl.h>
142 # include <sys/time.h>
144 # include <netinet/tcp.h>
146 # include <machine/endian.h>
147 # if BYTE_ORDER == LITTLE_ENDIAN
148 # define _LITTLE_ENDIAN_OO
149 # elif BYTE_ORDER == BIG_ENDIAN
150 # define _BIG_ENDIAN_OO
151 # elif BYTE_ORDER == PDP_ENDIAN
152 # define _PDP_ENDIAN_OO
154 # define IORESOURCE_TRANSFER_BSD
155 # define IOCHANNEL_TRANSFER_BSD_RENO
156 # define pthread_testcancel()
157 # define NO_PTHREAD_PRIORITY
158 # define NO_PTHREAD_SEMAPHORES
159 # define NO_PTHREAD_RTL
160 # define PTHREAD_SIGACTION pthread_sigaction
164 # define ETIME ETIMEDOUT
165 # include <pthread.h>
166 # include <sys/sem.h>
167 # include <semaphore.h>
169 # include <sys/filio.h>
170 # include <sys/ioctl.h>
171 # include <sys/param.h>
172 # include <sys/time.h>
173 # include <sys/uio.h>
174 # include <sys/exec.h>
176 # include <vm/vm_param.h>
177 # include <vm/pmap.h>
178 # include <vm/swap_pager.h>
180 # include <netinet/tcp.h>
181 # define IORESOURCE_TRANSFER_BSD
182 # include <machine/endian.h>
183 #if __FreeBSD_version < 500000
184 # if BYTE_ORDER == LITTLE_ENDIAN
185 # define _LITTLE_ENDIAN
186 # elif BYTE_ORDER == BIG_ENDIAN
188 # elif BYTE_ORDER == PDP_ENDIAN
192 # define NO_PTHREAD_RTL
197 # include <strings.h>
198 # include <pthread.h>
202 # include <sys/netinet/tcp.h>
203 # include <sys/types.h>
204 # include <sys/byteorder.h>
206 # if BYTE_ORDER == LITTLE_ENDIAN
207 # define _LITTLE_ENDIAN
208 # elif BYTE_ORDER == BIG_ENDIAN
210 # elif BYTE_ORDER == PDP_ENDIAN
213 # define sched_yield() pthread_yield()
214 # define pthread_testcancel()
215 # define NO_PTHREAD_RTL
216 # define NO_PTHREAD_PRIORITY
217 extern int pthread_cancel(pthread_t
);
218 extern unsigned int nanosleep(unsigned int);
219 # define SLEEP_TIMESPEC(timespec) (timespec .tv_sec > 0) ? sleep(timespec .tv_sec), nanosleep(timespec .tv_nsec) : nanosleep(timespec .tv_nsec)
220 # define PATH_MAX _POSIX_PATH_MAX
221 # define S_ISSOCK S_ISFIFO
222 # define PTHREAD_SIGACTION pthread_sigaction
223 # define STAT_PARENT stat
228 # include <strings.h>
229 # include <pthread.h>
230 # include <sys/time.h>
232 # include <netinet/tcp.h>
233 # include <sys/machine.h>
234 # if BYTE_ORDER == LITTLE_ENDIAN
235 # define _LITTLE_ENDIAN
236 # elif BYTE_ORDER == BIG_ENDIAN
238 # elif BYTE_ORDER == PDP_ENDIAN
241 # define sched_yield() pthread_yield()
242 # define SLEEP_TIMESPEC(timespec) nsleep(×pec, 0)
243 # define LIBPATH "LIBPATH"
244 # define NO_PTHREAD_SEMAPHORES
245 # define NO_DL_FUNCTIONS
252 # include <pthread.h>
254 # include <sys/sched.h>
255 # include <sys/xti.h>
256 # include <sys/pstat.h>
259 # include <machine/param.h>
260 # define LIBPATH "SHLIB_PATH"
261 # define PTR_FD_SET(s) ((int *)&(s))
262 # define PTHREAD_VALUE(t) ((t).field2)
263 # define PTHREAD_NONE_INIT { 0, -1 }
264 # define PTHREAD_ATTR_DEFAULT pthread_attr_default
265 # define PTHREAD_MUTEXATTR_DEFAULT pthread_mutexattr_default
266 # define PTHREAD_CONDATTR_DEFAULT pthread_condattr_default
267 # define pthread_detach(t) pthread_detach(&(t))
268 # define NO_PTHREAD_PRIORITY
269 # define NO_PTHREAD_SEMAPHORES
270 # define NO_DL_FUNCTIONS
272 # define PTHREAD_SIGACTION cma_sigaction
278 # include <stropts.h>
279 # include <pthread.h>
280 # include <semaphore.h>
281 # include <netinet/tcp.h>
282 # include <sys/filio.h>
284 # include <sys/isa_defs.h>
285 # define IORESOURCE_TRANSFER_SYSV
286 # define IOCHANNEL_TRANSFER_BSD
287 # define LIBPATH "LD_LIBRARY_PATH"
291 #define __OPENTRANSPORTPROVIDERS__ // these are already defined
292 #define TimeValue CFTimeValue // Do not conflict with TimeValue in sal/inc/osl/time.h
293 #include <Carbon/Carbon.h>
296 # define ETIME ETIMEDOUT
299 # include <pthread.h>
300 # include <sys/file.h>
301 # include <sys/ioctl.h>
302 # include <sys/uio.h>
304 # include <netinet/tcp.h>
305 # include <machine/endian.h>
306 # include <sys/time.h>
307 # include <sys/semaphore.h>
308 /* fixme are premac and postmac still needed here? */
310 # include <mach-o/dyld.h>
311 # include <postmac.h>
312 # if BYTE_ORDER == LITTLE_ENDIAN
313 # ifndef _LITTLE_ENDIAN
314 # define _LITTLE_ENDIAN
316 # elif BYTE_ORDER == BIG_ENDIAN
320 # elif BYTE_ORDER == PDP_ENDIAN
325 # define IOCHANNEL_TRANSFER_BSD_RENO
326 # define NO_PTHREAD_RTL
327 /* for NSGetArgc/Argv/Environ */
328 # include <crt_externs.h>
332 int macxp_resolveAlias(char *path
, int buflen
);
338 #if !defined(_WIN32) && !defined(_WIN16) && !defined(OS2) && \
339 !defined(LINUX) && !defined(NETBSD) && !defined(FREEBSD) && !defined(SCO) && \
340 !defined(AIX) && !defined(HPUX) && \
341 !defined(SOLARIS) && !defined(MACOSX)
342 # error "Target platform not specified!"
346 #if defined _LITTLE_ENDIAN_OO
347 # define _OSL_BIGENDIAN
348 #elif defined _BIG_ENDIAN_OO
349 # define _OSL_LITENDIAN
351 # error undetermined endianess
354 #if defined _LITTLE_ENDIAN
355 # define _OSL_BIGENDIAN
356 #elif defined _BIG_ENDIAN
357 # define _OSL_LITENDIAN
359 # error undetermined endianess
364 # define PTR_FD_SET(s) (&(s))
367 #ifndef NORMALIZE_TIMESPEC
368 # define NORMALIZE_TIMESPEC(timespec) \
369 timespec . tv_sec += timespec . tv_nsec / 1000000000; \
370 timespec . tv_nsec %= 1000000000;
374 # define SET_TIMESPEC(timespec, sec, nsec) \
375 timespec . tv_sec = (sec); \
376 timespec . tv_nsec = (nsec); \
377 NORMALIZE_TIMESPEC(timespec);
380 #ifndef SLEEP_TIMESPEC
381 # define SLEEP_TIMESPEC(timespec) nanosleep(×pec, 0)
385 # define INIT_GROUPS(name, gid) ((setgid((gid)) == 0) && (initgroups((name), (gid)) == 0))
388 #ifndef PTHREAD_VALUE
389 # define PTHREAD_VALUE(t) (t)
392 # if (__GNUC__ < 4) && !defined(MACOSX)
393 extern pthread_t _pthread_none_
;
395 # define PTHREAD_NONE _pthread_none_
396 # ifndef PTHREAD_NONE_INIT
397 # define PTHREAD_NONE_INIT ((pthread_t)-1)
401 #ifndef PTHREAD_ATTR_DEFAULT
402 # define PTHREAD_ATTR_DEFAULT NULL
404 #ifndef PTHREAD_MUTEXATTR_DEFAULT
405 # define PTHREAD_MUTEXATTR_DEFAULT NULL
407 #ifndef PTHREAD_CONDATTR_DEFAULT
408 # define PTHREAD_CONDATTR_DEFAULT NULL
411 #ifndef PTHREAD_SIGACTION
412 # define PTHREAD_SIGACTION sigaction
416 # define STAT_PARENT lstat
419 /* socket options which might not be defined on all unx flavors */
420 #ifndef SO_ACCEPTCONN
421 # define SO_ACCEPTCONN 0
424 # define SO_SNDLOWAT 0
427 # define SO_RCVLOWAT 0
430 # define SO_SNDTIMEO 0
433 # define SO_RCVTIMEO 0
435 #ifndef SO_USELOOPBACK
436 # define SO_USELOOPBACK 0
438 #ifndef MSG_MAXIOVLEN
439 # define MSG_MAXIOVLEN 0
443 /* dummy define and declarations for IPX should be replaced by */
444 /* original ipx headers when these are available for this platform */
446 #ifndef SA_FAMILY_DECL
447 # define SA_FAMILY_DECL short sa_family
450 typedef struct sockaddr_ipx
{
454 unsigned short sa_socket
;
457 #define NSPROTO_IPX 1000
458 #define NSPROTO_SPX 1256
459 #define NSPROTO_SPXII 1257
463 #ifdef NO_PTHREAD_SEMAPHORES
467 pthread_mutex_t mutex
;
468 pthread_cond_t increased
;
471 extern int sem_init(sem_t
* sem
, int pshared
, unsigned int value
);
472 extern int sem_destroy(sem_t
* sem
);
473 extern int sem_wait(sem_t
* sem
);
474 extern int sem_trywait(sem_t
* sem
);
475 extern int sem_post(sem_t
* sem
);
479 #ifdef NO_PTHREAD_RTL
480 #if !defined FREEBSD || (__FreeBSD_version < 500112)
481 struct passwd
*getpwent_r(struct passwd
*pwd
, char *buffer
, int buflen
);
482 extern struct spwd
*getspnam_r(const char *name
, struct spwd
*result
,
483 char *buffer
, int buflen
);
485 struct tm
*localtime_r(const time_t *timep
, struct tm
*buffer
);
486 struct tm
*gmtime_r(const time_t *timep
, struct tm
*buffer
);
487 #endif /* !defined FREEBSD || (__FreeBSD_version < 500112) */
488 #if !defined(FREEBSD) || (__FreeBSD_version < 601103)
489 struct hostent
*gethostbyname_r(const char *name
, struct hostent
*result
,
490 char *buffer
, int buflen
, int *h_errnop
);
491 #endif /* !defined(FREEBSD) || (__FreeBSD_version < 601103) */
494 #endif /* __OSL_SYSTEM_H__ */