VirtualBox

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

Last change on this file since 101749 was 101749, checked in by vboxsync, 15 months ago

libs/xpcom: Remove prsystem.{c,h} and uxrng.c as they aren't used anywhere, bugref:10545 [build fix]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.9 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)
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#ifdef VBOX
249/* Create a new detached process (fork() + exec()) */
250#define _MD_CREATE_PROCESS_DETACHED _MD_CreateUnixProcessDetached
251extern PRStatus _MD_CreateUnixProcessDetached(
252 const char *path,
253 char *const *argv,
254 char *const *envp,
255 const struct PRProcessAttr *attr
256);
257#endif /* VBOX */
258
259#define _MD_DETACH_PROCESS _MD_DetachUnixProcess
260extern PRStatus _MD_DetachUnixProcess(struct PRProcess *process);
261
262/* Wait for a child process to terminate */
263#define _MD_WAIT_PROCESS _MD_WaitUnixProcess
264extern PRStatus _MD_WaitUnixProcess(struct PRProcess *process,
265 PRInt32 *exitCode);
266
267#define _MD_KILL_PROCESS _MD_KillUnixProcess
268extern PRStatus _MD_KillUnixProcess(struct PRProcess *process);
269
270/************************************************************************/
271
272extern void _MD_EnableClockInterrupts(void);
273extern void _MD_DisableClockInterrupts(void);
274
275#define _MD_START_INTERRUPTS _MD_StartInterrupts
276#define _MD_STOP_INTERRUPTS _MD_StopInterrupts
277#define _MD_DISABLE_CLOCK_INTERRUPTS _MD_DisableClockInterrupts
278#define _MD_ENABLE_CLOCK_INTERRUPTS _MD_EnableClockInterrupts
279#define _MD_BLOCK_CLOCK_INTERRUPTS _MD_BlockClockInterrupts
280#define _MD_UNBLOCK_CLOCK_INTERRUPTS _MD_UnblockClockInterrupts
281
282/************************************************************************/
283
284extern void _MD_InitCPUS(void);
285#define _MD_INIT_CPUS _MD_InitCPUS
286
287extern void _MD_Wakeup_CPUs(void);
288#define _MD_WAKEUP_CPUS _MD_Wakeup_CPUs
289
290#define _MD_PAUSE_CPU _MD_PauseCPU
291
292#if defined(_PR_LOCAL_THREADS_ONLY) || defined(_PR_GLOBAL_THREADS_ONLY)
293#define _MD_CLEANUP_BEFORE_EXIT()
294#endif
295
296#ifndef IRIX
297#define _MD_EXIT(status) _exit(status)
298#endif
299
300/************************************************************************/
301
302#define _MD_GET_ENV getenv
303#define _MD_PUT_ENV putenv
304
305/************************************************************************/
306
307#define _MD_INIT_FILEDESC(fd)
308
309extern void _MD_MakeNonblock(PRFileDesc *fd);
310#define _MD_MAKE_NONBLOCK _MD_MakeNonblock
311
312/************************************************************************/
313
314#if !defined(_PR_PTHREADS)
315
316extern void _MD_InitSegs(void);
317extern PRStatus _MD_AllocSegment(PRSegment *seg, PRUint32 size,
318 void *vaddr);
319extern void _MD_FreeSegment(PRSegment *seg);
320
321#define _MD_INIT_SEGS _MD_InitSegs
322#define _MD_ALLOC_SEGMENT _MD_AllocSegment
323#define _MD_FREE_SEGMENT _MD_FreeSegment
324
325#endif /* !defined(_PR_PTHREADS) */
326
327/************************************************************************/
328
329#if !defined(HPUX_LW_TIMER)
330#define _MD_INTERVAL_INIT()
331#endif
332#define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000)
333#define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000)
334
335/************************************************************************/
336
337#define _MD_ERRNO() (errno)
338#define _MD_GET_SOCKET_ERROR() (errno)
339
340/************************************************************************/
341
342extern PRInt32 _MD_AvailableSocket(PRInt32 osfd);
343
344extern void _MD_StartInterrupts(void);
345extern void _MD_StopInterrupts(void);
346extern void _MD_DisableClockInterrupts(void);
347extern void _MD_BlockClockInterrupts(void);
348extern void _MD_UnblockClockInterrupts(void);
349extern void _MD_PauseCPU(PRIntervalTime timeout);
350
351extern PRStatus _MD_open_dir(struct _MDDir *, const char *);
352extern PRInt32 _MD_close_dir(struct _MDDir *);
353extern char * _MD_read_dir(struct _MDDir *, PRIntn);
354extern PRInt32 _MD_open(const char *name, PRIntn osflags, PRIntn mode);
355extern PRInt32 _MD_delete(const char *name);
356extern PRInt32 _MD_getfileinfo(const char *fn, PRFileInfo *info);
357extern PRInt32 _MD_getfileinfo64(const char *fn, PRFileInfo64 *info);
358extern PRInt32 _MD_getopenfileinfo(const PRFileDesc *fd, PRFileInfo *info);
359extern PRInt32 _MD_getopenfileinfo64(const PRFileDesc *fd, PRFileInfo64 *info);
360extern PRInt32 _MD_rename(const char *from, const char *to);
361extern PRInt32 _MD_access(const char *name, PRAccessHow how);
362extern PRInt32 _MD_mkdir(const char *name, PRIntn mode);
363extern PRInt32 _MD_rmdir(const char *name);
364extern PRInt32 _MD_accept_read(PRInt32 sock, PRInt32 *newSock,
365 PRNetAddr **raddr, void *buf, PRInt32 amount);
366extern PRInt32 _PR_UnixSendFile(PRFileDesc *sd, PRSendFileData *sfd,
367 PRTransmitFileFlags flags, PRIntervalTime timeout);
368
369extern PRStatus _MD_LockFile(PRInt32 osfd);
370extern PRStatus _MD_TLockFile(PRInt32 osfd);
371extern PRStatus _MD_UnlockFile(PRInt32 osfd);
372
373#define _MD_OPEN_DIR(dir, name) _MD_open_dir(dir, name)
374#define _MD_CLOSE_DIR(dir) _MD_close_dir(dir)
375#define _MD_READ_DIR(dir, flags) _MD_read_dir(dir, flags)
376#define _MD_OPEN(name, osflags, mode) _MD_open(name, osflags, mode)
377#define _MD_OPEN_FILE(name, osflags, mode) _MD_open(name, osflags, mode)
378extern PRInt32 _MD_read(PRFileDesc *fd, void *buf, PRInt32 amount);
379#define _MD_READ(fd,buf,amount) _MD_read(fd,buf,amount)
380extern PRInt32 _MD_write(PRFileDesc *fd, const void *buf, PRInt32 amount);
381#define _MD_WRITE(fd,buf,amount) _MD_write(fd,buf,amount)
382#define _MD_DELETE(name) _MD_delete(name)
383#define _MD_GETFILEINFO(fn, info) _MD_getfileinfo(fn, info)
384#define _MD_GETFILEINFO64(fn, info) _MD_getfileinfo64(fn, info)
385#define _MD_GETOPENFILEINFO(fd, info) _MD_getopenfileinfo(fd, info)
386#define _MD_GETOPENFILEINFO64(fd, info) _MD_getopenfileinfo64(fd, info)
387#define _MD_RENAME(from, to) _MD_rename(from, to)
388#define _MD_ACCESS(name, how) _MD_access(name, how)
389#define _MD_MKDIR(name, mode) _MD_mkdir(name, mode)
390#define _MD_MAKE_DIR(name, mode) _MD_mkdir(name, mode)
391#define _MD_RMDIR(name) _MD_rmdir(name)
392#define _MD_ACCEPT_READ(sock, newSock, raddr, buf, amount) _MD_accept_read(sock, newSock, raddr, buf, amount)
393
394#define _MD_LOCKFILE _MD_LockFile
395#define _MD_TLOCKFILE _MD_TLockFile
396#define _MD_UNLOCKFILE _MD_UnlockFile
397
398
399extern PRInt32 _MD_socket(int af, int type, int flags);
400#define _MD_SOCKET _MD_socket
401extern PRInt32 _MD_connect(PRFileDesc *fd, const PRNetAddr *addr,
402 PRUint32 addrlen, PRIntervalTime timeout);
403#define _MD_CONNECT _MD_connect
404extern PRInt32 _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen,
405 PRIntervalTime timeout);
406#define _MD_ACCEPT _MD_accept
407extern PRInt32 _MD_bind(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen);
408#define _MD_BIND _MD_bind
409extern PRInt32 _MD_listen(PRFileDesc *fd, PRIntn backlog);
410#define _MD_LISTEN _MD_listen
411extern PRInt32 _MD_shutdown(PRFileDesc *fd, PRIntn how);
412#define _MD_SHUTDOWN _MD_shutdown
413
414extern PRInt32 _MD_recv(PRFileDesc *fd, void *buf, PRInt32 amount,
415 PRIntn flags, PRIntervalTime timeout);
416#define _MD_RECV _MD_recv
417extern PRInt32 _MD_send(PRFileDesc *fd, const void *buf, PRInt32 amount,
418 PRIntn flags, PRIntervalTime timeout);
419#define _MD_SEND _MD_send
420extern PRInt32 _MD_recvfrom(PRFileDesc *fd, void *buf, PRInt32 amount,
421 PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen,
422 PRIntervalTime timeout);
423#define _MD_RECVFROM _MD_recvfrom
424extern PRInt32 _MD_sendto(PRFileDesc *fd, const void *buf, PRInt32 amount,
425 PRIntn flags, const PRNetAddr *addr, PRUint32 addrlen,
426 PRIntervalTime timeout);
427#define _MD_SENDTO _MD_sendto
428extern PRInt32 _MD_writev(PRFileDesc *fd, const struct PRIOVec *iov,
429 PRInt32 iov_size, PRIntervalTime timeout);
430#define _MD_WRITEV _MD_writev
431
432extern PRInt32 _MD_socketavailable(PRFileDesc *fd);
433#define _MD_SOCKETAVAILABLE _MD_socketavailable
434extern PRInt64 _MD_socketavailable64(PRFileDesc *fd);
435#define _MD_SOCKETAVAILABLE64 _MD_socketavailable64
436
437#define _MD_PIPEAVAILABLE _MD_socketavailable
438
439extern PRInt32 _MD_pr_poll(PRPollDesc *pds, PRIntn npds,
440 PRIntervalTime timeout);
441#define _MD_PR_POLL _MD_pr_poll
442
443extern PRInt32 _MD_close(PRInt32 osfd);
444#define _MD_CLOSE_FILE _MD_close
445extern PRInt32 _MD_lseek(PRFileDesc*, PRInt32, PRSeekWhence);
446#define _MD_LSEEK _MD_lseek
447extern PRInt64 _MD_lseek64(PRFileDesc*, PRInt64, PRSeekWhence);
448#define _MD_LSEEK64 _MD_lseek64
449extern PRInt32 _MD_fsync(PRFileDesc *fd);
450#define _MD_FSYNC _MD_fsync
451
452extern PRInt32 _MD_socketpair(int af, int type, int flags, PRInt32 *osfd);
453#define _MD_SOCKETPAIR _MD_socketpair
454
455#define _MD_CLOSE_SOCKET _MD_close
456
457#ifndef NO_NSPR_10_SUPPORT
458#define _MD_STAT stat
459#endif
460
461extern PRStatus _MD_getpeername(PRFileDesc *fd, PRNetAddr *addr,
462 PRUint32 *addrlen);
463#define _MD_GETPEERNAME _MD_getpeername
464extern PRStatus _MD_getsockname(PRFileDesc *fd, PRNetAddr *addr,
465 PRUint32 *addrlen);
466#define _MD_GETSOCKNAME _MD_getsockname
467
468extern PRStatus _MD_getsockopt(PRFileDesc *fd, PRInt32 level,
469 PRInt32 optname, char* optval, PRInt32* optlen);
470#define _MD_GETSOCKOPT _MD_getsockopt
471extern PRStatus _MD_setsockopt(PRFileDesc *fd, PRInt32 level,
472 PRInt32 optname, const char* optval, PRInt32 optlen);
473#define _MD_SETSOCKOPT _MD_setsockopt
474
475extern PRStatus _MD_set_fd_inheritable(PRFileDesc *fd, PRBool inheritable);
476#define _MD_SET_FD_INHERITABLE _MD_set_fd_inheritable
477
478extern void _MD_init_fd_inheritable(PRFileDesc *fd, PRBool imported);
479#define _MD_INIT_FD_INHERITABLE _MD_init_fd_inheritable
480
481extern void _MD_query_fd_inheritable(PRFileDesc *fd);
482#define _MD_QUERY_FD_INHERITABLE _MD_query_fd_inheritable
483
484extern PRStatus _MD_gethostname(char *name, PRUint32 namelen);
485#define _MD_GETHOSTNAME _MD_gethostname
486
487extern int _MD_unix_get_nonblocking_connect_error(int osfd);
488
489/* Memory-mapped files */
490
491struct _MDFileMap {
492 PRIntn prot;
493 PRIntn flags;
494 PRBool isAnonFM; /* when true, PR_CloseFileMap() must close the related fd */
495};
496
497extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
498#define _MD_CREATE_FILE_MAP _MD_CreateFileMap
499
500#define _MD_GET_MEM_MAP_ALIGNMENT() PR_GetPageSize()
501
502extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,
503 PRUint32 len);
504#define _MD_MEM_MAP _MD_MemMap
505
506extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);
507#define _MD_MEM_UNMAP _MD_MemUnmap
508
509extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
510#define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
511
512/*
513 * The standard (XPG4) gettimeofday() (from BSD) takes two arguments.
514 * On some SVR4 derivatives, gettimeofday() takes only one argument.
515 * The GETTIMEOFDAY macro is intended to hide this difference.
516 */
517#ifdef HAVE_SVID_GETTOD
518#define GETTIMEOFDAY(tp) gettimeofday(tp)
519#else
520#define GETTIMEOFDAY(tp) gettimeofday((tp), NULL)
521#endif
522
523#if defined(_PR_PTHREADS) && !defined(_PR_POLL_AVAILABLE)
524#define _PR_NEED_FAKE_POLL
525#endif
526
527#if defined(_PR_NEED_FAKE_POLL)
528
529/*
530 * Some platforms don't have poll(), but our pthreads code calls poll().
531 * As a temporary measure, I implemented a fake poll() using select().
532 * Here are the struct and macro definitions copied from sys/poll.h
533 * on Solaris 2.5.
534 */
535
536struct pollfd {
537 int fd;
538 short events;
539 short revents;
540};
541
542/* poll events */
543
544#define POLLIN 0x0001 /* fd is readable */
545#define POLLPRI 0x0002 /* high priority info at fd */
546#define POLLOUT 0x0004 /* fd is writeable (won't block) */
547#define POLLRDNORM 0x0040 /* normal data is readable */
548#define POLLWRNORM POLLOUT
549#define POLLRDBAND 0x0080 /* out-of-band data is readable */
550#define POLLWRBAND 0x0100 /* out-of-band data is writeable */
551
552#define POLLNORM POLLRDNORM
553
554#define POLLERR 0x0008 /* fd has error condition */
555#define POLLHUP 0x0010 /* fd has been hung up on */
556#define POLLNVAL 0x0020 /* invalid pollfd entry */
557
558extern int poll(struct pollfd *, unsigned long, int);
559
560#endif /* _PR_NEED_FAKE_POLL */
561
562/*
563** A vector of the UNIX I/O calls we use. These are here to smooth over
564** the rough edges needed for large files. All of NSPR's implmentaions
565** go through this vector using syntax of the form
566** result = _md_iovector.xxx64(args);
567*/
568
569#if defined(SOLARIS2_5)
570/*
571** Special case: Solaris 2.5.1
572** Solaris starts to have 64-bit file I/O in 2.6. We build on Solaris
573** 2.5.1 so that we can use the same binaries on both Solaris 2.5.1 and
574** 2.6. At run time, we detect whether 64-bit file I/O is available by
575** looking up the 64-bit file function symbols in libc. At build time,
576** we need to define the 64-bit file I/O datatypes that are compatible
577** with their definitions on Solaris 2.6.
578*/
579typedef PRInt64 off64_t;
580typedef PRUint64 ino64_t;
581typedef PRInt64 blkcnt64_t;
582struct stat64 {
583 dev_t st_dev;
584 long st_pad1[3];
585 ino64_t st_ino;
586 mode_t st_mode;
587 nlink_t st_nlink;
588 uid_t st_uid;
589 gid_t st_gid;
590 dev_t st_rdev;
591 long t_pad2[2];
592 off64_t st_size;
593 timestruc_t st_atim;
594 timestruc_t st_mtim;
595 timestruc_t st_ctim;
596 long st_blksize;
597 blkcnt64_t st_blocks;
598 char st_fstype[_ST_FSTYPSZ];
599 long st_pad4[8];
600};
601typedef struct stat64 _MDStat64;
602typedef off64_t _MDOff64_t;
603
604#elif defined(_PR_HAVE_OFF64_T)
605typedef struct stat64 _MDStat64;
606typedef off64_t _MDOff64_t;
607#elif defined(_PR_HAVE_LARGE_OFF_T)
608typedef struct stat _MDStat64;
609typedef off_t _MDOff64_t;
610#elif defined(_PR_NO_LARGE_FILES)
611typedef struct stat _MDStat64;
612typedef PRInt64 _MDOff64_t;
613#else
614#error "I don't know yet"
615#endif
616
617typedef PRIntn (*_MD_Fstat64)(PRIntn osfd, _MDStat64 *buf);
618typedef PRIntn (*_MD_Open64)(const char *path, int oflag, ...);
619#if defined(VMS)
620typedef PRIntn (*_MD_Stat64)(const char *path, _MDStat64 *buf, ...);
621#else
622typedef PRIntn (*_MD_Stat64)(const char *path, _MDStat64 *buf);
623#endif
624typedef _MDOff64_t (*_MD_Lseek64)(PRIntn osfd, _MDOff64_t, PRIntn whence);
625typedef void* (*_MD_Mmap64)(
626 void *addr, PRSize len, PRIntn prot, PRIntn flags,
627 PRIntn fildes, _MDOff64_t offset);
628struct _MD_IOVector
629{
630 _MD_Open64 _open64;
631 _MD_Mmap64 _mmap64;
632 _MD_Stat64 _stat64;
633 _MD_Fstat64 _fstat64;
634 _MD_Lseek64 _lseek64;
635};
636extern struct _MD_IOVector _md_iovector;
637
638#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