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