_unixos.h revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef prunixos_h___
#define prunixos_h___
/*
* If FD_SETSIZE is not defined on the command line, set the default value
* before include select.h
*/
/*
* not be redefined.
*/
#ifndef FD_SETSIZE
#define FD_SETSIZE 4096
#endif
#endif
#include <unistd.h>
#include <stddef.h>
#include <dirent.h>
#include <errno.h>
#include "prio.h"
#include "prmem.h"
#include "prclist.h"
/*
* For select(), fd_set, and struct timeval.
*
* In The Single UNIX(R) Specification, Version 2,
*
*/
#if defined(AIX) /* Only pre-4.2 AIX needs it, but for simplicity... */
#endif
#define PR_DIRECTORY_SEPARATOR '/'
#define PR_DIRECTORY_SEPARATOR_STR "/"
#define PR_PATH_SEPARATOR ':'
#define PR_PATH_SEPARATOR_STR ":"
#define GCPTR
typedef int (*FARPROC)();
/*
* intervals at which GLOBAL threads wakeup to check for pending interrupt
*/
#define _PR_INTERRUPT_CHECK_INTERVAL_SECS 5
extern PRIntervalTime intr_timeout_ticks;
/*
* The bit flags for the in_flags and out_flags fields
* of _PR_UnixPollDesc
*/
#ifdef _PR_USE_POLL
#define _PR_UNIX_POLL_READ POLLIN
#define _PR_UNIX_POLL_WRITE POLLOUT
#define _PR_UNIX_POLL_EXCEPT POLLPRI
#define _PR_UNIX_POLL_ERR POLLERR
#define _PR_UNIX_POLL_NVAL POLLNVAL
#define _PR_UNIX_POLL_HUP POLLHUP
#else /* _PR_USE_POLL */
#define _PR_UNIX_POLL_READ 0x1
#define _PR_UNIX_POLL_WRITE 0x2
#define _PR_UNIX_POLL_EXCEPT 0x4
#define _PR_UNIX_POLL_ERR 0x8
#define _PR_UNIX_POLL_NVAL 0x10
#define _PR_UNIX_POLL_HUP 0x20
#endif /* _PR_USE_POLL */
typedef struct _PRUnixPollDesc {
typedef struct PRPollQueue {
} PRPollQueue;
#define _PR_POLLQUEUE_PTR(_qp) \
extern PRInt32 _PR_WaitForMultipleFDs(
#if defined(_PR_LOCAL_THREADS_ONLY) || defined(_PR_GLOBAL_THREADS_ONLY)
#define _MD_CHECK_FOR_EXIT()
#endif
extern PRInt32 _pr_md_ioq_max_osfd;
extern PRUint32 _pr_md_ioq_timeout;
struct _MDFileDesc {
int osfd;
#if defined(LINUX) && defined(_PR_PTHREADS)
int tcp_nodelay; /* used by pt_LinuxSendFile */
#endif
};
struct _MDDir {
DIR *d;
};
struct _PRCPU;
/*
** Make a redzone at both ends of the stack segment. Disallow access
** to those pages of memory. It's ok if the mprotect call's don't
** work - it just means that we don't really have a functional
** redzone.
*/
#ifndef PROT_NONE
#define PROT_NONE 0x0
#endif
#if !defined(SOLARIS)
#include <string.h> /* for memset() */
/* \
** Fill stack memory with something that turns into an illegal \
** pointer value. This will sometimes find runtime references to \
** uninitialized pointers. We don't do this for solaris because we \
** can use purify instead. \
*/ \
if (_pr_debugStacks) { \
} \
#else /* !SOLARIS */
#endif /* !SOLARIS */
/*
* _MD_CLEAR_STACK
* Allow access to the redzone pages; the access was turned off in
* _MD_INIT_STACK.
*/
#define _MD_CLEAR_STACK(ts) \
#else /* DEBUG */
#define _MD_CLEAR_STACK(ts)
#endif /* DEBUG */
#if !defined(SOLARIS)
#define PR_SET_INTSOFF(newval)
#endif
/************************************************************************/
extern void _PR_UnixInit(void);
/************************************************************************/
struct _MDProcess {
};
struct PRProcess;
struct PRProcessAttr;
/* Create a new process (fork() + exec()) */
extern struct PRProcess * _MD_CreateUnixProcess(
const char *path,
char *const *argv,
char *const *envp,
const struct PRProcessAttr *attr
);
/* Wait for a child process to terminate */
#define _MD_WAIT_PROCESS _MD_WaitUnixProcess
#define _MD_KILL_PROCESS _MD_KillUnixProcess
/************************************************************************/
extern void _MD_EnableClockInterrupts(void);
extern void _MD_DisableClockInterrupts(void);
/************************************************************************/
extern void _MD_InitCPUS(void);
#define _MD_INIT_CPUS _MD_InitCPUS
extern void _MD_Wakeup_CPUs(void);
#define _MD_WAKEUP_CPUS _MD_Wakeup_CPUs
#define _MD_PAUSE_CPU _MD_PauseCPU
#if defined(_PR_LOCAL_THREADS_ONLY) || defined(_PR_GLOBAL_THREADS_ONLY)
#define _MD_CLEANUP_BEFORE_EXIT()
#endif
#ifndef IRIX
#endif
/************************************************************************/
#define _MD_GET_ENV getenv
#define _MD_PUT_ENV putenv
/************************************************************************/
#define _MD_INIT_FILEDESC(fd)
#define _MD_MAKE_NONBLOCK _MD_MakeNonblock
/************************************************************************/
#if !defined(_PR_PTHREADS)
extern void _MD_InitSegs(void);
void *vaddr);
#define _MD_INIT_SEGS _MD_InitSegs
#define _MD_ALLOC_SEGMENT _MD_AllocSegment
#define _MD_FREE_SEGMENT _MD_FreeSegment
#endif /* !defined(_PR_PTHREADS) */
/************************************************************************/
#if !defined(HPUX_LW_TIMER)
#define _MD_INTERVAL_INIT()
#endif
/************************************************************************/
#define _MD_GET_SOCKET_ERROR() (errno)
/************************************************************************/
extern void _MD_StartInterrupts(void);
extern void _MD_StopInterrupts(void);
extern void _MD_DisableClockInterrupts(void);
extern void _MD_BlockClockInterrupts(void);
extern void _MD_UnblockClockInterrupts(void);
#define _MD_ACCEPT_READ(sock, newSock, raddr, buf, amount) _MD_accept_read(sock, newSock, raddr, buf, amount)
#define _MD_LOCKFILE _MD_LockFile
#define _MD_TLOCKFILE _MD_TLockFile
#define _MD_UNLOCKFILE _MD_UnlockFile
#define _MD_SOCKET _MD_socket
#define _MD_CONNECT _MD_connect
#define _MD_ACCEPT _MD_accept
#define _MD_LISTEN _MD_listen
#define _MD_SHUTDOWN _MD_shutdown
#define _MD_RECVFROM _MD_recvfrom
#define _MD_SENDTO _MD_sendto
#define _MD_WRITEV _MD_writev
#define _MD_PIPEAVAILABLE _MD_socketavailable
#define _MD_PR_POLL _MD_pr_poll
#define _MD_CLOSE_FILE _MD_close
#define _MD_LSEEK64 _MD_lseek64
#define _MD_SOCKETPAIR _MD_socketpair
#define _MD_CLOSE_SOCKET _MD_close
#ifndef NO_NSPR_10_SUPPORT
#endif
#define _MD_GETPEERNAME _MD_getpeername
#define _MD_GETSOCKNAME _MD_getsockname
#define _MD_GETSOCKOPT _MD_getsockopt
#define _MD_SETSOCKOPT _MD_setsockopt
#define _MD_GETHOSTNAME _MD_gethostname
#define _MD_GETSYSINFO _MD_getsysinfo
extern int _MD_unix_get_nonblocking_connect_error(int osfd);
/* Memory-mapped files */
struct _MDFileMap {
};
#define _MD_CREATE_FILE_MAP _MD_CreateFileMap
#define _MD_GET_MEM_MAP_ALIGNMENT() PR_GetPageSize()
#define _MD_MEM_MAP _MD_MemMap
#define _MD_MEM_UNMAP _MD_MemUnmap
#define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
/*
* The standard (XPG4) gettimeofday() (from BSD) takes two arguments.
* On some SVR4 derivatives, gettimeofday() takes only one argument.
* The GETTIMEOFDAY macro is intended to hide this difference.
*/
#ifdef HAVE_SVID_GETTOD
#else
#endif
#if defined(_PR_PTHREADS) && !defined(_PR_POLL_AVAILABLE)
#define _PR_NEED_FAKE_POLL
#endif
#if defined(_PR_NEED_FAKE_POLL)
/*
* Some platforms don't have poll(), but our pthreads code calls poll().
* As a temporary measure, I implemented a fake poll() using select().
* on Solaris 2.5.
*/
struct pollfd {
int fd;
short events;
short revents;
};
/* poll events */
#define POLLWRNORM POLLOUT
#define POLLNORM POLLRDNORM
#endif /* _PR_NEED_FAKE_POLL */
/*
** A vector of the UNIX I/O calls we use. These are here to smooth over
** the rough edges needed for large files. All of NSPR's implmentaions
** go through this vector using syntax of the form
** result = _md_iovector.xxx64(args);
*/
#if defined(SOLARIS2_5)
/*
** Special case: Solaris 2.5.1
** Solaris starts to have 64-bit file I/O in 2.6. We build on Solaris
** 2.5.1 so that we can use the same binaries on both Solaris 2.5.1 and
** 2.6. At run time, we detect whether 64-bit file I/O is available by
** looking up the 64-bit file function symbols in libc. At build time,
** we need to define the 64-bit file I/O datatypes that are compatible
** with their definitions on Solaris 2.6.
*/
typedef PRInt64 blkcnt64_t;
struct stat64 {
long st_pad1[3];
long t_pad2[2];
long st_blksize;
char st_fstype[_ST_FSTYPSZ];
long st_pad4[8];
};
typedef off64_t _MDOff64_t;
#elif defined(_PR_HAVE_OFF64_T)
typedef off64_t _MDOff64_t;
#elif defined(_PR_HAVE_LARGE_OFF_T)
typedef off_t _MDOff64_t;
#elif defined(_PR_NO_LARGE_FILES)
typedef PRInt64 _MDOff64_t;
#else
#error "I don't know yet"
#endif
#if defined(VMS)
#else
#endif
typedef void* (*_MD_Mmap64)(
struct _MD_IOVector
{
};
extern struct _MD_IOVector _md_iovector;
#endif /* prunixos_h___ */