home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-v.zip / nspr30-v / include / md / _win16.h < prev    next >
C/C++ Source or Header  |  1998-11-02  |  20KB  |  557 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_win16_defs_h___
  20. #define nspr_win16_defs_h___
  21.  
  22. #include <windows.h>
  23. #include <winsock.h>
  24. #include <errno.h>
  25. #include <direct.h>
  26.  
  27. #include "nspr.h"
  28. /* $$ fix this */
  29. #define Remind(x)
  30.  
  31. /*
  32.  * Internal configuration macros
  33.  */
  34.  
  35. #define PR_LINKER_ARCH      "win16"
  36. #define _PR_SI_SYSNAME        "WIN16"
  37. #define _PR_SI_ARCHITECTURE   "x86"    /* XXXMB hardcode for now */
  38.  
  39. #define HAVE_DLL
  40. #define _PR_NO_PREEMPT
  41. #define _PR_LOCAL_THREADS_ONLY
  42. #undef  _PR_GLOBAL_THREADS_ONLY
  43. #undef  HAVE_THREAD_AFFINITY
  44. #define HAVE_SOCKET_REUSEADDR
  45. #define HAVE_SOCKET_KEEPALIVE
  46. #define _PR_HAVE_ATOMIC_OPS
  47.  
  48. /* --- Common User-Thread/Native-Thread Definitions --------------------- */
  49.  
  50. extern struct PRLock        *_pr_schedLock;
  51. extern char                 * _pr_top_of_task_stack;
  52.  
  53.  
  54. /* --- Typedefs --- */
  55.  
  56. #define PR_NUM_GCREGS           9
  57. typedef PRInt32                   PR_CONTEXT_TYPE[PR_NUM_GCREGS];
  58.  
  59. #define _MD_MAGIC_THREAD    0x22222222
  60. #define _MD_MAGIC_THREADSTACK    0x33333333
  61. #define _MD_MAGIC_SEGMENT    0x44444444
  62. #define _MD_MAGIC_DIR        0x55555555
  63. #define _MD_MAGIC_CV        0x66666666
  64.  
  65.  
  66. typedef struct _PRWin16PollDesc
  67. {
  68.     PRInt32 osfd;
  69.     PRInt16 in_flags;
  70.     PRInt16 out_flags;
  71. } _PRWin16PollDesc;
  72.  
  73. typedef struct PRPollQueue
  74. {
  75.     PRCList links;              /* for linking PRPollQueue's together */
  76.     _PRWin16PollDesc *pds;      /* array of poll descriptors */
  77.     PRUintn npds;                /* length of the array */
  78.     PRPackedBool on_ioq;        /* is this on the async i/o work q? */
  79.     PRIntervalTime timeout;     /* timeout, in ticks */
  80.     struct PRThread *thr;
  81. } PRPollQueue;
  82.  
  83. #define _PR_POLLQUEUE_PTR(_qp) \
  84.     ((PRPollQueue *) ((char*) (_qp) - offsetof(PRPollQueue,links)))
  85.  
  86. PR_EXTERN(PRInt32) _PR_WaitForFD(PRInt32 osfd, PRUintn how,
  87.                     PRIntervalTime timeout);
  88. PR_EXTERN(void) _PR_Unblock_IO_Wait(struct PRThread *thr);
  89.  
  90. #define _PR_MD_MAX_OSFD             FD_SETSIZE
  91. #define _PR_IOQ(_cpu)                ((_cpu)->md.ioQ)
  92. #define _PR_ADD_TO_IOQ(_pq, _cpu)     PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
  93. #define _PR_FD_READ_SET(_cpu)        ((_cpu)->md.fd_read_set)
  94. #define _PR_FD_READ_CNT(_cpu)        ((_cpu)->md.fd_read_cnt)
  95. #define _PR_FD_WRITE_SET(_cpu)        ((_cpu)->md.fd_write_set)
  96. #define _PR_FD_WRITE_CNT(_cpu)        ((_cpu)->md.fd_write_cnt)
  97. #define _PR_FD_EXCEPTION_SET(_cpu)    ((_cpu)->md.fd_exception_set)
  98. #define _PR_FD_EXCEPTION_CNT(_cpu)    ((_cpu)->md.fd_exception_cnt)
  99. #define _PR_IOQ_TIMEOUT(_cpu)        ((_cpu)->md.ioq_timeout)
  100. #define _PR_IOQ_MAX_OSFD(_cpu)        ((_cpu)->md.ioq_max_osfd)
  101.  
  102. struct _MDCPU {
  103.     PRCList        ioQ;
  104.     fd_set        fd_read_set, fd_write_set, fd_exception_set;
  105.     PRInt16        fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
  106.                 fd_exception_cnt[_PR_MD_MAX_OSFD];
  107.     PRUint32    ioq_timeout;
  108.     PRInt32        ioq_max_osfd;
  109. };
  110.  
  111. struct _MDThread {
  112.     /* The overlapped structure must be first! */
  113.     HANDLE           blocked_sema;      /* Threads block on this when waiting
  114.                                          * for IO or CondVar.
  115.                                          */
  116.     PRInt32         errcode;        /* preserved errno for this thread */
  117.     CATCHBUF        context;        /* thread context for Throw() */
  118.     void           *SP;             /* Stack pointer, used only by GarbColl */
  119.     int             threadNumber;   /* instrumentation: order of creation */
  120.     _PRWin16PollDesc thr_pd;       /* poll descriptor for i/o */
  121.     PRPollQueue        thr_pq;        /* i/o parameters            */
  122.     void           *exceptionContext; /* mfc exception context */
  123.     char            guardBand[24];  /* don't overwrite this */
  124.     PRUint32        magic;          /* self identifier, for debug */
  125. };
  126.  
  127. struct _MDThreadStack {
  128.     PRUint32           magic;          /* for debugging */
  129.     PRIntn          cxByteCount;    /* number of stack bytes to move */
  130.     char *          stackTop;       /* high address on stack */
  131. };
  132.  
  133. struct _MDSegment {
  134.     PRUint32           magic;          /* for debugging */
  135. };
  136.  
  137.  
  138. struct _MDLock {
  139.     PRUint32           magic;          /* for debugging */
  140.     PRUint32           mutex;
  141. };
  142.  
  143. struct _MDDir {
  144.     PRUint32         magic;          /* for debugging */
  145.     struct  dirent  *dir;
  146. };
  147.  
  148. struct _MDCVar {
  149.     PRUint32        magic;
  150. };
  151.  
  152. struct _MDSemaphore {
  153.     PRInt32            unused;
  154. };
  155.  
  156. struct _MDFileDesc {
  157.     PRInt32 osfd;
  158. };
  159.  
  160. struct _MDProcess {
  161.     HANDLE handle;
  162.     DWORD id;
  163. };
  164.  
  165. /*
  166. ** Microsoft 'struct _stat'
  167. ** ... taken directly from msvc 1.52c's header file sys/stat.h
  168. ** see PR_Stat() implemented in w16io.c
  169. ** See BugSplat: 98516
  170. */
  171. #pragma pack(push)
  172. #pragma pack(2)
  173.  
  174. typedef unsigned short _ino_t;
  175. typedef short _dev_t;
  176. typedef long _off_t;
  177.  
  178. typedef struct _MDMSStat {
  179.     _dev_t st_dev;
  180.     _ino_t st_ino;
  181.     unsigned short st_mode;
  182.     short st_nlink;
  183.     short st_uid;
  184.     short st_gid;
  185.     _dev_t st_rdev;
  186.     _off_t st_size;
  187.     time_t st_atime;
  188.     time_t st_mtime;
  189.     time_t st_ctime;
  190. } _MDMSStat;
  191. #pragma pack(pop)
  192.  
  193. /* --- Errors --- */
  194.     /* These are NSPR generated error codes which need to be unique from
  195.      * OS error codes.
  196.      */
  197. #define _MD_UNIQUEBASE                 50000
  198. #define _MD_EINTERRUPTED               _MD_UNIQUEBASE + 1
  199. #define _MD_ETIMEDOUT                  _MD_UNIQUEBASE + 2
  200. #define _MD_EIO                        _MD_UNIQUEBASE + 3
  201.  
  202. struct PRProcess;
  203. struct PRProcessAttr;
  204.  
  205. /* --- Create a new process --- */
  206. #define _MD_CREATE_PROCESS _PR_CreateWindowsProcess
  207. extern struct PRProcess * _PR_CreateWindowsProcess(
  208.     const char *path,
  209.     char *const *argv,
  210.     char *const *envp,
  211.     const struct PRProcessAttr *attr
  212. );
  213.  
  214. #define _MD_DETACH_PROCESS _PR_DetachWindowsProcess
  215. extern PRStatus _PR_DetachWindowsProcess(struct PRProcess *process);
  216.  
  217. /* --- Wait for a child process to terminate --- */
  218. #define _MD_WAIT_PROCESS _PR_WaitWindowsProcess
  219. extern PRStatus _PR_WaitWindowsProcess(struct PRProcess *process, 
  220.     PRInt32 *exitCode);
  221.  
  222. #define _MD_KILL_PROCESS _PR_KillWindowsProcess
  223. extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process);
  224.  
  225.  
  226. /* --- Misc stuff --- */
  227.  
  228. #define MD_ASSERTINT( x )             PR_ASSERT( (x) < 65535 )
  229.  
  230. /* --- IO stuff --- */
  231. #define MAX_PATH    256
  232. #define _MD_ERRNO()                   errno
  233. #define GetLastError()                errno
  234.  
  235. #define _MD_GET_FILE_ERROR()          errno
  236. #define _MD_SET_FILE_ERROR(_err)      errno = (_err)
  237.  
  238. #define _MD_OPEN                      _PR_MD_OPEN
  239. #define _MD_READ                      _PR_MD_READ
  240. #define _MD_WRITE                     _PR_MD_WRITE
  241. #define _MD_WRITEV                    _PR_MD_WRITEV
  242. #define _MD_LSEEK                     _PR_MD_LSEEK
  243. #define _MD_LSEEK64                   _PR_MD_LSEEK64
  244. #define _MD_CLOSE_FILE                _PR_MD_CLOSE_FILE
  245. #define _MD_GETFILEINFO               _PR_MD_GETFILEINFO
  246. #define _MD_GETOPENFILEINFO           _PR_MD_GETOPENFILEINFO
  247. #define _MD_STAT                      _PR_MD_STAT
  248. #define _MD_RENAME                    _PR_MD_RENAME     
  249. #define _MD_ACCESS                    _PR_MD_ACCESS     
  250. #define _MD_DELETE                    _PR_MD_DELETE     
  251. #define _MD_MKDIR                     _PR_MD_MKDIR      
  252. #define _MD_RMDIR                     _PR_MD_RMDIR      
  253. #define _MD_LOCKFILE                  _PR_MD_LOCKFILE
  254. #define _MD_TLOCKFILE                 _PR_MD_TLOCKFILE
  255. #define _MD_UNLOCKFILE                _PR_MD_UNLOCKFILE
  256.  
  257.  
  258. /* --- Socket IO stuff --- */
  259. #define _MD_EACCES                WSAEACCES
  260. #define _MD_EADDRINUSE            WSAEADDRINUSE
  261. #define _MD_EADDRNOTAVAIL         WSAEADDRNOTAVAIL
  262. #define _MD_EAFNOSUPPORT          WSAEAFNOSUPPORT
  263. #define _MD_EAGAIN                WSAEWOULDBLOCK
  264. #define _MD_EALREADY              WSAEALREADY
  265. #define _MD_EBADF                 WSAEBADF
  266. #define _MD_ECONNREFUSED          WSAECONNREFUSED
  267. #define _MD_ECONNRESET            WSAECONNRESET
  268. #define _MD_EFAULT                WSAEFAULT
  269. #define _MD_EINPROGRESS           WSAEINPROGRESS
  270. #define _MD_EINTR                 WSAEINTR
  271. #define _MD_EINVAL                EINVAL
  272. #define _MD_EISCONN               WSAEISCONN
  273. #define _MD_ENETUNREACH           WSAENETUNREACH
  274. #define _MD_ENOENT                ENOENT
  275. #define _MD_ENOTCONN              WSAENOTCONN
  276. #define _MD_ENOTSOCK              WSAENOTSOCK
  277. #define _MD_EOPNOTSUPP            WSAEOPNOTSUPP
  278. #define _MD_EWOULDBLOCK           WSAEWOULDBLOCK
  279. #define _MD_GET_SOCKET_ERROR()    WSAGetLastError()
  280. #define _MD_SET_SOCKET_ERROR(_err) WSASetLastError(_err)
  281.  
  282. #define _MD_MAKE_NONBLOCK             _PR_MD_MAKE_NONBLOCK
  283. #define _MD_SHUTDOWN                  _PR_MD_SHUTDOWN
  284. #define _MD_LISTEN                      _PR_MD_LISTEN
  285. #define _MD_CLOSE_SOCKET              _PR_MD_CLOSE_SOCKET
  286. #define _MD_SENDTO                    _PR_MD_SENDTO
  287. #define _MD_RECVFROM                  _PR_MD_RECVFROM
  288. #define _MD_SOCKETPAIR(s, type, proto, sv) -1
  289. #define _MD_GETSOCKNAME               _PR_MD_GETSOCKNAME
  290. #define _MD_GETPEERNAME               _PR_MD_GETPEERNAME
  291. #define _MD_GETSOCKOPT                _PR_MD_GETSOCKOPT
  292. #define _MD_SETSOCKOPT                _PR_MD_SETSOCKOPT
  293. #define _MD_SELECT                    select
  294. #define _MD_FSYNC                     _PR_MD_FSYNC
  295. #define _MD_SOCKETAVAILABLE           _PR_MD_SOCKETAVAILABLE
  296.  
  297. #define _MD_INIT_ATOMIC()
  298. #define _MD_ATOMIC_INCREMENT(x)       (*x++)
  299. #define _MD_ATOMIC_ADD(ptr, val)      ((*x) += val)
  300. #define _MD_ATOMIC_DECREMENT(x)       (*x--)
  301. #define _MD_ATOMIC_SET(x,y)           (*x, y)
  302.  
  303. #define _MD_INIT_IO                   _PR_MD_INIT_IO
  304. #define _MD_TRANSMITFILE              _PR_MD_TRANSMITFILE
  305.  
  306. /* win95 doesn't have async IO */
  307. #define _MD_SOCKET                    _PR_MD_SOCKET
  308. #define _MD_CONNECT                   _PR_MD_CONNECT
  309. #define _MD_ACCEPT                    _PR_MD_ACCEPT
  310. #define _MD_BIND                      _PR_MD_BIND
  311. #define _MD_RECV                      _PR_MD_RECV
  312. #define _MD_SEND                      _PR_MD_SEND
  313.  
  314. #define _MD_CHECK_FOR_EXIT()
  315.  
  316. /* --- Scheduler stuff --- */
  317. #define _MD_PAUSE_CPU                 _PR_MD_PAUSE_CPU
  318.  
  319. /* --- DIR stuff --- */
  320. #define PR_DIRECTORY_SEPARATOR        '\\'
  321. #define PR_DIRECTORY_SEPARATOR_STR    "\\"
  322. #define PR_PATH_SEPARATOR        ';'
  323. #define PR_PATH_SEPARATOR_STR        ";"
  324. #define _MD_OPEN_DIR                  _PR_MD_OPEN_DIR
  325. #define _MD_CLOSE_DIR                 _PR_MD_CLOSE_DIR
  326. #define _MD_READ_DIR                  _PR_MD_READ_DIR
  327.  
  328. /* --- Segment stuff --- */
  329. #define _MD_INIT_SEGS()
  330. #define _MD_ALLOC_SEGMENT           _MD_AllocSegment
  331. #define _MD_FREE_SEGMENT            _MD_FreeSegment
  332.  
  333. /* --- Environment Stuff --- */
  334. #define _MD_GET_ENV                 _PR_MD_GET_ENV
  335. #define _MD_PUT_ENV                 _PR_MD_PUT_ENV
  336.  
  337. /* --- Threading Stuff --- */
  338. #define _MD_DEFAULT_STACK_SIZE      32767L
  339. #define _MD_INIT_THREAD             _PR_MD_INIT_THREAD
  340. #define _MD_INIT_PRIMORDIAL_THREAD  _PR_MD_INIT_PRIMORDIAL_THREAD
  341. #define _MD_CREATE_THREAD(t,f,p,sc,st,stsiz) (PR_SUCCESS)
  342. #define _MD_YIELD                   _PR_MD_YIELD
  343. #define _MD_SET_PRIORITY(t,p)            
  344. #define _MD_CLEAN_THREAD(t)
  345. #define _MD_SETTHREADAFFINITYMASK   _PR_MD_SETTHREADAFFINITYMASK
  346. #define _MD_GETTHREADAFFINITYMASK   _PR_MD_GETTHREADAFFINITYMASK
  347. #define _MD_EXIT_THREAD
  348. #define _MD_SUSPEND_THREAD          _PR_MD_SUSPEND_THREAD
  349. #define _MD_RESUME_THREAD           _PR_MD_RESUME_THREAD
  350. #define _MD_SUSPEND_CPU             _PR_MD_SUSPEND_CPU
  351. #define _MD_RESUME_CPU              _PR_MD_RESUME_CPU
  352. #define _MD_BEGIN_SUSPEND_ALL()
  353. #define _MD_BEGIN_RESUME_ALL()
  354. #define _MD_END_SUSPEND_ALL()
  355. #define _MD_END_RESUME_ALL()
  356.  
  357. /* --- Lock stuff --- */
  358. /*
  359. ** Win16 does not need MD locks.
  360. */
  361. #define _PR_LOCK                    _MD_LOCK
  362. #define _PR_UNLOCK                  _MD_UNLOCK
  363.  
  364. #define _MD_NEW_LOCK(l)             (PR_SUCCESS)
  365. #define _MD_FREE_LOCK(l)
  366. #define _MD_LOCK(l)
  367. #define _MD_TEST_AND_LOCK(l)        (PR_FAILURE)
  368. #define _MD_UNLOCK(l)
  369.  
  370. /* --- lock and cv waiting --- */
  371. #define _MD_WAIT                      _PR_MD_WAIT
  372. #define _MD_WAKEUP_WAITER(a)
  373. #define _MD_WAKEUP_CPUS               _PR_MD_WAKEUP_CPUS
  374.  
  375. /* --- CVar ------------------- */
  376. #define _MD_WAIT_CV                      _PR_MD_WAIT_CV
  377. #define _MD_NEW_CV                      _PR_MD_NEW_CV
  378. #define _MD_FREE_CV                      _PR_MD_FREE_CV
  379. #define _MD_NOTIFY_CV                  _PR_MD_NOTIFY_CV    
  380. #define _MD_NOTIFYALL_CV              _PR_MD_NOTIFYALL_CV
  381.  
  382.    /* XXXMB- the IOQ stuff is certainly not working correctly yet. */
  383. #define _MD_IOQ_LOCK()                
  384. #define _MD_IOQ_UNLOCK()              
  385.  
  386.  
  387. /* --- Initialization stuff --- */
  388. PR_EXTERN(void) _MD_INIT_RUNNING_CPU(struct _PRCPU *cpu );
  389. #define _MD_START_INTERRUPTS()
  390. #define _MD_STOP_INTERRUPTS()
  391. #define _MD_DISABLE_CLOCK_INTERRUPTS()
  392. #define _MD_ENABLE_CLOCK_INTERRUPTS()
  393. #define _MD_BLOCK_CLOCK_INTERRUPTS()
  394. #define _MD_UNBLOCK_CLOCK_INTERRUPTS()
  395. #define _MD_EARLY_INIT                  _PR_MD_EARLY_INIT
  396. #define _MD_FINAL_INIT                  _PR_MD_FINAL_INIT
  397. #define _MD_INIT_CPUS()
  398.  
  399. /* --- User Threading stuff --- */
  400. #define _MD_EXIT
  401.  
  402. #define _MD_CLEANUP_BEFORE_EXIT              _PR_MD_CLEANUP_BEFORE_EXIT
  403.  
  404. /* --- Intervals --- */
  405. #define _MD_INTERVAL_INIT                 _PR_MD_INTERVAL_INIT
  406. #define _MD_GET_INTERVAL                  _PR_MD_GET_INTERVAL
  407. #define _MD_INTERVAL_PER_SEC              _PR_MD_INTERVAL_PER_SEC
  408. #define _MD_INTERVAL_PER_MILLISEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000)
  409. #define _MD_INTERVAL_PER_MICROSEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000000)
  410.  
  411. /* --- Scheduler stuff --- */
  412. #define LOCK_SCHEDULER()                 0
  413. #define UNLOCK_SCHEDULER()               0
  414. #define _PR_LockSched()                     0
  415. #define _PR_UnlockSched()                0
  416.  
  417. /* --- Initialization stuff --- */
  418. #define _MD_INIT_LOCKS()
  419.  
  420. /* --- Stack stuff --- */
  421. #define _MD_INIT_STACK                   _PR_MD_INIT_STACK
  422. #define _MD_CLEAR_STACK(stack)
  423.  
  424. /*
  425. ** Watcom needs to see this to make the linker work.
  426. **
  427. */
  428. PR_EXTERN(void) _PR_NativeDestroyThread(PRThread *thread);
  429. PR_EXTERN(void) _PR_UserDestroyThread(PRThread *thread);
  430.  
  431.  
  432. /*
  433.  * _PR_ShutdownLinker unloads all dlls loaded by the application via
  434.  * calls to PR_LoadLibrary
  435.  */
  436. void _PR_ShutdownLinker(void);
  437.  
  438.  
  439. /*
  440. ** If thread emulation is used, then setjmp/longjmp stores the register
  441. ** state of each thread.
  442. **
  443. ** CatchBuf layout:
  444. **  context[0] - IP
  445. **  context[1] - CS
  446. **  context[2] - SP
  447. **  context[3] - BP
  448. **  context[4] - SI
  449. **  context[5] - DI
  450. **  context[6] - DS
  451. **  context[7] - ?? (maybe flags)
  452. **  context[8] - SS
  453. */
  454. #define PR_CONTEXT_TYPE     CATCHBUF
  455. #define PR_NUM_GCREGS       9
  456.  
  457. #define _MD_GET_SP(thread)  ((thread)->md.SP)
  458. #define CONTEXT(_t)  ((_t)->md.context)
  459.  
  460. /*
  461. ** Initialize a thread context to run "e(o,a)" when started
  462. */
  463. #define _MD_INIT_CONTEXT(_t, sp, epa, stat )   \
  464. {                                              \
  465.      *(stat) = PR_TRUE;                        \
  466.      Catch((_t)->md.context );             \
  467.      (_t)->md.context[0] = OFFSETOF(epa);         \
  468.      (_t)->md.context[1] = SELECTOROF(epa);                       \
  469.      (_t)->md.context[2] = OFFSETOF(_pr_top_of_task_stack - 64);  \
  470.      (_t)->md.context[3]  = 0;                 \
  471. }
  472.  
  473. #define _MD_SWITCH_CONTEXT(_t)                 \
  474.     if (!Catch((_t)->md.context)) {            \
  475.         int     garbCollPlaceHolder;           \
  476.         (_t)->md.errcode = errno;              \
  477.         (_t)->md.SP = &garbCollPlaceHolder;    \
  478.         _PR_Schedule();                        \
  479.     }
  480.  
  481. #define _MD_SAVE_CONTEXT(_t)                    \
  482.     {                                           \
  483.         int     garbCollPlaceHolder;            \
  484.         Catch((_t)->md.context);                \
  485.         (_t)->md.errcode = errno;               \
  486.         (_t)->md.SP = &garbCollPlaceHolder;     \
  487.     }
  488.  
  489. /*
  490. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  491. */
  492. #define _PR_MD_RESTORE_CONTEXT  _MD_RESTORE_CONTEXT
  493.  
  494. /*
  495.  * Memory-mapped files
  496.  */
  497.  
  498. struct _MDFileMap {
  499.     PRInt8 unused;
  500. };
  501.  
  502. extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
  503. #define _MD_CREATE_FILE_MAP _MD_CreateFileMap
  504.  
  505. extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,
  506.         PRUint32 len);
  507. #define _MD_MEM_MAP _MD_MemMap
  508.  
  509. extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);
  510. #define _MD_MEM_UNMAP _MD_MemUnmap
  511.  
  512. extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
  513. #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
  514.  
  515.  
  516. /* --- Error mapping ----------------------------------- */
  517. extern void _PR_MD_map_error( int err );
  518.  
  519. #define _PR_MD_MAP_OPENDIR_ERROR        _PR_MD_map_error
  520. #define _PR_MD_MAP_CLOSEDIR_ERROR       _PR_MD_map_error
  521. #define _PR_MD_MAP_READDIR_ERROR        _PR_MD_map_error
  522. #define _PR_MD_MAP_DELETE_ERROR         _PR_MD_map_error
  523. #define _PR_MD_MAP_STAT_ERROR           _PR_MD_map_error
  524. #define _PR_MD_MAP_FSTAT_ERROR          _PR_MD_map_error
  525. #define _PR_MD_MAP_RENAME_ERROR         _PR_MD_map_error
  526. #define _PR_MD_MAP_ACCESS_ERROR         _PR_MD_map_error
  527. #define _PR_MD_MAP_MKDIR_ERROR          _PR_MD_map_error
  528. #define _PR_MD_MAP_RMDIR_ERROR          _PR_MD_map_error
  529. #define _PR_MD_MAP_READ_ERROR           _PR_MD_map_error
  530. #define _PR_MD_MAP_TRANSMITFILE_ERROR   _PR_MD_map_error
  531. #define _PR_MD_MAP_WRITE_ERROR          _PR_MD_map_error
  532. #define _PR_MD_MAP_LSEEK_ERROR          _PR_MD_map_error
  533. #define _PR_MD_MAP_FSYNC_ERROR          _PR_MD_map_error
  534. #define _PR_MD_MAP_CLOSE_ERROR          _PR_MD_map_error
  535. #define _PR_MD_MAP_SOCKET_ERROR         _PR_MD_map_error
  536. #define _PR_MD_MAP_RECV_ERROR           _PR_MD_map_error
  537. #define _PR_MD_MAP_RECVFROM_ERROR       _PR_MD_map_error
  538. #define _PR_MD_MAP_SEND_ERROR           _PR_MD_map_error
  539. #define _PR_MD_MAP_SENDTO_ERROR         _PR_MD_map_error
  540. #define _PR_MD_MAP_ACCEPT_ERROR         _PR_MD_map_error
  541. #define _PR_MD_MAP_ACCEPTEX_ERROR       _PR_MD_map_error
  542. #define _PR_MD_MAP_CONNECT_ERROR        _PR_MD_map_error
  543. #define _PR_MD_MAP_BIND_ERROR           _PR_MD_map_error
  544. #define _PR_MD_MAP_LISTEN_ERROR         _PR_MD_map_error
  545. #define _PR_MD_MAP_SHUTDOWN_ERROR       _PR_MD_map_error
  546. #define _PR_MD_MAP_GETSOCKNAME_ERROR    _PR_MD_map_error
  547. #define _PR_MD_MAP_GETPEERNAME_ERROR    _PR_MD_map_error
  548. #define _PR_MD_MAP_GETSOCKOPT_ERROR     _PR_MD_map_error
  549. #define _PR_MD_MAP_SETSOCKOPT_ERROR     _PR_MD_map_error
  550. #define _PR_MD_MAP_OPEN_ERROR           _PR_MD_map_error
  551. #define _PR_MD_MAP_GETHOSTNAME_ERROR    _PR_MD_map_error
  552. #define _PR_MD_MAP_SELECT_ERROR         _PR_MD_map_error
  553. #define _PR_MD_MAP_LOCKF_ERROR          _PR_MD_map_error
  554. #define _PR_MD_MAP_WSASTARTUP_ERROR     _PR_MD_map_error
  555.  
  556. #endif /* nspr_win16_defs_h___ */
  557.