OLD | NEW |
| (Empty) |
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | |
2 /* | |
3 * The contents of this file are subject to the Mozilla Public | |
4 * License Version 1.1 (the "License"); you may not use this file | |
5 * except in compliance with the License. You may obtain a copy of | |
6 * the License at http://www.mozilla.org/MPL/ | |
7 * | |
8 * Software distributed under the License is distributed on an "AS | |
9 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | |
10 * implied. See the License for the specific language governing | |
11 * rights and limitations under the License. | |
12 * | |
13 * The Original Code is the Netscape Portable Runtime (NSPR). | |
14 * | |
15 * The Initial Developer of the Original Code is Netscape | |
16 * Communications Corporation. Portions created by Netscape are | |
17 * Copyright (C) 1998-2000 Netscape Communications Corporation. All | |
18 * Rights Reserved. | |
19 * | |
20 * Contributor(s): | |
21 * | |
22 * Alternatively, the contents of this file may be used under the | |
23 * terms of the GNU General Public License Version 2 or later (the | |
24 * "GPL"), in which case the provisions of the GPL are applicable | |
25 * instead of those above. If you wish to allow use of your | |
26 * version of this file only under the terms of the GPL and not to | |
27 * allow others to use your version of this file under the MPL, | |
28 * indicate your decision by deleting the provisions above and | |
29 * replace them with the notice and other provisions required by | |
30 * the GPL. If you do not delete the provisions above, a recipient | |
31 * may use your version of this file under either the MPL or the | |
32 * GPL. | |
33 */ | |
34 | |
35 #ifndef nspr_win95_defs_h___ | |
36 #define nspr_win95_defs_h___ | |
37 | |
38 #include "prio.h" | |
39 | |
40 #include <windows.h> | |
41 #include <winsock.h> | |
42 #include <errno.h> | |
43 | |
44 /* | |
45 * Internal configuration macros | |
46 */ | |
47 | |
48 #define PR_LINKER_ARCH "win32" | |
49 #define _PR_SI_SYSNAME "WIN95" | |
50 #define _PR_SI_ARCHITECTURE "x86" /* XXXMB hardcode for now */ | |
51 | |
52 #define HAVE_DLL | |
53 #undef HAVE_THREAD_AFFINITY | |
54 #define _PR_HAVE_GETADDRINFO | |
55 #define _PR_INET6_PROBE | |
56 #ifndef _PR_INET6 | |
57 #define AF_INET6 23 | |
58 /* newer ws2tcpip.h provides these */ | |
59 #ifndef AI_CANONNAME | |
60 #define AI_CANONNAME 0x2 | |
61 struct addrinfo { | |
62 int ai_flags; | |
63 int ai_family; | |
64 int ai_socktype; | |
65 int ai_protocol; | |
66 size_t ai_addrlen; | |
67 char *ai_canonname; | |
68 struct sockaddr *ai_addr; | |
69 struct addrinfo *ai_next; | |
70 }; | |
71 #endif | |
72 #endif | |
73 #define _PR_HAVE_THREADSAFE_GETHOST | |
74 #define _PR_HAVE_ATOMIC_OPS | |
75 #define PR_HAVE_WIN32_NAMED_SHARED_MEMORY | |
76 | |
77 /* --- Common User-Thread/Native-Thread Definitions --------------------- */ | |
78 | |
79 /* --- Globals --- */ | |
80 extern struct PRLock *_pr_schedLock; | |
81 | |
82 /* --- Typedefs --- */ | |
83 typedef void (*FiberFunc)(void *); | |
84 | |
85 #define PR_NUM_GCREGS 8 | |
86 typedef PRInt32 PR_CONTEXT_TYPE[PR_NUM_GCREGS]; | |
87 #define GC_VMBASE 0x40000000 | |
88 #define GC_VMLIMIT 0x00FFFFFF | |
89 | |
90 #define _MD_MAGIC_THREAD 0x22222222 | |
91 #define _MD_MAGIC_THREADSTACK 0x33333333 | |
92 #define _MD_MAGIC_SEGMENT 0x44444444 | |
93 #define _MD_MAGIC_DIR 0x55555555 | |
94 #define _MD_MAGIC_CV 0x66666666 | |
95 | |
96 struct _MDCPU { | |
97 int unused; | |
98 }; | |
99 | |
100 struct _MDThread { | |
101 HANDLE blocked_sema; /* Threads block on this when waiting | |
102 * for IO or CondVar. | |
103 */ | |
104 PRBool inCVWaitQueue; /* PR_TRUE if the thread is in the | |
105 * wait queue of some cond var. | |
106 * PR_FALSE otherwise. */ | |
107 HANDLE handle; /* Win32 thread handle */ | |
108 PRUint32 id; | |
109 void *sp; /* only valid when suspended */ | |
110 PRUint32 magic; /* for debugging */ | |
111 PR_CONTEXT_TYPE gcContext; /* Thread context for GC */ | |
112 struct PRThread *prev, *next; /* used by the cvar wait queue to | |
113 * chain the PRThread structures | |
114 * together */ | |
115 void (*start)(void *); /* used by _PR_MD_CREATE_THREAD to | |
116 * pass its 'start' argument to | |
117 * pr_root. */ | |
118 }; | |
119 | |
120 struct _MDThreadStack { | |
121 PRUint32 magic; /* for debugging */ | |
122 }; | |
123 | |
124 struct _MDSegment { | |
125 PRUint32 magic; /* for debugging */ | |
126 }; | |
127 | |
128 #undef PROFILE_LOCKS | |
129 | |
130 struct _MDDir { | |
131 HANDLE d_hdl; | |
132 WIN32_FIND_DATA d_entry; | |
133 PRBool firstEntry; /* Is this the entry returned | |
134 * by FindFirstFile()? */ | |
135 PRUint32 magic; /* for debugging */ | |
136 }; | |
137 | |
138 #ifdef MOZ_UNICODE | |
139 struct _MDDirUTF16 { | |
140 HANDLE d_hdl; | |
141 WIN32_FIND_DATAW d_entry; | |
142 PRBool firstEntry; /* Is this the entry returned | |
143 * by FindFirstFileW()? */ | |
144 PRUint32 magic; /* for debugging */ | |
145 }; | |
146 #endif /* MOZ_UNICODE */ | |
147 | |
148 struct _MDCVar { | |
149 PRUint32 magic; | |
150 struct PRThread *waitHead, *waitTail; /* the wait queue: a doubly- | |
151 * linked list of threads | |
152 * waiting on this condition | |
153 * variable */ | |
154 PRIntn nwait; /* number of threads in the | |
155 * wait queue */ | |
156 }; | |
157 | |
158 #define _MD_CV_NOTIFIED_LENGTH 6 | |
159 typedef struct _MDNotified _MDNotified; | |
160 struct _MDNotified { | |
161 PRIntn length; /* # of used entries in this | |
162 * structure */ | |
163 struct { | |
164 struct _MDCVar *cv; /* the condition variable notified */ | |
165 PRIntn times; /* and the number of times notified */ | |
166 struct PRThread *notifyHead; /* list of threads to wake up */ | |
167 } cv[_MD_CV_NOTIFIED_LENGTH]; | |
168 _MDNotified *link; /* link to another of these, or NULL */ | |
169 }; | |
170 | |
171 struct _MDLock { | |
172 CRITICAL_SECTION mutex; /* this is recursive on NT */ | |
173 | |
174 /* | |
175 * When notifying cvars, there is no point in actually | |
176 * waking up the threads waiting on the cvars until we've | |
177 * released the lock. So, we temporarily record the cvars. | |
178 * When doing an unlock, we'll then wake up the waiting threads. | |
179 */ | |
180 struct _MDNotified notified; /* array of conditions notified */ | |
181 #ifdef PROFILE_LOCKS | |
182 PRInt32 hitcount; | |
183 PRInt32 misscount; | |
184 #endif | |
185 }; | |
186 | |
187 struct _MDSemaphore { | |
188 HANDLE sem; | |
189 }; | |
190 | |
191 struct _MDFileDesc { | |
192 PRInt32 osfd; /* The osfd can come from one of three spaces: | |
193 * - For stdin, stdout, and stderr, we are using | |
194 * the libc file handle (0, 1, 2), which is an int. | |
195 * - For files and pipes, we are using Win32 HANDLE, | |
196 * which is a void*. | |
197 * - For sockets, we are using Winsock SOCKET, which | |
198 * is a u_int. | |
199 */ | |
200 }; | |
201 | |
202 struct _MDProcess { | |
203 HANDLE handle; | |
204 DWORD id; | |
205 }; | |
206 | |
207 /* --- Misc stuff --- */ | |
208 #define _MD_GET_SP(thread) (thread)->md.gcContext[6] | |
209 | |
210 /* --- NT security stuff --- */ | |
211 | |
212 extern void _PR_NT_InitSids(void); | |
213 extern void _PR_NT_FreeSids(void); | |
214 extern PRStatus _PR_NT_MakeSecurityDescriptorACL( | |
215 PRIntn mode, | |
216 DWORD accessTable[], | |
217 PSECURITY_DESCRIPTOR *resultSD, | |
218 PACL *resultACL | |
219 ); | |
220 extern void _PR_NT_FreeSecurityDescriptorACL( | |
221 PSECURITY_DESCRIPTOR pSD, PACL pACL); | |
222 | |
223 /* --- IO stuff --- */ | |
224 | |
225 #define _MD_OPEN _PR_MD_OPEN | |
226 #define _MD_OPEN_FILE _PR_MD_OPEN_FILE | |
227 #define _MD_READ _PR_MD_READ | |
228 #define _MD_WRITE _PR_MD_WRITE | |
229 #define _MD_WRITEV _PR_MD_WRITEV | |
230 #define _MD_LSEEK _PR_MD_LSEEK | |
231 #define _MD_LSEEK64 _PR_MD_LSEEK64 | |
232 extern PRInt32 _MD_CloseFile(PRInt32 osfd); | |
233 #define _MD_CLOSE_FILE _MD_CloseFile | |
234 #define _MD_GETFILEINFO _PR_MD_GETFILEINFO | |
235 #define _MD_GETFILEINFO64 _PR_MD_GETFILEINFO64 | |
236 #define _MD_GETOPENFILEINFO _PR_MD_GETOPENFILEINFO | |
237 #define _MD_GETOPENFILEINFO64 _PR_MD_GETOPENFILEINFO64 | |
238 #define _MD_STAT _PR_MD_STAT | |
239 #define _MD_RENAME _PR_MD_RENAME | |
240 #define _MD_ACCESS _PR_MD_ACCESS | |
241 #define _MD_DELETE _PR_MD_DELETE | |
242 #define _MD_MKDIR _PR_MD_MKDIR | |
243 #define _MD_MAKE_DIR _PR_MD_MAKE_DIR | |
244 #define _MD_RMDIR _PR_MD_RMDIR | |
245 #define _MD_LOCKFILE _PR_MD_LOCKFILE | |
246 #define _MD_TLOCKFILE _PR_MD_TLOCKFILE | |
247 #define _MD_UNLOCKFILE _PR_MD_UNLOCKFILE | |
248 | |
249 #ifdef MOZ_UNICODE | |
250 /* --- UTF16 IO stuff --- */ | |
251 #define _MD_OPEN_FILE_UTF16 _PR_MD_OPEN_FILE_UTF16 | |
252 #define _MD_OPEN_DIR_UTF16 _PR_MD_OPEN_DIR_UTF16 | |
253 #define _MD_READ_DIR_UTF16 _PR_MD_READ_DIR_UTF16 | |
254 #define _MD_CLOSE_DIR_UTF16 _PR_MD_CLOSE_DIR_UTF16 | |
255 #define _MD_GETFILEINFO64_UTF16 _PR_MD_GETFILEINFO64_UTF16 | |
256 #endif /* MOZ_UNICODE */ | |
257 | |
258 /* --- Socket IO stuff --- */ | |
259 #define _MD_EACCES WSAEACCES | |
260 #define _MD_EADDRINUSE WSAEADDRINUSE | |
261 #define _MD_EADDRNOTAVAIL WSAEADDRNOTAVAIL | |
262 #define _MD_EAFNOSUPPORT WSAEAFNOSUPPORT | |
263 #define _MD_EAGAIN WSAEWOULDBLOCK | |
264 #define _MD_EALREADY WSAEALREADY | |
265 #define _MD_EBADF WSAEBADF | |
266 #define _MD_ECONNREFUSED WSAECONNREFUSED | |
267 #define _MD_ECONNRESET WSAECONNRESET | |
268 #define _MD_EFAULT WSAEFAULT | |
269 #define _MD_EINPROGRESS WSAEINPROGRESS | |
270 #define _MD_EINTR WSAEINTR | |
271 #define _MD_EINVAL EINVAL | |
272 #define _MD_EISCONN WSAEISCONN | |
273 #define _MD_ENETUNREACH WSAENETUNREACH | |
274 #define _MD_ENOENT ENOENT | |
275 #define _MD_ENOTCONN WSAENOTCONN | |
276 #define _MD_ENOTSOCK WSAENOTSOCK | |
277 #define _MD_EOPNOTSUPP WSAEOPNOTSUPP | |
278 #define _MD_EWOULDBLOCK WSAEWOULDBLOCK | |
279 #define _MD_GET_SOCKET_ERROR() WSAGetLastError() | |
280 #define _MD_SET_SOCKET_ERROR(_err) WSASetLastError(_err) | |
281 | |
282 #define _MD_INIT_FILEDESC(fd) | |
283 extern void _MD_MakeNonblock(PRFileDesc *f); | |
284 #define _MD_MAKE_NONBLOCK _MD_MakeNonblock | |
285 #define _MD_INIT_FD_INHERITABLE _PR_MD_INIT_FD_INHERITABLE | |
286 #define _MD_QUERY_FD_INHERITABLE _PR_MD_QUERY_FD_INHERITABLE | |
287 #define _MD_SHUTDOWN _PR_MD_SHUTDOWN | |
288 #define _MD_LISTEN _PR_MD_LISTEN | |
289 extern PRInt32 _MD_CloseSocket(PRInt32 osfd); | |
290 #define _MD_CLOSE_SOCKET _MD_CloseSocket | |
291 #define _MD_SENDTO _PR_MD_SENDTO | |
292 #define _MD_RECVFROM _PR_MD_RECVFROM | |
293 #define _MD_SOCKETPAIR(s, type, proto, sv) -1 | |
294 #define _MD_GETSOCKNAME _PR_MD_GETSOCKNAME | |
295 #define _MD_GETPEERNAME _PR_MD_GETPEERNAME | |
296 #define _MD_GETSOCKOPT _PR_MD_GETSOCKOPT | |
297 #define _MD_SETSOCKOPT _PR_MD_SETSOCKOPT | |
298 #define _MD_SET_FD_INHERITABLE _PR_MD_SET_FD_INHERITABLE | |
299 #define _MD_SELECT select | |
300 #define _MD_FSYNC _PR_MD_FSYNC | |
301 #define READ_FD 1 | |
302 #define WRITE_FD 2 | |
303 | |
304 #define _MD_INIT_ATOMIC() | |
305 #if defined(_M_IX86) || defined(_X86_) | |
306 #define _MD_ATOMIC_INCREMENT _PR_MD_ATOMIC_INCREMENT | |
307 #define _MD_ATOMIC_ADD _PR_MD_ATOMIC_ADD | |
308 #define _MD_ATOMIC_DECREMENT _PR_MD_ATOMIC_DECREMENT | |
309 #else /* non-x86 processors */ | |
310 #define _MD_ATOMIC_INCREMENT(x) InterlockedIncrement((PLONG)x) | |
311 #define _MD_ATOMIC_ADD(ptr,val) (InterlockedExchangeAdd((PLONG)ptr, (LONG)val
) + val) | |
312 #define _MD_ATOMIC_DECREMENT(x) InterlockedDecrement((PLONG)x) | |
313 #endif /* x86 */ | |
314 #define _MD_ATOMIC_SET(x,y) InterlockedExchange((PLONG)x, (LONG)y) | |
315 | |
316 #define _MD_INIT_IO _PR_MD_INIT_IO | |
317 | |
318 | |
319 /* win95 doesn't have async IO */ | |
320 #define _MD_SOCKET _PR_MD_SOCKET | |
321 extern PRInt32 _MD_SocketAvailable(PRFileDesc *fd); | |
322 #define _MD_SOCKETAVAILABLE _MD_SocketAvailable | |
323 #define _MD_PIPEAVAILABLE _PR_MD_PIPEAVAILABLE | |
324 #define _MD_CONNECT _PR_MD_CONNECT | |
325 extern PRInt32 _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen, | |
326 PRIntervalTime timeout); | |
327 #define _MD_ACCEPT _MD_Accept | |
328 #define _MD_BIND _PR_MD_BIND | |
329 #define _MD_RECV _PR_MD_RECV | |
330 #define _MD_SEND _PR_MD_SEND | |
331 #define _MD_PR_POLL _PR_MD_PR_POLL | |
332 | |
333 /* --- Scheduler stuff --- */ | |
334 // #define _MD_PAUSE_CPU _PR_MD_PAUSE_CPU | |
335 #define _MD_PAUSE_CPU | |
336 | |
337 /* --- DIR stuff --- */ | |
338 #define PR_DIRECTORY_SEPARATOR '\\' | |
339 #define PR_DIRECTORY_SEPARATOR_STR "\\" | |
340 #define PR_PATH_SEPARATOR ';' | |
341 #define PR_PATH_SEPARATOR_STR ";" | |
342 #define _MD_ERRNO() GetLastError() | |
343 #define _MD_OPEN_DIR _PR_MD_OPEN_DIR | |
344 #define _MD_CLOSE_DIR _PR_MD_CLOSE_DIR | |
345 #define _MD_READ_DIR _PR_MD_READ_DIR | |
346 | |
347 /* --- Segment stuff --- */ | |
348 #define _MD_INIT_SEGS() | |
349 #define _MD_ALLOC_SEGMENT(seg, size, vaddr) 0 | |
350 #define _MD_FREE_SEGMENT(seg) | |
351 | |
352 /* --- Environment Stuff --- */ | |
353 #define _MD_GET_ENV _PR_MD_GET_ENV | |
354 #define _MD_PUT_ENV _PR_MD_PUT_ENV | |
355 | |
356 /* --- Threading Stuff --- */ | |
357 #define _MD_DEFAULT_STACK_SIZE 0 | |
358 #define _MD_INIT_THREAD _PR_MD_INIT_THREAD | |
359 #define _MD_INIT_ATTACHED_THREAD _PR_MD_INIT_THREAD | |
360 #define _MD_CREATE_THREAD _PR_MD_CREATE_THREAD | |
361 #define _MD_YIELD _PR_MD_YIELD | |
362 #define _MD_SET_PRIORITY _PR_MD_SET_PRIORITY | |
363 #define _MD_CLEAN_THREAD _PR_MD_CLEAN_THREAD | |
364 #define _MD_SETTHREADAFFINITYMASK _PR_MD_SETTHREADAFFINITYMASK | |
365 #define _MD_GETTHREADAFFINITYMASK _PR_MD_GETTHREADAFFINITYMASK | |
366 #define _MD_EXIT_THREAD _PR_MD_EXIT_THREAD | |
367 #define _MD_EXIT _PR_MD_EXIT | |
368 #define _MD_SUSPEND_THREAD _PR_MD_SUSPEND_THREAD | |
369 #define _MD_RESUME_THREAD _PR_MD_RESUME_THREAD | |
370 #define _MD_SUSPEND_CPU _PR_MD_SUSPEND_CPU | |
371 #define _MD_RESUME_CPU _PR_MD_RESUME_CPU | |
372 #define _MD_BEGIN_SUSPEND_ALL() | |
373 #define _MD_BEGIN_RESUME_ALL() | |
374 #define _MD_END_SUSPEND_ALL() | |
375 #define _MD_END_RESUME_ALL() | |
376 | |
377 /* --- Lock stuff --- */ | |
378 #define _PR_LOCK _MD_LOCK | |
379 #define _PR_UNLOCK _MD_UNLOCK | |
380 | |
381 #define _MD_NEW_LOCK(lock) (InitializeCriticalSection(&((lock)->mutex
)),(lock)->notified.length=0,(lock)->notified.link=NULL,PR_SUCCESS) | |
382 #define _MD_FREE_LOCK(lock) DeleteCriticalSection(&((lock)->mutex)) | |
383 #define _MD_LOCK(lock) EnterCriticalSection(&((lock)->mutex)) | |
384 #define _MD_TEST_AND_LOCK(lock) (EnterCriticalSection(&((lock)->mutex)),0) | |
385 #define _MD_UNLOCK _PR_MD_UNLOCK | |
386 | |
387 /* --- lock and cv waiting --- */ | |
388 #define _MD_WAIT _PR_MD_WAIT | |
389 #define _MD_WAKEUP_WAITER _PR_MD_WAKEUP_WAITER | |
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 // extern struct _MDLock _pr_ioq_lock; | |
400 #define _MD_IOQ_LOCK() | |
401 #define _MD_IOQ_UNLOCK() | |
402 | |
403 | |
404 /* --- Initialization stuff --- */ | |
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() | |
413 #define _MD_INIT_CPUS() | |
414 #define _MD_INIT_RUNNING_CPU(cpu) | |
415 | |
416 struct PRProcess; | |
417 struct PRProcessAttr; | |
418 | |
419 #define _MD_CREATE_PROCESS _PR_CreateWindowsProcess | |
420 extern struct PRProcess * _PR_CreateWindowsProcess( | |
421 const char *path, | |
422 char *const *argv, | |
423 char *const *envp, | |
424 const struct PRProcessAttr *attr | |
425 ); | |
426 | |
427 #define _MD_DETACH_PROCESS _PR_DetachWindowsProcess | |
428 extern PRStatus _PR_DetachWindowsProcess(struct PRProcess *process); | |
429 | |
430 /* --- Wait for a child process to terminate --- */ | |
431 #define _MD_WAIT_PROCESS _PR_WaitWindowsProcess | |
432 extern PRStatus _PR_WaitWindowsProcess(struct PRProcess *process, | |
433 PRInt32 *exitCode); | |
434 | |
435 #define _MD_KILL_PROCESS _PR_KillWindowsProcess | |
436 extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process); | |
437 | |
438 #define _MD_CLEANUP_BEFORE_EXIT _PR_MD_CLEANUP_BEFORE_EXIT | |
439 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ | |
440 PR_BEGIN_MACRO \ | |
441 *status = PR_TRUE; \ | |
442 PR_END_MACRO | |
443 #define _MD_SWITCH_CONTEXT | |
444 #define _MD_RESTORE_CONTEXT | |
445 | |
446 /* --- Intervals --- */ | |
447 #define _MD_INTERVAL_INIT _PR_MD_INTERVAL_INIT | |
448 #define _MD_GET_INTERVAL _PR_MD_GET_INTERVAL | |
449 #define _MD_INTERVAL_PER_SEC _PR_MD_INTERVAL_PER_SEC | |
450 #define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000) | |
451 #define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000) | |
452 | |
453 /* --- Time --- */ | |
454 extern void _PR_FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm); | |
455 | |
456 /* --- Native-Thread Specific Definitions ------------------------------- */ | |
457 | |
458 extern struct PRThread * _MD_CURRENT_THREAD(void); | |
459 | |
460 #ifdef _PR_USE_STATIC_TLS | |
461 extern __declspec(thread) struct PRThread *_pr_currentThread; | |
462 #define _MD_GET_ATTACHED_THREAD() _pr_currentThread | |
463 #define _MD_SET_CURRENT_THREAD(_thread) (_pr_currentThread = (_thread)) | |
464 | |
465 extern __declspec(thread) struct PRThread *_pr_thread_last_run; | |
466 #define _MD_LAST_THREAD() _pr_thread_last_run | |
467 #define _MD_SET_LAST_THREAD(_thread) (_pr_thread_last_run = 0) | |
468 | |
469 extern __declspec(thread) struct _PRCPU *_pr_currentCPU; | |
470 #define _MD_CURRENT_CPU() _pr_currentCPU | |
471 #define _MD_SET_CURRENT_CPU(_cpu) (_pr_currentCPU = 0) | |
472 #else /* _PR_USE_STATIC_TLS */ | |
473 extern DWORD _pr_currentThreadIndex; | |
474 #define _MD_GET_ATTACHED_THREAD() ((PRThread *) TlsGetValue(_pr_currentThreadInd
ex)) | |
475 #define _MD_SET_CURRENT_THREAD(_thread) TlsSetValue(_pr_currentThreadIndex, (_th
read)) | |
476 | |
477 extern DWORD _pr_lastThreadIndex; | |
478 #define _MD_LAST_THREAD() ((PRThread *) TlsGetValue(_pr_lastThreadIndex)) | |
479 #define _MD_SET_LAST_THREAD(_thread) TlsSetValue(_pr_lastThreadIndex, 0) | |
480 | |
481 extern DWORD _pr_currentCPUIndex; | |
482 #define _MD_CURRENT_CPU() ((struct _PRCPU *) TlsGetValue(_pr_currentCPUIndex)) | |
483 #define _MD_SET_CURRENT_CPU(_cpu) TlsSetValue(_pr_currentCPUIndex, 0) | |
484 #endif /* _PR_USE_STATIC_TLS */ | |
485 | |
486 /* --- Scheduler stuff --- */ | |
487 #define LOCK_SCHEDULER() 0 | |
488 #define UNLOCK_SCHEDULER() 0 | |
489 #define _PR_LockSched() 0 | |
490 #define _PR_UnlockSched() 0 | |
491 | |
492 /* --- Initialization stuff --- */ | |
493 #define _MD_INIT_LOCKS() | |
494 | |
495 /* --- Stack stuff --- */ | |
496 #define _MD_INIT_STACK(stack, redzone) | |
497 #define _MD_CLEAR_STACK(stack) | |
498 | |
499 /* --- Memory-mapped files stuff --- */ | |
500 | |
501 struct _MDFileMap { | |
502 HANDLE hFileMap; | |
503 DWORD dwAccess; | |
504 }; | |
505 | |
506 extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size); | |
507 #define _MD_CREATE_FILE_MAP _MD_CreateFileMap | |
508 | |
509 extern PRInt32 _MD_GetMemMapAlignment(void); | |
510 #define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment | |
511 | |
512 extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset, | |
513 PRUint32 len); | |
514 #define _MD_MEM_MAP _MD_MemMap | |
515 | |
516 extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size); | |
517 #define _MD_MEM_UNMAP _MD_MemUnmap | |
518 | |
519 extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap); | |
520 #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap | |
521 | |
522 /* --- Named semaphores stuff --- */ | |
523 #define _PR_HAVE_NAMED_SEMAPHORES | |
524 #define _MD_OPEN_SEMAPHORE _PR_MD_OPEN_SEMAPHORE | |
525 #define _MD_WAIT_SEMAPHORE _PR_MD_WAIT_SEMAPHORE | |
526 #define _MD_POST_SEMAPHORE _PR_MD_POST_SEMAPHORE | |
527 #define _MD_CLOSE_SEMAPHORE _PR_MD_CLOSE_SEMAPHORE | |
528 #define _MD_DELETE_SEMAPHORE(name) PR_SUCCESS /* no op */ | |
529 | |
530 #endif /* nspr_win32_defs_h___ */ | |
OLD | NEW |