Back to index

lightning-sunbird  0.9+nobinonly
_win95.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Netscape Portable Runtime (NSPR).
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef nspr_win95_defs_h___
00039 #define nspr_win95_defs_h___
00040 
00041 #include "prio.h"
00042 
00043 #include <windows.h>
00044 #include <winsock.h>
00045 #include <errno.h>
00046 
00047 /*
00048  * Internal configuration macros
00049  */
00050 
00051 #define PR_LINKER_ARCH      "win32"
00052 #define _PR_SI_SYSNAME        "WIN95"
00053 #define _PR_SI_ARCHITECTURE   "x86"    /* XXXMB hardcode for now */
00054 
00055 #define HAVE_DLL
00056 #undef  HAVE_THREAD_AFFINITY
00057 #define _PR_HAVE_GETADDRINFO
00058 #define _PR_INET6_PROBE
00059 #ifndef _PR_INET6
00060 #define AF_INET6 23
00061 /* newer ws2tcpip.h provides these */
00062 #ifndef AI_CANONNAME
00063 #define AI_CANONNAME 0x2
00064 struct addrinfo {
00065     int ai_flags;
00066     int ai_family;
00067     int ai_socktype;
00068     int ai_protocol;
00069     size_t ai_addrlen;
00070     char *ai_canonname;
00071     struct sockaddr *ai_addr;
00072     struct addrinfo *ai_next;
00073 };
00074 #endif
00075 #define _PR_HAVE_MD_SOCKADDR_IN6
00076 /* isomorphic to struct in6_addr on Windows */
00077 struct _md_in6_addr {
00078     union {
00079         PRUint8  _S6_u8[16];
00080         PRUint16 _S6_u16[8];
00081     } _S6_un;
00082 };
00083 /* isomorphic to struct sockaddr_in6 on Windows */
00084 struct _md_sockaddr_in6 {
00085     PRInt16 sin6_family;
00086     PRUint16 sin6_port;
00087     PRUint32 sin6_flowinfo;
00088     struct _md_in6_addr sin6_addr;
00089     PRUint32 sin6_scope_id;
00090 };
00091 #endif
00092 #define _PR_HAVE_THREADSAFE_GETHOST
00093 #define _PR_HAVE_ATOMIC_OPS
00094 #define PR_HAVE_WIN32_NAMED_SHARED_MEMORY
00095 
00096 /* --- Common User-Thread/Native-Thread Definitions --------------------- */
00097 
00098 /* --- Globals --- */
00099 extern struct PRLock                      *_pr_schedLock;
00100 
00101 /* --- Typedefs --- */
00102 typedef void (*FiberFunc)(void *);
00103 
00104 #define PR_NUM_GCREGS           8
00105 typedef PRInt32                      PR_CONTEXT_TYPE[PR_NUM_GCREGS];
00106 #define GC_VMBASE               0x40000000
00107 #define GC_VMLIMIT              0x00FFFFFF
00108 
00109 #define _MD_MAGIC_THREAD    0x22222222
00110 #define _MD_MAGIC_THREADSTACK      0x33333333
00111 #define _MD_MAGIC_SEGMENT   0x44444444
00112 #define _MD_MAGIC_DIR              0x55555555
00113 #define _MD_MAGIC_CV        0x66666666
00114 
00115 struct _MDCPU {
00116     int              unused;
00117 };
00118 
00119 struct _MDThread {
00120     HANDLE           blocked_sema;      /* Threads block on this when waiting
00121                                          * for IO or CondVar.
00122                                          */
00123     PRBool           inCVWaitQueue;     /* PR_TRUE if the thread is in the
00124                                          * wait queue of some cond var.
00125                                          * PR_FALSE otherwise.  */
00126     HANDLE           handle;            /* Win32 thread handle */
00127     PRUint32         id;
00128     void            *sp;                /* only valid when suspended */
00129     PRUint32         magic;             /* for debugging */
00130     PR_CONTEXT_TYPE  gcContext;         /* Thread context for GC */
00131     struct PRThread *prev, *next;       /* used by the cvar wait queue to
00132                                          * chain the PRThread structures
00133                                          * together */
00134     void (*start)(void *);              /* used by _PR_MD_CREATE_THREAD to
00135                                          * pass its 'start' argument to
00136                                          * pr_root. */
00137 };
00138 
00139 struct _MDThreadStack {
00140     PRUint32           magic;          /* for debugging */
00141 };
00142 
00143 struct _MDSegment {
00144     PRUint32           magic;          /* for debugging */
00145 };
00146 
00147 #undef PROFILE_LOCKS
00148 
00149 struct _MDDir {
00150     HANDLE           d_hdl;
00151     WIN32_FIND_DATA  d_entry;
00152     PRBool           firstEntry;     /* Is this the entry returned
00153                                       * by FindFirstFile()? */
00154     PRUint32         magic;          /* for debugging */
00155 };
00156 
00157 #ifdef MOZ_UNICODE
00158 struct _MDDirUTF16 {
00159     HANDLE           d_hdl;
00160     WIN32_FIND_DATAW d_entry;
00161     PRBool           firstEntry;     /* Is this the entry returned
00162                                       * by FindFirstFileW()? */
00163     PRUint32         magic;          /* for debugging */
00164 };
00165 #endif /* MOZ_UNICODE */
00166 
00167 struct _MDCVar {
00168     PRUint32 magic;
00169     struct PRThread *waitHead, *waitTail;  /* the wait queue: a doubly-
00170                                             * linked list of threads
00171                                             * waiting on this condition
00172                                             * variable */
00173     PRIntn nwait;                          /* number of threads in the
00174                                             * wait queue */
00175 };
00176 
00177 #define _MD_CV_NOTIFIED_LENGTH 6
00178 typedef struct _MDNotified _MDNotified;
00179 struct _MDNotified {
00180     PRIntn length;                     /* # of used entries in this
00181                                         * structure */
00182     struct {
00183         struct _MDCVar *cv;            /* the condition variable notified */
00184         PRIntn times;                  /* and the number of times notified */
00185         struct PRThread *notifyHead;   /* list of threads to wake up */
00186     } cv[_MD_CV_NOTIFIED_LENGTH];
00187     _MDNotified *link;                 /* link to another of these, or NULL */
00188 };
00189 
00190 struct _MDLock {
00191     CRITICAL_SECTION mutex;          /* this is recursive on NT */
00192 
00193     /*
00194      * When notifying cvars, there is no point in actually
00195      * waking up the threads waiting on the cvars until we've
00196      * released the lock.  So, we temporarily record the cvars.
00197      * When doing an unlock, we'll then wake up the waiting threads.
00198      */
00199     struct _MDNotified notified;     /* array of conditions notified */
00200 #ifdef PROFILE_LOCKS
00201     PRInt32 hitcount;
00202     PRInt32 misscount;
00203 #endif
00204 };
00205 
00206 struct _MDSemaphore {
00207     HANDLE           sem;
00208 };
00209 
00210 struct _MDFileDesc {
00211     PRInt32 osfd;    /* The osfd can come from one of three spaces:
00212                       * - For stdin, stdout, and stderr, we are using
00213                       *   the libc file handle (0, 1, 2), which is an int.
00214                       * - For files and pipes, we are using Win32 HANDLE,
00215                       *   which is a void*.
00216                       * - For sockets, we are using Winsock SOCKET, which
00217                       *   is a u_int.
00218                       */
00219 };
00220 
00221 struct _MDProcess {
00222     HANDLE handle;
00223     DWORD id;
00224 };
00225 
00226 /* --- Misc stuff --- */
00227 #define _MD_GET_SP(thread)            (thread)->md.gcContext[6]
00228 
00229 /* --- NT security stuff --- */
00230 
00231 extern void _PR_NT_InitSids(void);
00232 extern void _PR_NT_FreeSids(void);
00233 extern PRStatus _PR_NT_MakeSecurityDescriptorACL(
00234     PRIntn mode,
00235     DWORD accessTable[],
00236     PSECURITY_DESCRIPTOR *resultSD,
00237     PACL *resultACL
00238 );
00239 extern void _PR_NT_FreeSecurityDescriptorACL(
00240     PSECURITY_DESCRIPTOR pSD, PACL pACL);
00241 
00242 /* --- IO stuff --- */
00243 
00244 #define _MD_OPEN                      _PR_MD_OPEN
00245 #define _MD_OPEN_FILE                 _PR_MD_OPEN_FILE
00246 #define _MD_READ                      _PR_MD_READ
00247 #define _MD_WRITE                     _PR_MD_WRITE
00248 #define _MD_WRITEV                    _PR_MD_WRITEV
00249 #define _MD_LSEEK                     _PR_MD_LSEEK
00250 #define _MD_LSEEK64                   _PR_MD_LSEEK64
00251 extern PRInt32 _MD_CloseFile(PRInt32 osfd);
00252 #define _MD_CLOSE_FILE                _MD_CloseFile
00253 #define _MD_GETFILEINFO               _PR_MD_GETFILEINFO
00254 #define _MD_GETFILEINFO64             _PR_MD_GETFILEINFO64
00255 #define _MD_GETOPENFILEINFO           _PR_MD_GETOPENFILEINFO
00256 #define _MD_GETOPENFILEINFO64         _PR_MD_GETOPENFILEINFO64
00257 #define _MD_STAT                      _PR_MD_STAT
00258 #define _MD_RENAME                    _PR_MD_RENAME     
00259 #define _MD_ACCESS                    _PR_MD_ACCESS     
00260 #define _MD_DELETE                    _PR_MD_DELETE     
00261 #define _MD_MKDIR                     _PR_MD_MKDIR      
00262 #define _MD_MAKE_DIR                  _PR_MD_MAKE_DIR
00263 #define _MD_RMDIR                     _PR_MD_RMDIR      
00264 #define _MD_LOCKFILE                  _PR_MD_LOCKFILE
00265 #define _MD_TLOCKFILE                 _PR_MD_TLOCKFILE
00266 #define _MD_UNLOCKFILE                _PR_MD_UNLOCKFILE
00267 
00268 /* --- UTF16 IO stuff --- */
00269 extern PRBool _pr_useUnicode;
00270 #ifdef MOZ_UNICODE
00271 #define _MD_OPEN_FILE_UTF16           _PR_MD_OPEN_FILE_UTF16
00272 #define _MD_OPEN_DIR_UTF16            _PR_MD_OPEN_DIR_UTF16
00273 #define _MD_READ_DIR_UTF16            _PR_MD_READ_DIR_UTF16
00274 #define _MD_CLOSE_DIR_UTF16           _PR_MD_CLOSE_DIR_UTF16
00275 #define _MD_GETFILEINFO64_UTF16       _PR_MD_GETFILEINFO64_UTF16
00276 #endif /* MOZ_UNICODE */
00277 
00278 /* --- Socket IO stuff --- */
00279 extern void _PR_MD_InitSockets(void);
00280 extern void _PR_MD_CleanupSockets(void);
00281 #define _MD_EACCES                WSAEACCES
00282 #define _MD_EADDRINUSE            WSAEADDRINUSE
00283 #define _MD_EADDRNOTAVAIL         WSAEADDRNOTAVAIL
00284 #define _MD_EAFNOSUPPORT          WSAEAFNOSUPPORT
00285 #define _MD_EAGAIN                WSAEWOULDBLOCK
00286 #define _MD_EALREADY              WSAEALREADY
00287 #define _MD_EBADF                 WSAEBADF
00288 #define _MD_ECONNREFUSED          WSAECONNREFUSED
00289 #define _MD_ECONNRESET            WSAECONNRESET
00290 #define _MD_EFAULT                WSAEFAULT
00291 #define _MD_EINPROGRESS           WSAEINPROGRESS
00292 #define _MD_EINTR                 WSAEINTR
00293 #define _MD_EINVAL                EINVAL
00294 #define _MD_EISCONN               WSAEISCONN
00295 #define _MD_ENETUNREACH           WSAENETUNREACH
00296 #define _MD_ENOENT                ENOENT
00297 #define _MD_ENOTCONN              WSAENOTCONN
00298 #define _MD_ENOTSOCK              WSAENOTSOCK
00299 #define _MD_EOPNOTSUPP            WSAEOPNOTSUPP
00300 #define _MD_EWOULDBLOCK           WSAEWOULDBLOCK
00301 #define _MD_GET_SOCKET_ERROR()    WSAGetLastError()
00302 #define _MD_SET_SOCKET_ERROR(_err) WSASetLastError(_err)
00303 
00304 #define _MD_INIT_FILEDESC(fd)
00305 extern void _MD_MakeNonblock(PRFileDesc *f);
00306 #define _MD_MAKE_NONBLOCK             _MD_MakeNonblock
00307 #define _MD_INIT_FD_INHERITABLE       _PR_MD_INIT_FD_INHERITABLE
00308 #define _MD_QUERY_FD_INHERITABLE      _PR_MD_QUERY_FD_INHERITABLE
00309 #define _MD_SHUTDOWN                  _PR_MD_SHUTDOWN
00310 #define _MD_LISTEN                    _PR_MD_LISTEN
00311 extern PRInt32 _MD_CloseSocket(PRInt32 osfd);
00312 #define _MD_CLOSE_SOCKET              _MD_CloseSocket
00313 #define _MD_SENDTO                    _PR_MD_SENDTO
00314 #define _MD_RECVFROM                  _PR_MD_RECVFROM
00315 #define _MD_SOCKETPAIR(s, type, proto, sv) -1
00316 #define _MD_GETSOCKNAME               _PR_MD_GETSOCKNAME
00317 #define _MD_GETPEERNAME               _PR_MD_GETPEERNAME
00318 #define _MD_GETSOCKOPT                _PR_MD_GETSOCKOPT
00319 #define _MD_SETSOCKOPT                _PR_MD_SETSOCKOPT
00320 #define _MD_SET_FD_INHERITABLE        _PR_MD_SET_FD_INHERITABLE
00321 #define _MD_SELECT                    select
00322 #define _MD_FSYNC                     _PR_MD_FSYNC
00323 #define READ_FD                       1
00324 #define WRITE_FD                      2
00325 
00326 #define _MD_INIT_ATOMIC()
00327 #if defined(_M_IX86) || defined(_X86_)
00328 #define _MD_ATOMIC_INCREMENT          _PR_MD_ATOMIC_INCREMENT
00329 #define _MD_ATOMIC_ADD               _PR_MD_ATOMIC_ADD
00330 #define _MD_ATOMIC_DECREMENT          _PR_MD_ATOMIC_DECREMENT
00331 #else /* non-x86 processors */
00332 #define _MD_ATOMIC_INCREMENT(x)       InterlockedIncrement((PLONG)x)
00333 #define _MD_ATOMIC_ADD(ptr,val)    (InterlockedExchangeAdd((PLONG)ptr, (LONG)val) + val)
00334 #define _MD_ATOMIC_DECREMENT(x)       InterlockedDecrement((PLONG)x)
00335 #endif /* x86 */
00336 #define _MD_ATOMIC_SET(x,y)           InterlockedExchange((PLONG)x, (LONG)y)
00337 
00338 #define _MD_INIT_IO                   _PR_MD_INIT_IO
00339 
00340 
00341 /* win95 doesn't have async IO */
00342 #define _MD_SOCKET                    _PR_MD_SOCKET
00343 extern PRInt32 _MD_SocketAvailable(PRFileDesc *fd);
00344 #define _MD_SOCKETAVAILABLE           _MD_SocketAvailable
00345 #define _MD_PIPEAVAILABLE             _PR_MD_PIPEAVAILABLE
00346 #define _MD_CONNECT                   _PR_MD_CONNECT
00347 extern PRInt32 _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen,
00348         PRIntervalTime timeout);
00349 #define _MD_ACCEPT                    _MD_Accept
00350 #define _MD_BIND                      _PR_MD_BIND
00351 #define _MD_RECV                      _PR_MD_RECV
00352 #define _MD_SEND                      _PR_MD_SEND
00353 #define _MD_PR_POLL                   _PR_MD_PR_POLL
00354 
00355 /* --- Scheduler stuff --- */
00356 // #define _MD_PAUSE_CPU                 _PR_MD_PAUSE_CPU
00357 #define _MD_PAUSE_CPU
00358 
00359 /* --- DIR stuff --- */
00360 #define PR_DIRECTORY_SEPARATOR        '\\'
00361 #define PR_DIRECTORY_SEPARATOR_STR    "\\"
00362 #define PR_PATH_SEPARATOR          ';'
00363 #define PR_PATH_SEPARATOR_STR             ";"
00364 #define _MD_ERRNO()                   GetLastError()
00365 #define _MD_OPEN_DIR                  _PR_MD_OPEN_DIR
00366 #define _MD_CLOSE_DIR                 _PR_MD_CLOSE_DIR
00367 #define _MD_READ_DIR                  _PR_MD_READ_DIR
00368 
00369 /* --- Segment stuff --- */
00370 #define _MD_INIT_SEGS()
00371 #define _MD_ALLOC_SEGMENT(seg, size, vaddr)   0
00372 #define _MD_FREE_SEGMENT(seg)
00373 
00374 /* --- Environment Stuff --- */
00375 #define _MD_GET_ENV                 _PR_MD_GET_ENV
00376 #define _MD_PUT_ENV                 _PR_MD_PUT_ENV
00377 
00378 /* --- Threading Stuff --- */
00379 #define _MD_DEFAULT_STACK_SIZE            0
00380 #define _MD_INIT_THREAD             _PR_MD_INIT_THREAD
00381 #define _MD_INIT_ATTACHED_THREAD    _PR_MD_INIT_THREAD
00382 #define _MD_CREATE_THREAD           _PR_MD_CREATE_THREAD
00383 #define _MD_YIELD                   _PR_MD_YIELD
00384 #define _MD_SET_PRIORITY            _PR_MD_SET_PRIORITY
00385 #define _MD_CLEAN_THREAD            _PR_MD_CLEAN_THREAD
00386 #define _MD_SETTHREADAFFINITYMASK   _PR_MD_SETTHREADAFFINITYMASK
00387 #define _MD_GETTHREADAFFINITYMASK   _PR_MD_GETTHREADAFFINITYMASK
00388 #define _MD_EXIT_THREAD             _PR_MD_EXIT_THREAD
00389 #define _MD_EXIT                    _PR_MD_EXIT
00390 #define _MD_SUSPEND_THREAD          _PR_MD_SUSPEND_THREAD
00391 #define _MD_RESUME_THREAD           _PR_MD_RESUME_THREAD
00392 #define _MD_SUSPEND_CPU             _PR_MD_SUSPEND_CPU
00393 #define _MD_RESUME_CPU              _PR_MD_RESUME_CPU
00394 #define _MD_BEGIN_SUSPEND_ALL()
00395 #define _MD_BEGIN_RESUME_ALL()
00396 #define _MD_END_SUSPEND_ALL()
00397 #define _MD_END_RESUME_ALL()
00398 
00399 /* --- Lock stuff --- */
00400 #define _PR_LOCK                      _MD_LOCK
00401 #define _PR_UNLOCK                                 _MD_UNLOCK
00402 
00403 #define _MD_NEW_LOCK(lock)            (InitializeCriticalSection(&((lock)->mutex)),(lock)->notified.length=0,(lock)->notified.link=NULL,PR_SUCCESS)
00404 #define _MD_FREE_LOCK(lock)           DeleteCriticalSection(&((lock)->mutex))
00405 #define _MD_LOCK(lock)                EnterCriticalSection(&((lock)->mutex))
00406 #define _MD_TEST_AND_LOCK(lock)       (EnterCriticalSection(&((lock)->mutex)),0)
00407 #define _MD_UNLOCK                    _PR_MD_UNLOCK
00408 
00409 /* --- lock and cv waiting --- */
00410 #define _MD_WAIT                      _PR_MD_WAIT
00411 #define _MD_WAKEUP_WAITER             _PR_MD_WAKEUP_WAITER
00412 
00413 /* --- CVar ------------------- */
00414 #define _MD_WAIT_CV                                _PR_MD_WAIT_CV
00415 #define _MD_NEW_CV                                 _PR_MD_NEW_CV
00416 #define _MD_FREE_CV                                _PR_MD_FREE_CV
00417 #define _MD_NOTIFY_CV                              _PR_MD_NOTIFY_CV   
00418 #define _MD_NOTIFYALL_CV                    _PR_MD_NOTIFYALL_CV
00419 
00420    /* XXXMB- the IOQ stuff is certainly not working correctly yet. */
00421 // extern  struct _MDLock              _pr_ioq_lock;
00422 #define _MD_IOQ_LOCK()                
00423 #define _MD_IOQ_UNLOCK()              
00424 
00425 
00426 /* --- Initialization stuff --- */
00427 #define _MD_START_INTERRUPTS()
00428 #define _MD_STOP_INTERRUPTS()
00429 #define _MD_DISABLE_CLOCK_INTERRUPTS()
00430 #define _MD_ENABLE_CLOCK_INTERRUPTS()
00431 #define _MD_BLOCK_CLOCK_INTERRUPTS()
00432 #define _MD_UNBLOCK_CLOCK_INTERRUPTS()
00433 #define _MD_EARLY_INIT                _PR_MD_EARLY_INIT
00434 #define _MD_FINAL_INIT()
00435 #define _MD_INIT_CPUS()
00436 #define _MD_INIT_RUNNING_CPU(cpu)
00437 
00438 struct PRProcess;
00439 struct PRProcessAttr;
00440 
00441 #define _MD_CREATE_PROCESS _PR_CreateWindowsProcess
00442 extern struct PRProcess * _PR_CreateWindowsProcess(
00443     const char *path,
00444     char *const *argv,
00445     char *const *envp,
00446     const struct PRProcessAttr *attr
00447 );
00448 
00449 #define _MD_DETACH_PROCESS _PR_DetachWindowsProcess
00450 extern PRStatus _PR_DetachWindowsProcess(struct PRProcess *process);
00451 
00452 /* --- Wait for a child process to terminate --- */
00453 #define _MD_WAIT_PROCESS _PR_WaitWindowsProcess
00454 extern PRStatus _PR_WaitWindowsProcess(struct PRProcess *process, 
00455     PRInt32 *exitCode);
00456 
00457 #define _MD_KILL_PROCESS _PR_KillWindowsProcess
00458 extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process);
00459 
00460 #define _MD_CLEANUP_BEFORE_EXIT           _PR_MD_CLEANUP_BEFORE_EXIT
00461 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
00462     PR_BEGIN_MACRO \
00463     *status = PR_TRUE; \
00464     PR_END_MACRO
00465 #define _MD_SWITCH_CONTEXT
00466 #define _MD_RESTORE_CONTEXT
00467 
00468 /* --- Intervals --- */
00469 #define _MD_INTERVAL_INIT                 _PR_MD_INTERVAL_INIT
00470 #define _MD_GET_INTERVAL                  _PR_MD_GET_INTERVAL
00471 #define _MD_INTERVAL_PER_SEC              _PR_MD_INTERVAL_PER_SEC
00472 #define _MD_INTERVAL_PER_MILLISEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000)
00473 #define _MD_INTERVAL_PER_MICROSEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000000)
00474 
00475 /* --- Time --- */
00476 extern void _PR_FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm);
00477 
00478 /* --- Native-Thread Specific Definitions ------------------------------- */
00479 
00480 extern struct PRThread * _MD_CURRENT_THREAD(void);
00481 
00482 #ifdef _PR_USE_STATIC_TLS
00483 extern __declspec(thread) struct PRThread *_pr_currentThread;
00484 #define _MD_GET_ATTACHED_THREAD() _pr_currentThread
00485 #define _MD_SET_CURRENT_THREAD(_thread) (_pr_currentThread = (_thread))
00486 
00487 extern __declspec(thread) struct PRThread *_pr_thread_last_run;
00488 #define _MD_LAST_THREAD() _pr_thread_last_run
00489 #define _MD_SET_LAST_THREAD(_thread) (_pr_thread_last_run = 0)
00490 
00491 extern __declspec(thread) struct _PRCPU *_pr_currentCPU;
00492 #define _MD_CURRENT_CPU() _pr_currentCPU
00493 #define _MD_SET_CURRENT_CPU(_cpu) (_pr_currentCPU = 0)
00494 #else /* _PR_USE_STATIC_TLS */
00495 extern DWORD _pr_currentThreadIndex;
00496 #define _MD_GET_ATTACHED_THREAD() ((PRThread *) TlsGetValue(_pr_currentThreadIndex))
00497 #define _MD_SET_CURRENT_THREAD(_thread) TlsSetValue(_pr_currentThreadIndex, (_thread))
00498 
00499 extern DWORD _pr_lastThreadIndex;
00500 #define _MD_LAST_THREAD() ((PRThread *) TlsGetValue(_pr_lastThreadIndex))
00501 #define _MD_SET_LAST_THREAD(_thread) TlsSetValue(_pr_lastThreadIndex, 0)
00502 
00503 extern DWORD _pr_currentCPUIndex;
00504 #define _MD_CURRENT_CPU() ((struct _PRCPU *) TlsGetValue(_pr_currentCPUIndex))
00505 #define _MD_SET_CURRENT_CPU(_cpu) TlsSetValue(_pr_currentCPUIndex, 0)
00506 #endif /* _PR_USE_STATIC_TLS */
00507 
00508 /* --- Scheduler stuff --- */
00509 #define LOCK_SCHEDULER()                 0
00510 #define UNLOCK_SCHEDULER()               0
00511 #define _PR_LockSched()                    0
00512 #define _PR_UnlockSched()                0
00513 
00514 /* --- Initialization stuff --- */
00515 #define _MD_INIT_LOCKS()
00516 
00517 /* --- Stack stuff --- */
00518 #define _MD_INIT_STACK(stack, redzone)
00519 #define _MD_CLEAR_STACK(stack)
00520 
00521 /* --- Memory-mapped files stuff --- */
00522 
00523 struct _MDFileMap {
00524     HANDLE hFileMap;
00525     DWORD dwAccess;
00526 };
00527 
00528 extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
00529 #define _MD_CREATE_FILE_MAP _MD_CreateFileMap
00530 
00531 extern PRInt32 _MD_GetMemMapAlignment(void);
00532 #define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment
00533 
00534 extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,
00535         PRUint32 len);
00536 #define _MD_MEM_MAP _MD_MemMap
00537 
00538 extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);
00539 #define _MD_MEM_UNMAP _MD_MemUnmap
00540 
00541 extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
00542 #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
00543 
00544 /* --- Named semaphores stuff --- */
00545 #define _PR_HAVE_NAMED_SEMAPHORES
00546 #define _MD_OPEN_SEMAPHORE            _PR_MD_OPEN_SEMAPHORE
00547 #define _MD_WAIT_SEMAPHORE            _PR_MD_WAIT_SEMAPHORE
00548 #define _MD_POST_SEMAPHORE            _PR_MD_POST_SEMAPHORE
00549 #define _MD_CLOSE_SEMAPHORE           _PR_MD_CLOSE_SEMAPHORE
00550 #define _MD_DELETE_SEMAPHORE(name)    PR_SUCCESS  /* no op */
00551 
00552 #endif /* nspr_win32_defs_h___ */