michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nspr_os2_defs_h___ michael@0: #define nspr_os2_defs_h___ michael@0: michael@0: #ifndef NO_LONG_LONG michael@0: #define INCL_LONGLONG michael@0: #endif michael@0: #define INCL_DOS michael@0: #define INCL_DOSPROCESS michael@0: #define INCL_DOSERRORS michael@0: #define INCL_WIN michael@0: #define INCL_WPS michael@0: #include michael@0: #include michael@0: michael@0: #include "prio.h" michael@0: michael@0: #include michael@0: michael@0: /* michael@0: * Internal configuration macros michael@0: */ michael@0: michael@0: #define PR_LINKER_ARCH "os2" michael@0: #define _PR_SI_SYSNAME "OS2" michael@0: #define _PR_SI_ARCHITECTURE "x86" /* XXXMB hardcode for now */ michael@0: michael@0: #define HAVE_DLL michael@0: #define _PR_GLOBAL_THREADS_ONLY michael@0: #undef HAVE_THREAD_AFFINITY michael@0: #define _PR_HAVE_THREADSAFE_GETHOST michael@0: #define _PR_HAVE_ATOMIC_OPS michael@0: #define HAVE_NETINET_TCP_H michael@0: michael@0: #define HANDLE unsigned long michael@0: #define HINSTANCE HMODULE michael@0: michael@0: /* --- Common User-Thread/Native-Thread Definitions --------------------- */ michael@0: michael@0: /* --- Globals --- */ michael@0: extern struct PRLock *_pr_schedLock; michael@0: michael@0: /* --- Typedefs --- */ michael@0: typedef void (*FiberFunc)(void *); michael@0: michael@0: #define PR_NUM_GCREGS 8 michael@0: typedef PRInt32 PR_CONTEXT_TYPE[PR_NUM_GCREGS]; michael@0: #define GC_VMBASE 0x40000000 michael@0: #define GC_VMLIMIT 0x00FFFFFF michael@0: typedef int (*FARPROC)(); michael@0: michael@0: #define _MD_MAGIC_THREAD 0x22222222 michael@0: #define _MD_MAGIC_THREADSTACK 0x33333333 michael@0: #define _MD_MAGIC_SEGMENT 0x44444444 michael@0: #define _MD_MAGIC_DIR 0x55555555 michael@0: #define _MD_MAGIC_CV 0x66666666 michael@0: michael@0: struct _MDSemaphore { michael@0: HEV sem; michael@0: }; michael@0: michael@0: struct _MDCPU { michael@0: int unused; michael@0: }; michael@0: michael@0: struct _MDThread { michael@0: HEV blocked_sema; /* Threads block on this when waiting michael@0: * for IO or CondVar. michael@0: */ michael@0: PRBool inCVWaitQueue; /* PR_TRUE if the thread is in the michael@0: * wait queue of some cond var. michael@0: * PR_FALSE otherwise. */ michael@0: TID handle; /* OS/2 thread handle */ michael@0: void *sp; /* only valid when suspended */ michael@0: PRUint32 magic; /* for debugging */ michael@0: PR_CONTEXT_TYPE gcContext; /* Thread context for GC */ michael@0: struct PRThread *prev, *next; /* used by the cvar wait queue to michael@0: * chain the PRThread structures michael@0: * together */ michael@0: }; michael@0: michael@0: struct _MDThreadStack { michael@0: PRUint32 magic; /* for debugging */ michael@0: }; michael@0: michael@0: struct _MDSegment { michael@0: PRUint32 magic; /* for debugging */ michael@0: }; michael@0: michael@0: #undef PROFILE_LOCKS michael@0: michael@0: struct _MDDir { michael@0: HDIR d_hdl; michael@0: union { michael@0: FILEFINDBUF3 small; michael@0: FILEFINDBUF3L large; michael@0: } d_entry; michael@0: PRBool firstEntry; /* Is this the entry returned michael@0: * by FindFirstFile()? */ michael@0: PRUint32 magic; /* for debugging */ michael@0: }; michael@0: michael@0: struct _MDCVar { michael@0: PRUint32 magic; michael@0: struct PRThread *waitHead, *waitTail; /* the wait queue: a doubly- michael@0: * linked list of threads michael@0: * waiting on this condition michael@0: * variable */ michael@0: PRIntn nwait; /* number of threads in the michael@0: * wait queue */ michael@0: }; michael@0: michael@0: #define _MD_CV_NOTIFIED_LENGTH 6 michael@0: typedef struct _MDNotified _MDNotified; michael@0: struct _MDNotified { michael@0: PRIntn length; /* # of used entries in this michael@0: * structure */ michael@0: struct { michael@0: struct _MDCVar *cv; /* the condition variable notified */ michael@0: PRIntn times; /* and the number of times notified */ michael@0: struct PRThread *notifyHead; /* list of threads to wake up */ michael@0: } cv[_MD_CV_NOTIFIED_LENGTH]; michael@0: _MDNotified *link; /* link to another of these, or NULL */ michael@0: }; michael@0: michael@0: struct _MDLock { michael@0: HMTX mutex; /* this is recursive on OS/2 */ michael@0: michael@0: /* michael@0: * When notifying cvars, there is no point in actually michael@0: * waking up the threads waiting on the cvars until we've michael@0: * released the lock. So, we temporarily record the cvars. michael@0: * When doing an unlock, we'll then wake up the waiting threads. michael@0: */ michael@0: struct _MDNotified notified; /* array of conditions notified */ michael@0: #ifdef PROFILE_LOCKS michael@0: PRInt32 hitcount; michael@0: PRInt32 misscount; michael@0: #endif michael@0: }; michael@0: michael@0: struct _MDFileDesc { michael@0: PRInt32 osfd; /* The osfd can come from one of three spaces: michael@0: * - For stdin, stdout, and stderr, we are using michael@0: * the libc file handle (0, 1, 2), which is an int. michael@0: * - For files and pipes, we are using OS/2 handles, michael@0: * which is a void*. michael@0: * - For sockets, we are using int michael@0: */ michael@0: }; michael@0: michael@0: struct _MDProcess { michael@0: PID pid; michael@0: }; michael@0: michael@0: /* --- Misc stuff --- */ michael@0: #define _MD_GET_SP(thread) (thread)->md.gcContext[6] michael@0: michael@0: /* --- IO stuff --- */ michael@0: michael@0: #define _MD_OPEN (_PR_MD_OPEN) michael@0: #define _MD_OPEN_FILE (_PR_MD_OPEN) michael@0: #define _MD_READ (_PR_MD_READ) michael@0: #define _MD_WRITE (_PR_MD_WRITE) michael@0: #define _MD_WRITEV (_PR_MD_WRITEV) michael@0: #define _MD_LSEEK (_PR_MD_LSEEK) michael@0: #define _MD_LSEEK64 (_PR_MD_LSEEK64) michael@0: extern PRInt32 _MD_CloseFile(PRInt32 osfd); michael@0: #define _MD_CLOSE_FILE _MD_CloseFile michael@0: #define _MD_GETFILEINFO (_PR_MD_GETFILEINFO) michael@0: #define _MD_GETFILEINFO64 (_PR_MD_GETFILEINFO64) michael@0: #define _MD_GETOPENFILEINFO (_PR_MD_GETOPENFILEINFO) michael@0: #define _MD_GETOPENFILEINFO64 (_PR_MD_GETOPENFILEINFO64) michael@0: #define _MD_STAT (_PR_MD_STAT) michael@0: #define _MD_RENAME (_PR_MD_RENAME) michael@0: #define _MD_ACCESS (_PR_MD_ACCESS) michael@0: #define _MD_DELETE (_PR_MD_DELETE) michael@0: #define _MD_MKDIR (_PR_MD_MKDIR) michael@0: #define _MD_MAKE_DIR (_PR_MD_MKDIR) michael@0: #define _MD_RMDIR (_PR_MD_RMDIR) michael@0: #define _MD_LOCKFILE (_PR_MD_LOCKFILE) michael@0: #define _MD_TLOCKFILE (_PR_MD_TLOCKFILE) michael@0: #define _MD_UNLOCKFILE (_PR_MD_UNLOCKFILE) michael@0: michael@0: /* --- Socket IO stuff --- */ michael@0: michael@0: /* The ones that don't map directly may need to be re-visited... */ michael@0: #define _MD_EACCES EACCES michael@0: #define _MD_EADDRINUSE EADDRINUSE michael@0: #define _MD_EADDRNOTAVAIL EADDRNOTAVAIL michael@0: #define _MD_EAFNOSUPPORT EAFNOSUPPORT michael@0: #define _MD_EAGAIN EWOULDBLOCK michael@0: #define _MD_EALREADY EALREADY michael@0: #define _MD_EBADF EBADF michael@0: #define _MD_ECONNREFUSED ECONNREFUSED michael@0: #define _MD_ECONNRESET ECONNRESET michael@0: #define _MD_EFAULT SOCEFAULT michael@0: #define _MD_EINPROGRESS EINPROGRESS michael@0: #define _MD_EINTR EINTR michael@0: #define _MD_EINVAL EINVAL michael@0: #define _MD_EISCONN EISCONN michael@0: #define _MD_ENETUNREACH ENETUNREACH michael@0: #define _MD_ENOENT ENOENT michael@0: #define _MD_ENOTCONN ENOTCONN michael@0: #define _MD_ENOTSOCK ENOTSOCK michael@0: #define _MD_EOPNOTSUPP EOPNOTSUPP michael@0: #define _MD_EWOULDBLOCK EWOULDBLOCK michael@0: #define _MD_GET_SOCKET_ERROR() sock_errno() michael@0: #ifndef INADDR_LOOPBACK /* For some reason this is not defined in OS2 tcpip */ michael@0: /* #define INADDR_LOOPBACK INADDR_ANY */ michael@0: #endif michael@0: michael@0: #define _MD_INIT_FILEDESC(fd) michael@0: extern void _MD_MakeNonblock(PRFileDesc *f); michael@0: #define _MD_MAKE_NONBLOCK _MD_MakeNonblock michael@0: #define _MD_INIT_FD_INHERITABLE (_PR_MD_INIT_FD_INHERITABLE) michael@0: #define _MD_QUERY_FD_INHERITABLE (_PR_MD_QUERY_FD_INHERITABLE) michael@0: #define _MD_SHUTDOWN (_PR_MD_SHUTDOWN) michael@0: #define _MD_LISTEN _PR_MD_LISTEN michael@0: extern PRInt32 _MD_CloseSocket(PRInt32 osfd); michael@0: #define _MD_CLOSE_SOCKET _MD_CloseSocket michael@0: #define _MD_SENDTO (_PR_MD_SENDTO) michael@0: #define _MD_RECVFROM (_PR_MD_RECVFROM) michael@0: #define _MD_SOCKETPAIR (_PR_MD_SOCKETPAIR) michael@0: #define _MD_GETSOCKNAME (_PR_MD_GETSOCKNAME) michael@0: #define _MD_GETPEERNAME (_PR_MD_GETPEERNAME) michael@0: #define _MD_GETSOCKOPT (_PR_MD_GETSOCKOPT) michael@0: #define _MD_SETSOCKOPT (_PR_MD_SETSOCKOPT) michael@0: michael@0: #define _MD_FSYNC _PR_MD_FSYNC michael@0: #define _MD_SET_FD_INHERITABLE (_PR_MD_SET_FD_INHERITABLE) michael@0: michael@0: #ifdef _PR_HAVE_ATOMIC_OPS michael@0: #define _MD_INIT_ATOMIC() michael@0: #define _MD_ATOMIC_INCREMENT _PR_MD_ATOMIC_INCREMENT michael@0: #define _MD_ATOMIC_ADD _PR_MD_ATOMIC_ADD michael@0: #define _MD_ATOMIC_DECREMENT _PR_MD_ATOMIC_DECREMENT michael@0: #define _MD_ATOMIC_SET _PR_MD_ATOMIC_SET michael@0: #endif michael@0: michael@0: #define _MD_INIT_IO (_PR_MD_INIT_IO) michael@0: #define _MD_PR_POLL (_PR_MD_PR_POLL) michael@0: michael@0: #define _MD_SOCKET (_PR_MD_SOCKET) michael@0: extern PRInt32 _MD_SocketAvailable(PRFileDesc *fd); michael@0: #define _MD_SOCKETAVAILABLE _MD_SocketAvailable michael@0: #define _MD_PIPEAVAILABLE _MD_SocketAvailable michael@0: #define _MD_CONNECT (_PR_MD_CONNECT) michael@0: extern PRInt32 _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen, michael@0: PRIntervalTime timeout); michael@0: #define _MD_ACCEPT _MD_Accept michael@0: #define _MD_BIND (_PR_MD_BIND) michael@0: #define _MD_RECV (_PR_MD_RECV) michael@0: #define _MD_SEND (_PR_MD_SEND) michael@0: michael@0: /* --- Scheduler stuff --- */ michael@0: /* #define _MD_PAUSE_CPU _PR_MD_PAUSE_CPU */ michael@0: #define _MD_PAUSE_CPU michael@0: michael@0: /* --- DIR stuff --- */ michael@0: #define PR_DIRECTORY_SEPARATOR '\\' michael@0: #define PR_DIRECTORY_SEPARATOR_STR "\\" michael@0: #define PR_PATH_SEPARATOR ';' michael@0: #define PR_PATH_SEPARATOR_STR ";" michael@0: #define _MD_ERRNO() errno michael@0: #define _MD_OPEN_DIR (_PR_MD_OPEN_DIR) michael@0: #define _MD_CLOSE_DIR (_PR_MD_CLOSE_DIR) michael@0: #define _MD_READ_DIR (_PR_MD_READ_DIR) michael@0: michael@0: /* --- Segment stuff --- */ michael@0: #define _MD_INIT_SEGS() michael@0: #define _MD_ALLOC_SEGMENT(seg, size, vaddr) 0 michael@0: #define _MD_FREE_SEGMENT(seg) michael@0: michael@0: /* --- Environment Stuff --- */ michael@0: #define _MD_GET_ENV (_PR_MD_GET_ENV) michael@0: #define _MD_PUT_ENV (_PR_MD_PUT_ENV) michael@0: michael@0: /* --- Threading Stuff --- */ michael@0: #define _MD_DEFAULT_STACK_SIZE 65536L michael@0: #define _MD_INIT_THREAD (_PR_MD_INIT_THREAD) michael@0: #define _MD_INIT_ATTACHED_THREAD (_PR_MD_INIT_THREAD) michael@0: #define _MD_CREATE_THREAD (_PR_MD_CREATE_THREAD) michael@0: #define _MD_YIELD (_PR_MD_YIELD) michael@0: #define _MD_SET_PRIORITY (_PR_MD_SET_PRIORITY) michael@0: #define _MD_CLEAN_THREAD (_PR_MD_CLEAN_THREAD) michael@0: #define _MD_SETTHREADAFFINITYMASK (_PR_MD_SETTHREADAFFINITYMASK) michael@0: #define _MD_GETTHREADAFFINITYMASK (_PR_MD_GETTHREADAFFINITYMASK) michael@0: #define _MD_EXIT_THREAD (_PR_MD_EXIT_THREAD) michael@0: #define _MD_SUSPEND_THREAD (_PR_MD_SUSPEND_THREAD) michael@0: #define _MD_RESUME_THREAD (_PR_MD_RESUME_THREAD) michael@0: #define _MD_SUSPEND_CPU (_PR_MD_SUSPEND_CPU) michael@0: #define _MD_RESUME_CPU (_PR_MD_RESUME_CPU) michael@0: #define _MD_WAKEUP_CPUS (_PR_MD_WAKEUP_CPUS) michael@0: #define _MD_BEGIN_SUSPEND_ALL() michael@0: #define _MD_BEGIN_RESUME_ALL() michael@0: #define _MD_END_SUSPEND_ALL() michael@0: #define _MD_END_RESUME_ALL() michael@0: michael@0: /* --- Lock stuff --- */ michael@0: #define _PR_LOCK _MD_LOCK michael@0: #define _PR_UNLOCK _MD_UNLOCK michael@0: michael@0: #define _MD_NEW_LOCK (_PR_MD_NEW_LOCK) michael@0: #define _MD_FREE_LOCK(lock) (DosCloseMutexSem((lock)->mutex)) michael@0: #define _MD_LOCK(lock) (DosRequestMutexSem((lock)->mutex, SEM_INDEFINITE_WAIT)) michael@0: #define _MD_TEST_AND_LOCK(lock) (DosRequestMutexSem((lock)->mutex, SEM_INDEFINITE_WAIT),0) michael@0: #define _MD_UNLOCK (_PR_MD_UNLOCK) michael@0: michael@0: /* --- lock and cv waiting --- */ michael@0: #define _MD_WAIT (_PR_MD_WAIT) michael@0: #define _MD_WAKEUP_WAITER (_PR_MD_WAKEUP_WAITER) michael@0: michael@0: /* --- CVar ------------------- */ michael@0: #define _MD_WAIT_CV (_PR_MD_WAIT_CV) michael@0: #define _MD_NEW_CV (_PR_MD_NEW_CV) michael@0: #define _MD_FREE_CV (_PR_MD_FREE_CV) michael@0: #define _MD_NOTIFY_CV (_PR_MD_NOTIFY_CV ) michael@0: #define _MD_NOTIFYALL_CV (_PR_MD_NOTIFYALL_CV) michael@0: michael@0: /* XXXMB- the IOQ stuff is certainly not working correctly yet. */ michael@0: /* extern struct _MDLock _pr_ioq_lock; */ michael@0: #define _MD_IOQ_LOCK() michael@0: #define _MD_IOQ_UNLOCK() michael@0: michael@0: michael@0: /* --- Initialization stuff --- */ michael@0: #define _MD_START_INTERRUPTS() michael@0: #define _MD_STOP_INTERRUPTS() michael@0: #define _MD_DISABLE_CLOCK_INTERRUPTS() michael@0: #define _MD_ENABLE_CLOCK_INTERRUPTS() michael@0: #define _MD_BLOCK_CLOCK_INTERRUPTS() michael@0: #define _MD_UNBLOCK_CLOCK_INTERRUPTS() michael@0: #define _MD_EARLY_INIT (_PR_MD_EARLY_INIT) michael@0: #define _MD_FINAL_INIT() michael@0: #define _MD_EARLY_CLEANUP() michael@0: #define _MD_INIT_CPUS() michael@0: #define _MD_INIT_RUNNING_CPU(cpu) michael@0: michael@0: struct PRProcess; michael@0: struct PRProcessAttr; michael@0: michael@0: #define _MD_CREATE_PROCESS _PR_CreateOS2Process michael@0: extern struct PRProcess * _PR_CreateOS2Process( michael@0: const char *path, michael@0: char *const *argv, michael@0: char *const *envp, michael@0: const struct PRProcessAttr *attr michael@0: ); michael@0: michael@0: #define _MD_DETACH_PROCESS _PR_DetachOS2Process michael@0: extern PRStatus _PR_DetachOS2Process(struct PRProcess *process); michael@0: michael@0: /* --- Wait for a child process to terminate --- */ michael@0: #define _MD_WAIT_PROCESS _PR_WaitOS2Process michael@0: extern PRStatus _PR_WaitOS2Process(struct PRProcess *process, michael@0: PRInt32 *exitCode); michael@0: michael@0: #define _MD_KILL_PROCESS _PR_KillOS2Process michael@0: extern PRStatus _PR_KillOS2Process(struct PRProcess *process); michael@0: michael@0: #define _MD_CLEANUP_BEFORE_EXIT() michael@0: #define _MD_EXIT (_PR_MD_EXIT) michael@0: #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ michael@0: PR_BEGIN_MACRO \ michael@0: *status = PR_TRUE; \ michael@0: PR_END_MACRO michael@0: #define _MD_SWITCH_CONTEXT michael@0: #define _MD_RESTORE_CONTEXT michael@0: michael@0: /* --- Intervals --- */ michael@0: #define _MD_INTERVAL_INIT (_PR_MD_INTERVAL_INIT) michael@0: #define _MD_GET_INTERVAL (_PR_MD_GET_INTERVAL) michael@0: #define _MD_INTERVAL_PER_SEC (_PR_MD_INTERVAL_PER_SEC) michael@0: #define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000) michael@0: #define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000) michael@0: michael@0: /* --- Native-Thread Specific Definitions ------------------------------- */ michael@0: michael@0: typedef struct __NSPR_TLS michael@0: { michael@0: struct PRThread *_pr_thread_last_run; michael@0: struct PRThread *_pr_currentThread; michael@0: struct _PRCPU *_pr_currentCPU; michael@0: } _NSPR_TLS; michael@0: michael@0: extern _NSPR_TLS* pThreadLocalStorage; michael@0: NSPR_API(void) _PR_MD_ENSURE_TLS(void); michael@0: michael@0: #define _MD_GET_ATTACHED_THREAD() pThreadLocalStorage->_pr_currentThread michael@0: extern struct PRThread * _MD_CURRENT_THREAD(void); michael@0: #define _MD_SET_CURRENT_THREAD(_thread) _PR_MD_ENSURE_TLS(); pThreadLocalStorage->_pr_currentThread = (_thread) michael@0: michael@0: #define _MD_LAST_THREAD() pThreadLocalStorage->_pr_thread_last_run michael@0: #define _MD_SET_LAST_THREAD(_thread) _PR_MD_ENSURE_TLS(); pThreadLocalStorage->_pr_thread_last_run = (_thread) michael@0: michael@0: #define _MD_CURRENT_CPU() pThreadLocalStorage->_pr_currentCPU michael@0: #define _MD_SET_CURRENT_CPU(_cpu) _PR_MD_ENSURE_TLS(); pThreadLocalStorage->_pr_currentCPU = (_cpu) michael@0: michael@0: /* lth. #define _MD_SET_INTSOFF(_val) (_pr_ints_off = (_val)) */ michael@0: /* lth. #define _MD_GET_INTSOFF() _pr_ints_off */ michael@0: /* lth. #define _MD_INCREMENT_INTSOFF() (_pr_ints_off++) */ michael@0: /* lth. #define _MD_DECREMENT_INTSOFF() (_pr_ints_off--) */ michael@0: michael@0: /* --- Scheduler stuff --- */ michael@0: #define LOCK_SCHEDULER() 0 michael@0: #define UNLOCK_SCHEDULER() 0 michael@0: #define _PR_LockSched() 0 michael@0: #define _PR_UnlockSched() 0 michael@0: michael@0: /* --- Initialization stuff --- */ michael@0: #define _MD_INIT_LOCKS() michael@0: michael@0: /* --- Stack stuff --- */ michael@0: #define _MD_INIT_STACK(stack, redzone) michael@0: #define _MD_CLEAR_STACK(stack) michael@0: michael@0: /* --- Memory-mapped files stuff --- */ michael@0: /* ReadOnly and WriteCopy modes are simulated on OS/2; michael@0: * ReadWrite mode is not supported. michael@0: */ michael@0: struct _MDFileMap { michael@0: PROffset64 maxExtent; michael@0: }; michael@0: michael@0: extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size); michael@0: #define _MD_CREATE_FILE_MAP _MD_CreateFileMap michael@0: michael@0: extern PRInt32 _MD_GetMemMapAlignment(void); michael@0: #define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment michael@0: michael@0: extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset, michael@0: PRUint32 len); michael@0: #define _MD_MEM_MAP _MD_MemMap michael@0: michael@0: extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size); michael@0: #define _MD_MEM_UNMAP _MD_MemUnmap michael@0: michael@0: extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap); michael@0: #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap michael@0: michael@0: /* Some stuff for setting up thread contexts */ michael@0: typedef ULONG DWORD, *PDWORD; michael@0: michael@0: /* The following definitions and two structures are new in OS/2 Warp 4.0. michael@0: */ michael@0: #ifndef CONTEXT_CONTROL michael@0: #define CONTEXT_CONTROL 0x00000001 michael@0: #define CONTEXT_INTEGER 0x00000002 michael@0: #define CONTEXT_SEGMENTS 0x00000004 michael@0: #define CONTEXT_FLOATING_POINT 0x00000008 michael@0: #define CONTEXT_FULL 0x0000000F michael@0: michael@0: #pragma pack(2) michael@0: typedef struct _FPREG { michael@0: ULONG losig; /* Low 32-bits of the significand. */ michael@0: ULONG hisig; /* High 32-bits of the significand. */ michael@0: USHORT signexp; /* Sign and exponent. */ michael@0: } FPREG; michael@0: typedef struct _CONTEXTRECORD { michael@0: ULONG ContextFlags; michael@0: ULONG ctx_env[7]; michael@0: FPREG ctx_stack[8]; michael@0: ULONG ctx_SegGs; /* GS register. */ michael@0: ULONG ctx_SegFs; /* FS register. */ michael@0: ULONG ctx_SegEs; /* ES register. */ michael@0: ULONG ctx_SegDs; /* DS register. */ michael@0: ULONG ctx_RegEdi; /* EDI register. */ michael@0: ULONG ctx_RegEsi; /* ESI register. */ michael@0: ULONG ctx_RegEax; /* EAX register. */ michael@0: ULONG ctx_RegEbx; /* EBX register. */ michael@0: ULONG ctx_RegEcx; /* ECX register. */ michael@0: ULONG ctx_RegEdx; /* EDX register. */ michael@0: ULONG ctx_RegEbp; /* EBP register. */ michael@0: ULONG ctx_RegEip; /* EIP register. */ michael@0: ULONG ctx_SegCs; /* CS register. */ michael@0: ULONG ctx_EFlags; /* EFLAGS register. */ michael@0: ULONG ctx_RegEsp; /* ESP register. */ michael@0: ULONG ctx_SegSs; /* SS register. */ michael@0: } CONTEXTRECORD, *PCONTEXTRECORD; michael@0: #pragma pack() michael@0: #endif michael@0: michael@0: extern APIRET (* APIENTRY QueryThreadContext)(TID, ULONG, PCONTEXTRECORD); michael@0: michael@0: /* michael@0: #define _pr_tid (((PTIB2)_getTIBvalue(offsetof(TIB, tib_ptib2)))->tib2_ultid) michael@0: #define _pr_current_Thread (_system_tls[_pr_tid-1].__pr_current_thread) michael@0: */ michael@0: michael@0: /* Some simple mappings of Windows API's to OS/2 API's to make our lives a michael@0: * little bit easier. Only add one here if it is a DIRECT mapping. We are michael@0: * not emulating anything. Just mapping. michael@0: */ michael@0: #define FreeLibrary(x) DosFreeModule((HMODULE)x) michael@0: #define OutputDebugStringA(x) michael@0: michael@0: extern int _MD_os2_get_nonblocking_connect_error(int osfd); michael@0: michael@0: #endif /* nspr_os2_defs_h___ */