VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/md/_nextstep.h@ 65823

Last change on this file since 65823 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: 8.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 nspr_nextstep_defs_h___
39#define nspr_nextstep_defs_h___
40
41#include "prthread.h"
42
43#include <bsd/libc.h>
44#include <bsd/syscall.h>
45
46/* syscall() is not declared in NEXTSTEP's syscall.h ...
47*/
48extern int syscall(int number, ...);
49
50/*
51 * Internal configuration macros
52 */
53
54#define PR_LINKER_ARCH "nextstep"
55#define _PR_SI_SYSNAME "NEXTSTEP"
56#if defined(__sparc__)
57#define _PR_SI_ARCHITECTURE "sparc"
58#elif defined(__m68k__)
59#define _PR_SI_ARCHITECTURE "m68k"
60#elif defined(__i386__)
61#define _PR_SI_ARCHITECTURE "x86"
62#else
63error Unknown NEXTSTEP architecture
64#endif
65#define PR_DLL_SUFFIX ".so"
66
67#define _PR_VMBASE 0x30000000
68#define _PR_STACK_VMBASE 0x50000000
69#define _MD_DEFAULT_STACK_SIZE 65536L
70#define _MD_MMAP_FLAGS MAP_PRIVATE
71
72#undef HAVE_STACK_GROWING_UP
73
74#define HAVE_WEAK_MALLOC_SYMBOLS
75
76#define HAVE_DLL
77#define USE_MACH_DYLD
78#define _PR_STAT_HAS_ONLY_ST_ATIME
79#define _PR_NO_LARGE_FILES
80
81#define USE_SETJMP
82
83#ifndef _PR_PTHREADS
84
85#include <setjmp.h>
86
87#define PR_CONTEXT_TYPE jmp_buf
88
89#define CONTEXT(_th) ((_th)->md.context)
90
91/* [email protected]:
92** __sparc__ is checked
93** __m68k__ is checked
94** __i386__ is a guess (one of the two defines should work)
95*/
96#if defined(__sparc__)
97#define _MD_GET_SP(_th) (_th)->md.context[2]
98#elif defined(__m68k__)
99#define _MD_GET_SP(_th) (_th)->md.context[2]
100#elif defined(__i386__)
101/* One of this two must be OK ... try using sc_onstack
102*/
103#define _MD_GET_SP(_th) (((struct sigcontext *) (_th)->md.context)->sc_onstack)
104//#define _MD_GET_SP(_th) (_th)->md.context[0].sc_esp
105#else
106error Unknown NEXTSTEP architecture
107#endif
108
109#define PR_NUM_GCREGS _JBLEN
110
111/*
112** Initialize a thread context to run "_main()" when started
113*/
114#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
115{ \
116 *status = PR_TRUE; \
117 if (setjmp(CONTEXT(_thread))) { \
118 _main(); \
119 } \
120 _MD_GET_SP(_thread) = (int) ((_sp) - 64); \
121}
122
123#define _MD_SWITCH_CONTEXT(_thread) \
124 if (!setjmp(CONTEXT(_thread))) { \
125 (_thread)->md.errcode = errno; \
126 _PR_Schedule(); \
127 }
128
129/*
130** Restore a thread context, saved by _MD_SWITCH_CONTEXT
131*/
132#define _MD_RESTORE_CONTEXT(_thread) \
133{ \
134 errno = (_thread)->md.errcode; \
135 _MD_SET_CURRENT_THREAD(_thread); \
136 longjmp(CONTEXT(_thread), 1); \
137}
138
139/* Machine-dependent (MD) data structures */
140
141struct _MDThread {
142 PR_CONTEXT_TYPE context;
143 int id;
144 int errcode;
145};
146
147struct _MDThreadStack {
148 PRInt8 notused;
149};
150
151struct _MDLock {
152 PRInt8 notused;
153};
154
155struct _MDSemaphore {
156 PRInt8 notused;
157};
158
159struct _MDCVar {
160 PRInt8 notused;
161};
162
163struct _MDSegment {
164 PRInt8 notused;
165};
166
167/*
168 * md-specific cpu structure field
169 */
170#define _PR_MD_MAX_OSFD FD_SETSIZE
171
172struct _MDCPU_Unix {
173 PRCList ioQ;
174 PRUint32 ioq_timeout;
175 PRInt32 ioq_max_osfd;
176 PRInt32 ioq_osfd_cnt;
177#ifndef _PR_USE_POLL
178 fd_set fd_read_set, fd_write_set, fd_exception_set;
179 PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
180 fd_exception_cnt[_PR_MD_MAX_OSFD];
181#else
182 struct pollfd *ioq_pollfds;
183 int ioq_pollfds_size;
184#endif /* _PR_USE_POLL */
185};
186
187#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
188#define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
189#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
190#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
191#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
192#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
193#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
194#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
195#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
196#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
197#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
198#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
199#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
200
201#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
202
203struct _MDCPU {
204 struct _MDCPU_Unix md_unix;
205};
206
207#define _MD_INIT_LOCKS()
208#define _MD_NEW_LOCK(lock) PR_SUCCESS
209#define _MD_FREE_LOCK(lock)
210#define _MD_LOCK(lock)
211#define _MD_UNLOCK(lock)
212#define _MD_INIT_IO()
213#define _MD_IOQ_LOCK()
214#define _MD_IOQ_UNLOCK()
215
216extern PRStatus _MD_InitializeThread(PRThread *thread);
217
218#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
219#define _MD_INIT_THREAD _MD_InitializeThread
220#define _MD_EXIT_THREAD(thread)
221#define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread
222#define _MD_RESUME_THREAD(thread) _MD_resume_thread
223#define _MD_CLEAN_THREAD(_thread)
224
225extern PRStatus _MD_CREATE_THREAD(
226 PRThread *thread,
227 void (*start) (void *),
228 PRThreadPriority priority,
229 PRThreadScope scope,
230 PRThreadState state,
231 PRUint32 stackSize);
232extern void _MD_SET_PRIORITY(struct _MDThread *thread, PRUintn newPri);
233extern PRStatus _MD_WAIT(PRThread *, PRIntervalTime timeout);
234extern PRStatus _MD_WAKEUP_WAITER(PRThread *);
235extern void _MD_YIELD(void);
236
237#endif /* ! _PR_PTHREADS */
238
239extern void _MD_EarlyInit(void);
240extern PRIntervalTime _PR_UNIX_GetInterval(void);
241extern PRIntervalTime _PR_UNIX_TicksPerSecond(void);
242
243#define _MD_EARLY_INIT _MD_EarlyInit
244#define _MD_FINAL_INIT _PR_UnixInit
245#define _MD_GET_INTERVAL _PR_UNIX_GetInterval
246#define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond
247
248/*
249 * We wrapped the select() call. _MD_SELECT refers to the built-in,
250 * unwrapped version.
251 */
252#define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
253
254/* For writev() */
255#include <sys/uio.h>
256
257/* signal.h */
258/* [email protected]: this is stolen from sunos4.h. The things is that
259** NEXTSTEP doesn't support these flags for `struct sigaction's sa_flags, so
260** I have to fake them ...
261*/
262#define SA_RESTART 0
263
264/* mmap */
265/* [email protected]: NEXTSTEP doesn't have mmap, at least not
266** publically. We have sys/mman.h, but it doesn't declare mmap(), and
267** PROT_NONE is also missing. syscall.h has entries for mmap, munmap, and
268** mprotect so I wrap these in nextstep.c as mmap(), munmap() and mprotect()
269** and pray for it to work.
270**
271*/
272caddr_t mmap(caddr_t addr, size_t len, int prot, int flags,
273 int fildes, off_t off);
274int munmap(caddr_t addr, size_t len);
275int mprotect(caddr_t addr, size_t len, int prot);
276
277/* my_mmap() is implemented in nextstep.c and is based on map_fd() of mach.
278*/
279caddr_t my_mmap(caddr_t addr, size_t len, int prot, int flags,
280 int fildes, off_t off);
281int my_munmap(caddr_t addr, size_t len);
282
283
284/* string.h
285*/
286/* [email protected]: this is missing so implemenetd in nextstep.c ...
287*/
288char *strdup(const char *s1);
289
290/* unistd.h
291*/
292/* [email protected]: these functions are hidden, though correctly
293** implemented in NEXTSTEP. Here I give the declaration for them to be used
294** by prmalloc.c, and I have a wrapped syscall() version of them in nextstep.c
295*/
296int brk(void *endds);
297void *sbrk(int incr);
298
299#endif /* nspr_nextstep_defs_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