andre@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: #ifndef nspr_win95_defs_h___ andre@0: #define nspr_win95_defs_h___ andre@0: andre@0: #include "prio.h" andre@0: andre@0: #include andre@0: #include andre@0: #include andre@0: andre@0: /* andre@0: * Internal configuration macros andre@0: */ andre@0: andre@0: #define PR_LINKER_ARCH "win32" andre@0: #define _PR_SI_SYSNAME "WIN95" andre@0: #if defined(_M_IX86) || defined(_X86_) andre@0: #define _PR_SI_ARCHITECTURE "x86" andre@0: #elif defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_) andre@0: #define _PR_SI_ARCHITECTURE "x86-64" andre@0: #elif defined(_M_IA64) || defined(_IA64_) andre@0: #define _PR_SI_ARCHITECTURE "ia64" andre@0: #elif defined(_M_ARM) || defined(_ARM_) andre@0: #define _PR_SI_ARCHITECTURE "arm" andre@0: #else andre@0: #error unknown processor architecture andre@0: #endif andre@0: andre@0: #define HAVE_DLL andre@0: #undef HAVE_THREAD_AFFINITY andre@0: #ifndef _PR_INET6 andre@0: #define AF_INET6 23 andre@0: /* newer ws2tcpip.h provides these */ andre@0: #ifndef AI_CANONNAME andre@0: #define AI_CANONNAME 0x2 andre@0: #define AI_NUMERICHOST 0x4 andre@0: #define NI_NUMERICHOST 0x02 andre@0: struct addrinfo { andre@0: int ai_flags; andre@0: int ai_family; andre@0: int ai_socktype; andre@0: int ai_protocol; andre@0: size_t ai_addrlen; andre@0: char *ai_canonname; andre@0: struct sockaddr *ai_addr; andre@0: struct addrinfo *ai_next; andre@0: }; andre@0: #endif andre@0: #define _PR_HAVE_MD_SOCKADDR_IN6 andre@0: /* isomorphic to struct in6_addr on Windows */ andre@0: struct _md_in6_addr { andre@0: union { andre@0: PRUint8 _S6_u8[16]; andre@0: PRUint16 _S6_u16[8]; andre@0: } _S6_un; andre@0: }; andre@0: /* isomorphic to struct sockaddr_in6 on Windows */ andre@0: struct _md_sockaddr_in6 { andre@0: PRInt16 sin6_family; andre@0: PRUint16 sin6_port; andre@0: PRUint32 sin6_flowinfo; andre@0: struct _md_in6_addr sin6_addr; andre@0: PRUint32 sin6_scope_id; andre@0: }; andre@0: #endif andre@0: #define _PR_HAVE_THREADSAFE_GETHOST andre@0: #define _PR_HAVE_ATOMIC_OPS andre@0: #define PR_HAVE_WIN32_NAMED_SHARED_MEMORY andre@0: andre@0: /* --- Common User-Thread/Native-Thread Definitions --------------------- */ andre@0: andre@0: /* --- Globals --- */ andre@0: extern struct PRLock *_pr_schedLock; andre@0: andre@0: /* --- Typedefs --- */ andre@0: typedef void (*FiberFunc)(void *); andre@0: andre@0: #define PR_NUM_GCREGS 8 andre@0: typedef PRInt32 PR_CONTEXT_TYPE[PR_NUM_GCREGS]; andre@0: #define GC_VMBASE 0x40000000 andre@0: #define GC_VMLIMIT 0x00FFFFFF andre@0: andre@0: #define _MD_MAGIC_THREAD 0x22222222 andre@0: #define _MD_MAGIC_THREADSTACK 0x33333333 andre@0: #define _MD_MAGIC_SEGMENT 0x44444444 andre@0: #define _MD_MAGIC_DIR 0x55555555 andre@0: #define _MD_MAGIC_CV 0x66666666 andre@0: andre@0: struct _MDCPU { andre@0: int unused; andre@0: }; andre@0: andre@0: struct _MDThread { andre@0: HANDLE blocked_sema; /* Threads block on this when waiting andre@0: * for IO or CondVar. andre@0: */ andre@0: PRBool inCVWaitQueue; /* PR_TRUE if the thread is in the andre@0: * wait queue of some cond var. andre@0: * PR_FALSE otherwise. */ andre@0: HANDLE handle; /* Win32 thread handle */ andre@0: PRUint32 id; andre@0: void *sp; /* only valid when suspended */ andre@0: PRUint32 magic; /* for debugging */ andre@0: PR_CONTEXT_TYPE gcContext; /* Thread context for GC */ andre@0: struct PRThread *prev, *next; /* used by the cvar wait queue to andre@0: * chain the PRThread structures andre@0: * together */ andre@0: void (*start)(void *); /* used by _PR_MD_CREATE_THREAD to andre@0: * pass its 'start' argument to andre@0: * pr_root. */ andre@0: }; andre@0: andre@0: struct _MDThreadStack { andre@0: PRUint32 magic; /* for debugging */ andre@0: }; andre@0: andre@0: struct _MDSegment { andre@0: PRUint32 magic; /* for debugging */ andre@0: }; andre@0: andre@0: #undef PROFILE_LOCKS andre@0: andre@0: struct _MDDir { andre@0: HANDLE d_hdl; andre@0: WIN32_FIND_DATAA d_entry; andre@0: PRBool firstEntry; /* Is this the entry returned andre@0: * by FindFirstFile()? */ andre@0: PRUint32 magic; /* for debugging */ andre@0: }; andre@0: andre@0: #ifdef MOZ_UNICODE andre@0: struct _MDDirUTF16 { andre@0: HANDLE d_hdl; andre@0: WIN32_FIND_DATAW d_entry; andre@0: PRBool firstEntry; /* Is this the entry returned andre@0: * by FindFirstFileW()? */ andre@0: PRUint32 magic; /* for debugging */ andre@0: }; andre@0: #endif /* MOZ_UNICODE */ andre@0: andre@0: struct _MDCVar { andre@0: PRUint32 magic; andre@0: struct PRThread *waitHead, *waitTail; /* the wait queue: a doubly- andre@0: * linked list of threads andre@0: * waiting on this condition andre@0: * variable */ andre@0: PRIntn nwait; /* number of threads in the andre@0: * wait queue */ andre@0: }; andre@0: andre@0: #define _MD_CV_NOTIFIED_LENGTH 6 andre@0: typedef struct _MDNotified _MDNotified; andre@0: struct _MDNotified { andre@0: PRIntn length; /* # of used entries in this andre@0: * structure */ andre@0: struct { andre@0: struct _MDCVar *cv; /* the condition variable notified */ andre@0: PRIntn times; /* and the number of times notified */ andre@0: struct PRThread *notifyHead; /* list of threads to wake up */ andre@0: } cv[_MD_CV_NOTIFIED_LENGTH]; andre@0: _MDNotified *link; /* link to another of these, or NULL */ andre@0: }; andre@0: andre@0: struct _MDLock { andre@0: CRITICAL_SECTION mutex; /* this is recursive on NT */ andre@0: andre@0: /* andre@0: * When notifying cvars, there is no point in actually andre@0: * waking up the threads waiting on the cvars until we've andre@0: * released the lock. So, we temporarily record the cvars. andre@0: * When doing an unlock, we'll then wake up the waiting threads. andre@0: */ andre@0: struct _MDNotified notified; /* array of conditions notified */ andre@0: #ifdef PROFILE_LOCKS andre@0: PRInt32 hitcount; andre@0: PRInt32 misscount; andre@0: #endif andre@0: }; andre@0: andre@0: struct _MDSemaphore { andre@0: HANDLE sem; andre@0: }; andre@0: andre@0: struct _MDFileDesc { andre@0: PROsfd osfd; /* The osfd can come from one of three spaces: andre@0: * - For stdin, stdout, and stderr, we are using andre@0: * the libc file handle (0, 1, 2), which is an int. andre@0: * - For files and pipes, we are using Win32 HANDLE, andre@0: * which is a void*. andre@0: * - For sockets, we are using Winsock SOCKET, which andre@0: * is a u_int. andre@0: */ andre@0: }; andre@0: andre@0: struct _MDProcess { andre@0: HANDLE handle; andre@0: DWORD id; andre@0: }; andre@0: andre@0: /* --- Misc stuff --- */ andre@0: #define _MD_GET_SP(thread) (thread)->md.gcContext[6] andre@0: andre@0: /* --- NT security stuff --- */ andre@0: andre@0: extern void _PR_NT_InitSids(void); andre@0: extern void _PR_NT_FreeSids(void); andre@0: extern PRStatus _PR_NT_MakeSecurityDescriptorACL( andre@0: PRIntn mode, andre@0: DWORD accessTable[], andre@0: PSECURITY_DESCRIPTOR *resultSD, andre@0: PACL *resultACL andre@0: ); andre@0: extern void _PR_NT_FreeSecurityDescriptorACL( andre@0: PSECURITY_DESCRIPTOR pSD, PACL pACL); andre@0: andre@0: /* --- IO stuff --- */ andre@0: andre@0: #define _MD_OPEN _PR_MD_OPEN andre@0: #define _MD_OPEN_FILE _PR_MD_OPEN_FILE andre@0: #define _MD_READ _PR_MD_READ andre@0: #define _MD_WRITE _PR_MD_WRITE andre@0: #define _MD_WRITEV _PR_MD_WRITEV andre@0: #define _MD_LSEEK _PR_MD_LSEEK andre@0: #define _MD_LSEEK64 _PR_MD_LSEEK64 andre@0: extern PRInt32 _MD_CloseFile(PROsfd osfd); andre@0: #define _MD_CLOSE_FILE _MD_CloseFile andre@0: #define _MD_GETFILEINFO _PR_MD_GETFILEINFO andre@0: #define _MD_GETFILEINFO64 _PR_MD_GETFILEINFO64 andre@0: #define _MD_GETOPENFILEINFO _PR_MD_GETOPENFILEINFO andre@0: #define _MD_GETOPENFILEINFO64 _PR_MD_GETOPENFILEINFO64 andre@0: #define _MD_STAT _PR_MD_STAT andre@0: #define _MD_RENAME _PR_MD_RENAME andre@0: #define _MD_ACCESS _PR_MD_ACCESS andre@0: #define _MD_DELETE _PR_MD_DELETE andre@0: #define _MD_MKDIR _PR_MD_MKDIR andre@0: #define _MD_MAKE_DIR _PR_MD_MAKE_DIR andre@0: #define _MD_RMDIR _PR_MD_RMDIR andre@0: #define _MD_LOCKFILE _PR_MD_LOCKFILE andre@0: #define _MD_TLOCKFILE _PR_MD_TLOCKFILE andre@0: #define _MD_UNLOCKFILE _PR_MD_UNLOCKFILE andre@0: andre@0: /* --- UTF16 IO stuff --- */ andre@0: #ifdef MOZ_UNICODE andre@0: #define _MD_OPEN_FILE_UTF16 _PR_MD_OPEN_FILE_UTF16 andre@0: #define _MD_OPEN_DIR_UTF16 _PR_MD_OPEN_DIR_UTF16 andre@0: #define _MD_READ_DIR_UTF16 _PR_MD_READ_DIR_UTF16 andre@0: #define _MD_CLOSE_DIR_UTF16 _PR_MD_CLOSE_DIR_UTF16 andre@0: #define _MD_GETFILEINFO64_UTF16 _PR_MD_GETFILEINFO64_UTF16 andre@0: #endif /* MOZ_UNICODE */ andre@0: andre@0: /* --- Socket IO stuff --- */ andre@0: extern void _PR_MD_InitSockets(void); andre@0: extern void _PR_MD_CleanupSockets(void); andre@0: #define _MD_EACCES WSAEACCES andre@0: #define _MD_EADDRINUSE WSAEADDRINUSE andre@0: #define _MD_EADDRNOTAVAIL WSAEADDRNOTAVAIL andre@0: #define _MD_EAFNOSUPPORT WSAEAFNOSUPPORT andre@0: #define _MD_EAGAIN WSAEWOULDBLOCK andre@0: #define _MD_EALREADY WSAEALREADY andre@0: #define _MD_EBADF WSAEBADF andre@0: #define _MD_ECONNREFUSED WSAECONNREFUSED andre@0: #define _MD_ECONNRESET WSAECONNRESET andre@0: #define _MD_EFAULT WSAEFAULT andre@0: #define _MD_EINPROGRESS WSAEINPROGRESS andre@0: #define _MD_EINTR WSAEINTR andre@0: #define _MD_EINVAL EINVAL andre@0: #define _MD_EISCONN WSAEISCONN andre@0: #define _MD_ENETUNREACH WSAENETUNREACH andre@0: #define _MD_ENOENT ENOENT andre@0: #define _MD_ENOTCONN WSAENOTCONN andre@0: #define _MD_ENOTSOCK WSAENOTSOCK andre@0: #define _MD_EOPNOTSUPP WSAEOPNOTSUPP andre@0: #define _MD_EWOULDBLOCK WSAEWOULDBLOCK andre@0: #define _MD_GET_SOCKET_ERROR() WSAGetLastError() andre@0: #define _MD_SET_SOCKET_ERROR(_err) WSASetLastError(_err) andre@0: andre@0: #define _MD_INIT_FILEDESC(fd) andre@0: extern void _MD_MakeNonblock(PRFileDesc *f); andre@0: #define _MD_MAKE_NONBLOCK _MD_MakeNonblock andre@0: #define _MD_INIT_FD_INHERITABLE _PR_MD_INIT_FD_INHERITABLE andre@0: #define _MD_QUERY_FD_INHERITABLE _PR_MD_QUERY_FD_INHERITABLE andre@0: #define _MD_SHUTDOWN _PR_MD_SHUTDOWN andre@0: #define _MD_LISTEN _PR_MD_LISTEN andre@0: extern PRInt32 _MD_CloseSocket(PROsfd osfd); andre@0: #define _MD_CLOSE_SOCKET _MD_CloseSocket andre@0: #define _MD_SENDTO _PR_MD_SENDTO andre@0: #define _MD_RECVFROM _PR_MD_RECVFROM andre@0: #define _MD_SOCKETPAIR(s, type, proto, sv) -1 andre@0: #define _MD_GETSOCKNAME _PR_MD_GETSOCKNAME andre@0: #define _MD_GETPEERNAME _PR_MD_GETPEERNAME andre@0: #define _MD_GETSOCKOPT _PR_MD_GETSOCKOPT andre@0: #define _MD_SETSOCKOPT _PR_MD_SETSOCKOPT andre@0: #define _MD_SET_FD_INHERITABLE _PR_MD_SET_FD_INHERITABLE andre@0: #define _MD_SELECT select andre@0: #define _MD_FSYNC _PR_MD_FSYNC andre@0: #define READ_FD 1 andre@0: #define WRITE_FD 2 andre@0: andre@0: #define _MD_INIT_ATOMIC() andre@0: #if defined(_M_IX86) || defined(_X86_) andre@0: #define _MD_ATOMIC_INCREMENT _PR_MD_ATOMIC_INCREMENT andre@0: #define _MD_ATOMIC_ADD _PR_MD_ATOMIC_ADD andre@0: #define _MD_ATOMIC_DECREMENT _PR_MD_ATOMIC_DECREMENT andre@0: #else /* non-x86 processors */ andre@0: #define _MD_ATOMIC_INCREMENT(x) InterlockedIncrement((PLONG)x) andre@0: #define _MD_ATOMIC_ADD(ptr,val) (InterlockedExchangeAdd((PLONG)ptr, (LONG)val) + val) andre@0: #define _MD_ATOMIC_DECREMENT(x) InterlockedDecrement((PLONG)x) andre@0: #endif /* x86 */ andre@0: #define _MD_ATOMIC_SET(x,y) InterlockedExchange((PLONG)x, (LONG)y) andre@0: andre@0: #define _MD_INIT_IO _PR_MD_INIT_IO andre@0: andre@0: andre@0: /* win95 doesn't have async IO */ andre@0: #define _MD_SOCKET _PR_MD_SOCKET andre@0: extern PRInt32 _MD_SocketAvailable(PRFileDesc *fd); andre@0: #define _MD_SOCKETAVAILABLE _MD_SocketAvailable andre@0: #define _MD_PIPEAVAILABLE _PR_MD_PIPEAVAILABLE andre@0: #define _MD_CONNECT _PR_MD_CONNECT andre@0: extern PROsfd _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen, andre@0: PRIntervalTime timeout); andre@0: #define _MD_ACCEPT _MD_Accept andre@0: #define _MD_BIND _PR_MD_BIND andre@0: #define _MD_RECV _PR_MD_RECV andre@0: #define _MD_SEND _PR_MD_SEND andre@0: #define _MD_PR_POLL _PR_MD_PR_POLL andre@0: andre@0: /* --- Scheduler stuff --- */ andre@0: // #define _MD_PAUSE_CPU _PR_MD_PAUSE_CPU andre@0: #define _MD_PAUSE_CPU andre@0: andre@0: /* --- DIR stuff --- */ andre@0: #define PR_DIRECTORY_SEPARATOR '\\' andre@0: #define PR_DIRECTORY_SEPARATOR_STR "\\" andre@0: #define PR_PATH_SEPARATOR ';' andre@0: #define PR_PATH_SEPARATOR_STR ";" andre@0: #define _MD_ERRNO() GetLastError() andre@0: #define _MD_OPEN_DIR _PR_MD_OPEN_DIR andre@0: #define _MD_CLOSE_DIR _PR_MD_CLOSE_DIR andre@0: #define _MD_READ_DIR _PR_MD_READ_DIR andre@0: andre@0: /* --- Segment stuff --- */ andre@0: #define _MD_INIT_SEGS() andre@0: #define _MD_ALLOC_SEGMENT(seg, size, vaddr) 0 andre@0: #define _MD_FREE_SEGMENT(seg) andre@0: andre@0: /* --- Environment Stuff --- */ andre@0: #define _MD_GET_ENV _PR_MD_GET_ENV andre@0: #define _MD_PUT_ENV _PR_MD_PUT_ENV andre@0: andre@0: /* --- Threading Stuff --- */ andre@0: #define _MD_DEFAULT_STACK_SIZE 0 andre@0: #define _MD_INIT_THREAD _PR_MD_INIT_THREAD andre@0: #define _MD_INIT_ATTACHED_THREAD _PR_MD_INIT_THREAD andre@0: #define _MD_CREATE_THREAD _PR_MD_CREATE_THREAD andre@0: #define _MD_YIELD _PR_MD_YIELD andre@0: #define _MD_SET_PRIORITY _PR_MD_SET_PRIORITY andre@0: #define _MD_SET_CURRENT_THREAD_NAME _PR_MD_SET_CURRENT_THREAD_NAME andre@0: #define _MD_CLEAN_THREAD _PR_MD_CLEAN_THREAD andre@0: #define _MD_SETTHREADAFFINITYMASK _PR_MD_SETTHREADAFFINITYMASK andre@0: #define _MD_GETTHREADAFFINITYMASK _PR_MD_GETTHREADAFFINITYMASK andre@0: #define _MD_EXIT_THREAD _PR_MD_EXIT_THREAD andre@0: #define _MD_EXIT _PR_MD_EXIT andre@0: #define _MD_SUSPEND_THREAD _PR_MD_SUSPEND_THREAD andre@0: #define _MD_RESUME_THREAD _PR_MD_RESUME_THREAD andre@0: #define _MD_SUSPEND_CPU _PR_MD_SUSPEND_CPU andre@0: #define _MD_RESUME_CPU _PR_MD_RESUME_CPU andre@0: #define _MD_BEGIN_SUSPEND_ALL() andre@0: #define _MD_BEGIN_RESUME_ALL() andre@0: #define _MD_END_SUSPEND_ALL() andre@0: #define _MD_END_RESUME_ALL() andre@0: andre@0: /* --- Lock stuff --- */ andre@0: #define _PR_LOCK _MD_LOCK andre@0: #define _PR_UNLOCK _MD_UNLOCK andre@0: andre@0: #define _MD_NEW_LOCK _PR_MD_NEW_LOCK andre@0: #define _MD_FREE_LOCK(lock) DeleteCriticalSection(&((lock)->mutex)) andre@0: #define _MD_LOCK(lock) EnterCriticalSection(&((lock)->mutex)) andre@0: #define _MD_TEST_AND_LOCK(lock) (EnterCriticalSection(&((lock)->mutex)),0) andre@0: #define _MD_UNLOCK _PR_MD_UNLOCK andre@0: andre@0: /* --- lock and cv waiting --- */ andre@0: #define _MD_WAIT _PR_MD_WAIT andre@0: #define _MD_WAKEUP_WAITER _PR_MD_WAKEUP_WAITER andre@0: andre@0: /* --- CVar ------------------- */ andre@0: #define _MD_WAIT_CV _PR_MD_WAIT_CV andre@0: #define _MD_NEW_CV _PR_MD_NEW_CV andre@0: #define _MD_FREE_CV _PR_MD_FREE_CV andre@0: #define _MD_NOTIFY_CV _PR_MD_NOTIFY_CV andre@0: #define _MD_NOTIFYALL_CV _PR_MD_NOTIFYALL_CV andre@0: andre@0: /* XXXMB- the IOQ stuff is certainly not working correctly yet. */ andre@0: // extern struct _MDLock _pr_ioq_lock; andre@0: #define _MD_IOQ_LOCK() andre@0: #define _MD_IOQ_UNLOCK() andre@0: andre@0: andre@0: /* --- Initialization stuff --- */ andre@0: #define _MD_START_INTERRUPTS() andre@0: #define _MD_STOP_INTERRUPTS() andre@0: #define _MD_DISABLE_CLOCK_INTERRUPTS() andre@0: #define _MD_ENABLE_CLOCK_INTERRUPTS() andre@0: #define _MD_BLOCK_CLOCK_INTERRUPTS() andre@0: #define _MD_UNBLOCK_CLOCK_INTERRUPTS() andre@0: #define _MD_EARLY_INIT _PR_MD_EARLY_INIT andre@0: #define _MD_FINAL_INIT() andre@0: #define _MD_EARLY_CLEANUP() andre@0: #define _MD_INIT_CPUS() andre@0: #define _MD_INIT_RUNNING_CPU(cpu) andre@0: andre@0: struct PRProcess; andre@0: struct PRProcessAttr; andre@0: andre@0: #define _MD_CREATE_PROCESS _PR_CreateWindowsProcess andre@0: extern struct PRProcess * _PR_CreateWindowsProcess( andre@0: const char *path, andre@0: char *const *argv, andre@0: char *const *envp, andre@0: const struct PRProcessAttr *attr andre@0: ); andre@0: andre@0: #define _MD_DETACH_PROCESS _PR_DetachWindowsProcess andre@0: extern PRStatus _PR_DetachWindowsProcess(struct PRProcess *process); andre@0: andre@0: /* --- Wait for a child process to terminate --- */ andre@0: #define _MD_WAIT_PROCESS _PR_WaitWindowsProcess andre@0: extern PRStatus _PR_WaitWindowsProcess(struct PRProcess *process, andre@0: PRInt32 *exitCode); andre@0: andre@0: #define _MD_KILL_PROCESS _PR_KillWindowsProcess andre@0: extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process); andre@0: andre@0: #define _MD_CLEANUP_BEFORE_EXIT _PR_MD_CLEANUP_BEFORE_EXIT andre@0: #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ andre@0: PR_BEGIN_MACRO \ andre@0: *status = PR_TRUE; \ andre@0: PR_END_MACRO andre@0: #define _MD_SWITCH_CONTEXT andre@0: #define _MD_RESTORE_CONTEXT andre@0: andre@0: /* --- Intervals --- */ andre@0: #define _MD_INTERVAL_INIT _PR_MD_INTERVAL_INIT andre@0: #define _MD_GET_INTERVAL _PR_MD_GET_INTERVAL andre@0: #define _MD_INTERVAL_PER_SEC _PR_MD_INTERVAL_PER_SEC andre@0: #define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000) andre@0: #define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000) andre@0: andre@0: /* --- Time --- */ andre@0: extern void _PR_FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm); andre@0: andre@0: #ifdef WINCE andre@0: extern void _MD_InitTime(void); andre@0: extern void _MD_CleanupTime(void); andre@0: #endif andre@0: andre@0: /* --- Native-Thread Specific Definitions ------------------------------- */ andre@0: andre@0: extern struct PRThread * _MD_CURRENT_THREAD(void); andre@0: andre@0: #ifdef _PR_USE_STATIC_TLS andre@0: extern __declspec(thread) struct PRThread *_pr_currentThread; andre@0: #define _MD_GET_ATTACHED_THREAD() _pr_currentThread andre@0: #define _MD_SET_CURRENT_THREAD(_thread) (_pr_currentThread = (_thread)) andre@0: andre@0: extern __declspec(thread) struct PRThread *_pr_thread_last_run; andre@0: #define _MD_LAST_THREAD() _pr_thread_last_run andre@0: #define _MD_SET_LAST_THREAD(_thread) (_pr_thread_last_run = 0) andre@0: andre@0: extern __declspec(thread) struct _PRCPU *_pr_currentCPU; andre@0: #define _MD_CURRENT_CPU() _pr_currentCPU andre@0: #define _MD_SET_CURRENT_CPU(_cpu) (_pr_currentCPU = 0) andre@0: #else /* _PR_USE_STATIC_TLS */ andre@0: extern DWORD _pr_currentThreadIndex; andre@0: #define _MD_GET_ATTACHED_THREAD() ((PRThread *) TlsGetValue(_pr_currentThreadIndex)) andre@0: #define _MD_SET_CURRENT_THREAD(_thread) TlsSetValue(_pr_currentThreadIndex, (_thread)) andre@0: andre@0: extern DWORD _pr_lastThreadIndex; andre@0: #define _MD_LAST_THREAD() ((PRThread *) TlsGetValue(_pr_lastThreadIndex)) andre@0: #define _MD_SET_LAST_THREAD(_thread) TlsSetValue(_pr_lastThreadIndex, 0) andre@0: andre@0: extern DWORD _pr_currentCPUIndex; andre@0: #define _MD_CURRENT_CPU() ((struct _PRCPU *) TlsGetValue(_pr_currentCPUIndex)) andre@0: #define _MD_SET_CURRENT_CPU(_cpu) TlsSetValue(_pr_currentCPUIndex, 0) andre@0: #endif /* _PR_USE_STATIC_TLS */ andre@0: andre@0: /* --- Scheduler stuff --- */ andre@0: #define LOCK_SCHEDULER() 0 andre@0: #define UNLOCK_SCHEDULER() 0 andre@0: #define _PR_LockSched() 0 andre@0: #define _PR_UnlockSched() 0 andre@0: andre@0: /* --- Initialization stuff --- */ andre@0: #define _MD_INIT_LOCKS _PR_MD_INIT_LOCKS andre@0: andre@0: /* --- Stack stuff --- */ andre@0: #define _MD_INIT_STACK(stack, redzone) andre@0: #define _MD_CLEAR_STACK(stack) andre@0: andre@0: /* --- Memory-mapped files stuff --- */ andre@0: andre@0: struct _MDFileMap { andre@0: HANDLE hFileMap; andre@0: DWORD dwAccess; andre@0: }; andre@0: andre@0: extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size); andre@0: #define _MD_CREATE_FILE_MAP _MD_CreateFileMap andre@0: andre@0: extern PRInt32 _MD_GetMemMapAlignment(void); andre@0: #define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment andre@0: andre@0: extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset, andre@0: PRUint32 len); andre@0: #define _MD_MEM_MAP _MD_MemMap andre@0: andre@0: extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size); andre@0: #define _MD_MEM_UNMAP _MD_MemUnmap andre@0: andre@0: extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap); andre@0: #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap andre@0: andre@0: extern PRStatus _MD_SyncMemMap( andre@0: PRFileDesc *fd, andre@0: void *addr, andre@0: PRUint32 len); andre@0: #define _MD_SYNC_MEM_MAP _MD_SyncMemMap andre@0: andre@0: /* --- Named semaphores stuff --- */ andre@0: #define _PR_HAVE_NAMED_SEMAPHORES andre@0: #define _MD_OPEN_SEMAPHORE _PR_MD_OPEN_SEMAPHORE andre@0: #define _MD_WAIT_SEMAPHORE _PR_MD_WAIT_SEMAPHORE andre@0: #define _MD_POST_SEMAPHORE _PR_MD_POST_SEMAPHORE andre@0: #define _MD_CLOSE_SEMAPHORE _PR_MD_CLOSE_SEMAPHORE andre@0: #define _MD_DELETE_SEMAPHORE(name) PR_SUCCESS /* no op */ andre@0: andre@0: #endif /* nspr_win32_defs_h___ */