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

📄 _win16.h

📁 gaca源码
💻 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_win16_defs_h___
#define nspr_win16_defs_h___

#include <windows.h>
#include <winsock.h>
#include <errno.h>
#include <direct.h>

#include "nspr.h"
/* $$ fix this */
#define Remind(x)

/*
 * Internal configuration macros
 */

#define PR_LINKER_ARCH      "win16"
#define _PR_SI_SYSNAME        "WIN16"
#define _PR_SI_ARCHITECTURE   "x86"    /* XXXMB hardcode for now */

#define HAVE_DLL
#define _PR_NO_PREEMPT
#define _PR_LOCAL_THREADS_ONLY
#undef  _PR_GLOBAL_THREADS_ONLY
#undef  HAVE_THREAD_AFFINITY
#define _PR_HAVE_ATOMIC_OPS

/* --- Common User-Thread/Native-Thread Definitions --------------------- */

extern struct PRLock        *_pr_schedLock;
extern char                 * _pr_top_of_task_stack;


/* --- Typedefs --- */

#define PR_NUM_GCREGS           9
typedef PRInt32	               PR_CONTEXT_TYPE[PR_NUM_GCREGS];

#define _MD_MAGIC_THREAD	0x22222222
#define _MD_MAGIC_THREADSTACK	0x33333333
#define _MD_MAGIC_SEGMENT	0x44444444
#define _MD_MAGIC_DIR		0x55555555
#define _MD_MAGIC_CV        0x66666666


typedef struct _PRWin16PollDesc
{
	PRInt32 osfd;
	PRInt16 in_flags;
	PRInt16 out_flags;
} _PRWin16PollDesc;

typedef struct PRPollQueue
{
    PRCList links;              /* for linking PRPollQueue's together */
    _PRWin16PollDesc *pds;      /* array of poll descriptors */
    PRUintn npds;				/* length of the array */
    PRPackedBool on_ioq;        /* is this on the async i/o work q? */
    PRIntervalTime timeout;     /* timeout, in ticks */
    struct PRThread *thr;
} PRPollQueue;

#define _PR_POLLQUEUE_PTR(_qp) \
    ((PRPollQueue *) ((char*) (_qp) - offsetof(PRPollQueue,links)))

NSPR_API(PRInt32) _PR_WaitForFD(PRInt32 osfd, PRUintn how,
					PRIntervalTime timeout);
NSPR_API(void) _PR_Unblock_IO_Wait(struct PRThread *thr);

#define _PR_MD_MAX_OSFD             FD_SETSIZE
#define _PR_IOQ(_cpu)				((_cpu)->md.ioQ)
#define _PR_ADD_TO_IOQ(_pq, _cpu) 	PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
#define _PR_FD_READ_SET(_cpu)		((_cpu)->md.fd_read_set)
#define _PR_FD_READ_CNT(_cpu)		((_cpu)->md.fd_read_cnt)
#define _PR_FD_WRITE_SET(_cpu)		((_cpu)->md.fd_write_set)
#define _PR_FD_WRITE_CNT(_cpu)		((_cpu)->md.fd_write_cnt)
#define _PR_FD_EXCEPTION_SET(_cpu)	((_cpu)->md.fd_exception_set)
#define _PR_FD_EXCEPTION_CNT(_cpu)	((_cpu)->md.fd_exception_cnt)
#define _PR_IOQ_TIMEOUT(_cpu)		((_cpu)->md.ioq_timeout)
#define _PR_IOQ_MAX_OSFD(_cpu)		((_cpu)->md.ioq_max_osfd)

struct _MDCPU {
    PRCList		ioQ;
    fd_set		fd_read_set, fd_write_set, fd_exception_set;
    PRInt16		fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
				fd_exception_cnt[_PR_MD_MAX_OSFD];
    PRUint32	ioq_timeout;
    PRInt32		ioq_max_osfd;
};

struct _MDThread {
    /* The overlapped structure must be first! */
    HANDLE           blocked_sema;      /* Threads block on this when waiting
                                         * for IO or CondVar.
                                         */
    PRInt32         errcode;        /* preserved errno for this thread */
    CATCHBUF        context;        /* thread context for Throw() */
    void           *SP;             /* Stack pointer, used only by GarbColl */
    int             threadNumber;   /* instrumentation: order of creation */
	_PRWin16PollDesc thr_pd;       /* poll descriptor for i/o */
	PRPollQueue		thr_pq;        /* i/o parameters			*/
    void           *exceptionContext; /* mfc exception context */
    char            guardBand[24];  /* don't overwrite this */
    PRUint32        magic;          /* self identifier, for debug */
};

struct _MDThreadStack {
    PRUint32           magic;          /* for debugging */
    PRIntn          cxByteCount;    /* number of stack bytes to move */
    char *          stackTop;       /* high address on stack */
};

struct _MDSegment {
    PRUint32           magic;          /* for debugging */
};


struct _MDLock {
    PRUint32           magic;          /* for debugging */
    PRUint32           mutex;
};

struct _MDDir {
    PRUint32         magic;          /* for debugging */
    struct  dirent  *dir;
};

struct _MDCVar {
	PRUint32        magic;
};

struct _MDSemaphore {
	PRInt32			unused;
};

struct _MDFileDesc {
    PRInt32 osfd;
};

struct _MDProcess {
    HANDLE handle;
    DWORD id;
};

/*
** Microsoft 'struct _stat'
** ... taken directly from msvc 1.52c's header file sys/stat.h
** see PR_Stat() implemented in w16io.c
** See BugSplat: 98516
*/
#pragma pack(push)
#pragma pack(2)

typedef unsigned short _ino_t;
typedef short _dev_t;
typedef long _off_t;

typedef struct _MDMSStat {
    _dev_t st_dev;
    _ino_t st_ino;
    unsigned short st_mode;
    short st_nlink;
    short st_uid;
    short st_gid;
    _dev_t st_rdev;
    _off_t st_size;
    time_t st_atime;
    time_t st_mtime;
    time_t st_ctime;
} _MDMSStat;
#pragma pack(pop)

/* --- Errors --- */
    /* These are NSPR generated error codes which need to be unique from
     * OS error codes.
     */
#define _MD_UNIQUEBASE                 50000
#define _MD_EINTERRUPTED               _MD_UNIQUEBASE + 1
#define _MD_ETIMEDOUT                  _MD_UNIQUEBASE + 2
#define _MD_EIO                        _MD_UNIQUEBASE + 3

struct PRProcess;
struct PRProcessAttr;

/* --- Create a new process --- */
#define _MD_CREATE_PROCESS _PR_CreateWindowsProcess
extern struct PRProcess * _PR_CreateWindowsProcess(
    const char *path,
    char *const *argv,
    char *const *envp,
    const struct PRProcessAttr *attr
);

#define _MD_DETACH_PROCESS _PR_DetachWindowsProcess
extern PRStatus _PR_DetachWindowsProcess(struct PRProcess *process);

/* --- Wait for a child process to terminate --- */
#define _MD_WAIT_PROCESS _PR_WaitWindowsProcess
extern PRStatus _PR_WaitWindowsProcess(struct PRProcess *process, 
    PRInt32 *exitCode);

#define _MD_KILL_PROCESS _PR_KillWindowsProcess
extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process);


/* --- Misc stuff --- */

#define MD_ASSERTINT( x )             PR_ASSERT( (x) < 65535 )

/* --- IO stuff --- */
#define MAX_PATH    256
#define _MD_ERRNO()                   errno
#define GetLastError()                errno

#define _MD_GET_FILE_ERROR()          errno
#define _MD_SET_FILE_ERROR(_err)      errno = (_err)

#define _MD_OPEN                      _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
#define _MD_CLOSE_FILE                _PR_MD_CLOSE_FILE
#define _MD_GETFILEINFO               _PR_MD_GETFILEINFO
#define _MD_GETOPENFILEINFO           _PR_MD_GETOPENFILEINFO
#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_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 --- */
#define _MD_EACCES                WSAEACCES
#define _MD_EADDRINUSE            WSAEADDRINUSE
#define _MD_EADDRNOTAVAIL         WSAEADDRNOTAVAIL
#define _MD_EAFNOSUPPORT          WSAEAFNOSUPPORT
#define _MD_EAGAIN                WSAEWOULDBLOCK
#define _MD_EALREADY              WSAEALREADY
#define _MD_EBADF                 WSAEBADF
#define _MD_ECONNREFUSED          WSAECONNREFUSED
#define _MD_ECONNRESET            WSAECONNRESET
#define _MD_EFAULT                WSAEFAULT
#define _MD_EINPROGRESS           WSAEINPROGRESS

⌨️ 快捷键说明

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