home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-e.zip / nspr30-e / include / md / _os2.h.merged < prev    next >
Text File  |  1998-07-21  |  19KB  |  515 lines

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