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 "prmem.h"
|
---|
62 | #include "prclist.h"
|
---|
63 |
|
---|
64 | /*
|
---|
65 | * For select(), fd_set, and struct timeval.
|
---|
66 | *
|
---|
67 | * In The Single UNIX(R) Specification, Version 2,
|
---|
68 | * the header file for select() is <sys/time.h>.
|
---|
69 | *
|
---|
70 | * fd_set is defined in <sys/types.h>. Usually
|
---|
71 | * <sys/time.h> includes <sys/types.h>, but on some
|
---|
72 | * older systems <sys/time.h> does not include
|
---|
73 | * <sys/types.h>, so we include it explicitly.
|
---|
74 | */
|
---|
75 | #include <sys/time.h>
|
---|
76 | #include <sys/types.h>
|
---|
77 |
|
---|
78 | #define PR_DIRECTORY_SEPARATOR '/'
|
---|
79 | #define PR_DIRECTORY_SEPARATOR_STR "/"
|
---|
80 | #define PR_PATH_SEPARATOR ':'
|
---|
81 | #define PR_PATH_SEPARATOR_STR ":"
|
---|
82 | #define GCPTR
|
---|
83 | typedef int (*FARPROC)();
|
---|
84 |
|
---|
85 | /*
|
---|
86 | * intervals at which GLOBAL threads wakeup to check for pending interrupt
|
---|
87 | */
|
---|
88 | #define _PR_INTERRUPT_CHECK_INTERVAL_SECS 5
|
---|
89 | extern PRIntervalTime intr_timeout_ticks;
|
---|
90 |
|
---|
91 | /*
|
---|
92 | ** Make a redzone at both ends of the stack segment. Disallow access
|
---|
93 | ** to those pages of memory. It's ok if the mprotect call's don't
|
---|
94 | ** work - it just means that we don't really have a functional
|
---|
95 | ** redzone.
|
---|
96 | */
|
---|
97 | #include <sys/mman.h>
|
---|
98 | #ifndef PROT_NONE
|
---|
99 | #define PROT_NONE 0x0
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | #if defined(DEBUG) && !defined(DARWIN) && !defined(NEXTSTEP)
|
---|
103 | #if !defined(SOLARIS)
|
---|
104 | #include <string.h> /* for memset() */
|
---|
105 | #define _MD_INIT_STACK(ts,REDZONE) \
|
---|
106 | PR_BEGIN_MACRO \
|
---|
107 | (void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_NONE); \
|
---|
108 | (void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\
|
---|
109 | REDZONE, PROT_NONE); \
|
---|
110 | /* \
|
---|
111 | ** Fill stack memory with something that turns into an illegal \
|
---|
112 | ** pointer value. This will sometimes find runtime references to \
|
---|
113 | ** uninitialized pointers. We don't do this for solaris because we \
|
---|
114 | ** can use purify instead. \
|
---|
115 | */ \
|
---|
116 | if (_pr_debugStacks) { \
|
---|
117 | memset(ts->allocBase + REDZONE, 0xf7, ts->stackSize); \
|
---|
118 | } \
|
---|
119 | PR_END_MACRO
|
---|
120 | #else /* !SOLARIS */
|
---|
121 | #define _MD_INIT_STACK(ts,REDZONE) \
|
---|
122 | PR_BEGIN_MACRO \
|
---|
123 | (void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_NONE); \
|
---|
124 | (void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\
|
---|
125 | REDZONE, PROT_NONE); \
|
---|
126 | PR_END_MACRO
|
---|
127 | #endif /* !SOLARIS */
|
---|
128 |
|
---|
129 | /*
|
---|
130 | * _MD_CLEAR_STACK
|
---|
131 | * Allow access to the redzone pages; the access was turned off in
|
---|
132 | * _MD_INIT_STACK.
|
---|
133 | */
|
---|
134 | #define _MD_CLEAR_STACK(ts) \
|
---|
135 | PR_BEGIN_MACRO \
|
---|
136 | (void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_READ|PROT_WRITE);\
|
---|
137 | (void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\
|
---|
138 | REDZONE, PROT_READ|PROT_WRITE); \
|
---|
139 | PR_END_MACRO
|
---|
140 |
|
---|
141 | #else /* DEBUG */
|
---|
142 |
|
---|
143 | #define _MD_INIT_STACK(ts,REDZONE)
|
---|
144 | #define _MD_CLEAR_STACK(ts)
|
---|
145 |
|
---|
146 | #endif /* DEBUG */
|
---|
147 |
|
---|
148 | #if !defined(SOLARIS)
|
---|
149 |
|
---|
150 | #define PR_SET_INTSOFF(newval)
|
---|
151 |
|
---|
152 | #endif
|
---|
153 |
|
---|
154 | /************************************************************************/
|
---|
155 |
|
---|
156 | extern void _PR_UnixInit(void);
|
---|
157 |
|
---|
158 | /************************************************************************/
|
---|
159 |
|
---|
160 | #if !defined(HPUX_LW_TIMER)
|
---|
161 | #define _MD_INTERVAL_INIT()
|
---|
162 | #endif
|
---|
163 | #define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000)
|
---|
164 | #define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000)
|
---|
165 |
|
---|
166 | /************************************************************************/
|
---|
167 |
|
---|
168 | #define _MD_ERRNO() (errno)
|
---|
169 | #define _MD_GET_SOCKET_ERROR() (errno)
|
---|
170 |
|
---|
171 | /************************************************************************/
|
---|
172 |
|
---|
173 | /*
|
---|
174 | * The standard (XPG4) gettimeofday() (from BSD) takes two arguments.
|
---|
175 | * On some SVR4 derivatives, gettimeofday() takes only one argument.
|
---|
176 | * The GETTIMEOFDAY macro is intended to hide this difference.
|
---|
177 | */
|
---|
178 | #ifdef HAVE_SVID_GETTOD
|
---|
179 | #define GETTIMEOFDAY(tp) gettimeofday(tp)
|
---|
180 | #else
|
---|
181 | #define GETTIMEOFDAY(tp) gettimeofday((tp), NULL)
|
---|
182 | #endif
|
---|
183 |
|
---|
184 | #endif /* prunixos_h___ */
|
---|