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