Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: nspr/pr/include/md/_unixos.h

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

Powered by Google App Engine
This is Rietveld 408576698