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 nspr_l4v2_defs_h___
|
---|
39 | #define nspr_l4v2_defs_h___
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * I have "#if 0"ed a lot of this out, and plan to add most of it manually as the
|
---|
43 | * compiler complains about it in order to get a better idea of what is here and
|
---|
44 | * what it does. Not to mention which bits are needed by the runtime itself, and
|
---|
45 | * which only by the unix port.
|
---|
46 | */
|
---|
47 |
|
---|
48 | #include "prthread.h"
|
---|
49 |
|
---|
50 | /*
|
---|
51 | * Internal configuration macros
|
---|
52 | */
|
---|
53 |
|
---|
54 | #define PR_LINKER_ARCH "l4v2"
|
---|
55 | #define _PR_SI_SYSNAME "L4ENV"
|
---|
56 | #define _PR_SI_ARCHITECTURE "x86"
|
---|
57 | #define PR_DLL_SUFFIX ".s.so"
|
---|
58 |
|
---|
59 | #define _PR_VMBASE 0x30000000 /* not used */
|
---|
60 | #define _PR_STACK_VMBASE 0x50000000 /* only used in an unused fn */
|
---|
61 | #define _MD_DEFAULT_STACK_SIZE 65536L
|
---|
62 | #define _MD_MMAP_FLAGS MAP_PRIVATE
|
---|
63 |
|
---|
64 | #undef HAVE_STACK_GROWING_UP
|
---|
65 |
|
---|
66 | /*
|
---|
67 | * L4env supports dl* functions
|
---|
68 | */
|
---|
69 | #define HAVE_DLL
|
---|
70 | #define USE_DLFCN
|
---|
71 |
|
---|
72 | #define USE_SETJMP
|
---|
73 | #undef _PR_USE_POLL
|
---|
74 | #define _PR_STAT_HAS_ONLY_ST_ATIME
|
---|
75 | #define _PR_HAVE_OFF64_T
|
---|
76 |
|
---|
77 | #include <setjmp.h>
|
---|
78 |
|
---|
79 | #define PR_CONTEXT_TYPE jmp_buf
|
---|
80 |
|
---|
81 | #define CONTEXT(_th) ((_th)->md.context)
|
---|
82 |
|
---|
83 | /* Now come the things specifically added for the l4v2 target */
|
---|
84 |
|
---|
85 | /* Don't know quite what this means yet, except that we don't have "it" */
|
---|
86 | /* #define TCP_NODELAY _PR_NO_SUCH_SOCKOPT */
|
---|
87 |
|
---|
88 | /* And what is this? Something to do with memory... Used in
|
---|
89 | xpcom18a4/nsprpub/pr/src/memory/prseg.c */
|
---|
90 | /**
|
---|
91 | * definitions and macros for l4env/memory.c
|
---|
92 | */
|
---|
93 |
|
---|
94 | struct _MDSegment {
|
---|
95 | PRInt8 notused;
|
---|
96 | };
|
---|
97 |
|
---|
98 |
|
---|
99 | extern void
|
---|
100 | _MD_InitSegs(void);
|
---|
101 | #define _MD_INIT_SEGS _MD_InitSegs
|
---|
102 |
|
---|
103 | extern PRStatus
|
---|
104 | _MD_AllocSegment(PRSegment *seg, PRUint32 size, void *vaddr);
|
---|
105 | #define _MD_ALLOC_SEGMENT _MD_AllocSegment
|
---|
106 |
|
---|
107 | extern void
|
---|
108 | _MD_FreeSegment(PRSegment *seg);
|
---|
109 | #define _MD_FREE_SEGMENT _MD_FreeSegment
|
---|
110 |
|
---|
111 | /**
|
---|
112 | * definitions and macros for l4env/clock.c
|
---|
113 | */
|
---|
114 | extern void
|
---|
115 | _MD_IntervalInit(void);
|
---|
116 | #define _MD_INTERVAL_INIT()
|
---|
117 |
|
---|
118 | /**
|
---|
119 | * definitions and macros for l4env/l4env.c
|
---|
120 | */
|
---|
121 |
|
---|
122 | /* See xpcom18a4/nsprpub/pr/src/misc/prinit.c regarding the following function */
|
---|
123 | extern void
|
---|
124 | _MD_EarlyInit(void);
|
---|
125 | #define _MD_EARLY_INIT() _MD_EarlyInit()
|
---|
126 |
|
---|
127 | extern void
|
---|
128 | _MD_StartInterrupts(void);
|
---|
129 |
|
---|
130 | extern void
|
---|
131 | _MD_StopInterrupts(void);
|
---|
132 |
|
---|
133 | extern void
|
---|
134 | _MD_DisableClockInterrupts(void);
|
---|
135 |
|
---|
136 | extern void
|
---|
137 | _MD_EnableClockInterrupts(void);
|
---|
138 |
|
---|
139 | extern void
|
---|
140 | _MD_BlockClockInterrupts(void);
|
---|
141 |
|
---|
142 | extern void
|
---|
143 | _MD_UnblockClockInterrupts(void);
|
---|
144 |
|
---|
145 | #define __USE_SVID /* for now, to get putenv */
|
---|
146 | #include <stdlib.h>
|
---|
147 |
|
---|
148 | /**
|
---|
149 | * definitions and macros for l4env/atomic.c
|
---|
150 | */
|
---|
151 | #if defined(__i386__)
|
---|
152 | #define _PR_HAVE_ATOMIC_OPS
|
---|
153 | #define _MD_INIT_ATOMIC()
|
---|
154 |
|
---|
155 | extern PRInt32
|
---|
156 | _PR_x86_AtomicIncrement(PRInt32 *val);
|
---|
157 | #define _MD_ATOMIC_INCREMENT _PR_x86_AtomicIncrement
|
---|
158 |
|
---|
159 | extern PRInt32
|
---|
160 | _PR_x86_AtomicDecrement(PRInt32 *val);
|
---|
161 | #define _MD_ATOMIC_DECREMENT _PR_x86_AtomicDecrement
|
---|
162 |
|
---|
163 | extern PRInt32
|
---|
164 | _PR_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val);
|
---|
165 |
|
---|
166 | #define _MD_ATOMIC_ADD _PR_x86_AtomicAdd
|
---|
167 | extern PRInt32
|
---|
168 | _PR_x86_AtomicSet(PRInt32 *val, PRInt32 newval);
|
---|
169 | #define _MD_ATOMIC_SET _PR_x86_AtomicSet
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | /**
|
---|
173 | * definitions and macros for l4env/threads.c
|
---|
174 | */
|
---|
175 | #define _PR_LOCAL_THREADS_ONLY
|
---|
176 | #if 0
|
---|
177 | struct _MDThread {
|
---|
178 | PRInt8 notused;
|
---|
179 | };
|
---|
180 |
|
---|
181 | struct _MDThreadStack {
|
---|
182 | PRInt8 notused;
|
---|
183 | };
|
---|
184 | #endif /* 0 */
|
---|
185 |
|
---|
186 | #ifndef _PR_LOCAL_THREADS_ONLY
|
---|
187 | extern PR_IMPLEMENT(PRThread*)
|
---|
188 | PR_GetCurrentThread(void);
|
---|
189 | #define _MD_CURRENT_THREAD() PR_GetCurrentThread()
|
---|
190 | #endif /* _PR_LOCAL_THREADS_ONLY */
|
---|
191 |
|
---|
192 | #define _MD_EXIT_THREAD(thread)
|
---|
193 |
|
---|
194 | #ifndef _PR_LOCAL_THREADS_ONLY
|
---|
195 | extern PR_IMPLEMENT(struct _PRCPU *)
|
---|
196 | PR_GetCurrentCPU(void);
|
---|
197 | #define _MD_CURRENT_CPU() PR_GetCurrentCPU()
|
---|
198 | #endif /* _PR_LOCAL_THREADS_ONLY */
|
---|
199 |
|
---|
200 | #if 0
|
---|
201 | #define _L4_GET_NUMBER_OF_CPUS() 1
|
---|
202 | #define _MD_SET_INTSOFF(_val)
|
---|
203 | #define _MD_GET_INTSOFF() 1
|
---|
204 | #endif /* 0 */
|
---|
205 |
|
---|
206 | #if 0 /* these are the Win32 versions of the above macros - all other versions are defined
|
---|
207 | as here. */
|
---|
208 | #define _MD_GET_INTSOFF() \
|
---|
209 | (_pr_use_static_tls ? _pr_ints_off \
|
---|
210 | : (PRUintn) TlsGetValue(_pr_intsOffIndex))
|
---|
211 |
|
---|
212 | #define _MD_SET_INTSOFF(_val) \
|
---|
213 | PR_BEGIN_MACRO \
|
---|
214 | if (_pr_use_static_tls) { \
|
---|
215 | _pr_ints_off = (_val); \
|
---|
216 | } else { \
|
---|
217 | TlsSetValue(_pr_intsOffIndex, (LPVOID) (_val)); \
|
---|
218 | } \
|
---|
219 | PR_END_MACRO
|
---|
220 | #endif /* 0 */
|
---|
221 |
|
---|
222 | /**
|
---|
223 | * definitions and macros for file l4env/mmap.c
|
---|
224 | */
|
---|
225 |
|
---|
226 | /* Memory-mapped files */
|
---|
227 |
|
---|
228 | extern PRStatus
|
---|
229 | _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
|
---|
230 | #define _MD_CREATE_FILE_MAP _MD_CreateFileMap
|
---|
231 |
|
---|
232 | extern PRStatus
|
---|
233 | _MD_CloseFileMap(struct PRFileMap *fmap);
|
---|
234 | #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
|
---|
235 |
|
---|
236 | #define _MD_GET_MEM_MAP_ALIGNMENT() PR_GetPageSize()
|
---|
237 |
|
---|
238 | extern void *
|
---|
239 | _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,
|
---|
240 | PRUint32 len);
|
---|
241 | #define _MD_MEM_MAP _MD_MemMap
|
---|
242 |
|
---|
243 | extern PRStatus
|
---|
244 | _MD_MemUnmap(void *addr, PRUint32 size);
|
---|
245 | #define _MD_MEM_UNMAP _MD_MemUnmap
|
---|
246 |
|
---|
247 | /**
|
---|
248 | * definitions and macros for file l4env/fileio.c
|
---|
249 | */
|
---|
250 | #define PR_DIRECTORY_SEPARATOR '/'
|
---|
251 | #define PR_DIRECTORY_SEPARATOR_STR "/"
|
---|
252 | #define PR_PATH_SEPARATOR ':'
|
---|
253 | #define PR_PATH_SEPARATOR_STR ":"
|
---|
254 | #define GCPTR
|
---|
255 |
|
---|
256 | #if 0
|
---|
257 | typedef int (*FARPROC)(); /* Where is this used? */
|
---|
258 | #endif
|
---|
259 |
|
---|
260 | extern PRInt32
|
---|
261 | _MD_write(PRFileDesc *fd, const void *buf, PRInt32 amount);
|
---|
262 | #define _MD_WRITE(fd,buf,amount) _MD_write(fd,buf,amount)
|
---|
263 |
|
---|
264 | extern void
|
---|
265 | _MD_query_fd_inheritable(PRFileDesc *fd);
|
---|
266 | #define _MD_QUERY_FD_INHERITABLE _MD_query_fd_inheritable
|
---|
267 |
|
---|
268 | /**
|
---|
269 | * definitions and macros for file l4env/sockets.c
|
---|
270 | */
|
---|
271 | extern PRStatus
|
---|
272 | _MD_getsockopt(PRFileDesc *fd, PRInt32 level,
|
---|
273 | PRInt32 optname, char* optval, PRInt32* optlen);
|
---|
274 | #define _MD_GETSOCKOPT _MD_getsockopt
|
---|
275 | extern PRStatus
|
---|
276 | _MD_setsockopt(PRFileDesc *fd, PRInt32 level,
|
---|
277 | PRInt32 optname, const char* optval, PRInt32 optlen);
|
---|
278 | #define _MD_SETSOCKOPT _MD_setsockopt
|
---|
279 |
|
---|
280 | extern PRStatus
|
---|
281 | _MD_gethostname(char *name, PRUint32 namelen);
|
---|
282 | #define _MD_GETHOSTNAME _MD_gethostname
|
---|
283 |
|
---|
284 | /**
|
---|
285 | * definitions and macros for file l4env/locks.c
|
---|
286 | */
|
---|
287 | struct _MDSemaphore {
|
---|
288 | PRInt8 notused;
|
---|
289 | };
|
---|
290 |
|
---|
291 | struct _MDCVar {
|
---|
292 | PRInt8 notused;
|
---|
293 | };
|
---|
294 |
|
---|
295 | struct _MDLock {
|
---|
296 | int unused;
|
---|
297 | };
|
---|
298 |
|
---|
299 |
|
---|
300 | /* Intel based Linux, err sorry, L4 */
|
---|
301 | #define _MD_GET_SP(_t) CONTEXT(_t)[0].__jmpbuf[JB_SP]
|
---|
302 | #define _MD_SET_FP(_t, val) (CONTEXT(_t)[0].__jmpbuf[JB_BP] = val)
|
---|
303 | #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
|
---|
304 | #define _MD_GET_FP_PTR(_t) &(CONTEXT(_t)[0].__jmpbuf[JB_BP])
|
---|
305 | #define _MD_SP_TYPE __ptr_t
|
---|
306 | #define PR_NUM_GCREGS 6
|
---|
307 |
|
---|
308 | /*
|
---|
309 | ** Initialize a thread context to run "_main()" when started
|
---|
310 | */
|
---|
311 | #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
|
---|
312 | { \
|
---|
313 | *status = PR_TRUE; \
|
---|
314 | if (sigsetjmp(CONTEXT(_thread), 1)) { \
|
---|
315 | _main(); \
|
---|
316 | } \
|
---|
317 | _MD_GET_SP(_thread) = (_MD_SP_TYPE) ((_sp) - 64); \
|
---|
318 | _thread->md.sp = _MD_GET_SP_PTR(_thread); \
|
---|
319 | _thread->md.fp = _MD_GET_FP_PTR(_thread); \
|
---|
320 | _MD_SET_FP(_thread, 0); \
|
---|
321 | }
|
---|
322 |
|
---|
323 | #define _MD_SWITCH_CONTEXT(_thread) \
|
---|
324 | if (!sigsetjmp(CONTEXT(_thread), 1)) { \
|
---|
325 | (_thread)->md.errcode = errno; \
|
---|
326 | _PR_Schedule(); \
|
---|
327 | }
|
---|
328 |
|
---|
329 | /*
|
---|
330 | ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
|
---|
331 | */
|
---|
332 | #define _MD_RESTORE_CONTEXT(_thread) \
|
---|
333 | { \
|
---|
334 | errno = (_thread)->md.errcode; \
|
---|
335 | _MD_SET_CURRENT_THREAD(_thread); \
|
---|
336 | siglongjmp(CONTEXT(_thread), 1); \
|
---|
337 | }
|
---|
338 |
|
---|
339 | /* Machine-dependent (MD) data structures */
|
---|
340 |
|
---|
341 | struct _MDThread {
|
---|
342 | PR_CONTEXT_TYPE context;
|
---|
343 | /* The next two are purely for debugging purposes */
|
---|
344 | int sp;
|
---|
345 | int fp;
|
---|
346 | int id;
|
---|
347 | int errcode;
|
---|
348 | };
|
---|
349 |
|
---|
350 | struct _MDThreadStack {
|
---|
351 | PRInt8 notused;
|
---|
352 | };
|
---|
353 |
|
---|
354 |
|
---|
355 | /*
|
---|
356 | * md-specific cpu structure field
|
---|
357 | */
|
---|
358 |
|
---|
359 | #include <sys/time.h> /* for FD_SETSIZE */
|
---|
360 | #define _PR_MD_MAX_OSFD FD_SETSIZE
|
---|
361 |
|
---|
362 | struct _MDCPU_Unix {
|
---|
363 | PRCList ioQ;
|
---|
364 | PRUint32 ioq_timeout;
|
---|
365 | PRInt32 ioq_max_osfd;
|
---|
366 | PRInt32 ioq_osfd_cnt;
|
---|
367 | #ifndef _PR_USE_POLL
|
---|
368 | fd_set fd_read_set, fd_write_set, fd_exception_set;
|
---|
369 | PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
|
---|
370 | fd_exception_cnt[_PR_MD_MAX_OSFD];
|
---|
371 | #else
|
---|
372 | struct pollfd *ioq_pollfds;
|
---|
373 | int ioq_pollfds_size;
|
---|
374 | #endif /* _PR_USE_POLL */
|
---|
375 | };
|
---|
376 |
|
---|
377 | #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
|
---|
378 | #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
|
---|
379 | #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
|
---|
380 | #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
|
---|
381 | #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
|
---|
382 | #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
|
---|
383 | #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
|
---|
384 | #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
|
---|
385 | #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
|
---|
386 | #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
|
---|
387 | #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
|
---|
388 | #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
|
---|
389 | #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
|
---|
390 |
|
---|
391 | #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
|
---|
392 |
|
---|
393 | struct _MDCPU {
|
---|
394 | struct _MDCPU_Unix md_unix;
|
---|
395 | };
|
---|
396 |
|
---|
397 | #define _MD_INIT_LOCKS()
|
---|
398 | #define _MD_NEW_LOCK(lock) PR_SUCCESS
|
---|
399 | #define _MD_FREE_LOCK(lock)
|
---|
400 | #define _MD_LOCK(lock)
|
---|
401 | #define _MD_UNLOCK(lock)
|
---|
402 | #define _MD_INIT_IO()
|
---|
403 | #define _MD_IOQ_LOCK()
|
---|
404 | #define _MD_IOQ_UNLOCK()
|
---|
405 |
|
---|
406 | #if 0
|
---|
407 | extern PRStatus _MD_InitializeThread(PRThread *thread);
|
---|
408 | #endif /* 0 */
|
---|
409 |
|
---|
410 | #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
|
---|
411 |
|
---|
412 | #define _MD_INIT_THREAD _MD_InitializeThread
|
---|
413 |
|
---|
414 | #if 0
|
---|
415 | #define _MD_EXIT_THREAD(thread)
|
---|
416 | #define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread
|
---|
417 | #define _MD_RESUME_THREAD(thread) _MD_resume_thread
|
---|
418 | #endif /* 0 */
|
---|
419 |
|
---|
420 | #define _MD_CLEAN_THREAD(_thread)
|
---|
421 |
|
---|
422 | #if 0
|
---|
423 | extern PRStatus _MD_CREATE_THREAD(
|
---|
424 | PRThread *thread,
|
---|
425 | void (*start) (void *),
|
---|
426 | PRThreadPriority priority,
|
---|
427 | PRThreadScope scope,
|
---|
428 | PRThreadState state,
|
---|
429 | PRUint32 stackSize);
|
---|
430 | extern void _MD_SET_PRIORITY(struct _MDThread *thread, PRUintn newPri);
|
---|
431 | #endif /* 0 */
|
---|
432 |
|
---|
433 | extern PRStatus _MD_WAIT(PRThread *, PRIntervalTime timeout);
|
---|
434 | extern PRStatus _MD_WAKEUP_WAITER(PRThread *);
|
---|
435 |
|
---|
436 | #if 0
|
---|
437 | extern void _MD_YIELD(void);
|
---|
438 |
|
---|
439 | extern void _MD_EarlyInit(void);
|
---|
440 | #endif /* 0 */
|
---|
441 |
|
---|
442 | extern PRIntervalTime _PR_UNIX_GetInterval(void);
|
---|
443 | extern PRIntervalTime _PR_UNIX_TicksPerSecond(void);
|
---|
444 |
|
---|
445 | #if 0
|
---|
446 | #define _MD_EARLY_INIT _MD_EarlyInit
|
---|
447 | #endif /* 0 */
|
---|
448 | #define _MD_FINAL_INIT _PR_UnixInit
|
---|
449 | #define _MD_GET_INTERVAL _PR_UNIX_GetInterval
|
---|
450 | #define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond
|
---|
451 |
|
---|
452 | /*
|
---|
453 | * We wrapped the select() call. _MD_SELECT refers to the built-in,
|
---|
454 | * unwrapped version.
|
---|
455 | */
|
---|
456 | #if 0
|
---|
457 | #define _MD_SELECT __select
|
---|
458 | #else
|
---|
459 | #define _MD_SELECT select
|
---|
460 | #endif
|
---|
461 |
|
---|
462 | #ifdef _PR_POLL_AVAILABLE
|
---|
463 | #include <sys/poll.h>
|
---|
464 | extern int __syscall_poll(struct pollfd *ufds, unsigned long int nfds,
|
---|
465 | int timeout);
|
---|
466 | #define _MD_POLL __syscall_poll
|
---|
467 | #endif
|
---|
468 |
|
---|
469 | #if 0
|
---|
470 | /* For writev() */
|
---|
471 | #include <sys/uio.h>
|
---|
472 |
|
---|
473 | extern void _MD_l4_map_sendfile_error(int err);
|
---|
474 |
|
---|
475 | #include <sys/types.h>
|
---|
476 | #include <dirent.h>
|
---|
477 |
|
---|
478 | #include "prio.h"
|
---|
479 | #include "prmem.h"
|
---|
480 | #include "prclist.h"
|
---|
481 | #endif /* 0 */
|
---|
482 |
|
---|
483 | #if 0
|
---|
484 | /*
|
---|
485 | * intervals at which GLOBAL threads wakeup to check for pending interrupt
|
---|
486 | */
|
---|
487 | #define _PR_INTERRUPT_CHECK_INTERVAL_SECS 5
|
---|
488 | extern PRIntervalTime intr_timeout_ticks;
|
---|
489 |
|
---|
490 | #define _PR_POLLQUEUE_PTR(_qp) \
|
---|
491 | ((PRPollQueue*) ((char*) (_qp) - offsetof(PRPollQueue,links)))
|
---|
492 |
|
---|
493 | extern void _PR_Unblock_IO_Wait(struct PRThread *thr);
|
---|
494 |
|
---|
495 | #endif /* 0 */
|
---|
496 |
|
---|
497 | #if 0
|
---|
498 |
|
---|
499 | struct _MDDir {
|
---|
500 | DIR *d;
|
---|
501 | };
|
---|
502 |
|
---|
503 | struct _PRCPU;
|
---|
504 | #endif /* 0 */
|
---|
505 |
|
---|
506 | /*
|
---|
507 | ** Make a redzone at both ends of the stack segment. Disallow access
|
---|
508 | ** to those pages of memory. It's ok if the mprotect call's don't
|
---|
509 | ** work - it just means that we don't really have a functional
|
---|
510 | ** redzone.
|
---|
511 | */
|
---|
512 | #if 0
|
---|
513 | #include <sys/mman.h>
|
---|
514 | #ifndef PROT_NONE
|
---|
515 | #define PROT_NONE 0x0
|
---|
516 | #endif
|
---|
517 |
|
---|
518 | #define _MD_INIT_STACK(ts,REDZONE)
|
---|
519 | #define _MD_CLEAR_STACK(ts)
|
---|
520 |
|
---|
521 | #define PR_SET_INTSOFF(newval)
|
---|
522 | #endif
|
---|
523 |
|
---|
524 | #if 0
|
---|
525 |
|
---|
526 | struct PRProcess;
|
---|
527 | struct PRProcessAttr;
|
---|
528 |
|
---|
529 | /* Create a new process (fork() + exec()) */
|
---|
530 | #define _MD_CREATE_PROCESS _MD_l4CreateProcess
|
---|
531 | /* When the compiler complains about this, we will do something about it. */
|
---|
532 |
|
---|
533 | #define _MD_DETACH_PROCESS _MD_l4DetachProcess
|
---|
534 |
|
---|
535 | /* Wait for a child process to terminate */
|
---|
536 | #define _MD_WAIT_PROCESS _MD_l4WaitProcess
|
---|
537 |
|
---|
538 | #define _MD_KILL_PROCESS _MD_l4KillProcess
|
---|
539 | #endif
|
---|
540 |
|
---|
541 | /************************************************************************/
|
---|
542 |
|
---|
543 | #if 0
|
---|
544 | extern void _MD_EnableClockInterrupts(void);
|
---|
545 | extern void _MD_DisableClockInterrupts(void);
|
---|
546 |
|
---|
547 | #define _MD_START_INTERRUPTS _MD_StartInterrupts
|
---|
548 | #define _MD_STOP_INTERRUPTS _MD_StopInterrupts
|
---|
549 | #define _MD_DISABLE_CLOCK_INTERRUPTS _MD_DisableClockInterrupts
|
---|
550 | #define _MD_ENABLE_CLOCK_INTERRUPTS _MD_EnableClockInterrupts
|
---|
551 | #define _MD_BLOCK_CLOCK_INTERRUPTS _MD_BlockClockInterrupts
|
---|
552 | #define _MD_UNBLOCK_CLOCK_INTERRUPTS _MD_UnblockClockInterrupts
|
---|
553 | #endif
|
---|
554 |
|
---|
555 | /************************************************************************/
|
---|
556 |
|
---|
557 | #if 0
|
---|
558 | extern void _MD_InitCPUS(void);
|
---|
559 | #define _MD_INIT_CPUS _MD_InitCPUS
|
---|
560 |
|
---|
561 | extern void _MD_Wakeup_CPUs(void);
|
---|
562 | #define _MD_WAKEUP_CPUS _MD_Wakeup_CPUs
|
---|
563 |
|
---|
564 | #define _MD_PAUSE_CPU _MD_PauseCPU
|
---|
565 |
|
---|
566 | #if defined(_PR_LOCAL_THREADS_ONLY) || defined(_PR_GLOBAL_THREADS_ONLY)
|
---|
567 | #define _MD_CLEANUP_BEFORE_EXIT()
|
---|
568 | #endif
|
---|
569 |
|
---|
570 | #define _MD_EXIT(status) _exit(status)
|
---|
571 | #endif
|
---|
572 |
|
---|
573 | /************************************************************************/
|
---|
574 |
|
---|
575 | #if 0
|
---|
576 | #define _MD_GET_ENV getenv
|
---|
577 | #define _MD_PUT_ENV putenv
|
---|
578 | #endif /* 0 */
|
---|
579 |
|
---|
580 | /************************************************************************/
|
---|
581 |
|
---|
582 | #if 0
|
---|
583 | #define _MD_INIT_FILEDESC(fd)
|
---|
584 |
|
---|
585 | extern void _MD_MakeNonblock(PRFileDesc *fd);
|
---|
586 | #define _MD_MAKE_NONBLOCK _MD_MakeNonblock
|
---|
587 | #endif
|
---|
588 |
|
---|
589 | /************************************************************************/
|
---|
590 |
|
---|
591 | #if 0
|
---|
592 | #if !defined(_PR_PTHREADS)
|
---|
593 |
|
---|
594 | extern void _MD_InitSegs(void);
|
---|
595 | extern PRStatus _MD_AllocSegment(PRSegment *seg, PRUint32 size,
|
---|
596 | void *vaddr);
|
---|
597 | extern void _MD_FreeSegment(PRSegment *seg);
|
---|
598 |
|
---|
599 | #define _MD_INIT_SEGS _MD_InitSegs
|
---|
600 | #define _MD_ALLOC_SEGMENT _MD_AllocSegment
|
---|
601 | #define _MD_FREE_SEGMENT _MD_FreeSegment
|
---|
602 |
|
---|
603 | #endif /* !defined(_PR_PTHREADS) */
|
---|
604 | #endif /* 0 */
|
---|
605 |
|
---|
606 | /************************************************************************/
|
---|
607 |
|
---|
608 | #if 0
|
---|
609 | #define _MD_INTERVAL_INIT()
|
---|
610 | #define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000)
|
---|
611 | #define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000)
|
---|
612 | #endif
|
---|
613 |
|
---|
614 | /************************************************************************/
|
---|
615 |
|
---|
616 | #if 0
|
---|
617 | #define _MD_ERRNO() (errno)
|
---|
618 | #define _MD_GET_SOCKET_ERROR() (errno)
|
---|
619 | #endif
|
---|
620 |
|
---|
621 | /************************************************************************/
|
---|
622 |
|
---|
623 | #if 0
|
---|
624 | extern PRInt32 _MD_AvailableSocket(PRInt32 osfd);
|
---|
625 |
|
---|
626 | extern void _MD_StartInterrupts(void);
|
---|
627 | extern void _MD_StopInterrupts(void);
|
---|
628 | extern void _MD_DisableClockInterrupts(void);
|
---|
629 | extern void _MD_BlockClockInterrupts(void);
|
---|
630 | extern void _MD_UnblockClockInterrupts(void);
|
---|
631 | extern void _MD_PauseCPU(PRIntervalTime timeout);
|
---|
632 | #endif /* 0 */
|
---|
633 |
|
---|
634 | #if 0
|
---|
635 | extern PRStatus _MD_open_dir(struct _MDDir *, const char *);
|
---|
636 | extern PRInt32 _MD_close_dir(struct _MDDir *);
|
---|
637 | extern char * _MD_read_dir(struct _MDDir *, PRIntn);
|
---|
638 | extern PRInt32 _MD_open(const char *name, PRIntn osflags, PRIntn mode);
|
---|
639 | extern PRInt32 _MD_delete(const char *name);
|
---|
640 | extern PRInt32 _MD_getfileinfo(const char *fn, PRFileInfo *info);
|
---|
641 | extern PRInt32 _MD_getfileinfo64(const char *fn, PRFileInfo64 *info);
|
---|
642 | extern PRInt32 _MD_getopenfileinfo(const PRFileDesc *fd, PRFileInfo *info);
|
---|
643 | extern PRInt32 _MD_getopenfileinfo64(const PRFileDesc *fd, PRFileInfo64 *info);
|
---|
644 | extern PRInt32 _MD_rename(const char *from, const char *to);
|
---|
645 | extern PRInt32 _MD_access(const char *name, PRAccessHow how);
|
---|
646 | extern PRInt32 _MD_mkdir(const char *name, PRIntn mode);
|
---|
647 | extern PRInt32 _MD_rmdir(const char *name);
|
---|
648 | extern PRInt32 _MD_accept_read(PRInt32 sock, PRInt32 *newSock,
|
---|
649 | PRNetAddr **raddr, void *buf, PRInt32 amount);
|
---|
650 | extern PRInt32 _PR_UnixSendFile(PRFileDesc *sd, PRSendFileData *sfd,
|
---|
651 | PRTransmitFileFlags flags, PRIntervalTime timeout);
|
---|
652 |
|
---|
653 | extern PRStatus _MD_LockFile(PRInt32 osfd);
|
---|
654 | extern PRStatus _MD_TLockFile(PRInt32 osfd);
|
---|
655 | extern PRStatus _MD_UnlockFile(PRInt32 osfd);
|
---|
656 |
|
---|
657 | #define _MD_OPEN_DIR(dir, name) _MD_open_dir(dir, name)
|
---|
658 | #define _MD_CLOSE_DIR(dir) _MD_close_dir(dir)
|
---|
659 | #define _MD_READ_DIR(dir, flags) _MD_read_dir(dir, flags)
|
---|
660 | #define _MD_OPEN(name, osflags, mode) _MD_open(name, osflags, mode)
|
---|
661 | #define _MD_OPEN_FILE(name, osflags, mode) _MD_open(name, osflags, mode)
|
---|
662 | extern PRInt32 _MD_read(PRFileDesc *fd, void *buf, PRInt32 amount);
|
---|
663 | #define _MD_READ(fd,buf,amount) _MD_read(fd,buf,amount)
|
---|
664 | extern PRInt32 _MD_write(PRFileDesc *fd, const void *buf, PRInt32 amount);
|
---|
665 | #define _MD_WRITE(fd,buf,amount) _MD_write(fd,buf,amount)
|
---|
666 | #define _MD_DELETE(name) _MD_delete(name)
|
---|
667 | #define _MD_GETFILEINFO(fn, info) _MD_getfileinfo(fn, info)
|
---|
668 | #define _MD_GETFILEINFO64(fn, info) _MD_getfileinfo64(fn, info)
|
---|
669 | #define _MD_GETOPENFILEINFO(fd, info) _MD_getopenfileinfo(fd, info)
|
---|
670 | #define _MD_GETOPENFILEINFO64(fd, info) _MD_getopenfileinfo64(fd, info)
|
---|
671 | #define _MD_RENAME(from, to) _MD_rename(from, to)
|
---|
672 | #define _MD_ACCESS(name, how) _MD_access(name, how)
|
---|
673 | #define _MD_MKDIR(name, mode) _MD_mkdir(name, mode)
|
---|
674 | #define _MD_MAKE_DIR(name, mode) _MD_mkdir(name, mode)
|
---|
675 | #define _MD_RMDIR(name) _MD_rmdir(name)
|
---|
676 | #define _MD_ACCEPT_READ(sock, newSock, raddr, buf, amount) _MD_accept_read(sock, newSock, raddr, buf, amount)
|
---|
677 |
|
---|
678 | #define _MD_LOCKFILE _MD_LockFile
|
---|
679 | #define _MD_TLOCKFILE _MD_TLockFile
|
---|
680 | #define _MD_UNLOCKFILE _MD_UnlockFile
|
---|
681 | #endif /* 0 */
|
---|
682 |
|
---|
683 | #if 0
|
---|
684 | extern PRInt32 _MD_socket(int af, int type, int flags);
|
---|
685 | #define _MD_SOCKET _MD_socket
|
---|
686 | extern PRInt32 _MD_connect(PRFileDesc *fd, const PRNetAddr *addr,
|
---|
687 | PRUint32 addrlen, PRIntervalTime timeout);
|
---|
688 | #define _MD_CONNECT _MD_connect
|
---|
689 | extern PRInt32 _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen,
|
---|
690 | PRIntervalTime timeout);
|
---|
691 | #define _MD_ACCEPT _MD_accept
|
---|
692 | extern PRInt32 _MD_bind(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen);
|
---|
693 | #define _MD_BIND _MD_bind
|
---|
694 | extern PRInt32 _MD_listen(PRFileDesc *fd, PRIntn backlog);
|
---|
695 | #define _MD_LISTEN _MD_listen
|
---|
696 | extern PRInt32 _MD_shutdown(PRFileDesc *fd, PRIntn how);
|
---|
697 | #define _MD_SHUTDOWN _MD_shutdown
|
---|
698 |
|
---|
699 | extern PRInt32 _MD_recv(PRFileDesc *fd, void *buf, PRInt32 amount,
|
---|
700 | PRIntn flags, PRIntervalTime timeout);
|
---|
701 | #define _MD_RECV _MD_recv
|
---|
702 | extern PRInt32 _MD_send(PRFileDesc *fd, const void *buf, PRInt32 amount,
|
---|
703 | PRIntn flags, PRIntervalTime timeout);
|
---|
704 | #define _MD_SEND _MD_send
|
---|
705 | extern PRInt32 _MD_recvfrom(PRFileDesc *fd, void *buf, PRInt32 amount,
|
---|
706 | PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen,
|
---|
707 | PRIntervalTime timeout);
|
---|
708 | #define _MD_RECVFROM _MD_recvfrom
|
---|
709 | extern PRInt32 _MD_sendto(PRFileDesc *fd, const void *buf, PRInt32 amount,
|
---|
710 | PRIntn flags, const PRNetAddr *addr, PRUint32 addrlen,
|
---|
711 | PRIntervalTime timeout);
|
---|
712 | #define _MD_SENDTO _MD_sendto
|
---|
713 | extern PRInt32 _MD_writev(PRFileDesc *fd, const struct PRIOVec *iov,
|
---|
714 | PRInt32 iov_size, PRIntervalTime timeout);
|
---|
715 | #define _MD_WRITEV _MD_writev
|
---|
716 |
|
---|
717 | extern PRInt32 _MD_socketavailable(PRFileDesc *fd);
|
---|
718 | #define _MD_SOCKETAVAILABLE _MD_socketavailable
|
---|
719 | extern PRInt64 _MD_socketavailable64(PRFileDesc *fd);
|
---|
720 | #define _MD_SOCKETAVAILABLE64 _MD_socketavailable64
|
---|
721 |
|
---|
722 | #define _MD_PIPEAVAILABLE _MD_socketavailable
|
---|
723 |
|
---|
724 | extern PRInt32 _MD_pr_poll(PRPollDesc *pds, PRIntn npds,
|
---|
725 | PRIntervalTime timeout);
|
---|
726 | #define _MD_PR_POLL _MD_pr_poll
|
---|
727 | #endif /* 0 */
|
---|
728 |
|
---|
729 | #if 0
|
---|
730 | extern PRInt32 _MD_close(PRInt32 osfd);
|
---|
731 | #define _MD_CLOSE_FILE _MD_close
|
---|
732 | extern PRInt32 _MD_lseek(PRFileDesc*, PRInt32, PRSeekWhence);
|
---|
733 | #define _MD_LSEEK _MD_lseek
|
---|
734 | extern PRInt64 _MD_lseek64(PRFileDesc*, PRInt64, PRSeekWhence);
|
---|
735 | #define _MD_LSEEK64 _MD_lseek64
|
---|
736 | extern PRInt32 _MD_fsync(PRFileDesc *fd);
|
---|
737 | #define _MD_FSYNC _MD_fsync
|
---|
738 | #endif /* 0 */
|
---|
739 |
|
---|
740 | #if 0
|
---|
741 | extern PRInt32 _MD_socketpair(int af, int type, int flags, PRInt32 *osfd);
|
---|
742 | #define _MD_SOCKETPAIR _MD_socketpair
|
---|
743 |
|
---|
744 | #define _MD_CLOSE_SOCKET _MD_close
|
---|
745 |
|
---|
746 | #ifndef NO_NSPR_10_SUPPORT
|
---|
747 | #define _MD_STAT stat
|
---|
748 | #endif
|
---|
749 |
|
---|
750 | extern PRStatus _MD_getpeername(PRFileDesc *fd, PRNetAddr *addr,
|
---|
751 | PRUint32 *addrlen);
|
---|
752 | #define _MD_GETPEERNAME _MD_getpeername
|
---|
753 | extern PRStatus _MD_getsockname(PRFileDesc *fd, PRNetAddr *addr,
|
---|
754 | PRUint32 *addrlen);
|
---|
755 | #define _MD_GETSOCKNAME _MD_getsockname
|
---|
756 |
|
---|
757 | extern PRStatus _MD_getsockopt(PRFileDesc *fd, PRInt32 level,
|
---|
758 | PRInt32 optname, char* optval, PRInt32* optlen);
|
---|
759 | #define _MD_GETSOCKOPT _MD_getsockopt
|
---|
760 | extern PRStatus _MD_setsockopt(PRFileDesc *fd, PRInt32 level,
|
---|
761 | PRInt32 optname, const char* optval, PRInt32 optlen);
|
---|
762 | #define _MD_SETSOCKOPT _MD_setsockopt
|
---|
763 |
|
---|
764 | extern PRStatus _MD_set_fd_inheritable(PRFileDesc *fd, PRBool inheritable);
|
---|
765 | #define _MD_SET_FD_INHERITABLE _MD_set_fd_inheritable
|
---|
766 |
|
---|
767 | extern void _MD_init_fd_inheritable(PRFileDesc *fd, PRBool imported);
|
---|
768 | #define _MD_INIT_FD_INHERITABLE _MD_init_fd_inheritable
|
---|
769 |
|
---|
770 | extern void _MD_query_fd_inheritable(PRFileDesc *fd);
|
---|
771 | #define _MD_QUERY_FD_INHERITABLE _MD_query_fd_inheritable
|
---|
772 |
|
---|
773 | extern PRStatus _MD_gethostname(char *name, PRUint32 namelen);
|
---|
774 | #define _MD_GETHOSTNAME _MD_gethostname
|
---|
775 |
|
---|
776 | extern PRStatus _MD_getsysinfo(PRSysInfo cmd, char *name, PRUint32 namelen);
|
---|
777 | #define _MD_GETSYSINFO _MD_getsysinfo
|
---|
778 | #endif /* 0 */
|
---|
779 |
|
---|
780 | #if 0
|
---|
781 | struct _MDFileMap {
|
---|
782 | PRIntn prot;
|
---|
783 | PRIntn flags;
|
---|
784 | PRBool isAnonFM; /* when true, PR_CloseFileMap() must close the related fd */
|
---|
785 | };
|
---|
786 |
|
---|
787 | extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
|
---|
788 | #define _MD_CREATE_FILE_MAP _MD_CreateFileMap
|
---|
789 |
|
---|
790 | #define _MD_GET_MEM_MAP_ALIGNMENT() PR_GetPageSize()
|
---|
791 |
|
---|
792 | extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,
|
---|
793 | PRUint32 len);
|
---|
794 | #define _MD_MEM_MAP _MD_MemMap
|
---|
795 |
|
---|
796 | extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);
|
---|
797 | #define _MD_MEM_UNMAP _MD_MemUnmap
|
---|
798 |
|
---|
799 | extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
|
---|
800 | #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
|
---|
801 | #endif /* 0 */
|
---|
802 |
|
---|
803 | #if 0
|
---|
804 | #define GETTIMEOFDAY(tp) gettimeofday((tp), NULL)
|
---|
805 |
|
---|
806 | #if defined(_PR_PTHREADS) && !defined(_PR_POLL_AVAILABLE)
|
---|
807 | #define _PR_NEED_FAKE_POLL
|
---|
808 | #endif
|
---|
809 |
|
---|
810 | /*
|
---|
811 | ** A vector of the UNIX I/O calls we use. These are here to smooth over
|
---|
812 | ** the rough edges needed for large files. All of NSPR's implmentaions
|
---|
813 | ** go through this vector using syntax of the form
|
---|
814 | ** result = _md_iovector.xxx64(args);
|
---|
815 | */
|
---|
816 |
|
---|
817 | typedef struct stat _MDStat64;
|
---|
818 | typedef off_t _MDOff64_t;
|
---|
819 |
|
---|
820 | typedef PRIntn (*_MD_Fstat64)(PRIntn osfd, _MDStat64 *buf);
|
---|
821 | typedef PRIntn (*_MD_Open64)(const char *path, int oflag, ...);
|
---|
822 | typedef PRIntn (*_MD_Stat64)(const char *path, _MDStat64 *buf);
|
---|
823 | typedef _MDOff64_t (*_MD_Lseek64)(PRIntn osfd, _MDOff64_t, PRIntn whence);
|
---|
824 | typedef void* (*_MD_Mmap64)(
|
---|
825 | void *addr, PRSize len, PRIntn prot, PRIntn flags,
|
---|
826 | PRIntn fildes, _MDOff64_t offset);
|
---|
827 | struct _MD_IOVector
|
---|
828 | {
|
---|
829 | _MD_Open64 _open64;
|
---|
830 | _MD_Mmap64 _mmap64;
|
---|
831 | _MD_Stat64 _stat64;
|
---|
832 | _MD_Fstat64 _fstat64;
|
---|
833 | _MD_Lseek64 _lseek64;
|
---|
834 | };
|
---|
835 | extern struct _MD_IOVector _md_iovector;
|
---|
836 | #endif /* 0 */
|
---|
837 |
|
---|
838 | #endif /* nspr_l4v2_defs_h___ */
|
---|