Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
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/. */
6 #ifndef nspr_win95_defs_h___
7 #define nspr_win95_defs_h___
9 #include "prio.h"
11 #include <windows.h>
12 #include <winsock.h>
13 #include <errno.h>
15 /*
16 * Internal configuration macros
17 */
19 #define PR_LINKER_ARCH "win32"
20 #define _PR_SI_SYSNAME "WIN95"
21 #if defined(_M_IX86) || defined(_X86_)
22 #define _PR_SI_ARCHITECTURE "x86"
23 #elif defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)
24 #define _PR_SI_ARCHITECTURE "x86-64"
25 #elif defined(_M_IA64) || defined(_IA64_)
26 #define _PR_SI_ARCHITECTURE "ia64"
27 #elif defined(_M_ARM) || defined(_ARM_)
28 #define _PR_SI_ARCHITECTURE "arm"
29 #else
30 #error unknown processor architecture
31 #endif
33 #define HAVE_DLL
34 #undef HAVE_THREAD_AFFINITY
35 #define _PR_HAVE_GETADDRINFO
36 #define _PR_INET6_PROBE
37 #ifndef _PR_INET6
38 #define AF_INET6 23
39 /* newer ws2tcpip.h provides these */
40 #ifndef AI_CANONNAME
41 #define AI_CANONNAME 0x2
42 #define AI_NUMERICHOST 0x4
43 #define NI_NUMERICHOST 0x02
44 struct addrinfo {
45 int ai_flags;
46 int ai_family;
47 int ai_socktype;
48 int ai_protocol;
49 size_t ai_addrlen;
50 char *ai_canonname;
51 struct sockaddr *ai_addr;
52 struct addrinfo *ai_next;
53 };
54 #endif
55 #define _PR_HAVE_MD_SOCKADDR_IN6
56 /* isomorphic to struct in6_addr on Windows */
57 struct _md_in6_addr {
58 union {
59 PRUint8 _S6_u8[16];
60 PRUint16 _S6_u16[8];
61 } _S6_un;
62 };
63 /* isomorphic to struct sockaddr_in6 on Windows */
64 struct _md_sockaddr_in6 {
65 PRInt16 sin6_family;
66 PRUint16 sin6_port;
67 PRUint32 sin6_flowinfo;
68 struct _md_in6_addr sin6_addr;
69 PRUint32 sin6_scope_id;
70 };
71 #endif
72 #define _PR_HAVE_THREADSAFE_GETHOST
73 #define _PR_HAVE_ATOMIC_OPS
74 #define PR_HAVE_WIN32_NAMED_SHARED_MEMORY
76 /* --- Common User-Thread/Native-Thread Definitions --------------------- */
78 /* --- Globals --- */
79 extern struct PRLock *_pr_schedLock;
81 /* --- Typedefs --- */
82 typedef void (*FiberFunc)(void *);
84 #define PR_NUM_GCREGS 8
85 typedef PRInt32 PR_CONTEXT_TYPE[PR_NUM_GCREGS];
86 #define GC_VMBASE 0x40000000
87 #define GC_VMLIMIT 0x00FFFFFF
89 #define _MD_MAGIC_THREAD 0x22222222
90 #define _MD_MAGIC_THREADSTACK 0x33333333
91 #define _MD_MAGIC_SEGMENT 0x44444444
92 #define _MD_MAGIC_DIR 0x55555555
93 #define _MD_MAGIC_CV 0x66666666
95 struct _MDCPU {
96 int unused;
97 };
99 struct _MDThread {
100 HANDLE blocked_sema; /* Threads block on this when waiting
101 * for IO or CondVar.
102 */
103 PRBool inCVWaitQueue; /* PR_TRUE if the thread is in the
104 * wait queue of some cond var.
105 * PR_FALSE otherwise. */
106 HANDLE handle; /* Win32 thread handle */
107 PRUint32 id;
108 void *sp; /* only valid when suspended */
109 PRUint32 magic; /* for debugging */
110 PR_CONTEXT_TYPE gcContext; /* Thread context for GC */
111 struct PRThread *prev, *next; /* used by the cvar wait queue to
112 * chain the PRThread structures
113 * together */
114 void (*start)(void *); /* used by _PR_MD_CREATE_THREAD to
115 * pass its 'start' argument to
116 * pr_root. */
117 };
119 struct _MDThreadStack {
120 PRUint32 magic; /* for debugging */
121 };
123 struct _MDSegment {
124 PRUint32 magic; /* for debugging */
125 };
127 #undef PROFILE_LOCKS
129 struct _MDDir {
130 HANDLE d_hdl;
131 WIN32_FIND_DATAA d_entry;
132 PRBool firstEntry; /* Is this the entry returned
133 * by FindFirstFile()? */
134 PRUint32 magic; /* for debugging */
135 };
137 #ifdef MOZ_UNICODE
138 struct _MDDirUTF16 {
139 HANDLE d_hdl;
140 WIN32_FIND_DATAW d_entry;
141 PRBool firstEntry; /* Is this the entry returned
142 * by FindFirstFileW()? */
143 PRUint32 magic; /* for debugging */
144 };
145 #endif /* MOZ_UNICODE */
147 struct _MDCVar {
148 PRUint32 magic;
149 struct PRThread *waitHead, *waitTail; /* the wait queue: a doubly-
150 * linked list of threads
151 * waiting on this condition
152 * variable */
153 PRIntn nwait; /* number of threads in the
154 * wait queue */
155 };
157 #define _MD_CV_NOTIFIED_LENGTH 6
158 typedef struct _MDNotified _MDNotified;
159 struct _MDNotified {
160 PRIntn length; /* # of used entries in this
161 * structure */
162 struct {
163 struct _MDCVar *cv; /* the condition variable notified */
164 PRIntn times; /* and the number of times notified */
165 struct PRThread *notifyHead; /* list of threads to wake up */
166 } cv[_MD_CV_NOTIFIED_LENGTH];
167 _MDNotified *link; /* link to another of these, or NULL */
168 };
170 struct _MDLock {
171 CRITICAL_SECTION mutex; /* this is recursive on NT */
173 /*
174 * When notifying cvars, there is no point in actually
175 * waking up the threads waiting on the cvars until we've
176 * released the lock. So, we temporarily record the cvars.
177 * When doing an unlock, we'll then wake up the waiting threads.
178 */
179 struct _MDNotified notified; /* array of conditions notified */
180 #ifdef PROFILE_LOCKS
181 PRInt32 hitcount;
182 PRInt32 misscount;
183 #endif
184 };
186 struct _MDSemaphore {
187 HANDLE sem;
188 };
190 struct _MDFileDesc {
191 PROsfd osfd; /* The osfd can come from one of three spaces:
192 * - For stdin, stdout, and stderr, we are using
193 * the libc file handle (0, 1, 2), which is an int.
194 * - For files and pipes, we are using Win32 HANDLE,
195 * which is a void*.
196 * - For sockets, we are using Winsock SOCKET, which
197 * is a u_int.
198 */
199 };
201 struct _MDProcess {
202 HANDLE handle;
203 DWORD id;
204 };
206 /* --- Misc stuff --- */
207 #define _MD_GET_SP(thread) (thread)->md.gcContext[6]
209 /* --- NT security stuff --- */
211 extern void _PR_NT_InitSids(void);
212 extern void _PR_NT_FreeSids(void);
213 extern PRStatus _PR_NT_MakeSecurityDescriptorACL(
214 PRIntn mode,
215 DWORD accessTable[],
216 PSECURITY_DESCRIPTOR *resultSD,
217 PACL *resultACL
218 );
219 extern void _PR_NT_FreeSecurityDescriptorACL(
220 PSECURITY_DESCRIPTOR pSD, PACL pACL);
222 /* --- IO stuff --- */
224 #define _MD_OPEN _PR_MD_OPEN
225 #define _MD_OPEN_FILE _PR_MD_OPEN_FILE
226 #define _MD_READ _PR_MD_READ
227 #define _MD_WRITE _PR_MD_WRITE
228 #define _MD_WRITEV _PR_MD_WRITEV
229 #define _MD_LSEEK _PR_MD_LSEEK
230 #define _MD_LSEEK64 _PR_MD_LSEEK64
231 extern PRInt32 _MD_CloseFile(PROsfd osfd);
232 #define _MD_CLOSE_FILE _MD_CloseFile
233 #define _MD_GETFILEINFO _PR_MD_GETFILEINFO
234 #define _MD_GETFILEINFO64 _PR_MD_GETFILEINFO64
235 #define _MD_GETOPENFILEINFO _PR_MD_GETOPENFILEINFO
236 #define _MD_GETOPENFILEINFO64 _PR_MD_GETOPENFILEINFO64
237 #define _MD_STAT _PR_MD_STAT
238 #define _MD_RENAME _PR_MD_RENAME
239 #define _MD_ACCESS _PR_MD_ACCESS
240 #define _MD_DELETE _PR_MD_DELETE
241 #define _MD_MKDIR _PR_MD_MKDIR
242 #define _MD_MAKE_DIR _PR_MD_MAKE_DIR
243 #define _MD_RMDIR _PR_MD_RMDIR
244 #define _MD_LOCKFILE _PR_MD_LOCKFILE
245 #define _MD_TLOCKFILE _PR_MD_TLOCKFILE
246 #define _MD_UNLOCKFILE _PR_MD_UNLOCKFILE
248 /* --- UTF16 IO stuff --- */
249 #ifdef MOZ_UNICODE
250 #define _MD_OPEN_FILE_UTF16 _PR_MD_OPEN_FILE_UTF16
251 #define _MD_OPEN_DIR_UTF16 _PR_MD_OPEN_DIR_UTF16
252 #define _MD_READ_DIR_UTF16 _PR_MD_READ_DIR_UTF16
253 #define _MD_CLOSE_DIR_UTF16 _PR_MD_CLOSE_DIR_UTF16
254 #define _MD_GETFILEINFO64_UTF16 _PR_MD_GETFILEINFO64_UTF16
255 #endif /* MOZ_UNICODE */
257 /* --- Socket IO stuff --- */
258 extern void _PR_MD_InitSockets(void);
259 extern void _PR_MD_CleanupSockets(void);
260 #define _MD_EACCES WSAEACCES
261 #define _MD_EADDRINUSE WSAEADDRINUSE
262 #define _MD_EADDRNOTAVAIL WSAEADDRNOTAVAIL
263 #define _MD_EAFNOSUPPORT WSAEAFNOSUPPORT
264 #define _MD_EAGAIN WSAEWOULDBLOCK
265 #define _MD_EALREADY WSAEALREADY
266 #define _MD_EBADF WSAEBADF
267 #define _MD_ECONNREFUSED WSAECONNREFUSED
268 #define _MD_ECONNRESET WSAECONNRESET
269 #define _MD_EFAULT WSAEFAULT
270 #define _MD_EINPROGRESS WSAEINPROGRESS
271 #define _MD_EINTR WSAEINTR
272 #define _MD_EINVAL EINVAL
273 #define _MD_EISCONN WSAEISCONN
274 #define _MD_ENETUNREACH WSAENETUNREACH
275 #define _MD_ENOENT ENOENT
276 #define _MD_ENOTCONN WSAENOTCONN
277 #define _MD_ENOTSOCK WSAENOTSOCK
278 #define _MD_EOPNOTSUPP WSAEOPNOTSUPP
279 #define _MD_EWOULDBLOCK WSAEWOULDBLOCK
280 #define _MD_GET_SOCKET_ERROR() WSAGetLastError()
281 #define _MD_SET_SOCKET_ERROR(_err) WSASetLastError(_err)
283 #define _MD_INIT_FILEDESC(fd)
284 extern void _MD_MakeNonblock(PRFileDesc *f);
285 #define _MD_MAKE_NONBLOCK _MD_MakeNonblock
286 #define _MD_INIT_FD_INHERITABLE _PR_MD_INIT_FD_INHERITABLE
287 #define _MD_QUERY_FD_INHERITABLE _PR_MD_QUERY_FD_INHERITABLE
288 #define _MD_SHUTDOWN _PR_MD_SHUTDOWN
289 #define _MD_LISTEN _PR_MD_LISTEN
290 extern PRInt32 _MD_CloseSocket(PROsfd osfd);
291 #define _MD_CLOSE_SOCKET _MD_CloseSocket
292 #define _MD_SENDTO _PR_MD_SENDTO
293 #define _MD_RECVFROM _PR_MD_RECVFROM
294 #define _MD_SOCKETPAIR(s, type, proto, sv) -1
295 #define _MD_GETSOCKNAME _PR_MD_GETSOCKNAME
296 #define _MD_GETPEERNAME _PR_MD_GETPEERNAME
297 #define _MD_GETSOCKOPT _PR_MD_GETSOCKOPT
298 #define _MD_SETSOCKOPT _PR_MD_SETSOCKOPT
299 #define _MD_SET_FD_INHERITABLE _PR_MD_SET_FD_INHERITABLE
300 #define _MD_SELECT select
301 #define _MD_FSYNC _PR_MD_FSYNC
302 #define READ_FD 1
303 #define WRITE_FD 2
305 #define _MD_INIT_ATOMIC()
306 #if defined(_M_IX86) || defined(_X86_)
307 #define _MD_ATOMIC_INCREMENT _PR_MD_ATOMIC_INCREMENT
308 #define _MD_ATOMIC_ADD _PR_MD_ATOMIC_ADD
309 #define _MD_ATOMIC_DECREMENT _PR_MD_ATOMIC_DECREMENT
310 #else /* non-x86 processors */
311 #define _MD_ATOMIC_INCREMENT(x) InterlockedIncrement((PLONG)x)
312 #define _MD_ATOMIC_ADD(ptr,val) (InterlockedExchangeAdd((PLONG)ptr, (LONG)val) + val)
313 #define _MD_ATOMIC_DECREMENT(x) InterlockedDecrement((PLONG)x)
314 #endif /* x86 */
315 #define _MD_ATOMIC_SET(x,y) InterlockedExchange((PLONG)x, (LONG)y)
317 #define _MD_INIT_IO _PR_MD_INIT_IO
320 /* win95 doesn't have async IO */
321 #define _MD_SOCKET _PR_MD_SOCKET
322 extern PRInt32 _MD_SocketAvailable(PRFileDesc *fd);
323 #define _MD_SOCKETAVAILABLE _MD_SocketAvailable
324 #define _MD_PIPEAVAILABLE _PR_MD_PIPEAVAILABLE
325 #define _MD_CONNECT _PR_MD_CONNECT
326 extern PROsfd _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen,
327 PRIntervalTime timeout);
328 #define _MD_ACCEPT _MD_Accept
329 #define _MD_BIND _PR_MD_BIND
330 #define _MD_RECV _PR_MD_RECV
331 #define _MD_SEND _PR_MD_SEND
332 #define _MD_PR_POLL _PR_MD_PR_POLL
334 /* --- Scheduler stuff --- */
335 // #define _MD_PAUSE_CPU _PR_MD_PAUSE_CPU
336 #define _MD_PAUSE_CPU
338 /* --- DIR stuff --- */
339 #define PR_DIRECTORY_SEPARATOR '\\'
340 #define PR_DIRECTORY_SEPARATOR_STR "\\"
341 #define PR_PATH_SEPARATOR ';'
342 #define PR_PATH_SEPARATOR_STR ";"
343 #define _MD_ERRNO() GetLastError()
344 #define _MD_OPEN_DIR _PR_MD_OPEN_DIR
345 #define _MD_CLOSE_DIR _PR_MD_CLOSE_DIR
346 #define _MD_READ_DIR _PR_MD_READ_DIR
348 /* --- Segment stuff --- */
349 #define _MD_INIT_SEGS()
350 #define _MD_ALLOC_SEGMENT(seg, size, vaddr) 0
351 #define _MD_FREE_SEGMENT(seg)
353 /* --- Environment Stuff --- */
354 #define _MD_GET_ENV _PR_MD_GET_ENV
355 #define _MD_PUT_ENV _PR_MD_PUT_ENV
357 /* --- Threading Stuff --- */
358 #define _MD_DEFAULT_STACK_SIZE 0
359 #define _MD_INIT_THREAD _PR_MD_INIT_THREAD
360 #define _MD_INIT_ATTACHED_THREAD _PR_MD_INIT_THREAD
361 #define _MD_CREATE_THREAD _PR_MD_CREATE_THREAD
362 #define _MD_YIELD _PR_MD_YIELD
363 #define _MD_SET_PRIORITY _PR_MD_SET_PRIORITY
364 #define _MD_SET_CURRENT_THREAD_NAME _PR_MD_SET_CURRENT_THREAD_NAME
365 #define _MD_CLEAN_THREAD _PR_MD_CLEAN_THREAD
366 #define _MD_SETTHREADAFFINITYMASK _PR_MD_SETTHREADAFFINITYMASK
367 #define _MD_GETTHREADAFFINITYMASK _PR_MD_GETTHREADAFFINITYMASK
368 #define _MD_EXIT_THREAD _PR_MD_EXIT_THREAD
369 #define _MD_EXIT _PR_MD_EXIT
370 #define _MD_SUSPEND_THREAD _PR_MD_SUSPEND_THREAD
371 #define _MD_RESUME_THREAD _PR_MD_RESUME_THREAD
372 #define _MD_SUSPEND_CPU _PR_MD_SUSPEND_CPU
373 #define _MD_RESUME_CPU _PR_MD_RESUME_CPU
374 #define _MD_BEGIN_SUSPEND_ALL()
375 #define _MD_BEGIN_RESUME_ALL()
376 #define _MD_END_SUSPEND_ALL()
377 #define _MD_END_RESUME_ALL()
379 /* --- Lock stuff --- */
380 #define _PR_LOCK _MD_LOCK
381 #define _PR_UNLOCK _MD_UNLOCK
383 #define _MD_NEW_LOCK _PR_MD_NEW_LOCK
384 #define _MD_FREE_LOCK(lock) DeleteCriticalSection(&((lock)->mutex))
385 #define _MD_LOCK(lock) EnterCriticalSection(&((lock)->mutex))
386 #define _MD_TEST_AND_LOCK(lock) (EnterCriticalSection(&((lock)->mutex)),0)
387 #define _MD_UNLOCK _PR_MD_UNLOCK
389 /* --- lock and cv waiting --- */
390 #define _MD_WAIT _PR_MD_WAIT
391 #define _MD_WAKEUP_WAITER _PR_MD_WAKEUP_WAITER
393 /* --- CVar ------------------- */
394 #define _MD_WAIT_CV _PR_MD_WAIT_CV
395 #define _MD_NEW_CV _PR_MD_NEW_CV
396 #define _MD_FREE_CV _PR_MD_FREE_CV
397 #define _MD_NOTIFY_CV _PR_MD_NOTIFY_CV
398 #define _MD_NOTIFYALL_CV _PR_MD_NOTIFYALL_CV
400 /* XXXMB- the IOQ stuff is certainly not working correctly yet. */
401 // extern struct _MDLock _pr_ioq_lock;
402 #define _MD_IOQ_LOCK()
403 #define _MD_IOQ_UNLOCK()
406 /* --- Initialization stuff --- */
407 #define _MD_START_INTERRUPTS()
408 #define _MD_STOP_INTERRUPTS()
409 #define _MD_DISABLE_CLOCK_INTERRUPTS()
410 #define _MD_ENABLE_CLOCK_INTERRUPTS()
411 #define _MD_BLOCK_CLOCK_INTERRUPTS()
412 #define _MD_UNBLOCK_CLOCK_INTERRUPTS()
413 #define _MD_EARLY_INIT _PR_MD_EARLY_INIT
414 #define _MD_FINAL_INIT()
415 #define _MD_EARLY_CLEANUP()
416 #define _MD_INIT_CPUS()
417 #define _MD_INIT_RUNNING_CPU(cpu)
419 struct PRProcess;
420 struct PRProcessAttr;
422 #define _MD_CREATE_PROCESS _PR_CreateWindowsProcess
423 extern struct PRProcess * _PR_CreateWindowsProcess(
424 const char *path,
425 char *const *argv,
426 char *const *envp,
427 const struct PRProcessAttr *attr
428 );
430 #define _MD_DETACH_PROCESS _PR_DetachWindowsProcess
431 extern PRStatus _PR_DetachWindowsProcess(struct PRProcess *process);
433 /* --- Wait for a child process to terminate --- */
434 #define _MD_WAIT_PROCESS _PR_WaitWindowsProcess
435 extern PRStatus _PR_WaitWindowsProcess(struct PRProcess *process,
436 PRInt32 *exitCode);
438 #define _MD_KILL_PROCESS _PR_KillWindowsProcess
439 extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process);
441 #define _MD_CLEANUP_BEFORE_EXIT _PR_MD_CLEANUP_BEFORE_EXIT
442 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
443 PR_BEGIN_MACRO \
444 *status = PR_TRUE; \
445 PR_END_MACRO
446 #define _MD_SWITCH_CONTEXT
447 #define _MD_RESTORE_CONTEXT
449 /* --- Intervals --- */
450 #define _MD_INTERVAL_INIT _PR_MD_INTERVAL_INIT
451 #define _MD_GET_INTERVAL _PR_MD_GET_INTERVAL
452 #define _MD_INTERVAL_PER_SEC _PR_MD_INTERVAL_PER_SEC
453 #define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000)
454 #define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000)
456 /* --- Time --- */
457 extern void _PR_FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm);
459 #ifdef WINCE
460 extern void _MD_InitTime(void);
461 extern void _MD_CleanupTime(void);
462 #endif
464 /* --- Native-Thread Specific Definitions ------------------------------- */
466 extern struct PRThread * _MD_CURRENT_THREAD(void);
468 #ifdef _PR_USE_STATIC_TLS
469 extern __declspec(thread) struct PRThread *_pr_currentThread;
470 #define _MD_GET_ATTACHED_THREAD() _pr_currentThread
471 #define _MD_SET_CURRENT_THREAD(_thread) (_pr_currentThread = (_thread))
473 extern __declspec(thread) struct PRThread *_pr_thread_last_run;
474 #define _MD_LAST_THREAD() _pr_thread_last_run
475 #define _MD_SET_LAST_THREAD(_thread) (_pr_thread_last_run = 0)
477 extern __declspec(thread) struct _PRCPU *_pr_currentCPU;
478 #define _MD_CURRENT_CPU() _pr_currentCPU
479 #define _MD_SET_CURRENT_CPU(_cpu) (_pr_currentCPU = 0)
480 #else /* _PR_USE_STATIC_TLS */
481 extern DWORD _pr_currentThreadIndex;
482 #define _MD_GET_ATTACHED_THREAD() ((PRThread *) TlsGetValue(_pr_currentThreadIndex))
483 #define _MD_SET_CURRENT_THREAD(_thread) TlsSetValue(_pr_currentThreadIndex, (_thread))
485 extern DWORD _pr_lastThreadIndex;
486 #define _MD_LAST_THREAD() ((PRThread *) TlsGetValue(_pr_lastThreadIndex))
487 #define _MD_SET_LAST_THREAD(_thread) TlsSetValue(_pr_lastThreadIndex, 0)
489 extern DWORD _pr_currentCPUIndex;
490 #define _MD_CURRENT_CPU() ((struct _PRCPU *) TlsGetValue(_pr_currentCPUIndex))
491 #define _MD_SET_CURRENT_CPU(_cpu) TlsSetValue(_pr_currentCPUIndex, 0)
492 #endif /* _PR_USE_STATIC_TLS */
494 /* --- Scheduler stuff --- */
495 #define LOCK_SCHEDULER() 0
496 #define UNLOCK_SCHEDULER() 0
497 #define _PR_LockSched() 0
498 #define _PR_UnlockSched() 0
500 /* --- Initialization stuff --- */
501 #define _MD_INIT_LOCKS _PR_MD_INIT_LOCKS
503 /* --- Stack stuff --- */
504 #define _MD_INIT_STACK(stack, redzone)
505 #define _MD_CLEAR_STACK(stack)
507 /* --- Memory-mapped files stuff --- */
509 struct _MDFileMap {
510 HANDLE hFileMap;
511 DWORD dwAccess;
512 };
514 extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
515 #define _MD_CREATE_FILE_MAP _MD_CreateFileMap
517 extern PRInt32 _MD_GetMemMapAlignment(void);
518 #define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment
520 extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,
521 PRUint32 len);
522 #define _MD_MEM_MAP _MD_MemMap
524 extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);
525 #define _MD_MEM_UNMAP _MD_MemUnmap
527 extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
528 #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
530 extern PRStatus _MD_SyncMemMap(
531 PRFileDesc *fd,
532 void *addr,
533 PRUint32 len);
534 #define _MD_SYNC_MEM_MAP _MD_SyncMemMap
536 /* --- Named semaphores stuff --- */
537 #define _PR_HAVE_NAMED_SEMAPHORES
538 #define _MD_OPEN_SEMAPHORE _PR_MD_OPEN_SEMAPHORE
539 #define _MD_WAIT_SEMAPHORE _PR_MD_WAIT_SEMAPHORE
540 #define _MD_POST_SEMAPHORE _PR_MD_POST_SEMAPHORE
541 #define _MD_CLOSE_SEMAPHORE _PR_MD_CLOSE_SEMAPHORE
542 #define _MD_DELETE_SEMAPHORE(name) PR_SUCCESS /* no op */
544 #endif /* nspr_win32_defs_h___ */