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