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
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/
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
15
* The Original Code is the Netscape Portable Runtime (NSPR).
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.
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.
36
* ***** END LICENSE BLOCK ***** */
40
* 5/18/96 Taken from nec.h -- chrisk@netscape.com
41
* 3/14/97 Modified for nspr20 -- chrisk@netscape.com
43
#ifndef nspr_reliantunix_defs_h___
44
#define nspr_reliantunix_defs_h___
47
* Internal configuration macros
50
#define PR_LINKER_ARCH "sinix"
51
#define _PR_SI_SYSNAME "SINIX"
52
#define _PR_SI_ARCHITECTURE "mips"
53
#define PR_DLL_SUFFIX ".so"
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
60
#undef HAVE_STACK_GROWING_UP
63
#define NEED_STRFTIME_LOCK
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
71
#define _PR_STAT_HAS_ST_ATIM
72
#define _PR_NO_LARGE_FILES
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 :-)
82
#define USE_SETCXT /* temporarily disabled... */
87
/* use non-syscall machine language replacement */
88
#define _GETCONTEXT getcxt
89
#define _SETCONTEXT setcxt
90
/* defined in os_ReliantUNIX.s */
91
extern int getcxt(ucontext_t *);
92
extern int setcxt(ucontext_t *);
94
#define _GETCONTEXT getcontext
95
#define _SETCONTEXT setcontext
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
102
#define CONTEXT(_thread) (&(_thread)->md.context)
104
#define _PR_IS_NATIVE_THREAD_SUPPORTED() 0
107
** Machine-dependent (MD) data structures.
110
_PR_CONTEXT_TYPE context;
115
struct _MDThreadStack {
123
struct _MDSemaphore {
136
* md-specific cpu structure field
138
#define _PR_MD_MAX_OSFD FD_SETSIZE
142
PRUint32 ioq_timeout;
143
PRInt32 ioq_max_osfd;
144
PRInt32 ioq_osfd_cnt;
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];
150
struct pollfd *ioq_pollfds;
151
int ioq_pollfds_size;
152
#endif /* _PR_USE_POLL */
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)
169
#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
172
struct _MDCPU_Unix md_unix;
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()
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"
190
#define _MD_INIT_CONTEXT(thread, _sp, _main, status) \
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; \
205
** Save current context as it is scheduled away
207
#define _MD_SWITCH_CONTEXT(_thread) \
209
if (!_GETCONTEXT(CONTEXT(_thread))) { \
210
_MD_SAVE_ERRNO(_thread); \
211
_MD_SET_LAST_THREAD(_thread); \
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
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
230
#define _MD_RESTORE_CONTEXT(_thread) \
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); \
240
#define _MD_SAVE_ERRNO(t) (t)->md.errcode = errno;
241
#define _MD_RESTORE_ERRNO(t) errno = (t)->md.errcode;
243
#define _MD_GET_INTERVAL _PR_UNIX_GetInterval
244
#define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond
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)
255
#if !defined(S_ISSOCK) && defined(S_IFSOCK)
256
#define S_ISSOCK(mode) ((mode&0xF000) == 0xC000)
258
#if !defined(S_ISLNK) && defined(S_IFLNK)
259
#define S_ISLNK(mode) ((mode&0xA000) == 0xC000)
262
#include <sys/time.h>
263
#include <sys/types.h>
264
#include <sys/select.h>
265
extern 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
270
#endif /* nspr_reliantunix_defs_h___ */