nsprpub/pr/include/md/_win95.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/include/md/_win95.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,544 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nspr_win95_defs_h___
    1.10 +#define nspr_win95_defs_h___
    1.11 +
    1.12 +#include "prio.h"
    1.13 +
    1.14 +#include <windows.h>
    1.15 +#include <winsock.h>
    1.16 +#include <errno.h>
    1.17 +
    1.18 +/*
    1.19 + * Internal configuration macros
    1.20 + */
    1.21 +
    1.22 +#define PR_LINKER_ARCH      "win32"
    1.23 +#define _PR_SI_SYSNAME        "WIN95"
    1.24 +#if defined(_M_IX86) || defined(_X86_)
    1.25 +#define _PR_SI_ARCHITECTURE   "x86"
    1.26 +#elif defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)
    1.27 +#define _PR_SI_ARCHITECTURE   "x86-64"
    1.28 +#elif defined(_M_IA64) || defined(_IA64_)
    1.29 +#define _PR_SI_ARCHITECTURE   "ia64"
    1.30 +#elif defined(_M_ARM) || defined(_ARM_)
    1.31 +#define _PR_SI_ARCHITECTURE   "arm"
    1.32 +#else
    1.33 +#error unknown processor architecture
    1.34 +#endif
    1.35 +
    1.36 +#define HAVE_DLL
    1.37 +#undef  HAVE_THREAD_AFFINITY
    1.38 +#define _PR_HAVE_GETADDRINFO
    1.39 +#define _PR_INET6_PROBE
    1.40 +#ifndef _PR_INET6
    1.41 +#define AF_INET6 23
    1.42 +/* newer ws2tcpip.h provides these */
    1.43 +#ifndef AI_CANONNAME
    1.44 +#define AI_CANONNAME 0x2
    1.45 +#define AI_NUMERICHOST 0x4
    1.46 +#define NI_NUMERICHOST 0x02
    1.47 +struct addrinfo {
    1.48 +    int ai_flags;
    1.49 +    int ai_family;
    1.50 +    int ai_socktype;
    1.51 +    int ai_protocol;
    1.52 +    size_t ai_addrlen;
    1.53 +    char *ai_canonname;
    1.54 +    struct sockaddr *ai_addr;
    1.55 +    struct addrinfo *ai_next;
    1.56 +};
    1.57 +#endif
    1.58 +#define _PR_HAVE_MD_SOCKADDR_IN6
    1.59 +/* isomorphic to struct in6_addr on Windows */
    1.60 +struct _md_in6_addr {
    1.61 +    union {
    1.62 +        PRUint8  _S6_u8[16];
    1.63 +        PRUint16 _S6_u16[8];
    1.64 +    } _S6_un;
    1.65 +};
    1.66 +/* isomorphic to struct sockaddr_in6 on Windows */
    1.67 +struct _md_sockaddr_in6 {
    1.68 +    PRInt16 sin6_family;
    1.69 +    PRUint16 sin6_port;
    1.70 +    PRUint32 sin6_flowinfo;
    1.71 +    struct _md_in6_addr sin6_addr;
    1.72 +    PRUint32 sin6_scope_id;
    1.73 +};
    1.74 +#endif
    1.75 +#define _PR_HAVE_THREADSAFE_GETHOST
    1.76 +#define _PR_HAVE_ATOMIC_OPS
    1.77 +#define PR_HAVE_WIN32_NAMED_SHARED_MEMORY
    1.78 +
    1.79 +/* --- Common User-Thread/Native-Thread Definitions --------------------- */
    1.80 +
    1.81 +/* --- Globals --- */
    1.82 +extern struct PRLock                      *_pr_schedLock;
    1.83 +
    1.84 +/* --- Typedefs --- */
    1.85 +typedef void (*FiberFunc)(void *);
    1.86 +
    1.87 +#define PR_NUM_GCREGS           8
    1.88 +typedef PRInt32	                PR_CONTEXT_TYPE[PR_NUM_GCREGS];
    1.89 +#define GC_VMBASE               0x40000000
    1.90 +#define GC_VMLIMIT              0x00FFFFFF
    1.91 +
    1.92 +#define _MD_MAGIC_THREAD	0x22222222
    1.93 +#define _MD_MAGIC_THREADSTACK	0x33333333
    1.94 +#define _MD_MAGIC_SEGMENT	0x44444444
    1.95 +#define _MD_MAGIC_DIR		0x55555555
    1.96 +#define _MD_MAGIC_CV        0x66666666
    1.97 +
    1.98 +struct _MDCPU {
    1.99 +    int              unused;
   1.100 +};
   1.101 +
   1.102 +struct _MDThread {
   1.103 +    HANDLE           blocked_sema;      /* Threads block on this when waiting
   1.104 +                                         * for IO or CondVar.
   1.105 +                                         */
   1.106 +    PRBool           inCVWaitQueue;     /* PR_TRUE if the thread is in the
   1.107 +                                         * wait queue of some cond var.
   1.108 +                                         * PR_FALSE otherwise.  */
   1.109 +    HANDLE           handle;            /* Win32 thread handle */
   1.110 +    PRUint32         id;
   1.111 +    void            *sp;                /* only valid when suspended */
   1.112 +    PRUint32         magic;             /* for debugging */
   1.113 +    PR_CONTEXT_TYPE  gcContext;         /* Thread context for GC */
   1.114 +    struct PRThread *prev, *next;       /* used by the cvar wait queue to
   1.115 +                                         * chain the PRThread structures
   1.116 +                                         * together */
   1.117 +    void (*start)(void *);              /* used by _PR_MD_CREATE_THREAD to
   1.118 +                                         * pass its 'start' argument to
   1.119 +                                         * pr_root. */
   1.120 +};
   1.121 +
   1.122 +struct _MDThreadStack {
   1.123 +    PRUint32           magic;          /* for debugging */
   1.124 +};
   1.125 +
   1.126 +struct _MDSegment {
   1.127 +    PRUint32           magic;          /* for debugging */
   1.128 +};
   1.129 +
   1.130 +#undef PROFILE_LOCKS
   1.131 +
   1.132 +struct _MDDir {
   1.133 +    HANDLE           d_hdl;
   1.134 +    WIN32_FIND_DATAA d_entry;
   1.135 +    PRBool           firstEntry;     /* Is this the entry returned
   1.136 +                                      * by FindFirstFile()? */
   1.137 +    PRUint32         magic;          /* for debugging */
   1.138 +};
   1.139 +
   1.140 +#ifdef MOZ_UNICODE
   1.141 +struct _MDDirUTF16 {
   1.142 +    HANDLE           d_hdl;
   1.143 +    WIN32_FIND_DATAW d_entry;
   1.144 +    PRBool           firstEntry;     /* Is this the entry returned
   1.145 +                                      * by FindFirstFileW()? */
   1.146 +    PRUint32         magic;          /* for debugging */
   1.147 +};
   1.148 +#endif /* MOZ_UNICODE */
   1.149 +
   1.150 +struct _MDCVar {
   1.151 +    PRUint32 magic;
   1.152 +    struct PRThread *waitHead, *waitTail;  /* the wait queue: a doubly-
   1.153 +                                            * linked list of threads
   1.154 +                                            * waiting on this condition
   1.155 +                                            * variable */
   1.156 +    PRIntn nwait;                          /* number of threads in the
   1.157 +                                            * wait queue */
   1.158 +};
   1.159 +
   1.160 +#define _MD_CV_NOTIFIED_LENGTH 6
   1.161 +typedef struct _MDNotified _MDNotified;
   1.162 +struct _MDNotified {
   1.163 +    PRIntn length;                     /* # of used entries in this
   1.164 +                                        * structure */
   1.165 +    struct {
   1.166 +        struct _MDCVar *cv;            /* the condition variable notified */
   1.167 +        PRIntn times;                  /* and the number of times notified */
   1.168 +        struct PRThread *notifyHead;   /* list of threads to wake up */
   1.169 +    } cv[_MD_CV_NOTIFIED_LENGTH];
   1.170 +    _MDNotified *link;                 /* link to another of these, or NULL */
   1.171 +};
   1.172 +
   1.173 +struct _MDLock {
   1.174 +    CRITICAL_SECTION mutex;          /* this is recursive on NT */
   1.175 +
   1.176 +    /*
   1.177 +     * When notifying cvars, there is no point in actually
   1.178 +     * waking up the threads waiting on the cvars until we've
   1.179 +     * released the lock.  So, we temporarily record the cvars.
   1.180 +     * When doing an unlock, we'll then wake up the waiting threads.
   1.181 +     */
   1.182 +    struct _MDNotified notified;     /* array of conditions notified */
   1.183 +#ifdef PROFILE_LOCKS
   1.184 +    PRInt32 hitcount;
   1.185 +    PRInt32 misscount;
   1.186 +#endif
   1.187 +};
   1.188 +
   1.189 +struct _MDSemaphore {
   1.190 +    HANDLE           sem;
   1.191 +};
   1.192 +
   1.193 +struct _MDFileDesc {
   1.194 +    PROsfd osfd;     /* The osfd can come from one of three spaces:
   1.195 +                      * - For stdin, stdout, and stderr, we are using
   1.196 +                      *   the libc file handle (0, 1, 2), which is an int.
   1.197 +                      * - For files and pipes, we are using Win32 HANDLE,
   1.198 +                      *   which is a void*.
   1.199 +                      * - For sockets, we are using Winsock SOCKET, which
   1.200 +                      *   is a u_int.
   1.201 +                      */
   1.202 +};
   1.203 +
   1.204 +struct _MDProcess {
   1.205 +    HANDLE handle;
   1.206 +    DWORD id;
   1.207 +};
   1.208 +
   1.209 +/* --- Misc stuff --- */
   1.210 +#define _MD_GET_SP(thread)            (thread)->md.gcContext[6]
   1.211 +
   1.212 +/* --- NT security stuff --- */
   1.213 +
   1.214 +extern void _PR_NT_InitSids(void);
   1.215 +extern void _PR_NT_FreeSids(void);
   1.216 +extern PRStatus _PR_NT_MakeSecurityDescriptorACL(
   1.217 +    PRIntn mode,
   1.218 +    DWORD accessTable[],
   1.219 +    PSECURITY_DESCRIPTOR *resultSD,
   1.220 +    PACL *resultACL
   1.221 +);
   1.222 +extern void _PR_NT_FreeSecurityDescriptorACL(
   1.223 +    PSECURITY_DESCRIPTOR pSD, PACL pACL);
   1.224 +
   1.225 +/* --- IO stuff --- */
   1.226 +
   1.227 +#define _MD_OPEN                      _PR_MD_OPEN
   1.228 +#define _MD_OPEN_FILE                 _PR_MD_OPEN_FILE
   1.229 +#define _MD_READ                      _PR_MD_READ
   1.230 +#define _MD_WRITE                     _PR_MD_WRITE
   1.231 +#define _MD_WRITEV                    _PR_MD_WRITEV
   1.232 +#define _MD_LSEEK                     _PR_MD_LSEEK
   1.233 +#define _MD_LSEEK64                   _PR_MD_LSEEK64
   1.234 +extern PRInt32 _MD_CloseFile(PROsfd osfd);
   1.235 +#define _MD_CLOSE_FILE                _MD_CloseFile
   1.236 +#define _MD_GETFILEINFO               _PR_MD_GETFILEINFO
   1.237 +#define _MD_GETFILEINFO64             _PR_MD_GETFILEINFO64
   1.238 +#define _MD_GETOPENFILEINFO           _PR_MD_GETOPENFILEINFO
   1.239 +#define _MD_GETOPENFILEINFO64         _PR_MD_GETOPENFILEINFO64
   1.240 +#define _MD_STAT                      _PR_MD_STAT
   1.241 +#define _MD_RENAME                    _PR_MD_RENAME     
   1.242 +#define _MD_ACCESS                    _PR_MD_ACCESS     
   1.243 +#define _MD_DELETE                    _PR_MD_DELETE     
   1.244 +#define _MD_MKDIR                     _PR_MD_MKDIR      
   1.245 +#define _MD_MAKE_DIR                  _PR_MD_MAKE_DIR
   1.246 +#define _MD_RMDIR                     _PR_MD_RMDIR      
   1.247 +#define _MD_LOCKFILE                  _PR_MD_LOCKFILE
   1.248 +#define _MD_TLOCKFILE                 _PR_MD_TLOCKFILE
   1.249 +#define _MD_UNLOCKFILE                _PR_MD_UNLOCKFILE
   1.250 +
   1.251 +/* --- UTF16 IO stuff --- */
   1.252 +#ifdef MOZ_UNICODE
   1.253 +#define _MD_OPEN_FILE_UTF16           _PR_MD_OPEN_FILE_UTF16
   1.254 +#define _MD_OPEN_DIR_UTF16            _PR_MD_OPEN_DIR_UTF16
   1.255 +#define _MD_READ_DIR_UTF16            _PR_MD_READ_DIR_UTF16
   1.256 +#define _MD_CLOSE_DIR_UTF16           _PR_MD_CLOSE_DIR_UTF16
   1.257 +#define _MD_GETFILEINFO64_UTF16       _PR_MD_GETFILEINFO64_UTF16
   1.258 +#endif /* MOZ_UNICODE */
   1.259 +
   1.260 +/* --- Socket IO stuff --- */
   1.261 +extern void _PR_MD_InitSockets(void);
   1.262 +extern void _PR_MD_CleanupSockets(void);
   1.263 +#define _MD_EACCES                WSAEACCES
   1.264 +#define _MD_EADDRINUSE            WSAEADDRINUSE
   1.265 +#define _MD_EADDRNOTAVAIL         WSAEADDRNOTAVAIL
   1.266 +#define _MD_EAFNOSUPPORT          WSAEAFNOSUPPORT
   1.267 +#define _MD_EAGAIN                WSAEWOULDBLOCK
   1.268 +#define _MD_EALREADY              WSAEALREADY
   1.269 +#define _MD_EBADF                 WSAEBADF
   1.270 +#define _MD_ECONNREFUSED          WSAECONNREFUSED
   1.271 +#define _MD_ECONNRESET            WSAECONNRESET
   1.272 +#define _MD_EFAULT                WSAEFAULT
   1.273 +#define _MD_EINPROGRESS           WSAEINPROGRESS
   1.274 +#define _MD_EINTR                 WSAEINTR
   1.275 +#define _MD_EINVAL                EINVAL
   1.276 +#define _MD_EISCONN               WSAEISCONN
   1.277 +#define _MD_ENETUNREACH           WSAENETUNREACH
   1.278 +#define _MD_ENOENT                ENOENT
   1.279 +#define _MD_ENOTCONN              WSAENOTCONN
   1.280 +#define _MD_ENOTSOCK              WSAENOTSOCK
   1.281 +#define _MD_EOPNOTSUPP            WSAEOPNOTSUPP
   1.282 +#define _MD_EWOULDBLOCK           WSAEWOULDBLOCK
   1.283 +#define _MD_GET_SOCKET_ERROR()    WSAGetLastError()
   1.284 +#define _MD_SET_SOCKET_ERROR(_err) WSASetLastError(_err)
   1.285 +
   1.286 +#define _MD_INIT_FILEDESC(fd)
   1.287 +extern void _MD_MakeNonblock(PRFileDesc *f);
   1.288 +#define _MD_MAKE_NONBLOCK             _MD_MakeNonblock
   1.289 +#define _MD_INIT_FD_INHERITABLE       _PR_MD_INIT_FD_INHERITABLE
   1.290 +#define _MD_QUERY_FD_INHERITABLE      _PR_MD_QUERY_FD_INHERITABLE
   1.291 +#define _MD_SHUTDOWN                  _PR_MD_SHUTDOWN
   1.292 +#define _MD_LISTEN                    _PR_MD_LISTEN
   1.293 +extern PRInt32 _MD_CloseSocket(PROsfd osfd);
   1.294 +#define _MD_CLOSE_SOCKET              _MD_CloseSocket
   1.295 +#define _MD_SENDTO                    _PR_MD_SENDTO
   1.296 +#define _MD_RECVFROM                  _PR_MD_RECVFROM
   1.297 +#define _MD_SOCKETPAIR(s, type, proto, sv) -1
   1.298 +#define _MD_GETSOCKNAME               _PR_MD_GETSOCKNAME
   1.299 +#define _MD_GETPEERNAME               _PR_MD_GETPEERNAME
   1.300 +#define _MD_GETSOCKOPT                _PR_MD_GETSOCKOPT
   1.301 +#define _MD_SETSOCKOPT                _PR_MD_SETSOCKOPT
   1.302 +#define _MD_SET_FD_INHERITABLE        _PR_MD_SET_FD_INHERITABLE
   1.303 +#define _MD_SELECT                    select
   1.304 +#define _MD_FSYNC                     _PR_MD_FSYNC
   1.305 +#define READ_FD                       1
   1.306 +#define WRITE_FD                      2
   1.307 +
   1.308 +#define _MD_INIT_ATOMIC()
   1.309 +#if defined(_M_IX86) || defined(_X86_)
   1.310 +#define _MD_ATOMIC_INCREMENT          _PR_MD_ATOMIC_INCREMENT
   1.311 +#define _MD_ATOMIC_ADD          	  _PR_MD_ATOMIC_ADD
   1.312 +#define _MD_ATOMIC_DECREMENT          _PR_MD_ATOMIC_DECREMENT
   1.313 +#else /* non-x86 processors */
   1.314 +#define _MD_ATOMIC_INCREMENT(x)       InterlockedIncrement((PLONG)x)
   1.315 +#define _MD_ATOMIC_ADD(ptr,val)    (InterlockedExchangeAdd((PLONG)ptr, (LONG)val) + val)
   1.316 +#define _MD_ATOMIC_DECREMENT(x)       InterlockedDecrement((PLONG)x)
   1.317 +#endif /* x86 */
   1.318 +#define _MD_ATOMIC_SET(x,y)           InterlockedExchange((PLONG)x, (LONG)y)
   1.319 +
   1.320 +#define _MD_INIT_IO                   _PR_MD_INIT_IO
   1.321 +
   1.322 +
   1.323 +/* win95 doesn't have async IO */
   1.324 +#define _MD_SOCKET                    _PR_MD_SOCKET
   1.325 +extern PRInt32 _MD_SocketAvailable(PRFileDesc *fd);
   1.326 +#define _MD_SOCKETAVAILABLE           _MD_SocketAvailable
   1.327 +#define _MD_PIPEAVAILABLE             _PR_MD_PIPEAVAILABLE
   1.328 +#define _MD_CONNECT                   _PR_MD_CONNECT
   1.329 +extern PROsfd _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen,
   1.330 +        PRIntervalTime timeout);
   1.331 +#define _MD_ACCEPT                    _MD_Accept
   1.332 +#define _MD_BIND                      _PR_MD_BIND
   1.333 +#define _MD_RECV                      _PR_MD_RECV
   1.334 +#define _MD_SEND                      _PR_MD_SEND
   1.335 +#define _MD_PR_POLL                   _PR_MD_PR_POLL
   1.336 +
   1.337 +/* --- Scheduler stuff --- */
   1.338 +// #define _MD_PAUSE_CPU                 _PR_MD_PAUSE_CPU
   1.339 +#define _MD_PAUSE_CPU
   1.340 +
   1.341 +/* --- DIR stuff --- */
   1.342 +#define PR_DIRECTORY_SEPARATOR        '\\'
   1.343 +#define PR_DIRECTORY_SEPARATOR_STR    "\\"
   1.344 +#define PR_PATH_SEPARATOR		';'
   1.345 +#define PR_PATH_SEPARATOR_STR		";"
   1.346 +#define _MD_ERRNO()                   GetLastError()
   1.347 +#define _MD_OPEN_DIR                  _PR_MD_OPEN_DIR
   1.348 +#define _MD_CLOSE_DIR                 _PR_MD_CLOSE_DIR
   1.349 +#define _MD_READ_DIR                  _PR_MD_READ_DIR
   1.350 +
   1.351 +/* --- Segment stuff --- */
   1.352 +#define _MD_INIT_SEGS()
   1.353 +#define _MD_ALLOC_SEGMENT(seg, size, vaddr)   0
   1.354 +#define _MD_FREE_SEGMENT(seg)
   1.355 +
   1.356 +/* --- Environment Stuff --- */
   1.357 +#define _MD_GET_ENV                 _PR_MD_GET_ENV
   1.358 +#define _MD_PUT_ENV                 _PR_MD_PUT_ENV
   1.359 +
   1.360 +/* --- Threading Stuff --- */
   1.361 +#define _MD_DEFAULT_STACK_SIZE            0
   1.362 +#define _MD_INIT_THREAD             _PR_MD_INIT_THREAD
   1.363 +#define _MD_INIT_ATTACHED_THREAD    _PR_MD_INIT_THREAD
   1.364 +#define _MD_CREATE_THREAD           _PR_MD_CREATE_THREAD
   1.365 +#define _MD_YIELD                   _PR_MD_YIELD
   1.366 +#define _MD_SET_PRIORITY            _PR_MD_SET_PRIORITY
   1.367 +#define _MD_SET_CURRENT_THREAD_NAME _PR_MD_SET_CURRENT_THREAD_NAME
   1.368 +#define _MD_CLEAN_THREAD            _PR_MD_CLEAN_THREAD
   1.369 +#define _MD_SETTHREADAFFINITYMASK   _PR_MD_SETTHREADAFFINITYMASK
   1.370 +#define _MD_GETTHREADAFFINITYMASK   _PR_MD_GETTHREADAFFINITYMASK
   1.371 +#define _MD_EXIT_THREAD             _PR_MD_EXIT_THREAD
   1.372 +#define _MD_EXIT                    _PR_MD_EXIT
   1.373 +#define _MD_SUSPEND_THREAD          _PR_MD_SUSPEND_THREAD
   1.374 +#define _MD_RESUME_THREAD           _PR_MD_RESUME_THREAD
   1.375 +#define _MD_SUSPEND_CPU             _PR_MD_SUSPEND_CPU
   1.376 +#define _MD_RESUME_CPU              _PR_MD_RESUME_CPU
   1.377 +#define _MD_BEGIN_SUSPEND_ALL()
   1.378 +#define _MD_BEGIN_RESUME_ALL()
   1.379 +#define _MD_END_SUSPEND_ALL()
   1.380 +#define _MD_END_RESUME_ALL()
   1.381 +
   1.382 +/* --- Lock stuff --- */
   1.383 +#define _PR_LOCK                      _MD_LOCK
   1.384 +#define _PR_UNLOCK                    _MD_UNLOCK
   1.385 +
   1.386 +#define _MD_NEW_LOCK                  _PR_MD_NEW_LOCK
   1.387 +#define _MD_FREE_LOCK(lock)           DeleteCriticalSection(&((lock)->mutex))
   1.388 +#define _MD_LOCK(lock)                EnterCriticalSection(&((lock)->mutex))
   1.389 +#define _MD_TEST_AND_LOCK(lock)       (EnterCriticalSection(&((lock)->mutex)),0)
   1.390 +#define _MD_UNLOCK                    _PR_MD_UNLOCK
   1.391 +
   1.392 +/* --- lock and cv waiting --- */
   1.393 +#define _MD_WAIT                      _PR_MD_WAIT
   1.394 +#define _MD_WAKEUP_WAITER             _PR_MD_WAKEUP_WAITER
   1.395 +
   1.396 +/* --- CVar ------------------- */
   1.397 +#define _MD_WAIT_CV					  _PR_MD_WAIT_CV
   1.398 +#define _MD_NEW_CV					  _PR_MD_NEW_CV
   1.399 +#define _MD_FREE_CV					  _PR_MD_FREE_CV
   1.400 +#define _MD_NOTIFY_CV				  _PR_MD_NOTIFY_CV	
   1.401 +#define _MD_NOTIFYALL_CV			  _PR_MD_NOTIFYALL_CV
   1.402 +
   1.403 +   /* XXXMB- the IOQ stuff is certainly not working correctly yet. */
   1.404 +// extern  struct _MDLock              _pr_ioq_lock;
   1.405 +#define _MD_IOQ_LOCK()                
   1.406 +#define _MD_IOQ_UNLOCK()              
   1.407 +
   1.408 +
   1.409 +/* --- Initialization stuff --- */
   1.410 +#define _MD_START_INTERRUPTS()
   1.411 +#define _MD_STOP_INTERRUPTS()
   1.412 +#define _MD_DISABLE_CLOCK_INTERRUPTS()
   1.413 +#define _MD_ENABLE_CLOCK_INTERRUPTS()
   1.414 +#define _MD_BLOCK_CLOCK_INTERRUPTS()
   1.415 +#define _MD_UNBLOCK_CLOCK_INTERRUPTS()
   1.416 +#define _MD_EARLY_INIT                _PR_MD_EARLY_INIT
   1.417 +#define _MD_FINAL_INIT()
   1.418 +#define _MD_EARLY_CLEANUP()
   1.419 +#define _MD_INIT_CPUS()
   1.420 +#define _MD_INIT_RUNNING_CPU(cpu)
   1.421 +
   1.422 +struct PRProcess;
   1.423 +struct PRProcessAttr;
   1.424 +
   1.425 +#define _MD_CREATE_PROCESS _PR_CreateWindowsProcess
   1.426 +extern struct PRProcess * _PR_CreateWindowsProcess(
   1.427 +    const char *path,
   1.428 +    char *const *argv,
   1.429 +    char *const *envp,
   1.430 +    const struct PRProcessAttr *attr
   1.431 +);
   1.432 +
   1.433 +#define _MD_DETACH_PROCESS _PR_DetachWindowsProcess
   1.434 +extern PRStatus _PR_DetachWindowsProcess(struct PRProcess *process);
   1.435 +
   1.436 +/* --- Wait for a child process to terminate --- */
   1.437 +#define _MD_WAIT_PROCESS _PR_WaitWindowsProcess
   1.438 +extern PRStatus _PR_WaitWindowsProcess(struct PRProcess *process, 
   1.439 +    PRInt32 *exitCode);
   1.440 +
   1.441 +#define _MD_KILL_PROCESS _PR_KillWindowsProcess
   1.442 +extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process);
   1.443 +
   1.444 +#define _MD_CLEANUP_BEFORE_EXIT           _PR_MD_CLEANUP_BEFORE_EXIT
   1.445 +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
   1.446 +    PR_BEGIN_MACRO \
   1.447 +    *status = PR_TRUE; \
   1.448 +    PR_END_MACRO
   1.449 +#define _MD_SWITCH_CONTEXT
   1.450 +#define _MD_RESTORE_CONTEXT
   1.451 +
   1.452 +/* --- Intervals --- */
   1.453 +#define _MD_INTERVAL_INIT                 _PR_MD_INTERVAL_INIT
   1.454 +#define _MD_GET_INTERVAL                  _PR_MD_GET_INTERVAL
   1.455 +#define _MD_INTERVAL_PER_SEC              _PR_MD_INTERVAL_PER_SEC
   1.456 +#define _MD_INTERVAL_PER_MILLISEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000)
   1.457 +#define _MD_INTERVAL_PER_MICROSEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000000)
   1.458 +
   1.459 +/* --- Time --- */
   1.460 +extern void _PR_FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm);
   1.461 +
   1.462 +#ifdef WINCE
   1.463 +extern void _MD_InitTime(void);
   1.464 +extern void _MD_CleanupTime(void);
   1.465 +#endif
   1.466 +
   1.467 +/* --- Native-Thread Specific Definitions ------------------------------- */
   1.468 +
   1.469 +extern struct PRThread * _MD_CURRENT_THREAD(void);
   1.470 +
   1.471 +#ifdef _PR_USE_STATIC_TLS
   1.472 +extern __declspec(thread) struct PRThread *_pr_currentThread;
   1.473 +#define _MD_GET_ATTACHED_THREAD() _pr_currentThread
   1.474 +#define _MD_SET_CURRENT_THREAD(_thread) (_pr_currentThread = (_thread))
   1.475 +
   1.476 +extern __declspec(thread) struct PRThread *_pr_thread_last_run;
   1.477 +#define _MD_LAST_THREAD() _pr_thread_last_run
   1.478 +#define _MD_SET_LAST_THREAD(_thread) (_pr_thread_last_run = 0)
   1.479 +
   1.480 +extern __declspec(thread) struct _PRCPU *_pr_currentCPU;
   1.481 +#define _MD_CURRENT_CPU() _pr_currentCPU
   1.482 +#define _MD_SET_CURRENT_CPU(_cpu) (_pr_currentCPU = 0)
   1.483 +#else /* _PR_USE_STATIC_TLS */
   1.484 +extern DWORD _pr_currentThreadIndex;
   1.485 +#define _MD_GET_ATTACHED_THREAD() ((PRThread *) TlsGetValue(_pr_currentThreadIndex))
   1.486 +#define _MD_SET_CURRENT_THREAD(_thread) TlsSetValue(_pr_currentThreadIndex, (_thread))
   1.487 +
   1.488 +extern DWORD _pr_lastThreadIndex;
   1.489 +#define _MD_LAST_THREAD() ((PRThread *) TlsGetValue(_pr_lastThreadIndex))
   1.490 +#define _MD_SET_LAST_THREAD(_thread) TlsSetValue(_pr_lastThreadIndex, 0)
   1.491 +
   1.492 +extern DWORD _pr_currentCPUIndex;
   1.493 +#define _MD_CURRENT_CPU() ((struct _PRCPU *) TlsGetValue(_pr_currentCPUIndex))
   1.494 +#define _MD_SET_CURRENT_CPU(_cpu) TlsSetValue(_pr_currentCPUIndex, 0)
   1.495 +#endif /* _PR_USE_STATIC_TLS */
   1.496 +
   1.497 +/* --- Scheduler stuff --- */
   1.498 +#define LOCK_SCHEDULER()                 0
   1.499 +#define UNLOCK_SCHEDULER()               0
   1.500 +#define _PR_LockSched()                	 0
   1.501 +#define _PR_UnlockSched()                0
   1.502 +
   1.503 +/* --- Initialization stuff --- */
   1.504 +#define _MD_INIT_LOCKS                   _PR_MD_INIT_LOCKS
   1.505 +
   1.506 +/* --- Stack stuff --- */
   1.507 +#define _MD_INIT_STACK(stack, redzone)
   1.508 +#define _MD_CLEAR_STACK(stack)
   1.509 +
   1.510 +/* --- Memory-mapped files stuff --- */
   1.511 +
   1.512 +struct _MDFileMap {
   1.513 +    HANDLE hFileMap;
   1.514 +    DWORD dwAccess;
   1.515 +};
   1.516 +
   1.517 +extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
   1.518 +#define _MD_CREATE_FILE_MAP _MD_CreateFileMap
   1.519 +
   1.520 +extern PRInt32 _MD_GetMemMapAlignment(void);
   1.521 +#define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment
   1.522 +
   1.523 +extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,
   1.524 +        PRUint32 len);
   1.525 +#define _MD_MEM_MAP _MD_MemMap
   1.526 +
   1.527 +extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);
   1.528 +#define _MD_MEM_UNMAP _MD_MemUnmap
   1.529 +
   1.530 +extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
   1.531 +#define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
   1.532 +
   1.533 +extern PRStatus _MD_SyncMemMap(
   1.534 +    PRFileDesc *fd,
   1.535 +    void *addr,
   1.536 +    PRUint32 len);
   1.537 +#define _MD_SYNC_MEM_MAP _MD_SyncMemMap
   1.538 +
   1.539 +/* --- Named semaphores stuff --- */
   1.540 +#define _PR_HAVE_NAMED_SEMAPHORES
   1.541 +#define _MD_OPEN_SEMAPHORE            _PR_MD_OPEN_SEMAPHORE
   1.542 +#define _MD_WAIT_SEMAPHORE            _PR_MD_WAIT_SEMAPHORE
   1.543 +#define _MD_POST_SEMAPHORE            _PR_MD_POST_SEMAPHORE
   1.544 +#define _MD_CLOSE_SEMAPHORE           _PR_MD_CLOSE_SEMAPHORE
   1.545 +#define _MD_DELETE_SEMAPHORE(name)    PR_SUCCESS  /* no op */
   1.546 +
   1.547 +#endif /* nspr_win32_defs_h___ */

mercurial