nsprpub/pr/include/md/_os2.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/include/md/_os2.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,504 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nspr_os2_defs_h___
    1.10 +#define nspr_os2_defs_h___
    1.11 +
    1.12 +#ifndef NO_LONG_LONG
    1.13 +#define INCL_LONGLONG
    1.14 +#endif
    1.15 +#define INCL_DOS
    1.16 +#define INCL_DOSPROCESS
    1.17 +#define INCL_DOSERRORS
    1.18 +#define INCL_WIN
    1.19 +#define INCL_WPS
    1.20 +#include <os2.h>
    1.21 +#include <sys/select.h>
    1.22 +
    1.23 +#include "prio.h"
    1.24 +
    1.25 +#include <errno.h>
    1.26 +
    1.27 +/*
    1.28 + * Internal configuration macros
    1.29 + */
    1.30 +
    1.31 +#define PR_LINKER_ARCH      "os2"
    1.32 +#define _PR_SI_SYSNAME        "OS2"
    1.33 +#define _PR_SI_ARCHITECTURE   "x86"    /* XXXMB hardcode for now */
    1.34 +
    1.35 +#define HAVE_DLL
    1.36 +#define _PR_GLOBAL_THREADS_ONLY
    1.37 +#undef  HAVE_THREAD_AFFINITY
    1.38 +#define _PR_HAVE_THREADSAFE_GETHOST
    1.39 +#define _PR_HAVE_ATOMIC_OPS
    1.40 +#define HAVE_NETINET_TCP_H
    1.41 +
    1.42 +#define HANDLE unsigned long
    1.43 +#define HINSTANCE HMODULE
    1.44 +
    1.45 +/* --- Common User-Thread/Native-Thread Definitions --------------------- */
    1.46 +
    1.47 +/* --- Globals --- */
    1.48 +extern struct PRLock                      *_pr_schedLock;
    1.49 +
    1.50 +/* --- Typedefs --- */
    1.51 +typedef void (*FiberFunc)(void *);
    1.52 +
    1.53 +#define PR_NUM_GCREGS           8
    1.54 +typedef PRInt32	                PR_CONTEXT_TYPE[PR_NUM_GCREGS];
    1.55 +#define GC_VMBASE               0x40000000
    1.56 +#define GC_VMLIMIT              0x00FFFFFF
    1.57 +typedef int (*FARPROC)();
    1.58 +
    1.59 +#define _MD_MAGIC_THREAD	0x22222222
    1.60 +#define _MD_MAGIC_THREADSTACK	0x33333333
    1.61 +#define _MD_MAGIC_SEGMENT	0x44444444
    1.62 +#define _MD_MAGIC_DIR		0x55555555
    1.63 +#define _MD_MAGIC_CV        0x66666666
    1.64 +
    1.65 +struct _MDSemaphore {
    1.66 +   HEV sem;
    1.67 +};
    1.68 +
    1.69 +struct _MDCPU {
    1.70 +    int              unused;
    1.71 +}; 
    1.72 +
    1.73 +struct _MDThread {
    1.74 +    HEV              blocked_sema;      /* Threads block on this when waiting
    1.75 +                                         * for IO or CondVar.
    1.76 +                                         */
    1.77 +    PRBool           inCVWaitQueue;     /* PR_TRUE if the thread is in the
    1.78 +                                         * wait queue of some cond var.
    1.79 +                                         * PR_FALSE otherwise.  */
    1.80 +    TID              handle;            /* OS/2 thread handle */
    1.81 +    void            *sp;                /* only valid when suspended */
    1.82 +    PRUint32         magic;             /* for debugging */
    1.83 +    PR_CONTEXT_TYPE  gcContext;         /* Thread context for GC */
    1.84 +    struct PRThread *prev, *next;       /* used by the cvar wait queue to
    1.85 +                                         * chain the PRThread structures
    1.86 +                                         * together */
    1.87 +};
    1.88 +
    1.89 +struct _MDThreadStack {
    1.90 +    PRUint32           magic;          /* for debugging */
    1.91 +};
    1.92 +
    1.93 +struct _MDSegment {
    1.94 +    PRUint32           magic;          /* for debugging */
    1.95 +};
    1.96 +
    1.97 +#undef PROFILE_LOCKS
    1.98 +
    1.99 +struct _MDDir {
   1.100 +    HDIR           d_hdl;
   1.101 +    union {
   1.102 +        FILEFINDBUF3  small;
   1.103 +        FILEFINDBUF3L large;
   1.104 +    } d_entry;
   1.105 +    PRBool           firstEntry;     /* Is this the entry returned
   1.106 +                                      * by FindFirstFile()? */
   1.107 +    PRUint32         magic;          /* for debugging */
   1.108 +};
   1.109 +
   1.110 +struct _MDCVar {
   1.111 +    PRUint32 magic;
   1.112 +    struct PRThread *waitHead, *waitTail;  /* the wait queue: a doubly-
   1.113 +                                            * linked list of threads
   1.114 +                                            * waiting on this condition
   1.115 +                                            * variable */
   1.116 +    PRIntn nwait;                          /* number of threads in the
   1.117 +                                            * wait queue */
   1.118 +};
   1.119 +
   1.120 +#define _MD_CV_NOTIFIED_LENGTH 6
   1.121 +typedef struct _MDNotified _MDNotified;
   1.122 +struct _MDNotified {
   1.123 +    PRIntn length;                     /* # of used entries in this
   1.124 +                                        * structure */
   1.125 +    struct {
   1.126 +        struct _MDCVar *cv;            /* the condition variable notified */
   1.127 +        PRIntn times;                  /* and the number of times notified */
   1.128 +        struct PRThread *notifyHead;   /* list of threads to wake up */
   1.129 +    } cv[_MD_CV_NOTIFIED_LENGTH];
   1.130 +    _MDNotified *link;                 /* link to another of these, or NULL */
   1.131 +};
   1.132 +
   1.133 +struct _MDLock {
   1.134 +    HMTX mutex;                        /* this is recursive on OS/2 */
   1.135 +
   1.136 +    /*
   1.137 +     * When notifying cvars, there is no point in actually
   1.138 +     * waking up the threads waiting on the cvars until we've
   1.139 +     * released the lock.  So, we temporarily record the cvars.
   1.140 +     * When doing an unlock, we'll then wake up the waiting threads.
   1.141 +     */
   1.142 +    struct _MDNotified notified;     /* array of conditions notified */
   1.143 +#ifdef PROFILE_LOCKS
   1.144 +    PRInt32 hitcount;
   1.145 +    PRInt32 misscount;
   1.146 +#endif
   1.147 +};
   1.148 +
   1.149 +struct _MDFileDesc {
   1.150 +    PRInt32 osfd;    /* The osfd can come from one of three spaces:
   1.151 +                      * - For stdin, stdout, and stderr, we are using
   1.152 +                      *   the libc file handle (0, 1, 2), which is an int.
   1.153 +                      * - For files and pipes, we are using OS/2 handles,
   1.154 +                      *   which is a void*.
   1.155 +                      * - For sockets, we are using int
   1.156 +                      */
   1.157 +};
   1.158 +
   1.159 +struct _MDProcess {
   1.160 +   PID pid;
   1.161 +};
   1.162 +
   1.163 +/* --- Misc stuff --- */
   1.164 +#define _MD_GET_SP(thread)            (thread)->md.gcContext[6]
   1.165 +
   1.166 +/* --- IO stuff --- */
   1.167 +
   1.168 +#define _MD_OPEN                      (_PR_MD_OPEN)
   1.169 +#define _MD_OPEN_FILE                 (_PR_MD_OPEN)
   1.170 +#define _MD_READ                      (_PR_MD_READ)
   1.171 +#define _MD_WRITE                     (_PR_MD_WRITE)
   1.172 +#define _MD_WRITEV                    (_PR_MD_WRITEV)
   1.173 +#define _MD_LSEEK                     (_PR_MD_LSEEK)
   1.174 +#define _MD_LSEEK64                   (_PR_MD_LSEEK64)
   1.175 +extern PRInt32 _MD_CloseFile(PRInt32 osfd);
   1.176 +#define _MD_CLOSE_FILE                _MD_CloseFile
   1.177 +#define _MD_GETFILEINFO               (_PR_MD_GETFILEINFO)
   1.178 +#define _MD_GETFILEINFO64             (_PR_MD_GETFILEINFO64)
   1.179 +#define _MD_GETOPENFILEINFO           (_PR_MD_GETOPENFILEINFO)
   1.180 +#define _MD_GETOPENFILEINFO64         (_PR_MD_GETOPENFILEINFO64)
   1.181 +#define _MD_STAT                      (_PR_MD_STAT)
   1.182 +#define _MD_RENAME                    (_PR_MD_RENAME)
   1.183 +#define _MD_ACCESS                    (_PR_MD_ACCESS)
   1.184 +#define _MD_DELETE                    (_PR_MD_DELETE)
   1.185 +#define _MD_MKDIR                     (_PR_MD_MKDIR)
   1.186 +#define _MD_MAKE_DIR                  (_PR_MD_MKDIR)
   1.187 +#define _MD_RMDIR                     (_PR_MD_RMDIR)
   1.188 +#define _MD_LOCKFILE                  (_PR_MD_LOCKFILE)
   1.189 +#define _MD_TLOCKFILE                 (_PR_MD_TLOCKFILE)
   1.190 +#define _MD_UNLOCKFILE                (_PR_MD_UNLOCKFILE)
   1.191 +
   1.192 +/* --- Socket IO stuff --- */
   1.193 +
   1.194 +/* The ones that don't map directly may need to be re-visited... */
   1.195 +#define _MD_EACCES                EACCES
   1.196 +#define _MD_EADDRINUSE            EADDRINUSE
   1.197 +#define _MD_EADDRNOTAVAIL         EADDRNOTAVAIL
   1.198 +#define _MD_EAFNOSUPPORT          EAFNOSUPPORT
   1.199 +#define _MD_EAGAIN                EWOULDBLOCK
   1.200 +#define _MD_EALREADY              EALREADY
   1.201 +#define _MD_EBADF                 EBADF
   1.202 +#define _MD_ECONNREFUSED          ECONNREFUSED
   1.203 +#define _MD_ECONNRESET            ECONNRESET
   1.204 +#define _MD_EFAULT                SOCEFAULT
   1.205 +#define _MD_EINPROGRESS           EINPROGRESS
   1.206 +#define _MD_EINTR                 EINTR
   1.207 +#define _MD_EINVAL                EINVAL
   1.208 +#define _MD_EISCONN               EISCONN
   1.209 +#define _MD_ENETUNREACH           ENETUNREACH
   1.210 +#define _MD_ENOENT                ENOENT
   1.211 +#define _MD_ENOTCONN              ENOTCONN
   1.212 +#define _MD_ENOTSOCK              ENOTSOCK
   1.213 +#define _MD_EOPNOTSUPP            EOPNOTSUPP
   1.214 +#define _MD_EWOULDBLOCK           EWOULDBLOCK
   1.215 +#define _MD_GET_SOCKET_ERROR()    sock_errno()
   1.216 +#ifndef INADDR_LOOPBACK /* For some reason this is not defined in OS2 tcpip */
   1.217 +/*  #define INADDR_LOOPBACK         INADDR_ANY */
   1.218 +#endif  
   1.219 +
   1.220 +#define _MD_INIT_FILEDESC(fd)
   1.221 +extern void _MD_MakeNonblock(PRFileDesc *f);
   1.222 +#define _MD_MAKE_NONBLOCK             _MD_MakeNonblock
   1.223 +#define _MD_INIT_FD_INHERITABLE       (_PR_MD_INIT_FD_INHERITABLE)
   1.224 +#define _MD_QUERY_FD_INHERITABLE      (_PR_MD_QUERY_FD_INHERITABLE)
   1.225 +#define _MD_SHUTDOWN                  (_PR_MD_SHUTDOWN)
   1.226 +#define _MD_LISTEN                    _PR_MD_LISTEN
   1.227 +extern PRInt32 _MD_CloseSocket(PRInt32 osfd);
   1.228 +#define _MD_CLOSE_SOCKET              _MD_CloseSocket
   1.229 +#define _MD_SENDTO                    (_PR_MD_SENDTO)
   1.230 +#define _MD_RECVFROM                  (_PR_MD_RECVFROM)
   1.231 +#define _MD_SOCKETPAIR                (_PR_MD_SOCKETPAIR)
   1.232 +#define _MD_GETSOCKNAME               (_PR_MD_GETSOCKNAME)
   1.233 +#define _MD_GETPEERNAME               (_PR_MD_GETPEERNAME)
   1.234 +#define _MD_GETSOCKOPT                (_PR_MD_GETSOCKOPT)
   1.235 +#define _MD_SETSOCKOPT                (_PR_MD_SETSOCKOPT)
   1.236 +
   1.237 +#define _MD_FSYNC                     _PR_MD_FSYNC
   1.238 +#define _MD_SET_FD_INHERITABLE        (_PR_MD_SET_FD_INHERITABLE)
   1.239 +
   1.240 +#ifdef _PR_HAVE_ATOMIC_OPS
   1.241 +#define _MD_INIT_ATOMIC()
   1.242 +#define _MD_ATOMIC_INCREMENT          _PR_MD_ATOMIC_INCREMENT
   1.243 +#define _MD_ATOMIC_ADD                _PR_MD_ATOMIC_ADD
   1.244 +#define _MD_ATOMIC_DECREMENT          _PR_MD_ATOMIC_DECREMENT
   1.245 +#define _MD_ATOMIC_SET                _PR_MD_ATOMIC_SET
   1.246 +#endif
   1.247 +
   1.248 +#define _MD_INIT_IO                   (_PR_MD_INIT_IO)
   1.249 +#define _MD_PR_POLL                   (_PR_MD_PR_POLL)
   1.250 +
   1.251 +#define _MD_SOCKET                    (_PR_MD_SOCKET)
   1.252 +extern PRInt32 _MD_SocketAvailable(PRFileDesc *fd);
   1.253 +#define _MD_SOCKETAVAILABLE           _MD_SocketAvailable
   1.254 +#define _MD_PIPEAVAILABLE             _MD_SocketAvailable
   1.255 +#define _MD_CONNECT                   (_PR_MD_CONNECT)
   1.256 +extern PRInt32 _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen,
   1.257 +        PRIntervalTime timeout);
   1.258 +#define _MD_ACCEPT                    _MD_Accept
   1.259 +#define _MD_BIND                      (_PR_MD_BIND)
   1.260 +#define _MD_RECV                      (_PR_MD_RECV)
   1.261 +#define _MD_SEND                      (_PR_MD_SEND)
   1.262 +
   1.263 +/* --- Scheduler stuff --- */
   1.264 +/* #define _MD_PAUSE_CPU                 _PR_MD_PAUSE_CPU */
   1.265 +#define _MD_PAUSE_CPU
   1.266 +
   1.267 +/* --- DIR stuff --- */
   1.268 +#define PR_DIRECTORY_SEPARATOR        '\\'
   1.269 +#define PR_DIRECTORY_SEPARATOR_STR    "\\"
   1.270 +#define PR_PATH_SEPARATOR		';'
   1.271 +#define PR_PATH_SEPARATOR_STR		";"
   1.272 +#define _MD_ERRNO()                   errno
   1.273 +#define _MD_OPEN_DIR                  (_PR_MD_OPEN_DIR)
   1.274 +#define _MD_CLOSE_DIR                 (_PR_MD_CLOSE_DIR)
   1.275 +#define _MD_READ_DIR                  (_PR_MD_READ_DIR)
   1.276 +
   1.277 +/* --- Segment stuff --- */
   1.278 +#define _MD_INIT_SEGS()
   1.279 +#define _MD_ALLOC_SEGMENT(seg, size, vaddr)   0
   1.280 +#define _MD_FREE_SEGMENT(seg)
   1.281 +
   1.282 +/* --- Environment Stuff --- */
   1.283 +#define _MD_GET_ENV                 (_PR_MD_GET_ENV)
   1.284 +#define _MD_PUT_ENV                 (_PR_MD_PUT_ENV)
   1.285 +
   1.286 +/* --- Threading Stuff --- */
   1.287 +#define _MD_DEFAULT_STACK_SIZE      65536L
   1.288 +#define _MD_INIT_THREAD             (_PR_MD_INIT_THREAD)
   1.289 +#define _MD_INIT_ATTACHED_THREAD    (_PR_MD_INIT_THREAD)
   1.290 +#define _MD_CREATE_THREAD           (_PR_MD_CREATE_THREAD)
   1.291 +#define _MD_YIELD                   (_PR_MD_YIELD)
   1.292 +#define _MD_SET_PRIORITY            (_PR_MD_SET_PRIORITY)
   1.293 +#define _MD_CLEAN_THREAD            (_PR_MD_CLEAN_THREAD)
   1.294 +#define _MD_SETTHREADAFFINITYMASK   (_PR_MD_SETTHREADAFFINITYMASK)
   1.295 +#define _MD_GETTHREADAFFINITYMASK   (_PR_MD_GETTHREADAFFINITYMASK)
   1.296 +#define _MD_EXIT_THREAD             (_PR_MD_EXIT_THREAD)
   1.297 +#define _MD_SUSPEND_THREAD          (_PR_MD_SUSPEND_THREAD)
   1.298 +#define _MD_RESUME_THREAD           (_PR_MD_RESUME_THREAD)
   1.299 +#define _MD_SUSPEND_CPU             (_PR_MD_SUSPEND_CPU)
   1.300 +#define _MD_RESUME_CPU              (_PR_MD_RESUME_CPU)
   1.301 +#define _MD_WAKEUP_CPUS             (_PR_MD_WAKEUP_CPUS)
   1.302 +#define _MD_BEGIN_SUSPEND_ALL()
   1.303 +#define _MD_BEGIN_RESUME_ALL()
   1.304 +#define _MD_END_SUSPEND_ALL()
   1.305 +#define _MD_END_RESUME_ALL()
   1.306 +
   1.307 +/* --- Lock stuff --- */
   1.308 +#define _PR_LOCK                      _MD_LOCK
   1.309 +#define _PR_UNLOCK					  _MD_UNLOCK
   1.310 +
   1.311 +#define _MD_NEW_LOCK                  (_PR_MD_NEW_LOCK)
   1.312 +#define _MD_FREE_LOCK(lock)           (DosCloseMutexSem((lock)->mutex))
   1.313 +#define _MD_LOCK(lock)                (DosRequestMutexSem((lock)->mutex, SEM_INDEFINITE_WAIT))
   1.314 +#define _MD_TEST_AND_LOCK(lock)       (DosRequestMutexSem((lock)->mutex, SEM_INDEFINITE_WAIT),0)
   1.315 +#define _MD_UNLOCK                    (_PR_MD_UNLOCK)
   1.316 +
   1.317 +/* --- lock and cv waiting --- */
   1.318 +#define _MD_WAIT                      (_PR_MD_WAIT)
   1.319 +#define _MD_WAKEUP_WAITER             (_PR_MD_WAKEUP_WAITER)
   1.320 +
   1.321 +/* --- CVar ------------------- */
   1.322 +#define _MD_WAIT_CV					  (_PR_MD_WAIT_CV)
   1.323 +#define _MD_NEW_CV					  (_PR_MD_NEW_CV)
   1.324 +#define _MD_FREE_CV					  (_PR_MD_FREE_CV)
   1.325 +#define _MD_NOTIFY_CV				  (_PR_MD_NOTIFY_CV	)
   1.326 +#define _MD_NOTIFYALL_CV			  (_PR_MD_NOTIFYALL_CV)
   1.327 +
   1.328 +   /* XXXMB- the IOQ stuff is certainly not working correctly yet. */
   1.329 +/* extern  struct _MDLock              _pr_ioq_lock; */
   1.330 +#define _MD_IOQ_LOCK()                
   1.331 +#define _MD_IOQ_UNLOCK()              
   1.332 +
   1.333 +
   1.334 +/* --- Initialization stuff --- */
   1.335 +#define _MD_START_INTERRUPTS()
   1.336 +#define _MD_STOP_INTERRUPTS()
   1.337 +#define _MD_DISABLE_CLOCK_INTERRUPTS()
   1.338 +#define _MD_ENABLE_CLOCK_INTERRUPTS()
   1.339 +#define _MD_BLOCK_CLOCK_INTERRUPTS()
   1.340 +#define _MD_UNBLOCK_CLOCK_INTERRUPTS()
   1.341 +#define _MD_EARLY_INIT                (_PR_MD_EARLY_INIT)
   1.342 +#define _MD_FINAL_INIT()
   1.343 +#define _MD_EARLY_CLEANUP()
   1.344 +#define _MD_INIT_CPUS()
   1.345 +#define _MD_INIT_RUNNING_CPU(cpu)
   1.346 +
   1.347 +struct PRProcess;
   1.348 +struct PRProcessAttr;
   1.349 +
   1.350 +#define _MD_CREATE_PROCESS _PR_CreateOS2Process
   1.351 +extern struct PRProcess * _PR_CreateOS2Process(
   1.352 +    const char *path,
   1.353 +    char *const *argv,
   1.354 +    char *const *envp,
   1.355 +    const struct PRProcessAttr *attr
   1.356 +);
   1.357 +
   1.358 +#define _MD_DETACH_PROCESS _PR_DetachOS2Process
   1.359 +extern PRStatus _PR_DetachOS2Process(struct PRProcess *process);
   1.360 +
   1.361 +/* --- Wait for a child process to terminate --- */
   1.362 +#define _MD_WAIT_PROCESS _PR_WaitOS2Process
   1.363 +extern PRStatus _PR_WaitOS2Process(struct PRProcess *process, 
   1.364 +    PRInt32 *exitCode);
   1.365 +
   1.366 +#define _MD_KILL_PROCESS _PR_KillOS2Process
   1.367 +extern PRStatus _PR_KillOS2Process(struct PRProcess *process);
   1.368 +
   1.369 +#define _MD_CLEANUP_BEFORE_EXIT()
   1.370 +#define _MD_EXIT                          (_PR_MD_EXIT)
   1.371 +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
   1.372 +    PR_BEGIN_MACRO \
   1.373 +    *status = PR_TRUE; \
   1.374 +    PR_END_MACRO
   1.375 +#define _MD_SWITCH_CONTEXT
   1.376 +#define _MD_RESTORE_CONTEXT
   1.377 +
   1.378 +/* --- Intervals --- */
   1.379 +#define _MD_INTERVAL_INIT                 (_PR_MD_INTERVAL_INIT)
   1.380 +#define _MD_GET_INTERVAL                  (_PR_MD_GET_INTERVAL)
   1.381 +#define _MD_INTERVAL_PER_SEC              (_PR_MD_INTERVAL_PER_SEC)
   1.382 +#define _MD_INTERVAL_PER_MILLISEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000)
   1.383 +#define _MD_INTERVAL_PER_MICROSEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000000)
   1.384 +
   1.385 +/* --- Native-Thread Specific Definitions ------------------------------- */
   1.386 +
   1.387 +typedef struct __NSPR_TLS
   1.388 +{
   1.389 +    struct PRThread  *_pr_thread_last_run;
   1.390 +    struct PRThread  *_pr_currentThread;
   1.391 +    struct _PRCPU    *_pr_currentCPU;
   1.392 +} _NSPR_TLS;
   1.393 +
   1.394 +extern _NSPR_TLS*  pThreadLocalStorage;
   1.395 +NSPR_API(void) _PR_MD_ENSURE_TLS(void);
   1.396 +
   1.397 +#define _MD_GET_ATTACHED_THREAD() pThreadLocalStorage->_pr_currentThread
   1.398 +extern struct PRThread * _MD_CURRENT_THREAD(void);
   1.399 +#define _MD_SET_CURRENT_THREAD(_thread) _PR_MD_ENSURE_TLS(); pThreadLocalStorage->_pr_currentThread = (_thread)
   1.400 +
   1.401 +#define _MD_LAST_THREAD() pThreadLocalStorage->_pr_thread_last_run
   1.402 +#define _MD_SET_LAST_THREAD(_thread) _PR_MD_ENSURE_TLS(); pThreadLocalStorage->_pr_thread_last_run = (_thread)
   1.403 +
   1.404 +#define _MD_CURRENT_CPU() pThreadLocalStorage->_pr_currentCPU
   1.405 +#define _MD_SET_CURRENT_CPU(_cpu) _PR_MD_ENSURE_TLS(); pThreadLocalStorage->_pr_currentCPU = (_cpu)
   1.406 +
   1.407 +/* lth. #define _MD_SET_INTSOFF(_val) (_pr_ints_off = (_val)) */
   1.408 +/* lth. #define _MD_GET_INTSOFF() _pr_ints_off */
   1.409 +/* lth. #define _MD_INCREMENT_INTSOFF() (_pr_ints_off++) */
   1.410 +/* lth. #define _MD_DECREMENT_INTSOFF() (_pr_ints_off--) */
   1.411 +
   1.412 +/* --- Scheduler stuff --- */
   1.413 +#define LOCK_SCHEDULER()                 0
   1.414 +#define UNLOCK_SCHEDULER()               0
   1.415 +#define _PR_LockSched()                	 0
   1.416 +#define _PR_UnlockSched()                0
   1.417 +
   1.418 +/* --- Initialization stuff --- */
   1.419 +#define _MD_INIT_LOCKS()
   1.420 +
   1.421 +/* --- Stack stuff --- */
   1.422 +#define _MD_INIT_STACK(stack, redzone)
   1.423 +#define _MD_CLEAR_STACK(stack)
   1.424 +
   1.425 +/* --- Memory-mapped files stuff --- */
   1.426 +/* ReadOnly and WriteCopy modes are simulated on OS/2;
   1.427 + * ReadWrite mode is not supported.
   1.428 + */
   1.429 +struct _MDFileMap {
   1.430 +    PROffset64  maxExtent;
   1.431 +};
   1.432 +
   1.433 +extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
   1.434 +#define _MD_CREATE_FILE_MAP _MD_CreateFileMap
   1.435 +
   1.436 +extern PRInt32 _MD_GetMemMapAlignment(void);
   1.437 +#define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment
   1.438 +
   1.439 +extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,
   1.440 +        PRUint32 len);
   1.441 +#define _MD_MEM_MAP _MD_MemMap
   1.442 +
   1.443 +extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);
   1.444 +#define _MD_MEM_UNMAP _MD_MemUnmap
   1.445 +
   1.446 +extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
   1.447 +#define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
   1.448 +
   1.449 +/* Some stuff for setting up thread contexts */
   1.450 +typedef ULONG DWORD, *PDWORD;
   1.451 +
   1.452 +/* The following definitions and two structures are new in OS/2 Warp 4.0.
   1.453 + */
   1.454 +#ifndef CONTEXT_CONTROL
   1.455 +#define CONTEXT_CONTROL        0x00000001
   1.456 +#define CONTEXT_INTEGER        0x00000002
   1.457 +#define CONTEXT_SEGMENTS       0x00000004
   1.458 +#define CONTEXT_FLOATING_POINT 0x00000008
   1.459 +#define CONTEXT_FULL           0x0000000F
   1.460 +
   1.461 +#pragma pack(2)
   1.462 +typedef struct _FPREG {
   1.463 +    ULONG      losig;    /*  Low 32-bits of the significand. */
   1.464 +    ULONG      hisig;    /*  High 32-bits of the significand. */
   1.465 +    USHORT     signexp;  /*  Sign and exponent. */
   1.466 +} FPREG;
   1.467 +typedef struct _CONTEXTRECORD {
   1.468 +    ULONG     ContextFlags;
   1.469 +    ULONG     ctx_env[7];
   1.470 +    FPREG     ctx_stack[8];
   1.471 +    ULONG     ctx_SegGs;     /*  GS register. */
   1.472 +    ULONG     ctx_SegFs;     /*  FS register. */
   1.473 +    ULONG     ctx_SegEs;     /*  ES register. */
   1.474 +    ULONG     ctx_SegDs;     /*  DS register. */
   1.475 +    ULONG     ctx_RegEdi;    /*  EDI register. */
   1.476 +    ULONG     ctx_RegEsi;    /*  ESI register. */
   1.477 +    ULONG     ctx_RegEax;    /*  EAX register. */
   1.478 +    ULONG     ctx_RegEbx;    /*  EBX register. */
   1.479 +    ULONG     ctx_RegEcx;    /*  ECX register. */
   1.480 +    ULONG     ctx_RegEdx;    /*  EDX register. */
   1.481 +    ULONG     ctx_RegEbp;    /*  EBP register. */
   1.482 +    ULONG     ctx_RegEip;    /*  EIP register. */
   1.483 +    ULONG     ctx_SegCs;     /*  CS register. */
   1.484 +    ULONG     ctx_EFlags;    /*  EFLAGS register. */
   1.485 +    ULONG     ctx_RegEsp;    /*  ESP register. */
   1.486 +    ULONG     ctx_SegSs;     /*  SS register. */
   1.487 +} CONTEXTRECORD, *PCONTEXTRECORD;
   1.488 +#pragma pack()
   1.489 +#endif
   1.490 +
   1.491 +extern APIRET (* APIENTRY QueryThreadContext)(TID, ULONG, PCONTEXTRECORD);
   1.492 +
   1.493 +/*
   1.494 +#define _pr_tid            (((PTIB2)_getTIBvalue(offsetof(TIB, tib_ptib2)))->tib2_ultid)
   1.495 +#define _pr_current_Thread (_system_tls[_pr_tid-1].__pr_current_thread)
   1.496 +*/
   1.497 +
   1.498 +/* Some simple mappings of Windows API's to OS/2 API's to make our lives a
   1.499 + * little bit easier.  Only add one here if it is a DIRECT mapping.  We are
   1.500 + * not emulating anything.  Just mapping.
   1.501 + */
   1.502 +#define FreeLibrary(x) DosFreeModule((HMODULE)x)
   1.503 +#define OutputDebugStringA(x)
   1.504 +                               
   1.505 +extern int _MD_os2_get_nonblocking_connect_error(int osfd);
   1.506 +
   1.507 +#endif /* nspr_os2_defs_h___ */

mercurial