1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: system.h,v $
10 * $Revision: 1.42.60.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __OSL_SYSTEM_H__
32 #define __OSL_SYSTEM_H__
54 #include <sys/types.h>
56 /* Make sockets of type AF_UNIX use underlying FS rights */
58 # define _XOPEN_SOURCE 500
59 # include <sys/socket.h>
62 # include <sys/socket.h>
65 #include <netinet/in.h>
66 #include <arpa/inet.h>
69 # include <sys/utsname.h>
80 # include <sys/file.h>
81 # include <sys/ioctl.h>
84 # include <netinet/tcp.h>
87 # include <sys/time.h>
88 # include <semaphore.h>
89 # if __BYTE_ORDER == __LITTLE_ENDIAN
90 # define _LITTLE_ENDIAN
91 # elif __BYTE_ORDER == __BIG_ENDIAN
95 # elif __BYTE_ORDER == __PDP_ENDIAN
98 # define IORESOURCE_TRANSFER_BSD
99 # define IOCHANNEL_TRANSFER_BSD_RENO
100 # define pthread_testcancel()
101 # define NO_PTHREAD_PRIORITY
102 # define PTHREAD_SIGACTION pthread_sigaction
105 # include <asm/sigcontext.h>
106 # include <pthread.h>
107 # include <sys/file.h>
108 # include <sys/ioctl.h>
109 # include <linux/net.h>
111 # include <netinet/tcp.h>
112 # include <linux/elfcore.h>
115 # if __BYTE_ORDER == __LITTLE_ENDIAN
116 # define _LITTLE_ENDIAN
117 # elif __BYTE_ORDER == __BIG_ENDIAN
119 # elif __BYTE_ORDER == __PDP_ENDIAN
122 # define IORESOURCE_TRANSFER_BSD
123 # define IOCHANNEL_TRANSFER_BSD_RENO
124 # define pthread_testcancel()
125 # define NO_PTHREAD_RTL
126 # define NO_PTHREAD_PRIORITY
127 # define PTHREAD_SIGACTION pthread_sigaction
132 # define ETIME ETIMEDOUT
133 # define _POSIX_THREAD_SYSCALL_SOFT 1
134 # include <pthread.h>
136 # include <sys/sem.h>
137 # include <sys/exec.h>
138 # include <sys/filio.h>
139 # include <sys/ioctl.h>
140 # include <sys/time.h>
142 # include <netinet/tcp.h>
144 # include <machine/endian.h>
145 # if BYTE_ORDER == LITTLE_ENDIAN
146 # define _LITTLE_ENDIAN_OO
147 # elif BYTE_ORDER == BIG_ENDIAN
148 # define _BIG_ENDIAN_OO
149 # elif BYTE_ORDER == PDP_ENDIAN
150 # define _PDP_ENDIAN_OO
152 # define IORESOURCE_TRANSFER_BSD
153 # define IOCHANNEL_TRANSFER_BSD_RENO
154 # define pthread_testcancel()
155 # define NO_PTHREAD_PRIORITY
156 # define NO_PTHREAD_SEMAPHORES
157 # define NO_PTHREAD_RTL
158 # define PTHREAD_SIGACTION pthread_sigaction
162 # define ETIME ETIMEDOUT
163 # include <pthread.h>
164 # include <sys/sem.h>
165 # include <semaphore.h>
167 # include <sys/filio.h>
168 # include <sys/ioctl.h>
169 # include <sys/param.h>
170 # include <sys/time.h>
171 # include <sys/uio.h>
172 # include <sys/exec.h>
174 # include <vm/vm_param.h>
175 # include <vm/pmap.h>
176 # include <vm/swap_pager.h>
178 # include <netinet/tcp.h>
179 # define IORESOURCE_TRANSFER_BSD
180 # include <machine/endian.h>
181 #if __FreeBSD_version < 500000
182 # if BYTE_ORDER == LITTLE_ENDIAN
183 # define _LITTLE_ENDIAN
184 # elif BYTE_ORDER == BIG_ENDIAN
186 # elif BYTE_ORDER == PDP_ENDIAN
190 # define NO_PTHREAD_RTL
195 # include <strings.h>
196 # include <pthread.h>
200 # include <sys/netinet/tcp.h>
201 # include <sys/types.h>
202 # include <sys/byteorder.h>
204 # if BYTE_ORDER == LITTLE_ENDIAN
205 # define _LITTLE_ENDIAN
206 # elif BYTE_ORDER == BIG_ENDIAN
208 # elif BYTE_ORDER == PDP_ENDIAN
211 # define sched_yield() pthread_yield()
212 # define pthread_testcancel()
213 # define NO_PTHREAD_RTL
214 # define NO_PTHREAD_PRIORITY
215 extern int pthread_cancel(pthread_t
);
216 extern unsigned int nanosleep(unsigned int);
217 # define SLEEP_TIMESPEC(timespec) (timespec .tv_sec > 0) ? sleep(timespec .tv_sec), nanosleep(timespec .tv_nsec) : nanosleep(timespec .tv_nsec)
218 # define PATH_MAX _POSIX_PATH_MAX
219 # define S_ISSOCK S_ISFIFO
220 # define PTHREAD_SIGACTION pthread_sigaction
221 # define STAT_PARENT stat
226 # include <strings.h>
227 # include <pthread.h>
228 # include <sys/time.h>
230 # include <netinet/tcp.h>
231 # include <sys/machine.h>
232 # if BYTE_ORDER == LITTLE_ENDIAN
233 # define _LITTLE_ENDIAN
234 # elif BYTE_ORDER == BIG_ENDIAN
236 # elif BYTE_ORDER == PDP_ENDIAN
239 # define sched_yield() pthread_yield()
240 # define SLEEP_TIMESPEC(timespec) nsleep(×pec, 0)
241 # define LIBPATH "LIBPATH"
242 # define NO_PTHREAD_SEMAPHORES
243 # define NO_DL_FUNCTIONS
250 # include <pthread.h>
252 # include <sys/sched.h>
253 # include <sys/xti.h>
254 # include <sys/pstat.h>
257 # include <machine/param.h>
258 # define LIBPATH "SHLIB_PATH"
259 # define PTR_FD_SET(s) ((int *)&(s))
260 # define PTHREAD_VALUE(t) ((t).field2)
261 # define PTHREAD_NONE_INIT { 0, -1 }
262 # define PTHREAD_ATTR_DEFAULT pthread_attr_default
263 # define PTHREAD_MUTEXATTR_DEFAULT pthread_mutexattr_default
264 # define PTHREAD_CONDATTR_DEFAULT pthread_condattr_default
265 # define pthread_detach(t) pthread_detach(&(t))
266 # define NO_PTHREAD_PRIORITY
267 # define NO_PTHREAD_SEMAPHORES
268 # define NO_DL_FUNCTIONS
270 # define PTHREAD_SIGACTION cma_sigaction
275 # include <pthread.h>
276 # include <semaphore.h>
278 # include <sys/socket.h>
280 # include <sys/stropts.h>
281 # include <netinet/tcp.h>
282 # include <sys/endian.h>
283 # if BYTE_ORDER == LITTLE_ENDIAN
286 # elif BYTE_ORDER == BIG_ENDIAN
287 # undef _LITTLE_ENDIAN
289 # elif BYTE_ORDER == PDP_ENDIAN
290 # undef _LITTLE_ENDIAN
293 # define SA_FAMILY_DECL \
294 union { struct { short sa_family2; } sa_generic; } sa_union
295 # define NO_PTHREAD_PRIORITY
297 # define IOCHANNEL_TRANSFER_BSD
298 extern char *strdup(const char *);
304 # include <stropts.h>
305 # include <pthread.h>
306 # include <semaphore.h>
307 # include <netinet/tcp.h>
308 # include <sys/filio.h>
310 # include <sys/isa_defs.h>
311 # define IORESOURCE_TRANSFER_SYSV
312 # define IOCHANNEL_TRANSFER_BSD
313 # define LIBPATH "LD_LIBRARY_PATH"
317 #define __OPENTRANSPORTPROVIDERS__ // these are already defined
318 #define TimeValue CFTimeValue // Do not conflict with TimeValue in sal/inc/osl/time.h
319 #include <Carbon/Carbon.h>
322 # define ETIME ETIMEDOUT
325 # include <pthread.h>
326 # include <sys/file.h>
327 # include <sys/ioctl.h>
328 # include <sys/uio.h>
330 # include <netinet/tcp.h>
331 # include <machine/endian.h>
332 # include <sys/time.h>
333 # include <sys/semaphore.h>
334 /* fixme are premac and postmac still needed here? */
336 # include <mach-o/dyld.h>
337 # include <postmac.h>
338 # if BYTE_ORDER == LITTLE_ENDIAN
339 # ifndef _LITTLE_ENDIAN
340 # define _LITTLE_ENDIAN
342 # elif BYTE_ORDER == BIG_ENDIAN
346 # elif BYTE_ORDER == PDP_ENDIAN
351 # define IOCHANNEL_TRANSFER_BSD_RENO
352 # define NO_PTHREAD_RTL
353 /* for NSGetArgc/Argv/Environ */
354 # include <crt_externs.h>
358 int macxp_resolveAlias(char *path
, int buflen
);
364 #if !defined(_WIN32) && !defined(_WIN16) && !defined(OS2) && \
365 !defined(LINUX) && !defined(NETBSD) && !defined(FREEBSD) && !defined(SCO) && \
366 !defined(AIX) && !defined(HPUX) && \
367 !defined(SOLARIS) && !defined(IRIX) && \
369 # error "Target platform not specified!"
373 #if defined _LITTLE_ENDIAN_OO
374 # define _OSL_BIGENDIAN
375 #elif defined _BIG_ENDIAN_OO
376 # define _OSL_LITENDIAN
378 # error undetermined endianess
381 #if defined _LITTLE_ENDIAN
382 # define _OSL_BIGENDIAN
383 #elif defined _BIG_ENDIAN
384 # define _OSL_LITENDIAN
386 # error undetermined endianess
391 # define PTR_FD_SET(s) (&(s))
394 #ifndef NORMALIZE_TIMESPEC
395 # define NORMALIZE_TIMESPEC(timespec) \
396 timespec . tv_sec += timespec . tv_nsec / 1000000000; \
397 timespec . tv_nsec %= 1000000000;
401 # define SET_TIMESPEC(timespec, sec, nsec) \
402 timespec . tv_sec = (sec); \
403 timespec . tv_nsec = (nsec); \
404 NORMALIZE_TIMESPEC(timespec);
407 #ifndef SLEEP_TIMESPEC
408 # define SLEEP_TIMESPEC(timespec) nanosleep(×pec, 0)
412 # define INIT_GROUPS(name, gid) ((setgid((gid)) == 0) && (initgroups((name), (gid)) == 0))
415 #ifndef PTHREAD_VALUE
416 # define PTHREAD_VALUE(t) (t)
419 # if (__GNUC__ < 4) && !defined(MACOSX)
420 extern pthread_t _pthread_none_
;
422 # define PTHREAD_NONE _pthread_none_
423 # ifndef PTHREAD_NONE_INIT
424 # define PTHREAD_NONE_INIT ((pthread_t)-1)
428 #ifndef PTHREAD_ATTR_DEFAULT
429 # define PTHREAD_ATTR_DEFAULT NULL
431 #ifndef PTHREAD_MUTEXATTR_DEFAULT
432 # define PTHREAD_MUTEXATTR_DEFAULT NULL
434 #ifndef PTHREAD_CONDATTR_DEFAULT
435 # define PTHREAD_CONDATTR_DEFAULT NULL
438 #ifndef PTHREAD_SIGACTION
439 # define PTHREAD_SIGACTION sigaction
443 # define STAT_PARENT lstat
446 /* socket options which might not be defined on all unx flavors */
447 #ifndef SO_ACCEPTCONN
448 # define SO_ACCEPTCONN 0
451 # define SO_SNDLOWAT 0
454 # define SO_RCVLOWAT 0
457 # define SO_SNDTIMEO 0
460 # define SO_RCVTIMEO 0
462 #ifndef SO_USELOOPBACK
463 # define SO_USELOOPBACK 0
465 #ifndef MSG_MAXIOVLEN
466 # define MSG_MAXIOVLEN 0
470 /* dummy define and declarations for IPX should be replaced by */
471 /* original ipx headers when these are available for this platform */
473 #ifndef SA_FAMILY_DECL
474 # define SA_FAMILY_DECL short sa_family
477 typedef struct sockaddr_ipx
{
481 unsigned short sa_socket
;
484 #define NSPROTO_IPX 1000
485 #define NSPROTO_SPX 1256
486 #define NSPROTO_SPXII 1257
490 #ifdef NO_PTHREAD_SEMAPHORES
494 pthread_mutex_t mutex
;
495 pthread_cond_t increased
;
498 extern int sem_init(sem_t
* sem
, int pshared
, unsigned int value
);
499 extern int sem_destroy(sem_t
* sem
);
500 extern int sem_wait(sem_t
* sem
);
501 extern int sem_trywait(sem_t
* sem
);
502 extern int sem_post(sem_t
* sem
);
506 #ifdef NO_PTHREAD_RTL
507 #if !defined FREEBSD || (__FreeBSD_version < 500112)
508 struct passwd
*getpwent_r(struct passwd
*pwd
, char *buffer
, int buflen
);
509 extern struct spwd
*getspnam_r(const char *name
, struct spwd
*result
,
510 char *buffer
, int buflen
);
512 struct tm
*localtime_r(const time_t *timep
, struct tm
*buffer
);
513 struct tm
*gmtime_r(const time_t *timep
, struct tm
*buffer
);
514 #endif /* !defined FREEBSD || (__FreeBSD_version < 500112) */
515 #if !defined(FREEBSD) || (__FreeBSD_version < 601103)
516 struct hostent
*gethostbyname_r(const char *name
, struct hostent
*result
,
517 char *buffer
, int buflen
, int *h_errnop
);
518 #endif /* !defined(FREEBSD) || (__FreeBSD_version < 601103) */
521 #endif /* __OSL_SYSTEM_H__ */