nsprpub/pr/include/md/_win95.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

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

mercurial