andre@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: #ifndef prunixos_h___ andre@0: #define prunixos_h___ andre@0: andre@0: /* andre@0: * If FD_SETSIZE is not defined on the command line, set the default value andre@0: * before include select.h andre@0: */ andre@0: /* andre@0: * Linux: FD_SETSIZE is defined in /usr/include/sys/select.h and should andre@0: * not be redefined. andre@0: */ andre@0: #if !defined(LINUX) && !defined(__GNU__) && !defined(__GLIBC__) \ andre@0: && !defined(DARWIN) andre@0: #ifndef FD_SETSIZE andre@0: #define FD_SETSIZE 4096 andre@0: #endif andre@0: #endif andre@0: andre@0: #include andre@0: #include andre@0: #include andre@0: #include andre@0: #include andre@0: andre@0: #include "prio.h" andre@0: #include "prmem.h" andre@0: #include "prclist.h" andre@0: andre@0: /* andre@0: * For select(), fd_set, and struct timeval. andre@0: * andre@0: * In The Single UNIX(R) Specification, Version 2, andre@0: * the header file for select() is . andre@0: * In Version 3, the header file for select() is andre@0: * changed to . andre@0: * andre@0: * fd_set is defined in . Usually andre@0: * includes , but on some andre@0: * older systems does not include andre@0: * , so we include it explicitly. andre@0: */ andre@0: #include andre@0: #include andre@0: #if defined(AIX) || defined(SYMBIAN) andre@0: #include andre@0: #endif andre@0: andre@0: #ifndef SYMBIAN andre@0: #define HAVE_NETINET_TCP_H andre@0: #endif andre@0: andre@0: #define _PR_HAVE_O_APPEND andre@0: andre@0: #define PR_DIRECTORY_SEPARATOR '/' andre@0: #define PR_DIRECTORY_SEPARATOR_STR "/" andre@0: #define PR_PATH_SEPARATOR ':' andre@0: #define PR_PATH_SEPARATOR_STR ":" andre@0: typedef int (*FARPROC)(); andre@0: andre@0: /* andre@0: * intervals at which GLOBAL threads wakeup to check for pending interrupt andre@0: */ andre@0: #define _PR_INTERRUPT_CHECK_INTERVAL_SECS 5 andre@0: extern PRIntervalTime intr_timeout_ticks; andre@0: andre@0: /* andre@0: * The bit flags for the in_flags and out_flags fields andre@0: * of _PR_UnixPollDesc andre@0: */ andre@0: #ifdef _PR_USE_POLL andre@0: #define _PR_UNIX_POLL_READ POLLIN andre@0: #define _PR_UNIX_POLL_WRITE POLLOUT andre@0: #define _PR_UNIX_POLL_EXCEPT POLLPRI andre@0: #define _PR_UNIX_POLL_ERR POLLERR andre@0: #define _PR_UNIX_POLL_NVAL POLLNVAL andre@0: #define _PR_UNIX_POLL_HUP POLLHUP andre@0: #else /* _PR_USE_POLL */ andre@0: #define _PR_UNIX_POLL_READ 0x1 andre@0: #define _PR_UNIX_POLL_WRITE 0x2 andre@0: #define _PR_UNIX_POLL_EXCEPT 0x4 andre@0: #define _PR_UNIX_POLL_ERR 0x8 andre@0: #define _PR_UNIX_POLL_NVAL 0x10 andre@0: #define _PR_UNIX_POLL_HUP 0x20 andre@0: #endif /* _PR_USE_POLL */ andre@0: andre@0: typedef struct _PRUnixPollDesc { andre@0: PRInt32 osfd; andre@0: PRInt16 in_flags; andre@0: PRInt16 out_flags; andre@0: } _PRUnixPollDesc; andre@0: andre@0: typedef struct PRPollQueue { andre@0: PRCList links; /* for linking PRPollQueue's together */ andre@0: _PRUnixPollDesc *pds; /* array of poll descriptors */ andre@0: PRUintn npds; /* length of the array */ andre@0: PRPackedBool on_ioq; /* is this on the async i/o work q? */ andre@0: PRIntervalTime timeout; /* timeout, in ticks */ andre@0: struct PRThread *thr; andre@0: } PRPollQueue; andre@0: andre@0: #define _PR_POLLQUEUE_PTR(_qp) \ andre@0: ((PRPollQueue*) ((char*) (_qp) - offsetof(PRPollQueue,links))) andre@0: andre@0: andre@0: extern PRInt32 _PR_WaitForMultipleFDs( andre@0: _PRUnixPollDesc *unixpds, andre@0: PRInt32 pdcnt, andre@0: PRIntervalTime timeout); andre@0: extern void _PR_Unblock_IO_Wait(struct PRThread *thr); andre@0: andre@0: #if defined(_PR_LOCAL_THREADS_ONLY) || defined(_PR_GLOBAL_THREADS_ONLY) andre@0: #define _MD_CHECK_FOR_EXIT() andre@0: #endif andre@0: andre@0: extern fd_set _pr_md_read_set, _pr_md_write_set, _pr_md_exception_set; andre@0: extern PRInt16 _pr_md_read_cnt[], _pr_md_write_cnt[], _pr_md_exception_cnt[]; andre@0: extern PRInt32 _pr_md_ioq_max_osfd; andre@0: extern PRUint32 _pr_md_ioq_timeout; andre@0: andre@0: struct _MDFileDesc { andre@0: int osfd; andre@0: #if defined(LINUX) && defined(_PR_PTHREADS) andre@0: int tcp_nodelay; /* used by pt_LinuxSendFile */ andre@0: #endif andre@0: }; andre@0: andre@0: struct _MDDir { andre@0: DIR *d; andre@0: }; andre@0: andre@0: struct _PRCPU; andre@0: extern void _MD_unix_init_running_cpu(struct _PRCPU *cpu); andre@0: andre@0: /* andre@0: ** Make a redzone at both ends of the stack segment. Disallow access andre@0: ** to those pages of memory. It's ok if the mprotect call's don't andre@0: ** work - it just means that we don't really have a functional andre@0: ** redzone. andre@0: */ andre@0: #include andre@0: #ifndef PROT_NONE andre@0: #define PROT_NONE 0x0 andre@0: #endif andre@0: andre@0: #if defined(DEBUG) && !defined(DARWIN) andre@0: #if !defined(SOLARIS) andre@0: #include /* for memset() */ andre@0: #define _MD_INIT_STACK(ts,REDZONE) \ andre@0: PR_BEGIN_MACRO \ andre@0: (void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_NONE); \ andre@0: (void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\ andre@0: REDZONE, PROT_NONE); \ andre@0: /* \ andre@0: ** Fill stack memory with something that turns into an illegal \ andre@0: ** pointer value. This will sometimes find runtime references to \ andre@0: ** uninitialized pointers. We don't do this for solaris because we \ andre@0: ** can use purify instead. \ andre@0: */ \ andre@0: if (_pr_debugStacks) { \ andre@0: memset(ts->allocBase + REDZONE, 0xf7, ts->stackSize); \ andre@0: } \ andre@0: PR_END_MACRO andre@0: #else /* !SOLARIS */ andre@0: #define _MD_INIT_STACK(ts,REDZONE) \ andre@0: PR_BEGIN_MACRO \ andre@0: (void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_NONE); \ andre@0: (void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\ andre@0: REDZONE, PROT_NONE); \ andre@0: PR_END_MACRO andre@0: #endif /* !SOLARIS */ andre@0: andre@0: /* andre@0: * _MD_CLEAR_STACK andre@0: * Allow access to the redzone pages; the access was turned off in andre@0: * _MD_INIT_STACK. andre@0: */ andre@0: #define _MD_CLEAR_STACK(ts) \ andre@0: PR_BEGIN_MACRO \ andre@0: (void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_READ|PROT_WRITE);\ andre@0: (void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\ andre@0: REDZONE, PROT_READ|PROT_WRITE); \ andre@0: PR_END_MACRO andre@0: andre@0: #else /* DEBUG */ andre@0: andre@0: #define _MD_INIT_STACK(ts,REDZONE) andre@0: #define _MD_CLEAR_STACK(ts) andre@0: andre@0: #endif /* DEBUG */ andre@0: andre@0: #if !defined(SOLARIS) andre@0: andre@0: #define PR_SET_INTSOFF(newval) andre@0: andre@0: #endif andre@0: andre@0: /************************************************************************/ andre@0: andre@0: extern void _PR_UnixInit(void); andre@0: andre@0: extern void _PR_UnixCleanup(void); andre@0: #define _MD_EARLY_CLEANUP _PR_UnixCleanup andre@0: andre@0: /************************************************************************/ andre@0: andre@0: struct _MDProcess { andre@0: pid_t pid; andre@0: }; andre@0: andre@0: struct PRProcess; andre@0: struct PRProcessAttr; andre@0: andre@0: /* Create a new process (fork() + exec()) */ andre@0: #define _MD_CREATE_PROCESS _MD_CreateUnixProcess andre@0: extern struct PRProcess * _MD_CreateUnixProcess( andre@0: const char *path, andre@0: char *const *argv, andre@0: char *const *envp, andre@0: const struct PRProcessAttr *attr andre@0: ); andre@0: andre@0: #define _MD_DETACH_PROCESS _MD_DetachUnixProcess andre@0: extern PRStatus _MD_DetachUnixProcess(struct PRProcess *process); andre@0: andre@0: /* Wait for a child process to terminate */ andre@0: #define _MD_WAIT_PROCESS _MD_WaitUnixProcess andre@0: extern PRStatus _MD_WaitUnixProcess(struct PRProcess *process, andre@0: PRInt32 *exitCode); andre@0: andre@0: #define _MD_KILL_PROCESS _MD_KillUnixProcess andre@0: extern PRStatus _MD_KillUnixProcess(struct PRProcess *process); andre@0: andre@0: /************************************************************************/ andre@0: andre@0: extern void _MD_EnableClockInterrupts(void); andre@0: extern void _MD_DisableClockInterrupts(void); andre@0: andre@0: #define _MD_START_INTERRUPTS _MD_StartInterrupts andre@0: #define _MD_STOP_INTERRUPTS _MD_StopInterrupts andre@0: #define _MD_DISABLE_CLOCK_INTERRUPTS _MD_DisableClockInterrupts andre@0: #define _MD_ENABLE_CLOCK_INTERRUPTS _MD_EnableClockInterrupts andre@0: #define _MD_BLOCK_CLOCK_INTERRUPTS _MD_BlockClockInterrupts andre@0: #define _MD_UNBLOCK_CLOCK_INTERRUPTS _MD_UnblockClockInterrupts andre@0: andre@0: /************************************************************************/ andre@0: andre@0: extern void _MD_InitCPUS(void); andre@0: #define _MD_INIT_CPUS _MD_InitCPUS andre@0: andre@0: extern void _MD_Wakeup_CPUs(void); andre@0: #define _MD_WAKEUP_CPUS _MD_Wakeup_CPUs andre@0: andre@0: #define _MD_PAUSE_CPU _MD_PauseCPU andre@0: andre@0: #if defined(_PR_LOCAL_THREADS_ONLY) || defined(_PR_GLOBAL_THREADS_ONLY) andre@0: #define _MD_CLEANUP_BEFORE_EXIT() andre@0: #endif andre@0: andre@0: #ifndef IRIX andre@0: #define _MD_EXIT(status) _exit(status) andre@0: #endif andre@0: andre@0: /************************************************************************/ andre@0: andre@0: #define _MD_GET_ENV getenv andre@0: #define _MD_PUT_ENV putenv andre@0: andre@0: /************************************************************************/ andre@0: andre@0: #define _MD_INIT_FILEDESC(fd) andre@0: andre@0: extern void _MD_MakeNonblock(PRFileDesc *fd); andre@0: #define _MD_MAKE_NONBLOCK _MD_MakeNonblock andre@0: andre@0: /************************************************************************/ andre@0: andre@0: #if !defined(_PR_PTHREADS) andre@0: andre@0: extern void _MD_InitSegs(void); andre@0: extern PRStatus _MD_AllocSegment(PRSegment *seg, PRUint32 size, andre@0: void *vaddr); andre@0: extern void _MD_FreeSegment(PRSegment *seg); andre@0: andre@0: #define _MD_INIT_SEGS _MD_InitSegs andre@0: #define _MD_ALLOC_SEGMENT _MD_AllocSegment andre@0: #define _MD_FREE_SEGMENT _MD_FreeSegment andre@0: andre@0: #endif /* !defined(_PR_PTHREADS) */ andre@0: andre@0: /************************************************************************/ andre@0: andre@0: #ifdef _MD_INTERVAL_USE_GTOD andre@0: extern PRIntervalTime _PR_UNIX_GetInterval(void); andre@0: extern PRIntervalTime _PR_UNIX_TicksPerSecond(void); andre@0: #define _MD_INTERVAL_INIT() andre@0: #define _MD_GET_INTERVAL _PR_UNIX_GetInterval andre@0: #define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond andre@0: #endif andre@0: andre@0: #ifdef HAVE_CLOCK_MONOTONIC andre@0: extern PRIntervalTime _PR_UNIX_GetInterval2(void); andre@0: extern PRIntervalTime _PR_UNIX_TicksPerSecond2(void); andre@0: #define _MD_INTERVAL_INIT() andre@0: #define _MD_GET_INTERVAL _PR_UNIX_GetInterval2 andre@0: #define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond2 andre@0: #endif andre@0: andre@0: #define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000) andre@0: #define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000) andre@0: andre@0: /************************************************************************/ andre@0: andre@0: #define _MD_ERRNO() (errno) andre@0: #define _MD_GET_SOCKET_ERROR() (errno) andre@0: andre@0: /************************************************************************/ andre@0: andre@0: extern PRInt32 _MD_AvailableSocket(PRInt32 osfd); andre@0: andre@0: extern void _MD_StartInterrupts(void); andre@0: extern void _MD_StopInterrupts(void); andre@0: extern void _MD_DisableClockInterrupts(void); andre@0: extern void _MD_BlockClockInterrupts(void); andre@0: extern void _MD_UnblockClockInterrupts(void); andre@0: extern void _MD_PauseCPU(PRIntervalTime timeout); andre@0: andre@0: extern PRStatus _MD_open_dir(struct _MDDir *, const char *); andre@0: extern PRInt32 _MD_close_dir(struct _MDDir *); andre@0: extern char * _MD_read_dir(struct _MDDir *, PRIntn); andre@0: extern PRInt32 _MD_open(const char *name, PRIntn osflags, PRIntn mode); andre@0: extern PRInt32 _MD_delete(const char *name); andre@0: extern PRInt32 _MD_getfileinfo(const char *fn, PRFileInfo *info); andre@0: extern PRInt32 _MD_getfileinfo64(const char *fn, PRFileInfo64 *info); andre@0: extern PRInt32 _MD_getopenfileinfo(const PRFileDesc *fd, PRFileInfo *info); andre@0: extern PRInt32 _MD_getopenfileinfo64(const PRFileDesc *fd, PRFileInfo64 *info); andre@0: extern PRInt32 _MD_rename(const char *from, const char *to); andre@0: extern PRInt32 _MD_access(const char *name, PRAccessHow how); andre@0: extern PRInt32 _MD_mkdir(const char *name, PRIntn mode); andre@0: extern PRInt32 _MD_rmdir(const char *name); andre@0: extern PRInt32 _MD_accept_read(PRInt32 sock, PRInt32 *newSock, andre@0: PRNetAddr **raddr, void *buf, PRInt32 amount); andre@0: extern PRInt32 _PR_UnixSendFile(PRFileDesc *sd, PRSendFileData *sfd, andre@0: PRTransmitFileFlags flags, PRIntervalTime timeout); andre@0: andre@0: extern PRStatus _MD_LockFile(PRInt32 osfd); andre@0: extern PRStatus _MD_TLockFile(PRInt32 osfd); andre@0: extern PRStatus _MD_UnlockFile(PRInt32 osfd); andre@0: andre@0: #define _MD_OPEN_DIR(dir, name) _MD_open_dir(dir, name) andre@0: #define _MD_CLOSE_DIR(dir) _MD_close_dir(dir) andre@0: #define _MD_READ_DIR(dir, flags) _MD_read_dir(dir, flags) andre@0: #define _MD_OPEN(name, osflags, mode) _MD_open(name, osflags, mode) andre@0: #define _MD_OPEN_FILE(name, osflags, mode) _MD_open(name, osflags, mode) andre@0: extern PRInt32 _MD_read(PRFileDesc *fd, void *buf, PRInt32 amount); andre@0: #define _MD_READ(fd,buf,amount) _MD_read(fd,buf,amount) andre@0: extern PRInt32 _MD_write(PRFileDesc *fd, const void *buf, PRInt32 amount); andre@0: #define _MD_WRITE(fd,buf,amount) _MD_write(fd,buf,amount) andre@0: #define _MD_DELETE(name) _MD_delete(name) andre@0: #define _MD_GETFILEINFO(fn, info) _MD_getfileinfo(fn, info) andre@0: #define _MD_GETFILEINFO64(fn, info) _MD_getfileinfo64(fn, info) andre@0: #define _MD_GETOPENFILEINFO(fd, info) _MD_getopenfileinfo(fd, info) andre@0: #define _MD_GETOPENFILEINFO64(fd, info) _MD_getopenfileinfo64(fd, info) andre@0: #define _MD_RENAME(from, to) _MD_rename(from, to) andre@0: #define _MD_ACCESS(name, how) _MD_access(name, how) andre@0: #define _MD_MKDIR(name, mode) _MD_mkdir(name, mode) andre@0: #define _MD_MAKE_DIR(name, mode) _MD_mkdir(name, mode) andre@0: #define _MD_RMDIR(name) _MD_rmdir(name) andre@0: #define _MD_ACCEPT_READ(sock, newSock, raddr, buf, amount) _MD_accept_read(sock, newSock, raddr, buf, amount) andre@0: andre@0: #define _MD_LOCKFILE _MD_LockFile andre@0: #define _MD_TLOCKFILE _MD_TLockFile andre@0: #define _MD_UNLOCKFILE _MD_UnlockFile andre@0: andre@0: andre@0: extern PRInt32 _MD_socket(int af, int type, int flags); andre@0: #define _MD_SOCKET _MD_socket andre@0: extern PRInt32 _MD_connect(PRFileDesc *fd, const PRNetAddr *addr, andre@0: PRUint32 addrlen, PRIntervalTime timeout); andre@0: #define _MD_CONNECT _MD_connect andre@0: extern PRInt32 _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, andre@0: PRIntervalTime timeout); andre@0: #define _MD_ACCEPT _MD_accept andre@0: extern PRInt32 _MD_bind(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen); andre@0: #define _MD_BIND _MD_bind andre@0: extern PRInt32 _MD_listen(PRFileDesc *fd, PRIntn backlog); andre@0: #define _MD_LISTEN _MD_listen andre@0: extern PRInt32 _MD_shutdown(PRFileDesc *fd, PRIntn how); andre@0: #define _MD_SHUTDOWN _MD_shutdown andre@0: andre@0: extern PRInt32 _MD_recv(PRFileDesc *fd, void *buf, PRInt32 amount, andre@0: PRIntn flags, PRIntervalTime timeout); andre@0: #define _MD_RECV _MD_recv andre@0: extern PRInt32 _MD_send(PRFileDesc *fd, const void *buf, PRInt32 amount, andre@0: PRIntn flags, PRIntervalTime timeout); andre@0: #define _MD_SEND _MD_send andre@0: extern PRInt32 _MD_recvfrom(PRFileDesc *fd, void *buf, PRInt32 amount, andre@0: PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen, andre@0: PRIntervalTime timeout); andre@0: #define _MD_RECVFROM _MD_recvfrom andre@0: extern PRInt32 _MD_sendto(PRFileDesc *fd, const void *buf, PRInt32 amount, andre@0: PRIntn flags, const PRNetAddr *addr, PRUint32 addrlen, andre@0: PRIntervalTime timeout); andre@0: #define _MD_SENDTO _MD_sendto andre@0: extern PRInt32 _MD_writev(PRFileDesc *fd, const struct PRIOVec *iov, andre@0: PRInt32 iov_size, PRIntervalTime timeout); andre@0: #define _MD_WRITEV _MD_writev andre@0: andre@0: extern PRInt32 _MD_socketavailable(PRFileDesc *fd); andre@0: #define _MD_SOCKETAVAILABLE _MD_socketavailable andre@0: extern PRInt64 _MD_socketavailable64(PRFileDesc *fd); andre@0: #define _MD_SOCKETAVAILABLE64 _MD_socketavailable64 andre@0: andre@0: #define _MD_PIPEAVAILABLE _MD_socketavailable andre@0: andre@0: extern PRInt32 _MD_pr_poll(PRPollDesc *pds, PRIntn npds, andre@0: PRIntervalTime timeout); andre@0: #define _MD_PR_POLL _MD_pr_poll andre@0: andre@0: extern PRInt32 _MD_close(PRInt32 osfd); andre@0: #define _MD_CLOSE_FILE _MD_close andre@0: extern PRInt32 _MD_lseek(PRFileDesc*, PRInt32, PRSeekWhence); andre@0: #define _MD_LSEEK _MD_lseek andre@0: extern PRInt64 _MD_lseek64(PRFileDesc*, PRInt64, PRSeekWhence); andre@0: #define _MD_LSEEK64 _MD_lseek64 andre@0: extern PRInt32 _MD_fsync(PRFileDesc *fd); andre@0: #define _MD_FSYNC _MD_fsync andre@0: andre@0: extern PRInt32 _MD_socketpair(int af, int type, int flags, PRInt32 *osfd); andre@0: #define _MD_SOCKETPAIR _MD_socketpair andre@0: andre@0: #define _MD_CLOSE_SOCKET _MD_close andre@0: andre@0: #ifndef NO_NSPR_10_SUPPORT andre@0: #define _MD_STAT stat andre@0: #endif andre@0: andre@0: extern PRStatus _MD_getpeername(PRFileDesc *fd, PRNetAddr *addr, andre@0: PRUint32 *addrlen); andre@0: #define _MD_GETPEERNAME _MD_getpeername andre@0: extern PRStatus _MD_getsockname(PRFileDesc *fd, PRNetAddr *addr, andre@0: PRUint32 *addrlen); andre@0: #define _MD_GETSOCKNAME _MD_getsockname andre@0: andre@0: extern PRStatus _MD_getsockopt(PRFileDesc *fd, PRInt32 level, andre@0: PRInt32 optname, char* optval, PRInt32* optlen); andre@0: #define _MD_GETSOCKOPT _MD_getsockopt andre@0: extern PRStatus _MD_setsockopt(PRFileDesc *fd, PRInt32 level, andre@0: PRInt32 optname, const char* optval, PRInt32 optlen); andre@0: #define _MD_SETSOCKOPT _MD_setsockopt andre@0: andre@0: extern PRStatus _MD_set_fd_inheritable(PRFileDesc *fd, PRBool inheritable); andre@0: #define _MD_SET_FD_INHERITABLE _MD_set_fd_inheritable andre@0: andre@0: extern void _MD_init_fd_inheritable(PRFileDesc *fd, PRBool imported); andre@0: #define _MD_INIT_FD_INHERITABLE _MD_init_fd_inheritable andre@0: andre@0: extern void _MD_query_fd_inheritable(PRFileDesc *fd); andre@0: #define _MD_QUERY_FD_INHERITABLE _MD_query_fd_inheritable andre@0: andre@0: extern PRStatus _MD_gethostname(char *name, PRUint32 namelen); andre@0: #define _MD_GETHOSTNAME _MD_gethostname andre@0: andre@0: extern PRStatus _MD_getsysinfo(PRSysInfo cmd, char *name, PRUint32 namelen); andre@0: #define _MD_GETSYSINFO _MD_getsysinfo andre@0: andre@0: extern int _MD_unix_get_nonblocking_connect_error(int osfd); andre@0: andre@0: /* Memory-mapped files */ andre@0: andre@0: struct _MDFileMap { andre@0: PRIntn prot; andre@0: PRIntn flags; andre@0: PRBool isAnonFM; /* when true, PR_CloseFileMap() must close the related fd */ andre@0: }; andre@0: andre@0: extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size); andre@0: #define _MD_CREATE_FILE_MAP _MD_CreateFileMap andre@0: andre@0: #define _MD_GET_MEM_MAP_ALIGNMENT() PR_GetPageSize() andre@0: andre@0: extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset, andre@0: PRUint32 len); andre@0: #define _MD_MEM_MAP _MD_MemMap andre@0: andre@0: extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size); andre@0: #define _MD_MEM_UNMAP _MD_MemUnmap andre@0: andre@0: extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap); andre@0: #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap andre@0: andre@0: extern PRStatus _MD_SyncMemMap( andre@0: PRFileDesc *fd, andre@0: void *addr, andre@0: PRUint32 len); andre@0: #define _MD_SYNC_MEM_MAP _MD_SyncMemMap andre@0: andre@0: /* andre@0: * The standard (XPG4) gettimeofday() (from BSD) takes two arguments. andre@0: * On some SVR4 derivatives, gettimeofday() takes only one argument. andre@0: * The GETTIMEOFDAY macro is intended to hide this difference. andre@0: */ andre@0: #ifdef HAVE_SVID_GETTOD andre@0: #define GETTIMEOFDAY(tp) gettimeofday(tp) andre@0: #else andre@0: #define GETTIMEOFDAY(tp) gettimeofday((tp), NULL) andre@0: #endif andre@0: andre@0: #if defined(_PR_PTHREADS) && !defined(_PR_POLL_AVAILABLE) andre@0: #define _PR_NEED_FAKE_POLL andre@0: #endif andre@0: andre@0: #if defined(_PR_NEED_FAKE_POLL) andre@0: andre@0: /* andre@0: * Some platforms don't have poll(), but our pthreads code calls poll(). andre@0: * As a temporary measure, I implemented a fake poll() using select(). andre@0: * Here are the struct and macro definitions copied from sys/poll.h andre@0: * on Solaris 2.5. andre@0: */ andre@0: andre@0: struct pollfd { andre@0: int fd; andre@0: short events; andre@0: short revents; andre@0: }; andre@0: andre@0: /* poll events */ andre@0: andre@0: #define POLLIN 0x0001 /* fd is readable */ andre@0: #define POLLPRI 0x0002 /* high priority info at fd */ andre@0: #define POLLOUT 0x0004 /* fd is writeable (won't block) */ andre@0: #define POLLRDNORM 0x0040 /* normal data is readable */ andre@0: #define POLLWRNORM POLLOUT andre@0: #define POLLRDBAND 0x0080 /* out-of-band data is readable */ andre@0: #define POLLWRBAND 0x0100 /* out-of-band data is writeable */ andre@0: andre@0: #define POLLNORM POLLRDNORM andre@0: andre@0: #define POLLERR 0x0008 /* fd has error condition */ andre@0: #define POLLHUP 0x0010 /* fd has been hung up on */ andre@0: #define POLLNVAL 0x0020 /* invalid pollfd entry */ andre@0: andre@0: extern int poll(struct pollfd *, unsigned long, int); andre@0: andre@0: #endif /* _PR_NEED_FAKE_POLL */ andre@0: andre@0: /* andre@0: ** A vector of the UNIX I/O calls we use. These are here to smooth over andre@0: ** the rough edges needed for large files. All of NSPR's implmentaions andre@0: ** go through this vector using syntax of the form andre@0: ** result = _md_iovector.xxx64(args); andre@0: */ andre@0: andre@0: #if defined(SOLARIS2_5) andre@0: /* andre@0: ** Special case: Solaris 2.5.1 andre@0: ** Solaris starts to have 64-bit file I/O in 2.6. We build on Solaris andre@0: ** 2.5.1 so that we can use the same binaries on both Solaris 2.5.1 and andre@0: ** 2.6. At run time, we detect whether 64-bit file I/O is available by andre@0: ** looking up the 64-bit file function symbols in libc. At build time, andre@0: ** we need to define the 64-bit file I/O datatypes that are compatible andre@0: ** with their definitions on Solaris 2.6. andre@0: */ andre@0: typedef PRInt64 off64_t; andre@0: typedef PRUint64 ino64_t; andre@0: typedef PRInt64 blkcnt64_t; andre@0: struct stat64 { andre@0: dev_t st_dev; andre@0: long st_pad1[3]; andre@0: ino64_t st_ino; andre@0: mode_t st_mode; andre@0: nlink_t st_nlink; andre@0: uid_t st_uid; andre@0: gid_t st_gid; andre@0: dev_t st_rdev; andre@0: long t_pad2[2]; andre@0: off64_t st_size; andre@0: timestruc_t st_atim; andre@0: timestruc_t st_mtim; andre@0: timestruc_t st_ctim; andre@0: long st_blksize; andre@0: blkcnt64_t st_blocks; andre@0: char st_fstype[_ST_FSTYPSZ]; andre@0: long st_pad4[8]; andre@0: }; andre@0: typedef struct stat64 _MDStat64; andre@0: typedef off64_t _MDOff64_t; andre@0: andre@0: #elif defined(_PR_HAVE_OFF64_T) andre@0: typedef struct stat64 _MDStat64; andre@0: typedef off64_t _MDOff64_t; andre@0: #elif defined(_PR_HAVE_LARGE_OFF_T) andre@0: typedef struct stat _MDStat64; andre@0: typedef off_t _MDOff64_t; andre@0: #elif defined(_PR_NO_LARGE_FILES) andre@0: typedef struct stat _MDStat64; andre@0: typedef PRInt64 _MDOff64_t; andre@0: #else andre@0: #error "I don't know yet" andre@0: #endif andre@0: andre@0: typedef PRIntn (*_MD_Fstat64)(PRIntn osfd, _MDStat64 *buf); andre@0: typedef PRIntn (*_MD_Open64)(const char *path, int oflag, ...); andre@0: typedef PRIntn (*_MD_Stat64)(const char *path, _MDStat64 *buf); andre@0: typedef _MDOff64_t (*_MD_Lseek64)(PRIntn osfd, _MDOff64_t, PRIntn whence); andre@0: typedef void* (*_MD_Mmap64)( andre@0: void *addr, PRSize len, PRIntn prot, PRIntn flags, andre@0: PRIntn fildes, _MDOff64_t offset); andre@0: struct _MD_IOVector andre@0: { andre@0: _MD_Open64 _open64; andre@0: _MD_Mmap64 _mmap64; andre@0: _MD_Stat64 _stat64; andre@0: _MD_Fstat64 _fstat64; andre@0: _MD_Lseek64 _lseek64; andre@0: }; andre@0: extern struct _MD_IOVector _md_iovector; andre@0: andre@0: #endif /* prunixos_h___ */