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_win16_defs_h___
|
---|
39 | #define nspr_win16_defs_h___
|
---|
40 |
|
---|
41 | #include <windows.h>
|
---|
42 | #include <winsock.h>
|
---|
43 | #include <errno.h>
|
---|
44 | #include <direct.h>
|
---|
45 |
|
---|
46 | #include "nspr.h"
|
---|
47 | /* $$ fix this */
|
---|
48 | #define Remind(x)
|
---|
49 |
|
---|
50 | /*
|
---|
51 | * Internal configuration macros
|
---|
52 | */
|
---|
53 |
|
---|
54 | #define PR_LINKER_ARCH "win16"
|
---|
55 | #define _PR_SI_SYSNAME "WIN16"
|
---|
56 | #define _PR_SI_ARCHITECTURE "x86" /* XXXMB hardcode for now */
|
---|
57 |
|
---|
58 | #define HAVE_DLL
|
---|
59 | #define _PR_NO_PREEMPT
|
---|
60 | #define _PR_LOCAL_THREADS_ONLY
|
---|
61 | #undef _PR_GLOBAL_THREADS_ONLY
|
---|
62 | #undef HAVE_THREAD_AFFINITY
|
---|
63 | #define _PR_HAVE_ATOMIC_OPS
|
---|
64 |
|
---|
65 | /* --- Common User-Thread/Native-Thread Definitions --------------------- */
|
---|
66 |
|
---|
67 | extern struct PRLock *_pr_schedLock;
|
---|
68 | extern char * _pr_top_of_task_stack;
|
---|
69 |
|
---|
70 |
|
---|
71 | /* --- Typedefs --- */
|
---|
72 |
|
---|
73 | #define PR_NUM_GCREGS 9
|
---|
74 | typedef PRInt32 PR_CONTEXT_TYPE[PR_NUM_GCREGS];
|
---|
75 |
|
---|
76 | #define _MD_MAGIC_THREAD 0x22222222
|
---|
77 | #define _MD_MAGIC_THREADSTACK 0x33333333
|
---|
78 | #define _MD_MAGIC_SEGMENT 0x44444444
|
---|
79 | #define _MD_MAGIC_DIR 0x55555555
|
---|
80 | #define _MD_MAGIC_CV 0x66666666
|
---|
81 |
|
---|
82 |
|
---|
83 | typedef struct _PRWin16PollDesc
|
---|
84 | {
|
---|
85 | PRInt32 osfd;
|
---|
86 | PRInt16 in_flags;
|
---|
87 | PRInt16 out_flags;
|
---|
88 | } _PRWin16PollDesc;
|
---|
89 |
|
---|
90 | typedef struct PRPollQueue
|
---|
91 | {
|
---|
92 | PRCList links; /* for linking PRPollQueue's together */
|
---|
93 | _PRWin16PollDesc *pds; /* array of poll descriptors */
|
---|
94 | PRUintn npds; /* length of the array */
|
---|
95 | PRPackedBool on_ioq; /* is this on the async i/o work q? */
|
---|
96 | PRIntervalTime timeout; /* timeout, in ticks */
|
---|
97 | struct PRThread *thr;
|
---|
98 | } PRPollQueue;
|
---|
99 |
|
---|
100 | #define _PR_POLLQUEUE_PTR(_qp) \
|
---|
101 | ((PRPollQueue *) ((char*) (_qp) - offsetof(PRPollQueue,links)))
|
---|
102 |
|
---|
103 | NSPR_API(PRInt32) _PR_WaitForFD(PRInt32 osfd, PRUintn how,
|
---|
104 | PRIntervalTime timeout);
|
---|
105 | NSPR_API(void) _PR_Unblock_IO_Wait(struct PRThread *thr);
|
---|
106 |
|
---|
107 | #define _PR_MD_MAX_OSFD FD_SETSIZE
|
---|
108 | #define _PR_IOQ(_cpu) ((_cpu)->md.ioQ)
|
---|
109 | #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
|
---|
110 | #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.fd_read_set)
|
---|
111 | #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.fd_read_cnt)
|
---|
112 | #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.fd_write_set)
|
---|
113 | #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.fd_write_cnt)
|
---|
114 | #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.fd_exception_set)
|
---|
115 | #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.fd_exception_cnt)
|
---|
116 | #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.ioq_timeout)
|
---|
117 | #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.ioq_max_osfd)
|
---|
118 |
|
---|
119 | struct _MDCPU {
|
---|
120 | PRCList ioQ;
|
---|
121 | fd_set fd_read_set, fd_write_set, fd_exception_set;
|
---|
122 | PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
|
---|
123 | fd_exception_cnt[_PR_MD_MAX_OSFD];
|
---|
124 | PRUint32 ioq_timeout;
|
---|
125 | PRInt32 ioq_max_osfd;
|
---|
126 | };
|
---|
127 |
|
---|
128 | struct _MDThread {
|
---|
129 | /* The overlapped structure must be first! */
|
---|
130 | HANDLE blocked_sema; /* Threads block on this when waiting
|
---|
131 | * for IO or CondVar.
|
---|
132 | */
|
---|
133 | PRInt32 errcode; /* preserved errno for this thread */
|
---|
134 | CATCHBUF context; /* thread context for Throw() */
|
---|
135 | void *SP; /* Stack pointer, used only by GarbColl */
|
---|
136 | int threadNumber; /* instrumentation: order of creation */
|
---|
137 | _PRWin16PollDesc thr_pd; /* poll descriptor for i/o */
|
---|
138 | PRPollQueue thr_pq; /* i/o parameters */
|
---|
139 | void *exceptionContext; /* mfc exception context */
|
---|
140 | char guardBand[24]; /* don't overwrite this */
|
---|
141 | PRUint32 magic; /* self identifier, for debug */
|
---|
142 | };
|
---|
143 |
|
---|
144 | struct _MDThreadStack {
|
---|
145 | PRUint32 magic; /* for debugging */
|
---|
146 | PRIntn cxByteCount; /* number of stack bytes to move */
|
---|
147 | char * stackTop; /* high address on stack */
|
---|
148 | };
|
---|
149 |
|
---|
150 | struct _MDSegment {
|
---|
151 | PRUint32 magic; /* for debugging */
|
---|
152 | };
|
---|
153 |
|
---|
154 |
|
---|
155 | struct _MDLock {
|
---|
156 | PRUint32 magic; /* for debugging */
|
---|
157 | PRUint32 mutex;
|
---|
158 | };
|
---|
159 |
|
---|
160 | struct _MDDir {
|
---|
161 | PRUint32 magic; /* for debugging */
|
---|
162 | struct dirent *dir;
|
---|
163 | };
|
---|
164 |
|
---|
165 | struct _MDCVar {
|
---|
166 | PRUint32 magic;
|
---|
167 | };
|
---|
168 |
|
---|
169 | struct _MDSemaphore {
|
---|
170 | PRInt32 unused;
|
---|
171 | };
|
---|
172 |
|
---|
173 | struct _MDFileDesc {
|
---|
174 | PRInt32 osfd;
|
---|
175 | };
|
---|
176 |
|
---|
177 | struct _MDProcess {
|
---|
178 | HANDLE handle;
|
---|
179 | DWORD id;
|
---|
180 | };
|
---|
181 |
|
---|
182 | /*
|
---|
183 | ** Microsoft 'struct _stat'
|
---|
184 | ** ... taken directly from msvc 1.52c's header file sys/stat.h
|
---|
185 | ** see PR_Stat() implemented in w16io.c
|
---|
186 | ** See BugSplat: 98516
|
---|
187 | */
|
---|
188 | #pragma pack(push)
|
---|
189 | #pragma pack(2)
|
---|
190 |
|
---|
191 | typedef unsigned short _ino_t;
|
---|
192 | typedef short _dev_t;
|
---|
193 | typedef long _off_t;
|
---|
194 |
|
---|
195 | typedef struct _MDMSStat {
|
---|
196 | _dev_t st_dev;
|
---|
197 | _ino_t st_ino;
|
---|
198 | unsigned short st_mode;
|
---|
199 | short st_nlink;
|
---|
200 | short st_uid;
|
---|
201 | short st_gid;
|
---|
202 | _dev_t st_rdev;
|
---|
203 | _off_t st_size;
|
---|
204 | time_t st_atime;
|
---|
205 | time_t st_mtime;
|
---|
206 | time_t st_ctime;
|
---|
207 | } _MDMSStat;
|
---|
208 | #pragma pack(pop)
|
---|
209 |
|
---|
210 | /* --- Errors --- */
|
---|
211 | /* These are NSPR generated error codes which need to be unique from
|
---|
212 | * OS error codes.
|
---|
213 | */
|
---|
214 | #define _MD_UNIQUEBASE 50000
|
---|
215 | #define _MD_EINTERRUPTED _MD_UNIQUEBASE + 1
|
---|
216 | #define _MD_ETIMEDOUT _MD_UNIQUEBASE + 2
|
---|
217 | #define _MD_EIO _MD_UNIQUEBASE + 3
|
---|
218 |
|
---|
219 | struct PRProcess;
|
---|
220 | struct PRProcessAttr;
|
---|
221 |
|
---|
222 | /* --- Create a new process --- */
|
---|
223 | #define _MD_CREATE_PROCESS _PR_CreateWindowsProcess
|
---|
224 | extern struct PRProcess * _PR_CreateWindowsProcess(
|
---|
225 | const char *path,
|
---|
226 | char *const *argv,
|
---|
227 | char *const *envp,
|
---|
228 | const struct PRProcessAttr *attr
|
---|
229 | );
|
---|
230 |
|
---|
231 | #define _MD_DETACH_PROCESS _PR_DetachWindowsProcess
|
---|
232 | extern PRStatus _PR_DetachWindowsProcess(struct PRProcess *process);
|
---|
233 |
|
---|
234 | /* --- Wait for a child process to terminate --- */
|
---|
235 | #define _MD_WAIT_PROCESS _PR_WaitWindowsProcess
|
---|
236 | extern PRStatus _PR_WaitWindowsProcess(struct PRProcess *process,
|
---|
237 | PRInt32 *exitCode);
|
---|
238 |
|
---|
239 | #define _MD_KILL_PROCESS _PR_KillWindowsProcess
|
---|
240 | extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process);
|
---|
241 |
|
---|
242 |
|
---|
243 | /* --- Misc stuff --- */
|
---|
244 |
|
---|
245 | #define MD_ASSERTINT( x ) PR_ASSERT( (x) < 65535 )
|
---|
246 |
|
---|
247 | /* --- IO stuff --- */
|
---|
248 | #define MAX_PATH 256
|
---|
249 | #define _MD_ERRNO() errno
|
---|
250 | #define GetLastError() errno
|
---|
251 |
|
---|
252 | #define _MD_GET_FILE_ERROR() errno
|
---|
253 | #define _MD_SET_FILE_ERROR(_err) errno = (_err)
|
---|
254 |
|
---|
255 | #define _MD_OPEN _PR_MD_OPEN
|
---|
256 | #define _MD_READ _PR_MD_READ
|
---|
257 | #define _MD_WRITE _PR_MD_WRITE
|
---|
258 | #define _MD_WRITEV _PR_MD_WRITEV
|
---|
259 | #define _MD_LSEEK _PR_MD_LSEEK
|
---|
260 | #define _MD_LSEEK64 _PR_MD_LSEEK64
|
---|
261 | #define _MD_CLOSE_FILE _PR_MD_CLOSE_FILE
|
---|
262 | #define _MD_GETFILEINFO _PR_MD_GETFILEINFO
|
---|
263 | #define _MD_GETOPENFILEINFO _PR_MD_GETOPENFILEINFO
|
---|
264 | #define _MD_STAT _PR_MD_STAT
|
---|
265 | #define _MD_RENAME _PR_MD_RENAME
|
---|
266 | #define _MD_ACCESS _PR_MD_ACCESS
|
---|
267 | #define _MD_DELETE _PR_MD_DELETE
|
---|
268 | #define _MD_MKDIR _PR_MD_MKDIR
|
---|
269 | #define _MD_RMDIR _PR_MD_RMDIR
|
---|
270 | #define _MD_LOCKFILE _PR_MD_LOCKFILE
|
---|
271 | #define _MD_TLOCKFILE _PR_MD_TLOCKFILE
|
---|
272 | #define _MD_UNLOCKFILE _PR_MD_UNLOCKFILE
|
---|
273 |
|
---|
274 |
|
---|
275 | /* --- Socket IO stuff --- */
|
---|
276 | #define _MD_EACCES WSAEACCES
|
---|
277 | #define _MD_EADDRINUSE WSAEADDRINUSE
|
---|
278 | #define _MD_EADDRNOTAVAIL WSAEADDRNOTAVAIL
|
---|
279 | #define _MD_EAFNOSUPPORT WSAEAFNOSUPPORT
|
---|
280 | #define _MD_EAGAIN WSAEWOULDBLOCK
|
---|
281 | #define _MD_EALREADY WSAEALREADY
|
---|
282 | #define _MD_EBADF WSAEBADF
|
---|
283 | #define _MD_ECONNREFUSED WSAECONNREFUSED
|
---|
284 | #define _MD_ECONNRESET WSAECONNRESET
|
---|
285 | #define _MD_EFAULT WSAEFAULT
|
---|
286 | #define _MD_EINPROGRESS WSAEINPROGRESS
|
---|
287 | #define _MD_EINTR WSAEINTR
|
---|
288 | #define _MD_EINVAL EINVAL
|
---|
289 | #define _MD_EISCONN WSAEISCONN
|
---|
290 | #define _MD_ENETUNREACH WSAENETUNREACH
|
---|
291 | #define _MD_ENOENT ENOENT
|
---|
292 | #define _MD_ENOTCONN WSAENOTCONN
|
---|
293 | #define _MD_ENOTSOCK WSAENOTSOCK
|
---|
294 | #define _MD_EOPNOTSUPP WSAEOPNOTSUPP
|
---|
295 | #define _MD_EWOULDBLOCK WSAEWOULDBLOCK
|
---|
296 | #define _MD_GET_SOCKET_ERROR() WSAGetLastError()
|
---|
297 | #define _MD_SET_SOCKET_ERROR(_err) WSASetLastError(_err)
|
---|
298 |
|
---|
299 | #define _MD_INIT_FILEDESC(fd)
|
---|
300 | #define _MD_MAKE_NONBLOCK _PR_MD_MAKE_NONBLOCK
|
---|
301 | #define _MD_SHUTDOWN _PR_MD_SHUTDOWN
|
---|
302 | #define _MD_LISTEN _PR_MD_LISTEN
|
---|
303 | #define _MD_CLOSE_SOCKET _PR_MD_CLOSE_SOCKET
|
---|
304 | #define _MD_SENDTO _PR_MD_SENDTO
|
---|
305 | #define _MD_RECVFROM _PR_MD_RECVFROM
|
---|
306 | #define _MD_SOCKETPAIR(s, type, proto, sv) -1
|
---|
307 | #define _MD_GETSOCKNAME _PR_MD_GETSOCKNAME
|
---|
308 | #define _MD_GETPEERNAME _PR_MD_GETPEERNAME
|
---|
309 | #define _MD_GETSOCKOPT _PR_MD_GETSOCKOPT
|
---|
310 | #define _MD_SETSOCKOPT _PR_MD_SETSOCKOPT
|
---|
311 | #define _MD_SELECT select
|
---|
312 | #define _MD_FSYNC _PR_MD_FSYNC
|
---|
313 | #define _MD_SOCKETAVAILABLE _PR_MD_SOCKETAVAILABLE
|
---|
314 |
|
---|
315 | #define _MD_INIT_ATOMIC()
|
---|
316 | #define _MD_ATOMIC_INCREMENT(x) (*x++)
|
---|
317 | #define _MD_ATOMIC_ADD(ptr, val) ((*x) += val)
|
---|
318 | #define _MD_ATOMIC_DECREMENT(x) (*x--)
|
---|
319 | #define _MD_ATOMIC_SET(x,y) (*x, y)
|
---|
320 |
|
---|
321 | #define _MD_INIT_IO _PR_MD_INIT_IO
|
---|
322 |
|
---|
323 | /* win95 doesn't have async IO */
|
---|
324 | #define _MD_SOCKET _PR_MD_SOCKET
|
---|
325 | #define _MD_CONNECT _PR_MD_CONNECT
|
---|
326 | #define _MD_ACCEPT _PR_MD_ACCEPT
|
---|
327 | #define _MD_BIND _PR_MD_BIND
|
---|
328 | #define _MD_RECV _PR_MD_RECV
|
---|
329 | #define _MD_SEND _PR_MD_SEND
|
---|
330 |
|
---|
331 | #define _MD_CHECK_FOR_EXIT()
|
---|
332 |
|
---|
333 | /* --- Scheduler stuff --- */
|
---|
334 | #define _MD_PAUSE_CPU _PR_MD_PAUSE_CPU
|
---|
335 |
|
---|
336 | /* --- DIR stuff --- */
|
---|
337 | #define PR_DIRECTORY_SEPARATOR '\\'
|
---|
338 | #define PR_DIRECTORY_SEPARATOR_STR "\\"
|
---|
339 | #define PR_PATH_SEPARATOR ';'
|
---|
340 | #define PR_PATH_SEPARATOR_STR ";"
|
---|
341 | #define _MD_OPEN_DIR _PR_MD_OPEN_DIR
|
---|
342 | #define _MD_CLOSE_DIR _PR_MD_CLOSE_DIR
|
---|
343 | #define _MD_READ_DIR _PR_MD_READ_DIR
|
---|
344 |
|
---|
345 | /* --- Segment stuff --- */
|
---|
346 | #define _MD_INIT_SEGS()
|
---|
347 | #define _MD_ALLOC_SEGMENT _MD_AllocSegment
|
---|
348 | #define _MD_FREE_SEGMENT _MD_FreeSegment
|
---|
349 |
|
---|
350 | /* --- Environment Stuff --- */
|
---|
351 | #define _MD_GET_ENV _PR_MD_GET_ENV
|
---|
352 | #define _MD_PUT_ENV _PR_MD_PUT_ENV
|
---|
353 |
|
---|
354 | /* --- Threading Stuff --- */
|
---|
355 | #define _MD_DEFAULT_STACK_SIZE 32767L
|
---|
356 | #define _MD_INIT_THREAD _PR_MD_INIT_THREAD
|
---|
357 | #define _MD_CREATE_THREAD(t,f,p,sc,st,stsiz) (PR_SUCCESS)
|
---|
358 | #define _MD_YIELD _PR_MD_YIELD
|
---|
359 | #define _MD_SET_PRIORITY(t,p)
|
---|
360 | #define _MD_CLEAN_THREAD(t)
|
---|
361 | #define _MD_SETTHREADAFFINITYMASK _PR_MD_SETTHREADAFFINITYMASK
|
---|
362 | #define _MD_GETTHREADAFFINITYMASK _PR_MD_GETTHREADAFFINITYMASK
|
---|
363 | #define _MD_EXIT_THREAD
|
---|
364 | #define _MD_SUSPEND_THREAD _PR_MD_SUSPEND_THREAD
|
---|
365 | #define _MD_RESUME_THREAD _PR_MD_RESUME_THREAD
|
---|
366 | #define _MD_SUSPEND_CPU _PR_MD_SUSPEND_CPU
|
---|
367 | #define _MD_RESUME_CPU _PR_MD_RESUME_CPU
|
---|
368 | #define _MD_BEGIN_SUSPEND_ALL()
|
---|
369 | #define _MD_BEGIN_RESUME_ALL()
|
---|
370 | #define _MD_END_SUSPEND_ALL()
|
---|
371 | #define _MD_END_RESUME_ALL()
|
---|
372 |
|
---|
373 | /* --- Lock stuff --- */
|
---|
374 | /*
|
---|
375 | ** Win16 does not need MD locks.
|
---|
376 | */
|
---|
377 | #define _PR_LOCK _MD_LOCK
|
---|
378 | #define _PR_UNLOCK _MD_UNLOCK
|
---|
379 |
|
---|
380 | #define _MD_NEW_LOCK(l) (PR_SUCCESS)
|
---|
381 | #define _MD_FREE_LOCK(l)
|
---|
382 | #define _MD_LOCK(l)
|
---|
383 | #define _MD_TEST_AND_LOCK(l) (-1)
|
---|
384 | #define _MD_UNLOCK(l)
|
---|
385 |
|
---|
386 | /* --- lock and cv waiting --- */
|
---|
387 | #define _MD_WAIT _PR_MD_WAIT
|
---|
388 | #define _MD_WAKEUP_WAITER(a)
|
---|
389 | #define _MD_WAKEUP_CPUS _PR_MD_WAKEUP_CPUS
|
---|
390 |
|
---|
391 | /* --- CVar ------------------- */
|
---|
392 | #define _MD_WAIT_CV _PR_MD_WAIT_CV
|
---|
393 | #define _MD_NEW_CV _PR_MD_NEW_CV
|
---|
394 | #define _MD_FREE_CV _PR_MD_FREE_CV
|
---|
395 | #define _MD_NOTIFY_CV _PR_MD_NOTIFY_CV
|
---|
396 | #define _MD_NOTIFYALL_CV _PR_MD_NOTIFYALL_CV
|
---|
397 |
|
---|
398 | /* XXXMB- the IOQ stuff is certainly not working correctly yet. */
|
---|
399 | #define _MD_IOQ_LOCK()
|
---|
400 | #define _MD_IOQ_UNLOCK()
|
---|
401 |
|
---|
402 |
|
---|
403 | /* --- Initialization stuff --- */
|
---|
404 | NSPR_API(void) _MD_INIT_RUNNING_CPU(struct _PRCPU *cpu );
|
---|
405 | #define _MD_START_INTERRUPTS()
|
---|
406 | #define _MD_STOP_INTERRUPTS()
|
---|
407 | #define _MD_DISABLE_CLOCK_INTERRUPTS()
|
---|
408 | #define _MD_ENABLE_CLOCK_INTERRUPTS()
|
---|
409 | #define _MD_BLOCK_CLOCK_INTERRUPTS()
|
---|
410 | #define _MD_UNBLOCK_CLOCK_INTERRUPTS()
|
---|
411 | #define _MD_EARLY_INIT _PR_MD_EARLY_INIT
|
---|
412 | #define _MD_FINAL_INIT _PR_MD_FINAL_INIT
|
---|
413 | #define _MD_INIT_CPUS()
|
---|
414 |
|
---|
415 | /* --- User Threading stuff --- */
|
---|
416 | #define _MD_EXIT
|
---|
417 |
|
---|
418 | #define _MD_CLEANUP_BEFORE_EXIT _PR_MD_CLEANUP_BEFORE_EXIT
|
---|
419 |
|
---|
420 | /* --- Intervals --- */
|
---|
421 | #define _MD_INTERVAL_INIT _PR_MD_INTERVAL_INIT
|
---|
422 | #define _MD_GET_INTERVAL _PR_MD_GET_INTERVAL
|
---|
423 | #define _MD_INTERVAL_PER_SEC _PR_MD_INTERVAL_PER_SEC
|
---|
424 | #define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000)
|
---|
425 | #define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000)
|
---|
426 |
|
---|
427 | /* --- Scheduler stuff --- */
|
---|
428 | #define LOCK_SCHEDULER() 0
|
---|
429 | #define UNLOCK_SCHEDULER() 0
|
---|
430 | #define _PR_LockSched() 0
|
---|
431 | #define _PR_UnlockSched() 0
|
---|
432 |
|
---|
433 | /* --- Initialization stuff --- */
|
---|
434 | #define _MD_INIT_LOCKS()
|
---|
435 |
|
---|
436 | /* --- Stack stuff --- */
|
---|
437 | #define _MD_INIT_STACK _PR_MD_INIT_STACK
|
---|
438 | #define _MD_CLEAR_STACK(stack)
|
---|
439 |
|
---|
440 | /*
|
---|
441 | ** Watcom needs to see this to make the linker work.
|
---|
442 | **
|
---|
443 | */
|
---|
444 | NSPR_API(void) _PR_NativeDestroyThread(PRThread *thread);
|
---|
445 | NSPR_API(void) _PR_UserDestroyThread(PRThread *thread);
|
---|
446 |
|
---|
447 |
|
---|
448 | /*
|
---|
449 | ** If thread emulation is used, then setjmp/longjmp stores the register
|
---|
450 | ** state of each thread.
|
---|
451 | **
|
---|
452 | ** CatchBuf layout:
|
---|
453 | ** context[0] - IP
|
---|
454 | ** context[1] - CS
|
---|
455 | ** context[2] - SP
|
---|
456 | ** context[3] - BP
|
---|
457 | ** context[4] - SI
|
---|
458 | ** context[5] - DI
|
---|
459 | ** context[6] - DS
|
---|
460 | ** context[7] - ?? (maybe flags)
|
---|
461 | ** context[8] - SS
|
---|
462 | */
|
---|
463 | #define PR_CONTEXT_TYPE CATCHBUF
|
---|
464 | #define PR_NUM_GCREGS 9
|
---|
465 |
|
---|
466 | #define _MD_GET_SP(thread) ((thread)->md.SP)
|
---|
467 | #define CONTEXT(_t) ((_t)->md.context)
|
---|
468 |
|
---|
469 | /*
|
---|
470 | ** Initialize a thread context to run "e(o,a)" when started
|
---|
471 | */
|
---|
472 | #define _MD_INIT_CONTEXT(_t, sp, epa, stat ) \
|
---|
473 | { \
|
---|
474 | *(stat) = PR_TRUE; \
|
---|
475 | Catch((_t)->md.context ); \
|
---|
476 | (_t)->md.context[0] = OFFSETOF(epa); \
|
---|
477 | (_t)->md.context[1] = SELECTOROF(epa); \
|
---|
478 | (_t)->md.context[2] = OFFSETOF(_pr_top_of_task_stack - 64); \
|
---|
479 | (_t)->md.context[3] = 0; \
|
---|
480 | }
|
---|
481 |
|
---|
482 | #define _MD_SWITCH_CONTEXT(_t) \
|
---|
483 | if (!Catch((_t)->md.context)) { \
|
---|
484 | int garbCollPlaceHolder; \
|
---|
485 | (_t)->md.errcode = errno; \
|
---|
486 | (_t)->md.SP = &garbCollPlaceHolder; \
|
---|
487 | _PR_Schedule(); \
|
---|
488 | }
|
---|
489 |
|
---|
490 | #define _MD_SAVE_CONTEXT(_t) \
|
---|
491 | { \
|
---|
492 | int garbCollPlaceHolder; \
|
---|
493 | Catch((_t)->md.context); \
|
---|
494 | (_t)->md.errcode = errno; \
|
---|
495 | (_t)->md.SP = &garbCollPlaceHolder; \
|
---|
496 | }
|
---|
497 |
|
---|
498 | /*
|
---|
499 | ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
|
---|
500 | */
|
---|
501 | #define _PR_MD_RESTORE_CONTEXT _MD_RESTORE_CONTEXT
|
---|
502 |
|
---|
503 | /*
|
---|
504 | * Memory-mapped files
|
---|
505 | */
|
---|
506 |
|
---|
507 | struct _MDFileMap {
|
---|
508 | PRInt8 unused;
|
---|
509 | };
|
---|
510 |
|
---|
511 | extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
|
---|
512 | #define _MD_CREATE_FILE_MAP _MD_CreateFileMap
|
---|
513 |
|
---|
514 | extern PRInt32 _MD_GetMemMapAlignment(void);
|
---|
515 | #define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment
|
---|
516 |
|
---|
517 | extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,
|
---|
518 | PRUint32 len);
|
---|
519 | #define _MD_MEM_MAP _MD_MemMap
|
---|
520 |
|
---|
521 | extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);
|
---|
522 | #define _MD_MEM_UNMAP _MD_MemUnmap
|
---|
523 |
|
---|
524 | extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
|
---|
525 | #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
|
---|
526 |
|
---|
527 |
|
---|
528 | /* --- Error mapping ----------------------------------- */
|
---|
529 | extern void _PR_MD_map_error( int err );
|
---|
530 |
|
---|
531 | #define _PR_MD_MAP_OPENDIR_ERROR _PR_MD_map_error
|
---|
532 | #define _PR_MD_MAP_CLOSEDIR_ERROR _PR_MD_map_error
|
---|
533 | #define _PR_MD_MAP_READDIR_ERROR _PR_MD_map_error
|
---|
534 | #define _PR_MD_MAP_DELETE_ERROR _PR_MD_map_error
|
---|
535 | #define _PR_MD_MAP_STAT_ERROR _PR_MD_map_error
|
---|
536 | #define _PR_MD_MAP_FSTAT_ERROR _PR_MD_map_error
|
---|
537 | #define _PR_MD_MAP_RENAME_ERROR _PR_MD_map_error
|
---|
538 | #define _PR_MD_MAP_ACCESS_ERROR _PR_MD_map_error
|
---|
539 | #define _PR_MD_MAP_MKDIR_ERROR _PR_MD_map_error
|
---|
540 | #define _PR_MD_MAP_RMDIR_ERROR _PR_MD_map_error
|
---|
541 | #define _PR_MD_MAP_READ_ERROR _PR_MD_map_error
|
---|
542 | #define _PR_MD_MAP_TRANSMITFILE_ERROR _PR_MD_map_error
|
---|
543 | #define _PR_MD_MAP_WRITE_ERROR _PR_MD_map_error
|
---|
544 | #define _PR_MD_MAP_LSEEK_ERROR _PR_MD_map_error
|
---|
545 | #define _PR_MD_MAP_FSYNC_ERROR _PR_MD_map_error
|
---|
546 | #define _PR_MD_MAP_CLOSE_ERROR _PR_MD_map_error
|
---|
547 | #define _PR_MD_MAP_SOCKET_ERROR _PR_MD_map_error
|
---|
548 | #define _PR_MD_MAP_RECV_ERROR _PR_MD_map_error
|
---|
549 | #define _PR_MD_MAP_RECVFROM_ERROR _PR_MD_map_error
|
---|
550 | #define _PR_MD_MAP_SEND_ERROR _PR_MD_map_error
|
---|
551 | #define _PR_MD_MAP_SENDTO_ERROR _PR_MD_map_error
|
---|
552 | #define _PR_MD_MAP_ACCEPT_ERROR _PR_MD_map_error
|
---|
553 | #define _PR_MD_MAP_ACCEPTEX_ERROR _PR_MD_map_error
|
---|
554 | #define _PR_MD_MAP_CONNECT_ERROR _PR_MD_map_error
|
---|
555 | #define _PR_MD_MAP_BIND_ERROR _PR_MD_map_error
|
---|
556 | #define _PR_MD_MAP_LISTEN_ERROR _PR_MD_map_error
|
---|
557 | #define _PR_MD_MAP_SHUTDOWN_ERROR _PR_MD_map_error
|
---|
558 | #define _PR_MD_MAP_GETSOCKNAME_ERROR _PR_MD_map_error
|
---|
559 | #define _PR_MD_MAP_GETPEERNAME_ERROR _PR_MD_map_error
|
---|
560 | #define _PR_MD_MAP_GETSOCKOPT_ERROR _PR_MD_map_error
|
---|
561 | #define _PR_MD_MAP_SETSOCKOPT_ERROR _PR_MD_map_error
|
---|
562 | #define _PR_MD_MAP_OPEN_ERROR _PR_MD_map_error
|
---|
563 | #define _PR_MD_MAP_GETHOSTNAME_ERROR _PR_MD_map_error
|
---|
564 | #define _PR_MD_MAP_SELECT_ERROR _PR_MD_map_error
|
---|
565 | #define _PR_MD_MAP_LOCKF_ERROR _PR_MD_map_error
|
---|
566 | #define _PR_MD_MAP_WSASTARTUP_ERROR _PR_MD_map_error
|
---|
567 |
|
---|
568 | #endif /* nspr_win16_defs_h___ */
|
---|