VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/md/_unixos.h@ 1

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.7 KB
Line 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38#ifndef prunixos_h___
39#define prunixos_h___
40
41/*
42 * If FD_SETSIZE is not defined on the command line, set the default value
43 * before include select.h
44 */
45/*
46 * Linux: FD_SETSIZE is defined in /usr/include/sys/select.h and should
47 * not be redefined.
48 */
49#if !defined(LINUX) && !defined(DARWIN) && !defined(NEXTSTEP) && !defined(L4ENV)
50#ifndef FD_SETSIZE
51#define FD_SETSIZE 4096
52#endif
53#endif
54
55#include <unistd.h>
56#include <stddef.h>
57#include <sys/stat.h>
58#include <dirent.h>
59#include <errno.h>
60
61#include "prio.h"
62#include "prmem.h"
63#include "prclist.h"
64
65/*
66 * For select(), fd_set, and struct timeval.
67 *
68 * In The Single UNIX(R) Specification, Version 2,
69 * the header file for select() is <sys/time.h>.
70 *
71 * fd_set is defined in <sys/types.h>. Usually
72 * <sys/time.h> includes <sys/types.h>, but on some
73 * older systems <sys/time.h> does not include
74 * <sys/types.h>, so we include it explicitly.
75 */
76#include <sys/time.h>
77#include <sys/types.h>
78#if defined(AIX) /* Only pre-4.2 AIX needs it, but for simplicity... */
79#include <sys/select.h>
80#endif
81
82#define PR_DIRECTORY_SEPARATOR '/'
83#define PR_DIRECTORY_SEPARATOR_STR "/"
84#define PR_PATH_SEPARATOR ':'
85#define PR_PATH_SEPARATOR_STR ":"
86#define GCPTR
87typedef int (*FARPROC)();
88
89/*
90 * intervals at which GLOBAL threads wakeup to check for pending interrupt
91 */
92#define _PR_INTERRUPT_CHECK_INTERVAL_SECS 5
93extern PRIntervalTime intr_timeout_ticks;
94
95/*
96 * The bit flags for the in_flags and out_flags fields
97 * of _PR_UnixPollDesc
98 */
99#ifdef _PR_USE_POLL
100#define _PR_UNIX_POLL_READ POLLIN
101#define _PR_UNIX_POLL_WRITE POLLOUT
102#define _PR_UNIX_POLL_EXCEPT POLLPRI
103#define _PR_UNIX_POLL_ERR POLLERR
104#define _PR_UNIX_POLL_NVAL POLLNVAL
105#define _PR_UNIX_POLL_HUP POLLHUP
106#else /* _PR_USE_POLL */
107#define _PR_UNIX_POLL_READ 0x1
108#define _PR_UNIX_POLL_WRITE 0x2
109#define _PR_UNIX_POLL_EXCEPT 0x4
110#define _PR_UNIX_POLL_ERR 0x8
111#define _PR_UNIX_POLL_NVAL 0x10
112#define _PR_UNIX_POLL_HUP 0x20
113#endif /* _PR_USE_POLL */
114
115typedef struct _PRUnixPollDesc {
116 PRInt32 osfd;
117 PRInt16 in_flags;
118 PRInt16 out_flags;
119} _PRUnixPollDesc;
120
121typedef struct PRPollQueue {
122 PRCList links; /* for linking PRPollQueue's together */
123 _PRUnixPollDesc *pds; /* array of poll descriptors */
124 PRUintn npds; /* length of the array */
125 PRPackedBool on_ioq; /* is this on the async i/o work q? */
126 PRIntervalTime timeout; /* timeout, in ticks */
127 struct PRThread *thr;
128} PRPollQueue;
129
130#define _PR_POLLQUEUE_PTR(_qp) \
131 ((PRPollQueue*) ((char*) (_qp) - offsetof(PRPollQueue,links)))
132
133
134extern PRInt32 _PR_WaitForMultipleFDs(
135 _PRUnixPollDesc *unixpds,
136 PRInt32 pdcnt,
137 PRIntervalTime timeout);
138extern void _PR_Unblock_IO_Wait(struct PRThread *thr);
139
140#if defined(_PR_LOCAL_THREADS_ONLY) || defined(_PR_GLOBAL_THREADS_ONLY)
141#define _MD_CHECK_FOR_EXIT()
142#endif
143
144extern fd_set _pr_md_read_set, _pr_md_write_set, _pr_md_exception_set;
145extern PRInt16 _pr_md_read_cnt[], _pr_md_write_cnt[], _pr_md_exception_cnt[];
146extern PRInt32 _pr_md_ioq_max_osfd;
147extern PRUint32 _pr_md_ioq_timeout;
148
149struct _MDFileDesc {
150 int osfd;
151#if defined(LINUX) && defined(_PR_PTHREADS)
152 int tcp_nodelay; /* used by pt_LinuxSendFile */
153#endif
154};
155
156struct _MDDir {
157 DIR *d;
158};
159
160struct _PRCPU;
161extern void _MD_unix_init_running_cpu(struct _PRCPU *cpu);
162
163/*
164** Make a redzone at both ends of the stack segment. Disallow access
165** to those pages of memory. It's ok if the mprotect call's don't
166** work - it just means that we don't really have a functional
167** redzone.
168*/
169#include <sys/mman.h>
170#ifndef PROT_NONE
171#define PROT_NONE 0x0
172#endif
173
174#if defined(DEBUG) && !defined(DARWIN) && !defined(NEXTSTEP)
175#if !defined(SOLARIS)
176#include <string.h> /* for memset() */
177#define _MD_INIT_STACK(ts,REDZONE) \
178 PR_BEGIN_MACRO \
179 (void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_NONE); \
180 (void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\
181 REDZONE, PROT_NONE); \
182 /* \
183 ** Fill stack memory with something that turns into an illegal \
184 ** pointer value. This will sometimes find runtime references to \
185 ** uninitialized pointers. We don't do this for solaris because we \
186 ** can use purify instead. \
187 */ \
188 if (_pr_debugStacks) { \
189 memset(ts->allocBase + REDZONE, 0xf7, ts->stackSize); \
190 } \
191 PR_END_MACRO
192#else /* !SOLARIS */
193#define _MD_INIT_STACK(ts,REDZONE) \
194 PR_BEGIN_MACRO \
195 (void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_NONE); \
196 (void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\
197 REDZONE, PROT_NONE); \
198 PR_END_MACRO
199#endif /* !SOLARIS */
200
201/*
202 * _MD_CLEAR_STACK
203 * Allow access to the redzone pages; the access was turned off in
204 * _MD_INIT_STACK.
205 */
206#define _MD_CLEAR_STACK(ts) \
207 PR_BEGIN_MACRO \
208 (void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_READ|PROT_WRITE);\
209 (void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\
210 REDZONE, PROT_READ|PROT_WRITE); \
211 PR_END_MACRO
212
213#else /* DEBUG */
214
215#define _MD_INIT_STACK(ts,REDZONE)
216#define _MD_CLEAR_STACK(ts)
217
218#endif /* DEBUG */
219
220#if !defined(SOLARIS)
221
222#define PR_SET_INTSOFF(newval)
223
224#endif
225
226/************************************************************************/
227
228extern void _PR_UnixInit(void);
229
230/************************************************************************/
231
232struct _MDProcess {
233 pid_t pid;
234};
235
236struct PRProcess;
237struct PRProcessAttr;
238
239/* Create a new process (fork() + exec()) */
240#define _MD_CREATE_PROCESS _MD_CreateUnixProcess
241extern struct PRProcess * _MD_CreateUnixProcess(
242 const char *path,
243 char *const *argv,
244 char *const *envp,
245 const struct PRProcessAttr *attr
246);
247
248#define _MD_DETACH_PROCESS _MD_DetachUnixProcess
249extern PRStatus _MD_DetachUnixProcess(struct PRProcess *process);
250
251/* Wait for a child process to terminate */
252#define _MD_WAIT_PROCESS _MD_WaitUnixProcess
253extern PRStatus _MD_WaitUnixProcess(struct PRProcess *process,
254 PRInt32 *exitCode);
255
256#define _MD_KILL_PROCESS _MD_KillUnixProcess
257extern PRStatus _MD_KillUnixProcess(struct PRProcess *process);
258
259/************************************************************************/
260
261extern void _MD_EnableClockInterrupts(void);
262extern void _MD_DisableClockInterrupts(void);
263
264#define _MD_START_INTERRUPTS _MD_StartInterrupts
265#define _MD_STOP_INTERRUPTS _MD_StopInterrupts
266#define _MD_DISABLE_CLOCK_INTERRUPTS _MD_DisableClockInterrupts
267#define _MD_ENABLE_CLOCK_INTERRUPTS _MD_EnableClockInterrupts
268#define _MD_BLOCK_CLOCK_INTERRUPTS _MD_BlockClockInterrupts
269#define _MD_UNBLOCK_CLOCK_INTERRUPTS _MD_UnblockClockInterrupts
270
271/************************************************************************/
272
273extern void _MD_InitCPUS(void);
274#define _MD_INIT_CPUS _MD_InitCPUS
275
276extern void _MD_Wakeup_CPUs(void);
277#define _MD_WAKEUP_CPUS _MD_Wakeup_CPUs
278
279#define _MD_PAUSE_CPU _MD_PauseCPU
280
281#if defined(_PR_LOCAL_THREADS_ONLY) || defined(_PR_GLOBAL_THREADS_ONLY)
282#define _MD_CLEANUP_BEFORE_EXIT()
283#endif
284
285#ifndef IRIX
286#define _MD_EXIT(status) _exit(status)
287#endif
288
289/************************************************************************/
290
291#define _MD_GET_ENV getenv
292#define _MD_PUT_ENV putenv
293
294/************************************************************************/
295
296#define _MD_INIT_FILEDESC(fd)
297
298extern void _MD_MakeNonblock(PRFileDesc *fd);
299#define _MD_MAKE_NONBLOCK _MD_MakeNonblock
300
301/************************************************************************/
302
303#if !defined(_PR_PTHREADS)
304
305extern void _MD_InitSegs(void);
306extern PRStatus _MD_AllocSegment(PRSegment *seg, PRUint32 size,
307 void *vaddr);
308extern void _MD_FreeSegment(PRSegment *seg);
309
310#define _MD_INIT_SEGS _MD_InitSegs
311#define _MD_ALLOC_SEGMENT _MD_AllocSegment
312#define _MD_FREE_SEGMENT _MD_FreeSegment
313
314#endif /* !defined(_PR_PTHREADS) */
315
316/************************************************************************/
317
318#if !defined(HPUX_LW_TIMER)
319#define _MD_INTERVAL_INIT()
320#endif
321#define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000)
322#define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000)
323
324/************************************************************************/
325
326#define _MD_ERRNO() (errno)
327#define _MD_GET_SOCKET_ERROR() (errno)
328
329/************************************************************************/
330
331extern PRInt32 _MD_AvailableSocket(PRInt32 osfd);
332
333extern void _MD_StartInterrupts(void);
334extern void _MD_StopInterrupts(void);
335extern void _MD_DisableClockInterrupts(void);
336extern void _MD_BlockClockInterrupts(void);
337extern void _MD_UnblockClockInterrupts(void);
338extern void _MD_PauseCPU(PRIntervalTime timeout);
339
340extern PRStatus _MD_open_dir(struct _MDDir *, const char *);
341extern PRInt32 _MD_close_dir(struct _MDDir *);
342extern char * _MD_read_dir(struct _MDDir *, PRIntn);
343extern PRInt32 _MD_open(const char *name, PRIntn osflags, PRIntn mode);
344extern PRInt32 _MD_delete(const char *name);
345extern PRInt32 _MD_getfileinfo(const char *fn, PRFileInfo *info);
346extern PRInt32 _MD_getfileinfo64(const char *fn, PRFileInfo64 *info);
347extern PRInt32 _MD_getopenfileinfo(const PRFileDesc *fd, PRFileInfo *info);
348extern PRInt32 _MD_getopenfileinfo64(const PRFileDesc *fd, PRFileInfo64 *info);
349extern PRInt32 _MD_rename(const char *from, const char *to);
350extern PRInt32 _MD_access(const char *name, PRAccessHow how);
351extern PRInt32 _MD_mkdir(const char *name, PRIntn mode);
352extern PRInt32 _MD_rmdir(const char *name);
353extern PRInt32 _MD_accept_read(PRInt32 sock, PRInt32 *newSock,
354 PRNetAddr **raddr, void *buf, PRInt32 amount);
355extern PRInt32 _PR_UnixSendFile(PRFileDesc *sd, PRSendFileData *sfd,
356 PRTransmitFileFlags flags, PRIntervalTime timeout);
357
358extern PRStatus _MD_LockFile(PRInt32 osfd);
359extern PRStatus _MD_TLockFile(PRInt32 osfd);
360extern PRStatus _MD_UnlockFile(PRInt32 osfd);
361
362#define _MD_OPEN_DIR(dir, name) _MD_open_dir(dir, name)
363#define _MD_CLOSE_DIR(dir) _MD_close_dir(dir)
364#define _MD_READ_DIR(dir, flags) _MD_read_dir(dir, flags)
365#define _MD_OPEN(name, osflags, mode) _MD_open(name, osflags, mode)
366#define _MD_OPEN_FILE(name, osflags, mode) _MD_open(name, osflags, mode)
367extern PRInt32 _MD_read(PRFileDesc *fd, void *buf, PRInt32 amount);
368#define _MD_READ(fd,buf,amount) _MD_read(fd,buf,amount)
369extern PRInt32 _MD_write(PRFileDesc *fd, const void *buf, PRInt32 amount);
370#define _MD_WRITE(fd,buf,amount) _MD_write(fd,buf,amount)
371#define _MD_DELETE(name) _MD_delete(name)
372#define _MD_GETFILEINFO(fn, info) _MD_getfileinfo(fn, info)
373#define _MD_GETFILEINFO64(fn, info) _MD_getfileinfo64(fn, info)
374#define _MD_GETOPENFILEINFO(fd, info) _MD_getopenfileinfo(fd, info)
375#define _MD_GETOPENFILEINFO64(fd, info) _MD_getopenfileinfo64(fd, info)
376#define _MD_RENAME(from, to) _MD_rename(from, to)
377#define _MD_ACCESS(name, how) _MD_access(name, how)
378#define _MD_MKDIR(name, mode) _MD_mkdir(name, mode)
379#define _MD_MAKE_DIR(name, mode) _MD_mkdir(name, mode)
380#define _MD_RMDIR(name) _MD_rmdir(name)
381#define _MD_ACCEPT_READ(sock, newSock, raddr, buf, amount) _MD_accept_read(sock, newSock, raddr, buf, amount)
382
383#define _MD_LOCKFILE _MD_LockFile
384#define _MD_TLOCKFILE _MD_TLockFile
385#define _MD_UNLOCKFILE _MD_UnlockFile
386
387
388extern PRInt32 _MD_socket(int af, int type, int flags);
389#define _MD_SOCKET _MD_socket
390extern PRInt32 _MD_connect(PRFileDesc *fd, const PRNetAddr *addr,
391 PRUint32 addrlen, PRIntervalTime timeout);
392#define _MD_CONNECT _MD_connect
393extern PRInt32 _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen,
394 PRIntervalTime timeout);
395#define _MD_ACCEPT _MD_accept
396extern PRInt32 _MD_bind(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen);
397#define _MD_BIND _MD_bind
398extern PRInt32 _MD_listen(PRFileDesc *fd, PRIntn backlog);
399#define _MD_LISTEN _MD_listen
400extern PRInt32 _MD_shutdown(PRFileDesc *fd, PRIntn how);
401#define _MD_SHUTDOWN _MD_shutdown
402
403extern PRInt32 _MD_recv(PRFileDesc *fd, void *buf, PRInt32 amount,
404 PRIntn flags, PRIntervalTime timeout);
405#define _MD_RECV _MD_recv
406extern PRInt32 _MD_send(PRFileDesc *fd, const void *buf, PRInt32 amount,
407 PRIntn flags, PRIntervalTime timeout);
408#define _MD_SEND _MD_send
409extern PRInt32 _MD_recvfrom(PRFileDesc *fd, void *buf, PRInt32 amount,
410 PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen,
411 PRIntervalTime timeout);
412#define _MD_RECVFROM _MD_recvfrom
413extern PRInt32 _MD_sendto(PRFileDesc *fd, const void *buf, PRInt32 amount,
414 PRIntn flags, const PRNetAddr *addr, PRUint32 addrlen,
415 PRIntervalTime timeout);
416#define _MD_SENDTO _MD_sendto
417extern PRInt32 _MD_writev(PRFileDesc *fd, const struct PRIOVec *iov,
418 PRInt32 iov_size, PRIntervalTime timeout);
419#define _MD_WRITEV _MD_writev
420
421extern PRInt32 _MD_socketavailable(PRFileDesc *fd);
422#define _MD_SOCKETAVAILABLE _MD_socketavailable
423extern PRInt64 _MD_socketavailable64(PRFileDesc *fd);
424#define _MD_SOCKETAVAILABLE64 _MD_socketavailable64
425
426#define _MD_PIPEAVAILABLE _MD_socketavailable
427
428extern PRInt32 _MD_pr_poll(PRPollDesc *pds, PRIntn npds,
429 PRIntervalTime timeout);
430#define _MD_PR_POLL _MD_pr_poll
431
432extern PRInt32 _MD_close(PRInt32 osfd);
433#define _MD_CLOSE_FILE _MD_close
434extern PRInt32 _MD_lseek(PRFileDesc*, PRInt32, PRSeekWhence);
435#define _MD_LSEEK _MD_lseek
436extern PRInt64 _MD_lseek64(PRFileDesc*, PRInt64, PRSeekWhence);
437#define _MD_LSEEK64 _MD_lseek64
438extern PRInt32 _MD_fsync(PRFileDesc *fd);
439#define _MD_FSYNC _MD_fsync
440
441extern PRInt32 _MD_socketpair(int af, int type, int flags, PRInt32 *osfd);
442#define _MD_SOCKETPAIR _MD_socketpair
443
444#define _MD_CLOSE_SOCKET _MD_close
445
446#ifndef NO_NSPR_10_SUPPORT
447#define _MD_STAT stat
448#endif
449
450extern PRStatus _MD_getpeername(PRFileDesc *fd, PRNetAddr *addr,
451 PRUint32 *addrlen);
452#define _MD_GETPEERNAME _MD_getpeername
453extern PRStatus _MD_getsockname(PRFileDesc *fd, PRNetAddr *addr,
454 PRUint32 *addrlen);
455#define _MD_GETSOCKNAME _MD_getsockname
456
457extern PRStatus _MD_getsockopt(PRFileDesc *fd, PRInt32 level,
458 PRInt32 optname, char* optval, PRInt32* optlen);
459#define _MD_GETSOCKOPT _MD_getsockopt
460extern PRStatus _MD_setsockopt(PRFileDesc *fd, PRInt32 level,
461 PRInt32 optname, const char* optval, PRInt32 optlen);
462#define _MD_SETSOCKOPT _MD_setsockopt
463
464extern PRStatus _MD_set_fd_inheritable(PRFileDesc *fd, PRBool inheritable);
465#define _MD_SET_FD_INHERITABLE _MD_set_fd_inheritable
466
467extern void _MD_init_fd_inheritable(PRFileDesc *fd, PRBool imported);
468#define _MD_INIT_FD_INHERITABLE _MD_init_fd_inheritable
469
470extern void _MD_query_fd_inheritable(PRFileDesc *fd);
471#define _MD_QUERY_FD_INHERITABLE _MD_query_fd_inheritable
472
473extern PRStatus _MD_gethostname(char *name, PRUint32 namelen);
474#define _MD_GETHOSTNAME _MD_gethostname
475
476extern PRStatus _MD_getsysinfo(PRSysInfo cmd, char *name, PRUint32 namelen);
477#define _MD_GETSYSINFO _MD_getsysinfo
478
479extern int _MD_unix_get_nonblocking_connect_error(int osfd);
480
481/* Memory-mapped files */
482
483struct _MDFileMap {
484 PRIntn prot;
485 PRIntn flags;
486 PRBool isAnonFM; /* when true, PR_CloseFileMap() must close the related fd */
487};
488
489extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
490#define _MD_CREATE_FILE_MAP _MD_CreateFileMap
491
492#define _MD_GET_MEM_MAP_ALIGNMENT() PR_GetPageSize()
493
494extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,
495 PRUint32 len);
496#define _MD_MEM_MAP _MD_MemMap
497
498extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);
499#define _MD_MEM_UNMAP _MD_MemUnmap
500
501extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
502#define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
503
504/*
505 * The standard (XPG4) gettimeofday() (from BSD) takes two arguments.
506 * On some SVR4 derivatives, gettimeofday() takes only one argument.
507 * The GETTIMEOFDAY macro is intended to hide this difference.
508 */
509#ifdef HAVE_SVID_GETTOD
510#define GETTIMEOFDAY(tp) gettimeofday(tp)
511#else
512#define GETTIMEOFDAY(tp) gettimeofday((tp), NULL)
513#endif
514
515#if defined(_PR_PTHREADS) && !defined(_PR_POLL_AVAILABLE)
516#define _PR_NEED_FAKE_POLL
517#endif
518
519#if defined(_PR_NEED_FAKE_POLL)
520
521/*
522 * Some platforms don't have poll(), but our pthreads code calls poll().
523 * As a temporary measure, I implemented a fake poll() using select().
524 * Here are the struct and macro definitions copied from sys/poll.h
525 * on Solaris 2.5.
526 */
527
528struct pollfd {
529 int fd;
530 short events;
531 short revents;
532};
533
534/* poll events */
535
536#define POLLIN 0x0001 /* fd is readable */
537#define POLLPRI 0x0002 /* high priority info at fd */
538#define POLLOUT 0x0004 /* fd is writeable (won't block) */
539#define POLLRDNORM 0x0040 /* normal data is readable */
540#define POLLWRNORM POLLOUT
541#define POLLRDBAND 0x0080 /* out-of-band data is readable */
542#define POLLWRBAND 0x0100 /* out-of-band data is writeable */
543
544#define POLLNORM POLLRDNORM
545
546#define POLLERR 0x0008 /* fd has error condition */
547#define POLLHUP 0x0010 /* fd has been hung up on */
548#define POLLNVAL 0x0020 /* invalid pollfd entry */
549
550extern int poll(struct pollfd *, unsigned long, int);
551
552#endif /* _PR_NEED_FAKE_POLL */
553
554/*
555** A vector of the UNIX I/O calls we use. These are here to smooth over
556** the rough edges needed for large files. All of NSPR's implmentaions
557** go through this vector using syntax of the form
558** result = _md_iovector.xxx64(args);
559*/
560
561#if defined(SOLARIS2_5)
562/*
563** Special case: Solaris 2.5.1
564** Solaris starts to have 64-bit file I/O in 2.6. We build on Solaris
565** 2.5.1 so that we can use the same binaries on both Solaris 2.5.1 and
566** 2.6. At run time, we detect whether 64-bit file I/O is available by
567** looking up the 64-bit file function symbols in libc. At build time,
568** we need to define the 64-bit file I/O datatypes that are compatible
569** with their definitions on Solaris 2.6.
570*/
571typedef PRInt64 off64_t;
572typedef PRUint64 ino64_t;
573typedef PRInt64 blkcnt64_t;
574struct stat64 {
575 dev_t st_dev;
576 long st_pad1[3];
577 ino64_t st_ino;
578 mode_t st_mode;
579 nlink_t st_nlink;
580 uid_t st_uid;
581 gid_t st_gid;
582 dev_t st_rdev;
583 long t_pad2[2];
584 off64_t st_size;
585 timestruc_t st_atim;
586 timestruc_t st_mtim;
587 timestruc_t st_ctim;
588 long st_blksize;
589 blkcnt64_t st_blocks;
590 char st_fstype[_ST_FSTYPSZ];
591 long st_pad4[8];
592};
593typedef struct stat64 _MDStat64;
594typedef off64_t _MDOff64_t;
595
596#elif defined(_PR_HAVE_OFF64_T)
597typedef struct stat64 _MDStat64;
598typedef off64_t _MDOff64_t;
599#elif defined(_PR_HAVE_LARGE_OFF_T)
600typedef struct stat _MDStat64;
601typedef off_t _MDOff64_t;
602#elif defined(_PR_NO_LARGE_FILES)
603typedef struct stat _MDStat64;
604typedef PRInt64 _MDOff64_t;
605#else
606#error "I don't know yet"
607#endif
608
609typedef PRIntn (*_MD_Fstat64)(PRIntn osfd, _MDStat64 *buf);
610typedef PRIntn (*_MD_Open64)(const char *path, int oflag, ...);
611#if defined(VMS)
612typedef PRIntn (*_MD_Stat64)(const char *path, _MDStat64 *buf, ...);
613#else
614typedef PRIntn (*_MD_Stat64)(const char *path, _MDStat64 *buf);
615#endif
616typedef _MDOff64_t (*_MD_Lseek64)(PRIntn osfd, _MDOff64_t, PRIntn whence);
617typedef void* (*_MD_Mmap64)(
618 void *addr, PRSize len, PRIntn prot, PRIntn flags,
619 PRIntn fildes, _MDOff64_t offset);
620struct _MD_IOVector
621{
622 _MD_Open64 _open64;
623 _MD_Mmap64 _mmap64;
624 _MD_Stat64 _stat64;
625 _MD_Fstat64 _fstat64;
626 _MD_Lseek64 _lseek64;
627};
628extern struct _MD_IOVector _md_iovector;
629
630#endif /* prunixos_h___ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette