⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _os2.h

📁 Netscape NSPR库源码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- *//*  * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ *  * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. *  * The Original Code is the Netscape Portable Runtime (NSPR). *  * The Initial Developer of the Original Code is Netscape * Communications Corporation.  Portions created by Netscape are  * Copyright (C) 1998-2000 Netscape Communications Corporation.  All * Rights Reserved. *  * Contributor(s): *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL"), in which case the provisions of the GPL are applicable  * instead of those above.  If you wish to allow use of your  * version of this file only under the terms of the GPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by * the GPL.  If you do not delete the provisions above, a recipient * may use your version of this file under either the MPL or the * GPL. */#ifndef nspr_os2_defs_h___#define nspr_os2_defs_h___#define INCL_DOS#define INCL_DOSPROCESS#define INCL_DOSERRORS#define INCL_WIN#define INCL_WPS#include <os2.h>#include <sys/select.h>#include "prio.h"#include <errno.h>#define USE_RAMSEM#ifdef USE_RAMSEM#pragma pack(4)#pragma pack(2)typedef struct _RAMSEM{   ULONG   ulTIDPID;   ULONG   hevSem;   ULONG   cLocks;   USHORT  cWaiting;   USHORT  cPosts;} RAMSEM, *PRAMSEM;typedef struct _CRITICAL_SECTION{    ULONG ulReserved[4]; /* Same size as RAMSEM */} CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION;#pragma pack(4)APIRET _Optlink SemRequest486(PRAMSEM, ULONG);APIRET _Optlink SemReleasex86(PRAMSEM, ULONG);#endif#ifdef XP_OS2_EMX/* * EMX-specific tweaks: *    o Use stricmp instead of strcmpi. *    o Use errno rather than sock_errno() *    o Use close rather than soclose *    o Ignore sock_init calls. */#define strcmpi stricmp #define sock_errno() errno#define soclose close#define sock_init()#endif/* * Internal configuration macros */#define PR_LINKER_ARCH      "os2"#define _PR_SI_SYSNAME        "OS2"#define _PR_SI_ARCHITECTURE   "x86"    /* XXXMB hardcode for now */#define HAVE_DLL#undef  HAVE_THREAD_AFFINITY#define _PR_HAVE_ATOMIC_OPS#define HANDLE unsigned long#define HINSTANCE HMODULE/* --- Common User-Thread/Native-Thread Definitions --------------------- *//* --- Globals --- */extern struct PRLock                      *_pr_schedLock;/* --- Typedefs --- */typedef void (*FiberFunc)(void *);#define PR_NUM_GCREGS           8typedef PRInt32	                PR_CONTEXT_TYPE[PR_NUM_GCREGS];#define GC_VMBASE               0x40000000#define GC_VMLIMIT              0x00FFFFFFtypedef int (*FARPROC)();#define _MD_MAGIC_THREAD	0x22222222#define _MD_MAGIC_THREADSTACK	0x33333333#define _MD_MAGIC_SEGMENT	0x44444444#define _MD_MAGIC_DIR		0x55555555#define _MD_MAGIC_CV        0x66666666struct _MDSemaphore {   HEV sem;};struct _MDCPU {    int              unused;}; struct _MDThread {    HEV              blocked_sema;      /* Threads block on this when waiting                                         * for IO or CondVar.                                         */    PRBool           inCVWaitQueue;     /* PR_TRUE if the thread is in the                                         * wait queue of some cond var.                                         * PR_FALSE otherwise.  */    TID              handle;            /* OS/2 thread handle */    void            *sp;                /* only valid when suspended */    PRUint32         magic;             /* for debugging */    PR_CONTEXT_TYPE  gcContext;         /* Thread context for GC */    struct PRThread *prev, *next;       /* used by the cvar wait queue to                                         * chain the PRThread structures                                         * together */};struct _MDThreadStack {    PRUint32           magic;          /* for debugging */};struct _MDSegment {    PRUint32           magic;          /* for debugging */};#undef PROFILE_LOCKSstruct _MDDir {    HDIR           d_hdl;    FILEFINDBUF3  d_entry;    PRBool           firstEntry;     /* Is this the entry returned                                      * by FindFirstFile()? */    PRUint32         magic;          /* for debugging */};struct _MDCVar {    PRUint32 magic;    struct PRThread *waitHead, *waitTail;  /* the wait queue: a doubly-                                            * linked list of threads                                            * waiting on this condition                                            * variable */    PRIntn nwait;                          /* number of threads in the                                            * wait queue */};#define _MD_CV_NOTIFIED_LENGTH 6typedef struct _MDNotified _MDNotified;struct _MDNotified {    PRIntn length;                     /* # of used entries in this                                        * structure */    struct {        struct _MDCVar *cv;            /* the condition variable notified */        PRIntn times;                  /* and the number of times notified */        struct PRThread *notifyHead;   /* list of threads to wake up */    } cv[_MD_CV_NOTIFIED_LENGTH];    _MDNotified *link;                 /* link to another of these, or NULL */};struct _MDLock {#ifdef USE_RAMSEM    CRITICAL_SECTION mutex;            /* this is recursive on NT */#else    HMTX mutex;                        /* this is recursive on NT */#endif    /*     * When notifying cvars, there is no point in actually     * waking up the threads waiting on the cvars until we've     * released the lock.  So, we temporarily record the cvars.     * When doing an unlock, we'll then wake up the waiting threads.     */    struct _MDNotified notified;     /* array of conditions notified */#ifdef PROFILE_LOCKS    PRInt32 hitcount;    PRInt32 misscount;#endif};struct _MDFileDesc {    PRInt32 osfd;    /* The osfd can come from one of three spaces:                      * - For stdin, stdout, and stderr, we are using                      *   the libc file handle (0, 1, 2), which is an int.                      * - For files and pipes, we are using OS/2 handles,                      *   which is a void*.                      * - For sockets, we are using int                      */};struct _MDProcess {   PID pid;};/* --- Misc stuff --- */#define _MD_GET_SP(thread)            (thread)->md.gcContext[6]/* --- IO stuff --- */#define _MD_OPEN                      (_PR_MD_OPEN)#define _MD_OPEN_FILE                 (_PR_MD_OPEN)#define _MD_READ                      (_PR_MD_READ)#define _MD_WRITE                     (_PR_MD_WRITE)#define _MD_WRITEV                    (_PR_MD_WRITEV)#define _MD_LSEEK                     (_PR_MD_LSEEK)#define _MD_LSEEK64                   (_PR_MD_LSEEK64)extern PRInt32 _MD_CloseFile(PRInt32 osfd);#define _MD_CLOSE_FILE                _MD_CloseFile#define _MD_GETFILEINFO               (_PR_MD_GETFILEINFO)#define _MD_GETFILEINFO64             (_PR_MD_GETFILEINFO64)#define _MD_GETOPENFILEINFO           (_PR_MD_GETOPENFILEINFO)#define _MD_GETOPENFILEINFO64         (_PR_MD_GETOPENFILEINFO64)#define _MD_STAT                      (_PR_MD_STAT)#define _MD_RENAME                    (_PR_MD_RENAME)#define _MD_ACCESS                    (_PR_MD_ACCESS)#define _MD_DELETE                    (_PR_MD_DELETE)#define _MD_MKDIR                     (_PR_MD_MKDIR)#define _MD_MAKE_DIR                  (_PR_MD_MKDIR)#define _MD_RMDIR                     (_PR_MD_RMDIR)#define _MD_LOCKFILE                  (_PR_MD_LOCKFILE)#define _MD_TLOCKFILE                 (_PR_MD_TLOCKFILE)#define _MD_UNLOCKFILE                (_PR_MD_UNLOCKFILE)/* --- Socket IO stuff --- *//* The ones that don't map directly may need to be re-visited... */#ifdef XP_OS2_VACPP#define EPIPE                     EBADF#define EIO                       ECONNREFUSED#endif#define _MD_EACCES                EACCES#define _MD_EADDRINUSE            EADDRINUSE#define _MD_EADDRNOTAVAIL         EADDRNOTAVAIL#define _MD_EAFNOSUPPORT          EAFNOSUPPORT#define _MD_EAGAIN                EWOULDBLOCK#define _MD_EALREADY              EALREADY#define _MD_EBADF                 EBADF#define _MD_ECONNREFUSED          ECONNREFUSED#define _MD_ECONNRESET            ECONNRESET#define _MD_EFAULT                SOCEFAULT#define _MD_EINPROGRESS           EINPROGRESS#define _MD_EINTR                 EINTR#define _MD_EINVAL                EINVAL#define _MD_EISCONN               EISCONN#define _MD_ENETUNREACH           ENETUNREACH#define _MD_ENOENT                ENOENT#define _MD_ENOTCONN              ENOTCONN#define _MD_ENOTSOCK              ENOTSOCK#define _MD_EOPNOTSUPP            EOPNOTSUPP#define _MD_EWOULDBLOCK           EWOULDBLOCK#define _MD_GET_SOCKET_ERROR()    sock_errno()#ifndef INADDR_LOOPBACK /* For some reason this is not defined in OS2 tcpip *//*  #define INADDR_LOOPBACK         INADDR_ANY */#endif  #define _MD_INIT_FILEDESC(fd)extern void _MD_MakeNonblock(PRFileDesc *f);#define _MD_MAKE_NONBLOCK             _MD_MakeNonblock#define _MD_INIT_FD_INHERITABLE       (_PR_MD_INIT_FD_INHERITABLE)#define _MD_QUERY_FD_INHERITABLE      (_PR_MD_QUERY_FD_INHERITABLE)#define _MD_SHUTDOWN                  (_PR_MD_SHUTDOWN)#define _MD_LISTEN                    _PR_MD_LISTENextern PRInt32 _MD_CloseSocket(PRInt32 osfd);#define _MD_CLOSE_SOCKET              _MD_CloseSocket#define _MD_SENDTO                    (_PR_MD_SENDTO)#define _MD_RECVFROM                  (_PR_MD_RECVFROM)#define _MD_SOCKETPAIR(s, type, proto, sv) -1#define _MD_GETSOCKNAME               (_PR_MD_GETSOCKNAME)#define _MD_GETPEERNAME               (_PR_MD_GETPEERNAME)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -