VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/md/_reliantunix.h@ 1

Last change on this file since 1 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.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/*
39 * reliantunix.h
40 * 5/18/96 Taken from nec.h -- [email protected]
41 * 3/14/97 Modified for nspr20 -- [email protected]
42 */
43#ifndef nspr_reliantunix_defs_h___
44#define nspr_reliantunix_defs_h___
45
46/*
47 * Internal configuration macros
48 */
49
50#define PR_LINKER_ARCH "sinix"
51#define _PR_SI_SYSNAME "SINIX"
52#define _PR_SI_ARCHITECTURE "mips"
53#define PR_DLL_SUFFIX ".so"
54
55#define _PR_VMBASE 0x30000000
56#define _PR_STACK_VMBASE 0x50000000
57#define _MD_DEFAULT_STACK_SIZE (2*65536L)
58#define _MD_MMAP_FLAGS MAP_PRIVATE|MAP_FIXED
59
60#undef HAVE_STACK_GROWING_UP
61#define HAVE_DLL
62#define USE_DLFCN
63#define NEED_STRFTIME_LOCK
64#define NEED_TIME_R
65#define HAVE_NETCONFIG
66#define HAVE_WEAK_IO_SYMBOLS
67#define HAVE_WEAK_MALLOC_SYMBOLS
68#define _PR_RECV_BROKEN /* recv doesn't work on Unix Domain Sockets */
69#define _PR_POLL_AVAILABLE
70#define _PR_USE_POLL
71#define _PR_STAT_HAS_ST_ATIM
72#define _PR_NO_LARGE_FILES
73
74/*
75 * Mike Patnode indicated that it is possibly safe now to use context-switching
76 * calls that do not change the signal mask, like setjmp vs. sigsetjmp.
77 * So we'll use our homegrown, getcontext/setcontext-compatible stuff which
78 * will save us the getcontext/setcontext system calls at each context switch.
79 * It already works in FastTrack 2.01, so it should do it here :-)
80 * - chrisk 040497
81 */
82#define USE_SETCXT /* temporarily disabled... */
83
84#include <ucontext.h>
85
86#ifdef USE_SETCXT
87/* use non-syscall machine language replacement */
88#define _GETCONTEXT getcxt
89#define _SETCONTEXT setcxt
90/* defined in os_ReliantUNIX.s */
91extern int getcxt(ucontext_t *);
92extern int setcxt(ucontext_t *);
93#else
94#define _GETCONTEXT getcontext
95#define _SETCONTEXT setcontext
96#endif
97
98#define _MD_GET_SP(_t) (_t)->md.context.uc_mcontext.gpregs[CXT_SP]
99#define _PR_CONTEXT_TYPE ucontext_t
100#define _PR_NUM_GCREGS NGREG
101
102#define CONTEXT(_thread) (&(_thread)->md.context)
103
104#define _PR_IS_NATIVE_THREAD_SUPPORTED() 0
105
106/*
107** Machine-dependent (MD) data structures.
108*/
109struct _MDThread {
110 _PR_CONTEXT_TYPE context;
111 int id;
112 int errcode;
113};
114
115struct _MDThreadStack {
116 PRInt8 notused;
117};
118
119struct _MDLock {
120 PRInt8 notused;
121};
122
123struct _MDSemaphore {
124 PRInt8 notused;
125};
126
127struct _MDCVar {
128 PRInt8 notused;
129};
130
131struct _MDSegment {
132 PRInt8 notused;
133};
134
135/*
136 * md-specific cpu structure field
137 */
138#define _PR_MD_MAX_OSFD FD_SETSIZE
139
140struct _MDCPU_Unix {
141 PRCList ioQ;
142 PRUint32 ioq_timeout;
143 PRInt32 ioq_max_osfd;
144 PRInt32 ioq_osfd_cnt;
145#ifndef _PR_USE_POLL
146 fd_set fd_read_set, fd_write_set, fd_exception_set;
147 PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
148 fd_exception_cnt[_PR_MD_MAX_OSFD];
149#else
150 struct pollfd *ioq_pollfds;
151 int ioq_pollfds_size;
152#endif /* _PR_USE_POLL */
153};
154
155#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
156#define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
157#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
158#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
159#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
160#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
161#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
162#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
163#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
164#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
165#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
166#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
167#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
168
169#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
170
171struct _MDCPU {
172 struct _MDCPU_Unix md_unix;
173};
174
175#define _MD_INIT_LOCKS()
176#define _MD_NEW_LOCK(lock) PR_SUCCESS
177#define _MD_FREE_LOCK(lock)
178#define _MD_LOCK(lock)
179#define _MD_UNLOCK(lock)
180#define _MD_INIT_IO()
181#define _MD_IOQ_LOCK()
182#define _MD_IOQ_UNLOCK()
183
184/*
185** Initialize the thread context preparing it to execute "_main()"
186** - get a nice, fresh context
187** - set its SP to the stack we allcoated for it
188** - set it to start things at "e"
189*/
190#define _MD_INIT_CONTEXT(thread, _sp, _main, status) \
191 PR_BEGIN_MACRO \
192 *status = PR_TRUE; \
193 _GETCONTEXT(CONTEXT(thread)); \
194 /* this is supposed to point to the stack BASE, not to SP */ \
195 CONTEXT(thread)->uc_stack.ss_sp = thread->stack->stackBottom; \
196 CONTEXT(thread)->uc_stack.ss_size = thread->stack->stackSize; \
197 CONTEXT(thread)->uc_mcontext.gpregs[CXT_SP] = ((unsigned long)_sp - 128) & 0xfffffff8; \
198 CONTEXT(thread)->uc_mcontext.gpregs[CXT_T9] = _main; \
199 CONTEXT(thread)->uc_mcontext.gpregs[CXT_EPC] = _main; \
200 CONTEXT(thread)->uc_mcontext.gpregs[CXT_RA] = 0; \
201 thread->no_sched = 0; \
202 PR_END_MACRO
203
204/*
205** Save current context as it is scheduled away
206*/
207#define _MD_SWITCH_CONTEXT(_thread) \
208 PR_BEGIN_MACRO \
209 if (!_GETCONTEXT(CONTEXT(_thread))) { \
210 _MD_SAVE_ERRNO(_thread); \
211 _MD_SET_LAST_THREAD(_thread); \
212 _PR_Schedule(); \
213 } \
214 PR_END_MACRO
215
216/*
217** Restore a thread context, saved by _MD_SWITCH_CONTEXT or set up
218** by _MD_INIT_CONTEXT
219** CXT_V0 is the register that holds the return value.
220** We must set it to 1 so that we can see if the return from
221** getcontext() is the result of calling getcontext() or
222** setcontext()...
223** setting a context got with getcontext() appears to
224** return from getcontext(), too!
225** CXT_A3 is the register that holds status when returning
226** from a syscall. It is set to 0 to indicate success,
227** because we want getcontext() on the other side of the magic
228** door to be ok.
229*/
230#define _MD_RESTORE_CONTEXT(_thread) \
231 PR_BEGIN_MACRO \
232 ucontext_t *uc = CONTEXT(_thread); \
233 uc->uc_mcontext.gpregs[CXT_V0] = 1;\
234 uc->uc_mcontext.gpregs[CXT_A3] = 0;\
235 _MD_RESTORE_ERRNO(_thread); \
236 _MD_SET_CURRENT_THREAD(_thread); \
237 _SETCONTEXT(uc); \
238 PR_END_MACRO
239
240#define _MD_SAVE_ERRNO(t) (t)->md.errcode = errno;
241#define _MD_RESTORE_ERRNO(t) errno = (t)->md.errcode;
242
243#define _MD_GET_INTERVAL _PR_UNIX_GetInterval
244#define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond
245
246#define _MD_EARLY_INIT _MD_EarlyInit
247#define _MD_FINAL_INIT _PR_UnixInit
248#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
249#define _MD_INIT_THREAD _MD_InitializeThread
250#define _MD_EXIT_THREAD(thread)
251#define _MD_SUSPEND_THREAD(thread)
252#define _MD_RESUME_THREAD(thread)
253#define _MD_CLEAN_THREAD(_thread)
254
255#if !defined(S_ISSOCK) && defined(S_IFSOCK)
256#define S_ISSOCK(mode) ((mode&0xF000) == 0xC000)
257#endif
258#if !defined(S_ISLNK) && defined(S_IFLNK)
259#define S_ISLNK(mode) ((mode&0xA000) == 0xC000)
260#endif
261
262#include <sys/time.h>
263#include <sys/types.h>
264#include <sys/select.h>
265extern int _select(int nfds, fd_set *readfds, fd_set *writefds,
266 fd_set *execptfds, struct timeval *timeout);
267#define _MD_SELECT(nfds,r,w,e,tv) _select(nfds,r,w,e,tv)
268#define _MD_POLL _poll
269
270#endif /* nspr_reliantunix_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