_os2.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nspr_os2_defs_h___
  6. #define nspr_os2_defs_h___
  7. #ifndef NO_LONG_LONG
  8. #define INCL_LONGLONG
  9. #endif
  10. #define INCL_DOS
  11. #define INCL_DOSPROCESS
  12. #define INCL_DOSERRORS
  13. #define INCL_WIN
  14. #define INCL_WPS
  15. #include <os2.h>
  16. #include <sys/select.h>
  17. #include "prio.h"
  18. #include <errno.h>
  19. /*
  20. * Internal configuration macros
  21. */
  22. #define PR_LINKER_ARCH "os2"
  23. #define _PR_SI_SYSNAME "OS2"
  24. #define _PR_SI_ARCHITECTURE "x86" /* XXXMB hardcode for now */
  25. #define HAVE_DLL
  26. #define _PR_GLOBAL_THREADS_ONLY
  27. #undef HAVE_THREAD_AFFINITY
  28. #define _PR_HAVE_THREADSAFE_GETHOST
  29. #define _PR_HAVE_ATOMIC_OPS
  30. #define HAVE_NETINET_TCP_H
  31. #define HANDLE unsigned long
  32. #define HINSTANCE HMODULE
  33. /* --- Common User-Thread/Native-Thread Definitions --------------------- */
  34. /* --- Globals --- */
  35. extern struct PRLock *_pr_schedLock;
  36. /* --- Typedefs --- */
  37. typedef void (*FiberFunc)(void *);
  38. #define PR_NUM_GCREGS 8
  39. typedef PRInt32 PR_CONTEXT_TYPE[PR_NUM_GCREGS];
  40. #define GC_VMBASE 0x40000000
  41. #define GC_VMLIMIT 0x00FFFFFF
  42. typedef int (*FARPROC)();
  43. #define _MD_MAGIC_THREAD 0x22222222
  44. #define _MD_MAGIC_THREADSTACK 0x33333333
  45. #define _MD_MAGIC_SEGMENT 0x44444444
  46. #define _MD_MAGIC_DIR 0x55555555
  47. #define _MD_MAGIC_CV 0x66666666
  48. struct _MDSemaphore {
  49. HEV sem;
  50. };
  51. struct _MDCPU {
  52. int unused;
  53. };
  54. struct _MDThread {
  55. HEV blocked_sema; /* Threads block on this when waiting
  56. * for IO or CondVar.
  57. */
  58. PRBool inCVWaitQueue; /* PR_TRUE if the thread is in the
  59. * wait queue of some cond var.
  60. * PR_FALSE otherwise. */
  61. TID handle; /* OS/2 thread handle */
  62. void *sp; /* only valid when suspended */
  63. PRUint32 magic; /* for debugging */
  64. PR_CONTEXT_TYPE gcContext; /* Thread context for GC */
  65. struct PRThread *prev, *next; /* used by the cvar wait queue to
  66. * chain the PRThread structures
  67. * together */
  68. };
  69. struct _MDThreadStack {
  70. PRUint32 magic; /* for debugging */
  71. };
  72. struct _MDSegment {
  73. PRUint32 magic; /* for debugging */
  74. };
  75. #undef PROFILE_LOCKS
  76. struct _MDDir {
  77. HDIR d_hdl;
  78. union {
  79. FILEFINDBUF3 small;
  80. FILEFINDBUF3L large;
  81. } d_entry;
  82. PRBool firstEntry; /* Is this the entry returned
  83. * by FindFirstFile()? */
  84. PRUint32 magic; /* for debugging */
  85. };
  86. struct _MDCVar {
  87. PRUint32 magic;
  88. struct PRThread *waitHead, *waitTail; /* the wait queue: a doubly-
  89. * linked list of threads
  90. * waiting on this condition
  91. * variable */
  92. PRIntn nwait; /* number of threads in the
  93. * wait queue */
  94. };
  95. #define _MD_CV_NOTIFIED_LENGTH 6
  96. typedef struct _MDNotified _MDNotified;
  97. struct _MDNotified {
  98. PRIntn length; /* # of used entries in this
  99. * structure */
  100. struct {
  101. struct _MDCVar *cv; /* the condition variable notified */
  102. PRIntn times; /* and the number of times notified */
  103. struct PRThread *notifyHead; /* list of threads to wake up */
  104. } cv[_MD_CV_NOTIFIED_LENGTH];
  105. _MDNotified *link; /* link to another of these, or NULL */
  106. };
  107. struct _MDLock {
  108. HMTX mutex; /* this is recursive on OS/2 */
  109. /*
  110. * When notifying cvars, there is no point in actually
  111. * waking up the threads waiting on the cvars until we've
  112. * released the lock. So, we temporarily record the cvars.
  113. * When doing an unlock, we'll then wake up the waiting threads.
  114. */
  115. struct _MDNotified notified; /* array of conditions notified */
  116. #ifdef PROFILE_LOCKS
  117. PRInt32 hitcount;
  118. PRInt32 misscount;
  119. #endif
  120. };
  121. struct _MDFileDesc {
  122. PRInt32 osfd; /* The osfd can come from one of three spaces:
  123. * - For stdin, stdout, and stderr, we are using
  124. * the libc file handle (0, 1, 2), which is an int.
  125. * - For files and pipes, we are using OS/2 handles,
  126. * which is a void*.
  127. * - For sockets, we are using int
  128. */
  129. };
  130. struct _MDProcess {
  131. PID pid;
  132. };
  133. /* --- Misc stuff --- */
  134. #define _MD_GET_SP(thread) (thread)->md.gcContext[6]
  135. /* --- IO stuff --- */
  136. #define _MD_OPEN (_PR_MD_OPEN)
  137. #define _MD_OPEN_FILE (_PR_MD_OPEN)
  138. #define _MD_READ (_PR_MD_READ)
  139. #define _MD_WRITE (_PR_MD_WRITE)
  140. #define _MD_WRITEV (_PR_MD_WRITEV)
  141. #define _MD_LSEEK (_PR_MD_LSEEK)
  142. #define _MD_LSEEK64 (_PR_MD_LSEEK64)
  143. extern PRInt32 _MD_CloseFile(PRInt32 osfd);
  144. #define _MD_CLOSE_FILE _MD_CloseFile
  145. #define _MD_GETFILEINFO (_PR_MD_GETFILEINFO)
  146. #define _MD_GETFILEINFO64 (_PR_MD_GETFILEINFO64)
  147. #define _MD_GETOPENFILEINFO (_PR_MD_GETOPENFILEINFO)
  148. #define _MD_GETOPENFILEINFO64 (_PR_MD_GETOPENFILEINFO64)
  149. #define _MD_STAT (_PR_MD_STAT)
  150. #define _MD_RENAME (_PR_MD_RENAME)
  151. #define _MD_ACCESS (_PR_MD_ACCESS)
  152. #define _MD_DELETE (_PR_MD_DELETE)
  153. #define _MD_MKDIR (_PR_MD_MKDIR)
  154. #define _MD_MAKE_DIR (_PR_MD_MKDIR)
  155. #define _MD_RMDIR (_PR_MD_RMDIR)
  156. #define _MD_LOCKFILE (_PR_MD_LOCKFILE)
  157. #define _MD_TLOCKFILE (_PR_MD_TLOCKFILE)
  158. #define _MD_UNLOCKFILE (_PR_MD_UNLOCKFILE)
  159. /* --- Socket IO stuff --- */
  160. /* The ones that don't map directly may need to be re-visited... */
  161. #define _MD_EACCES EACCES
  162. #define _MD_EADDRINUSE EADDRINUSE
  163. #define _MD_EADDRNOTAVAIL EADDRNOTAVAIL
  164. #define _MD_EAFNOSUPPORT EAFNOSUPPORT
  165. #define _MD_EAGAIN EWOULDBLOCK
  166. #define _MD_EALREADY EALREADY
  167. #define _MD_EBADF EBADF
  168. #define _MD_ECONNREFUSED ECONNREFUSED
  169. #define _MD_ECONNRESET ECONNRESET
  170. #define _MD_EFAULT SOCEFAULT
  171. #define _MD_EINPROGRESS EINPROGRESS
  172. #define _MD_EINTR EINTR
  173. #define _MD_EINVAL EINVAL
  174. #define _MD_EISCONN EISCONN
  175. #define _MD_ENETUNREACH ENETUNREACH
  176. #define _MD_ENOENT ENOENT
  177. #define _MD_ENOTCONN ENOTCONN
  178. #define _MD_ENOTSOCK ENOTSOCK
  179. #define _MD_EOPNOTSUPP EOPNOTSUPP
  180. #define _MD_EWOULDBLOCK EWOULDBLOCK
  181. #define _MD_GET_SOCKET_ERROR() sock_errno()
  182. #ifndef INADDR_LOOPBACK /* For some reason this is not defined in OS2 tcpip */
  183. /* #define INADDR_LOOPBACK INADDR_ANY */
  184. #endif
  185. #define _MD_INIT_FILEDESC(fd)
  186. extern void _MD_MakeNonblock(PRFileDesc *f);
  187. #define _MD_MAKE_NONBLOCK _MD_MakeNonblock
  188. #define _MD_INIT_FD_INHERITABLE (_PR_MD_INIT_FD_INHERITABLE)
  189. #define _MD_QUERY_FD_INHERITABLE (_PR_MD_QUERY_FD_INHERITABLE)
  190. #define _MD_SHUTDOWN (_PR_MD_SHUTDOWN)
  191. #define _MD_LISTEN _PR_MD_LISTEN
  192. extern PRInt32 _MD_CloseSocket(PRInt32 osfd);
  193. #define _MD_CLOSE_SOCKET _MD_CloseSocket
  194. #define _MD_SENDTO (_PR_MD_SENDTO)
  195. #define _MD_RECVFROM (_PR_MD_RECVFROM)
  196. #define _MD_SOCKETPAIR (_PR_MD_SOCKETPAIR)
  197. #define _MD_GETSOCKNAME (_PR_MD_GETSOCKNAME)
  198. #define _MD_GETPEERNAME (_PR_MD_GETPEERNAME)
  199. #define _MD_GETSOCKOPT (_PR_MD_GETSOCKOPT)
  200. #define _MD_SETSOCKOPT (_PR_MD_SETSOCKOPT)
  201. #define _MD_FSYNC _PR_MD_FSYNC
  202. #define _MD_SET_FD_INHERITABLE (_PR_MD_SET_FD_INHERITABLE)
  203. #ifdef _PR_HAVE_ATOMIC_OPS
  204. #define _MD_INIT_ATOMIC()
  205. #define _MD_ATOMIC_INCREMENT _PR_MD_ATOMIC_INCREMENT
  206. #define _MD_ATOMIC_ADD _PR_MD_ATOMIC_ADD
  207. #define _MD_ATOMIC_DECREMENT _PR_MD_ATOMIC_DECREMENT
  208. #define _MD_ATOMIC_SET _PR_MD_ATOMIC_SET
  209. #endif
  210. #define _MD_INIT_IO (_PR_MD_INIT_IO)
  211. #define _MD_PR_POLL (_PR_MD_PR_POLL)
  212. #define _MD_SOCKET (_PR_MD_SOCKET)
  213. extern PRInt32 _MD_SocketAvailable(PRFileDesc *fd);
  214. #define _MD_SOCKETAVAILABLE _MD_SocketAvailable
  215. #define _MD_PIPEAVAILABLE _MD_SocketAvailable
  216. #define _MD_CONNECT (_PR_MD_CONNECT)
  217. extern PRInt32 _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen,
  218. PRIntervalTime timeout);
  219. #define _MD_ACCEPT _MD_Accept
  220. #define _MD_BIND (_PR_MD_BIND)
  221. #define _MD_RECV (_PR_MD_RECV)
  222. #define _MD_SEND (_PR_MD_SEND)
  223. /* --- Scheduler stuff --- */
  224. /* #define _MD_PAUSE_CPU _PR_MD_PAUSE_CPU */
  225. #define _MD_PAUSE_CPU
  226. /* --- DIR stuff --- */
  227. #define PR_DIRECTORY_SEPARATOR '\\'
  228. #define PR_DIRECTORY_SEPARATOR_STR "\\"
  229. #define PR_PATH_SEPARATOR ';'
  230. #define PR_PATH_SEPARATOR_STR ";"
  231. #define _MD_ERRNO() errno
  232. #define _MD_OPEN_DIR (_PR_MD_OPEN_DIR)
  233. #define _MD_CLOSE_DIR (_PR_MD_CLOSE_DIR)
  234. #define _MD_READ_DIR (_PR_MD_READ_DIR)
  235. /* --- Segment stuff --- */
  236. #define _MD_INIT_SEGS()
  237. #define _MD_ALLOC_SEGMENT(seg, size, vaddr) 0
  238. #define _MD_FREE_SEGMENT(seg)
  239. /* --- Environment Stuff --- */
  240. #define _MD_GET_ENV (_PR_MD_GET_ENV)
  241. #define _MD_PUT_ENV (_PR_MD_PUT_ENV)
  242. /* --- Threading Stuff --- */
  243. #define _MD_DEFAULT_STACK_SIZE 65536L
  244. #define _MD_INIT_THREAD (_PR_MD_INIT_THREAD)
  245. #define _MD_INIT_ATTACHED_THREAD (_PR_MD_INIT_THREAD)
  246. #define _MD_CREATE_THREAD (_PR_MD_CREATE_THREAD)
  247. #define _MD_YIELD (_PR_MD_YIELD)
  248. #define _MD_SET_PRIORITY (_PR_MD_SET_PRIORITY)
  249. #define _MD_CLEAN_THREAD (_PR_MD_CLEAN_THREAD)
  250. #define _MD_SETTHREADAFFINITYMASK (_PR_MD_SETTHREADAFFINITYMASK)
  251. #define _MD_GETTHREADAFFINITYMASK (_PR_MD_GETTHREADAFFINITYMASK)
  252. #define _MD_EXIT_THREAD (_PR_MD_EXIT_THREAD)
  253. #define _MD_SUSPEND_THREAD (_PR_MD_SUSPEND_THREAD)
  254. #define _MD_RESUME_THREAD (_PR_MD_RESUME_THREAD)
  255. #define _MD_SUSPEND_CPU (_PR_MD_SUSPEND_CPU)
  256. #define _MD_RESUME_CPU (_PR_MD_RESUME_CPU)
  257. #define _MD_WAKEUP_CPUS (_PR_MD_WAKEUP_CPUS)
  258. #define _MD_BEGIN_SUSPEND_ALL()
  259. #define _MD_BEGIN_RESUME_ALL()
  260. #define _MD_END_SUSPEND_ALL()
  261. #define _MD_END_RESUME_ALL()
  262. /* --- Lock stuff --- */
  263. #define _PR_LOCK _MD_LOCK
  264. #define _PR_UNLOCK _MD_UNLOCK
  265. #define _MD_NEW_LOCK (_PR_MD_NEW_LOCK)
  266. #define _MD_FREE_LOCK(lock) (DosCloseMutexSem((lock)->mutex))
  267. #define _MD_LOCK(lock) (DosRequestMutexSem((lock)->mutex, SEM_INDEFINITE_WAIT))
  268. #define _MD_TEST_AND_LOCK(lock) (DosRequestMutexSem((lock)->mutex, SEM_INDEFINITE_WAIT),0)
  269. #define _MD_UNLOCK (_PR_MD_UNLOCK)
  270. /* --- lock and cv waiting --- */
  271. #define _MD_WAIT (_PR_MD_WAIT)
  272. #define _MD_WAKEUP_WAITER (_PR_MD_WAKEUP_WAITER)
  273. /* --- CVar ------------------- */
  274. #define _MD_WAIT_CV (_PR_MD_WAIT_CV)
  275. #define _MD_NEW_CV (_PR_MD_NEW_CV)
  276. #define _MD_FREE_CV (_PR_MD_FREE_CV)
  277. #define _MD_NOTIFY_CV (_PR_MD_NOTIFY_CV )
  278. #define _MD_NOTIFYALL_CV (_PR_MD_NOTIFYALL_CV)
  279. /* XXXMB- the IOQ stuff is certainly not working correctly yet. */
  280. /* extern struct _MDLock _pr_ioq_lock; */
  281. #define _MD_IOQ_LOCK()
  282. #define _MD_IOQ_UNLOCK()
  283. /* --- Initialization stuff --- */
  284. #define _MD_START_INTERRUPTS()
  285. #define _MD_STOP_INTERRUPTS()
  286. #define _MD_DISABLE_CLOCK_INTERRUPTS()
  287. #define _MD_ENABLE_CLOCK_INTERRUPTS()
  288. #define _MD_BLOCK_CLOCK_INTERRUPTS()
  289. #define _MD_UNBLOCK_CLOCK_INTERRUPTS()
  290. #define _MD_EARLY_INIT (_PR_MD_EARLY_INIT)
  291. #define _MD_FINAL_INIT()
  292. #define _MD_EARLY_CLEANUP()
  293. #define _MD_INIT_CPUS()
  294. #define _MD_INIT_RUNNING_CPU(cpu)
  295. struct PRProcess;
  296. struct PRProcessAttr;
  297. #define _MD_CREATE_PROCESS _PR_CreateOS2Process
  298. extern struct PRProcess * _PR_CreateOS2Process(
  299. const char *path,
  300. char *const *argv,
  301. char *const *envp,
  302. const struct PRProcessAttr *attr
  303. );
  304. #define _MD_DETACH_PROCESS _PR_DetachOS2Process
  305. extern PRStatus _PR_DetachOS2Process(struct PRProcess *process);
  306. /* --- Wait for a child process to terminate --- */
  307. #define _MD_WAIT_PROCESS _PR_WaitOS2Process
  308. extern PRStatus _PR_WaitOS2Process(struct PRProcess *process,
  309. PRInt32 *exitCode);
  310. #define _MD_KILL_PROCESS _PR_KillOS2Process
  311. extern PRStatus _PR_KillOS2Process(struct PRProcess *process);
  312. #define _MD_CLEANUP_BEFORE_EXIT()
  313. #define _MD_EXIT (_PR_MD_EXIT)
  314. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
  315. PR_BEGIN_MACRO \
  316. *status = PR_TRUE; \
  317. PR_END_MACRO
  318. #define _MD_SWITCH_CONTEXT
  319. #define _MD_RESTORE_CONTEXT
  320. /* --- Intervals --- */
  321. #define _MD_INTERVAL_INIT (_PR_MD_INTERVAL_INIT)
  322. #define _MD_GET_INTERVAL (_PR_MD_GET_INTERVAL)
  323. #define _MD_INTERVAL_PER_SEC (_PR_MD_INTERVAL_PER_SEC)
  324. #define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000)
  325. #define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000)
  326. /* --- Native-Thread Specific Definitions ------------------------------- */
  327. typedef struct __NSPR_TLS
  328. {
  329. struct PRThread *_pr_thread_last_run;
  330. struct PRThread *_pr_currentThread;
  331. struct _PRCPU *_pr_currentCPU;
  332. } _NSPR_TLS;
  333. extern _NSPR_TLS* pThreadLocalStorage;
  334. NSPR_API(void) _PR_MD_ENSURE_TLS(void);
  335. #define _MD_GET_ATTACHED_THREAD() pThreadLocalStorage->_pr_currentThread
  336. extern struct PRThread * _MD_CURRENT_THREAD(void);
  337. #define _MD_SET_CURRENT_THREAD(_thread) _PR_MD_ENSURE_TLS(); pThreadLocalStorage->_pr_currentThread = (_thread)
  338. #define _MD_LAST_THREAD() pThreadLocalStorage->_pr_thread_last_run
  339. #define _MD_SET_LAST_THREAD(_thread) _PR_MD_ENSURE_TLS(); pThreadLocalStorage->_pr_thread_last_run = (_thread)
  340. #define _MD_CURRENT_CPU() pThreadLocalStorage->_pr_currentCPU
  341. #define _MD_SET_CURRENT_CPU(_cpu) _PR_MD_ENSURE_TLS(); pThreadLocalStorage->_pr_currentCPU = (_cpu)
  342. /* lth. #define _MD_SET_INTSOFF(_val) (_pr_ints_off = (_val)) */
  343. /* lth. #define _MD_GET_INTSOFF() _pr_ints_off */
  344. /* lth. #define _MD_INCREMENT_INTSOFF() (_pr_ints_off++) */
  345. /* lth. #define _MD_DECREMENT_INTSOFF() (_pr_ints_off--) */
  346. /* --- Scheduler stuff --- */
  347. #define LOCK_SCHEDULER() 0
  348. #define UNLOCK_SCHEDULER() 0
  349. #define _PR_LockSched() 0
  350. #define _PR_UnlockSched() 0
  351. /* --- Initialization stuff --- */
  352. #define _MD_INIT_LOCKS()
  353. /* --- Stack stuff --- */
  354. #define _MD_INIT_STACK(stack, redzone)
  355. #define _MD_CLEAR_STACK(stack)
  356. /* --- Memory-mapped files stuff --- */
  357. /* ReadOnly and WriteCopy modes are simulated on OS/2;
  358. * ReadWrite mode is not supported.
  359. */
  360. struct _MDFileMap {
  361. PROffset64 maxExtent;
  362. };
  363. extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
  364. #define _MD_CREATE_FILE_MAP _MD_CreateFileMap
  365. extern PRInt32 _MD_GetMemMapAlignment(void);
  366. #define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment
  367. extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,
  368. PRUint32 len);
  369. #define _MD_MEM_MAP _MD_MemMap
  370. extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);
  371. #define _MD_MEM_UNMAP _MD_MemUnmap
  372. extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
  373. #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
  374. /* Some stuff for setting up thread contexts */
  375. typedef ULONG DWORD, *PDWORD;
  376. /* The following definitions and two structures are new in OS/2 Warp 4.0.
  377. */
  378. #ifndef CONTEXT_CONTROL
  379. #define CONTEXT_CONTROL 0x00000001
  380. #define CONTEXT_INTEGER 0x00000002
  381. #define CONTEXT_SEGMENTS 0x00000004
  382. #define CONTEXT_FLOATING_POINT 0x00000008
  383. #define CONTEXT_FULL 0x0000000F
  384. #pragma pack(2)
  385. typedef struct _FPREG {
  386. ULONG losig; /* Low 32-bits of the significand. */
  387. ULONG hisig; /* High 32-bits of the significand. */
  388. USHORT signexp; /* Sign and exponent. */
  389. } FPREG;
  390. typedef struct _CONTEXTRECORD {
  391. ULONG ContextFlags;
  392. ULONG ctx_env[7];
  393. FPREG ctx_stack[8];
  394. ULONG ctx_SegGs; /* GS register. */
  395. ULONG ctx_SegFs; /* FS register. */
  396. ULONG ctx_SegEs; /* ES register. */
  397. ULONG ctx_SegDs; /* DS register. */
  398. ULONG ctx_RegEdi; /* EDI register. */
  399. ULONG ctx_RegEsi; /* ESI register. */
  400. ULONG ctx_RegEax; /* EAX register. */
  401. ULONG ctx_RegEbx; /* EBX register. */
  402. ULONG ctx_RegEcx; /* ECX register. */
  403. ULONG ctx_RegEdx; /* EDX register. */
  404. ULONG ctx_RegEbp; /* EBP register. */
  405. ULONG ctx_RegEip; /* EIP register. */
  406. ULONG ctx_SegCs; /* CS register. */
  407. ULONG ctx_EFlags; /* EFLAGS register. */
  408. ULONG ctx_RegEsp; /* ESP register. */
  409. ULONG ctx_SegSs; /* SS register. */
  410. } CONTEXTRECORD, *PCONTEXTRECORD;
  411. #pragma pack()
  412. #endif
  413. extern APIRET (* APIENTRY QueryThreadContext)(TID, ULONG, PCONTEXTRECORD);
  414. /*
  415. #define _pr_tid (((PTIB2)_getTIBvalue(offsetof(TIB, tib_ptib2)))->tib2_ultid)
  416. #define _pr_current_Thread (_system_tls[_pr_tid-1].__pr_current_thread)
  417. */
  418. /* Some simple mappings of Windows API's to OS/2 API's to make our lives a
  419. * little bit easier. Only add one here if it is a DIRECT mapping. We are
  420. * not emulating anything. Just mapping.
  421. */
  422. #define FreeLibrary(x) DosFreeModule((HMODULE)x)
  423. #define OutputDebugStringA(x)
  424. extern int _MD_os2_get_nonblocking_connect_error(int osfd);
  425. #endif /* nspr_os2_defs_h___ */