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

📄 primpl.h

📁 Netscape NSPR库源码
💻 H
📖 第 1 页 / 共 5 页
字号:
    PRUintn flags;    char *allocBase;            /* base of stack's allocated memory */    PRUint32 allocSize;         /* size of stack's allocated memory */    char *stackBottom;          /* bottom of stack from C's point of view */    char *stackTop;             /* top of stack from C's point of view */    PRUint32 stackSize;         /* size of usable portion of the stack */    PRSegment *seg;        PRThread* thr;          /* back pointer to thread owning this stack */#if defined(_PR_PTHREADS)#else /* defined(_PR_PTHREADS) */    _MDThreadStack md;#endif /* defined(_PR_PTHREADS) */};extern void _PR_DestroyThreadPrivate(PRThread*);typedef void (PR_CALLBACK *_PRStartFn)(void *);struct PRThread {    PRUint32 state;                 /* thread's creation state */    PRThreadPriority priority;      /* apparent priority, loosly defined */    void *arg;                      /* argument to the client's entry point */    _PRStartFn startFunc;           /* the root of the client's thread */    PRThreadStack *stack;           /* info about thread's stack (for GC) */    void *environment;              /* pointer to execution environment */    PRThreadDumpProc dump;          /* dump thread info out */    void *dumpArg;                  /* argument for the dump function */    /*    ** Per thread private data    */    PRUint32 tpdLength;             /* thread's current vector length */    void **privateData;             /* private data vector or NULL */    PRErrorCode errorCode;          /* current NSPR error code | zero */    PRInt32 osErrorCode;            /* mapping of errorCode | zero */    PRIntn  errorStringLength;      /* textLength from last call to PR_SetErrorText() */    PRInt32 errorStringSize;        /* malloc()'d size of buffer | zero */    char *errorString;              /* current error string | NULL */#if defined(_PR_PTHREADS)    pthread_t id;                   /* pthread identifier for the thread */    PRBool okToDelete;              /* ok to delete the PRThread struct? */    PRCondVar *waiting;             /* where the thread is waiting | NULL */    void *sp;                       /* recorded sp for garbage collection */    PRThread *next, *prev;          /* simple linked list of all threads */    PRUint32 suspend;               /* used to store suspend and resume flags */#ifdef PT_NO_SIGTIMEDWAIT    pthread_mutex_t suspendResumeMutex;    pthread_cond_t suspendResumeCV;#endif    PRUint32 interrupt_blocked;     /* interrupt blocked */    struct pollfd *syspoll_list;    /* Unix polling list used by PR_Poll */    PRUint32 syspoll_count;         /* number of elements in syspoll_list */#if defined(_PR_POLL_WITH_SELECT)    int *selectfd_list;             /* Unix fd's that PR_Poll selects on */    PRUint32 selectfd_count;        /* number of elements in selectfd_list */#endif#elif defined(_PR_BTHREADS)    PRUint32 flags;    _MDThread md;    PRBool io_pending;    PRInt32 io_fd;    PRBool io_suspended;#else /* not pthreads or Be threads */    _MDLock threadLock;             /* Lock to protect thread state variables.                                     * Protects the following fields:                                     *     state                                     *     priority                                     *     links                                     *     wait                                     *     cpu                                     */    PRUint32 queueCount;    PRUint32 waitCount;    PRCList active;                 /* on list of all active threads        */    PRCList links;    PRCList waitQLinks;             /* when thread is PR_Wait'ing */    PRCList lockList;               /* list of locks currently holding */    PRIntervalTime sleep;           /* sleep time when thread is sleeping */    struct _wait {        struct PRLock *lock;        struct PRCondVar *cvar;    } wait;    PRUint32 id;    PRUint32 flags;    PRUint32 no_sched;              /* Don't schedule the thread to run.                                     * This flag has relevance only when                                     * multiple NSPR CPUs are created.                                     * When a thread is de-scheduled, there                                     * is a narrow window of time in which                                     * the thread is put on the run queue                                     * but the scheduler is actually using                                     * the stack of this thread.  It is safe                                     * to run this thread on a different CPU                                     * only when its stack is not in use on                                     * any other CPU.  The no_sched flag is                                     * set during this interval to prevent                                     * the thread from being scheduled on a                                     * different CPU.                                     */    /* thread termination condition variable for join */    PRCondVar *term;    _PRCPU *cpu;                    /* cpu to which this thread is bound    */    PRUint32 threadAllocatedOnStack;/* boolean */    /* When an async IO is in progress and a second async IO cannot be      * initiated, the io_pending flag is set to true.  Some platforms will     * not use the io_pending flag.  If the io_pending flag is true, then     * io_fd is the OS-file descriptor on which IO is pending.     */    PRBool io_pending;    PRInt32 io_fd;     /* If a timeout occurs or if an outstanding IO is interrupted and the     * OS doesn't support a real cancellation (NT or MAC), then the      * io_suspended flag will be set to true.  The thread will be resumed     * but may run into trouble issuing additional IOs until the io_pending     * flag can be cleared      */    PRBool io_suspended;    _MDThread md;#endif};struct PRProcessAttr {    PRFileDesc *stdinFd;    PRFileDesc *stdoutFd;    PRFileDesc *stderrFd;    char *currentDirectory;    char *fdInheritBuffer;    PRSize fdInheritBufferSize;    PRSize fdInheritBufferUsed;};struct PRProcess {    _MDProcess md;};struct PRFileMap {    PRFileDesc *fd;    PRFileMapProtect prot;    _MDFileMap md;};/************************************************************************//*** File descriptors of the NSPR layer can be in one of the** following states (stored in the 'state' field of struct** PRFilePrivate):** - _PR_FILEDESC_OPEN: The OS fd is open.** - _PR_FILEDESC_CLOSED: The OS fd is closed.  The PRFileDesc**   is still open but is unusable.  The only operation allowed**   on the PRFileDesc is PR_Close().** - _PR_FILEDESC_FREED: The OS fd is closed and the PRFileDesc**   structure is freed.*/#define _PR_FILEDESC_OPEN       0xaaaaaaaa    /* 1010101... */#define _PR_FILEDESC_CLOSED     0x55555555    /* 0101010... */#define _PR_FILEDESC_FREED      0x11111111/*** A boolean type with an additional "unknown" state*/typedef enum {    _PR_TRI_TRUE = 1,    _PR_TRI_FALSE = 0,    _PR_TRI_UNKNOWN = -1} _PRTriStateBool;struct PRFilePrivate {    PRInt32 state;    PRBool nonblocking;    _PRTriStateBool inheritable;    PRFileDesc *next;    PRIntn lockCount;   /*   0: not locked                         *  -1: a native lockfile call is in progress                         * > 0: # times the file is locked */#ifdef _PR_HAVE_PEEK_BUFFER    char *peekBuffer;    PRInt32 peekBufSize;    PRInt32 peekBytes;#endif#if !defined(XP_UNIX)   /* BugZilla: 4090 */    PRBool  appendMode;                             #endif    _MDFileDesc md;#ifdef _PR_STRICT_ADDR_LEN    PRUint16 af;        /* If the platform requires passing the exact                         * length of the sockaddr structure for the                         * address family of the socket to socket                         * functions like accept(), we need to save                         * the address family of the socket. */#endif};struct PRDir {    PRDirEntry d;    _MDDir md;};extern void _PR_InitSegs(void);extern void _PR_InitStacks(void);extern void _PR_InitTPD(void);extern void _PR_InitMem(void);extern void _PR_InitEnv(void);extern void _PR_InitCMon(void);extern void _PR_InitIO(void);extern void _PR_InitLog(void);extern void _PR_InitNet(void);extern void _PR_InitClock(void);extern void _PR_InitLinker(void);extern void _PR_InitAtomic(void);extern void _PR_InitCPUs(void);extern void _PR_InitDtoa(void);extern void _PR_InitMW(void);extern void _PR_InitRWLocks(void);extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me);extern void _PR_CleanupThread(PRThread *thread);extern void _PR_CleanupCallOnce(void);extern void _PR_CleanupMW(void);extern void _PR_CleanupDtoa(void);extern void _PR_ShutdownLinker(void);extern void _PR_CleanupEnv(void);extern void _PR_CleanupIO(void);extern void _PR_CleanupNet(void);extern void _PR_CleanupLayerCache(void);extern void _PR_CleanupStacks(void);#ifdef WINNTextern void _PR_CleanupCPUs(void);#endifextern void _PR_CleanupThreads(void);extern void _PR_CleanupTPD(void);extern void _PR_Cleanup(void);extern void _PR_LogCleanup(void);extern void _PR_InitLayerCache(void);#ifdef GC_LEAK_DETECTORextern void _PR_InitGarbageCollector(void);#endifextern PRBool _pr_initialized;extern void _PR_ImplicitInitialization(void);extern PRBool _PR_Obsolete(const char *obsolete, const char *preferred);/************************************************************************/struct PRSegment {    void *vaddr;    PRUint32 size;    PRUintn flags;#if defined(_PR_PTHREADS)#else  /* defined(_PR_PTHREADS) */    _MDSegment md;#endif /* defined(_PR_PTHREADS) */};/* PRSegment.flags */#define _PR_SEG_VM    0x1/************************************************************************/extern PRInt32 _pr_pageSize;extern PRInt32 _pr_pageShift;extern PRLogModuleInfo *_pr_clock_lm;extern PRLogModuleInfo *_pr_cmon_lm;extern PRLogModuleInfo *_pr_io_lm;extern PRLogModuleInfo *_pr_cvar_lm;extern PRLogModuleInfo *_pr_mon_lm;extern PRLogModuleInfo *_pr_linker_lm;extern PRLogModuleInfo *_pr_sched_lm;extern PRLogModuleInfo *_pr_thread_lm;extern PRLogModuleInfo *_pr_gc_lm;extern PRFileDesc *_pr_stdin;extern PRFileDesc *_pr_stdout;extern PRFileDesc *_pr_stderr;/* Zone allocator *//*** The zone allocator code has hardcoded pthread types and** functions, so it can only be used in the pthreads version.** This can be fixed by replacing the hardcoded pthread types** and functions with macros that expand to the native thread** types and functions on each platform.*/#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)#define _PR_ZONE_ALLOCATOR#endif#ifdef _PR_ZONE_ALLOCATORextern void _PR_InitZones(void);extern void _PR_DestroyZones(void);#endif/* Overriding malloc, free, etc. */#if !defined(_PR_NO_PREEMPT) && defined(XP_UNIX) \        && !defined(_PR_PTHREADS) && !defined(_PR_GLOBAL_THREADS_ONLY) \        && !defined(PURIFY) \        && !defined(DARWIN) \        && !defined(NEXTSTEP) \        && !defined(QNX) \        && !(defined (UNIXWARE) && defined (USE_SVR4_THREADS))#define _PR_OVERRIDE_MALLOC#endif/************************************************************************** External machine-dependent code provided by each OS.                     *                                                                     **************************************************************************//* Initialization related */extern void _PR_MD_EARLY_INIT(void);#define    _PR_MD_EARLY_INIT _MD_EARLY_INITextern void _PR_MD_INTERVAL_INIT(void);#define    _PR_MD_INTERVAL_INIT _MD_INTERVAL_INITNSPR_API(void) _PR_MD_FINAL_INIT(void);#define    _PR_MD_FINAL_INIT _MD_FINAL_INIT/* Process control */extern PRProcess * _PR_MD_CREATE_PROCESS(    const char *path,    char *const *argv,    char *const *envp,    const PRProcessAttr *attr);#define    _PR_MD_CREATE_PROCESS _MD_CREATE_PROCESSextern PRStatus _PR_MD_DETACH_PROCESS(PRProcess *process);#define    _PR_MD_DETACH_PROCESS _MD_DETACH_PROCESSextern PRStatus _PR_MD_WAIT_PROCESS(PRProcess *process, PRInt32 *exitCode);#define    _PR_MD_WAIT_PROCESS _MD_WAIT_PROCESSextern PRStatus _PR_MD_KILL_PROCESS(PRProcess *process);#define    _PR_MD_KILL_PROCESS _MD_KILL_PROCESS        /* Current Time */NSPR_API(PRTime) _PR_MD_NOW(void);#define    _PR_MD_NOW _MD_NOW/* Environment related */extern char* _PR_MD_GET_ENV(const char *name);#define    _PR_MD_GET_ENV _MD_GET_ENVextern PRIntn _PR_MD_PUT_ENV(const char *name);#define    _PR_MD_PUT_ENV _MD_PUT_ENV/* Atomic operations */extern void _PR_MD_INIT_ATOMIC(void);#define    _PR_MD_INIT_ATOMIC _MD_INIT_ATOMICextern PRInt32 _PR_MD_ATOMIC_INCREMENT(PRInt32 *);#define    _PR_MD_ATOMIC_INCREMENT _MD_ATOMIC_INCREMENTextern PRInt32 _PR_MD_ATOMIC_ADD(PRInt32 *, PRInt32);#define    _PR_MD_ATOMIC_ADD _MD_ATOMIC_ADDextern PRInt32 _PR_MD_ATOMIC_DECREMENT(PRInt32 *);#define    _PR_MD_ATOMIC_DECREMENT _MD_ATOMIC_DECREMENTextern PRInt32 _PR_MD_ATOMIC_SET(PRInt32 *, PRInt32);#define    _PR_MD_ATOMIC_SET _MD_ATOMIC_SE

⌨️ 快捷键说明

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