nsprpub/pr/include/md/_nto.h

branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
equal deleted inserted replaced
-1:000000000000 0:20f50bcaf670
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef nspr_nto_defs_h___
7 #define nspr_nto_defs_h___
8
9 /*
10 ** Internal configuration macros
11 */
12 #define PR_LINKER_ARCH "nto"
13 #define _PR_SI_SYSNAME "NTO"
14 #define _PR_SI_ARCHITECTURE "x86"
15 #define PR_DLL_SUFFIX ".so"
16
17 #define _PR_VMBASE 0x30000000
18 #define _PR_STACK_VMBASE 0x50000000
19 #define _MD_DEFAULT_STACK_SIZE 65536L
20 #define _MD_MINIMUM_STACK_SIZE 131072L
21 #define _MD_MMAP_FLAGS MAP_PRIVATE
22
23 #ifndef HAVE_WEAK_IO_SYMBOLS
24 #define HAVE_WEAK_IO_SYMBOLS
25 #endif
26
27 #undef _PR_POLL_AVAILABLE
28 #undef _PR_USE_POLL
29 #define _PR_HAVE_SOCKADDR_LEN
30 #undef HAVE_BSD_FLOCK
31 #define HAVE_FCNTL_FILE_LOCKING
32 #define _PR_NO_LARGE_FILES
33 #define _PR_STAT_HAS_ONLY_ST_ATIME
34 #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY
35 #define _PR_HAVE_POSIX_SEMAPHORES
36
37 #undef FD_SETSIZE
38 #define FD_SETSIZE 4096
39 #include <sys/time.h>
40 #include <sys/types.h>
41 #include <sys/select.h>
42
43 #undef HAVE_STACK_GROWING_UP
44 #define HAVE_DLL
45 #define USE_DLFCN
46 #define NEED_STRFTIME_LOCK
47 #define NEED_TIME_R
48 #define _PR_NEED_STRCASECMP
49
50 #ifndef HAVE_STRERROR
51 #define HAVE_STRERROR
52 #endif
53
54 #define USE_SETJMP
55
56 #include <setjmp.h>
57
58 #define _SETJMP setjmp
59 #define _LONGJMP longjmp
60 #define _PR_CONTEXT_TYPE jmp_buf
61 #define _PR_NUM_GCREGS _JBLEN
62 #define _MD_GET_SP(_t) (_t)->md.context[7]
63
64 #define CONTEXT(_th) ((_th)->md.context)
65
66
67 /*
68 ** Initialize the thread context preparing it to execute _main.
69 */
70 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
71 { \
72 *status = PR_TRUE; \
73 if(_SETJMP(CONTEXT(_thread))) (*_main)(); \
74 _MD_GET_SP(_thread) = (int) ((_sp) - 128); \
75 }
76
77 #define _MD_SWITCH_CONTEXT(_thread) \
78 if (!_SETJMP(CONTEXT(_thread))) { \
79 (_thread)->md.errcode = errno; \
80 _PR_Schedule(); \
81 }
82
83 /*
84 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
85 */
86 #define _MD_RESTORE_CONTEXT(_thread) \
87 { \
88 errno = (_thread)->md.errcode; \
89 _MD_SET_CURRENT_THREAD(_thread); \
90 _LONGJMP(CONTEXT(_thread), 1); \
91 }
92
93 /*
94 ** Machine-dependent (MD) data structures.
95 */
96 struct _MDThread {
97 _PR_CONTEXT_TYPE context;
98 int id;
99 int errcode;
100 };
101
102 struct _MDThreadStack {
103 PRInt8 notused;
104 };
105
106 struct _MDLock {
107 PRInt8 notused;
108 };
109
110 struct _MDSemaphore {
111 PRInt8 notused;
112 };
113
114 struct _MDCVar {
115 PRInt8 notused;
116 };
117
118 struct _MDSegment {
119 PRInt8 notused;
120 };
121
122 /*
123 ** md-specific cpu structure field
124 */
125 #define _PR_MD_MAX_OSFD FD_SETSIZE
126
127 struct _MDCPU_Unix {
128 PRCList ioQ;
129 PRUint32 ioq_timeout;
130 PRInt32 ioq_max_osfd;
131 PRInt32 ioq_osfd_cnt;
132 #ifndef _PR_USE_POLL
133 fd_set fd_read_set, fd_write_set, fd_exception_set;
134 PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD], fd_exception_cnt[_PR_MD_MAX_OSFD];
135 #else
136 struct pollfd *ioq_pollfds;
137 int ioq_pollfds_size;
138 #endif
139 };
140
141 #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
142 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
143 #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
144 #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
145 #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
146 #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
147 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
148 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
149 #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
150 #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
151 #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
152 #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
153 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
154
155 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
156
157 struct _MDCPU {
158 struct _MDCPU_Unix md_unix;
159 };
160
161 #define _MD_INIT_LOCKS()
162 #define _MD_NEW_LOCK(lock) PR_SUCCESS
163 #define _MD_FREE_LOCK(lock)
164 #define _MD_LOCK(lock)
165 #define _MD_UNLOCK(lock)
166 #define _MD_INIT_IO()
167 #define _MD_IOQ_LOCK()
168 #define _MD_IOQ_UNLOCK()
169
170 #define _MD_INTERVAL_USE_GTOD
171 #define _MD_EARLY_INIT _MD_EarlyInit
172 #define _MD_FINAL_INIT _PR_UnixInit
173 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
174 #define _MD_INIT_THREAD _MD_InitializeThread
175 #define _MD_EXIT_THREAD(thread)
176 #define _MD_SUSPEND_THREAD(thread)
177 #define _MD_RESUME_THREAD(thread)
178 #define _MD_CLEAN_THREAD(_thread)
179
180 /*
181 ** We wrapped the select() call. _MD_SELECT refers to the built-in,
182 ** unwrapped version.
183 */
184 #define _MD_SELECT select
185
186 #define SA_RESTART 0
187
188 #endif /* nspr_nto_defs_h___ */

mercurial