📄 _winnt.h
字号:
/* -*- 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_win32_defs_h___#define nspr_win32_defs_h___/* Need to force service-pack 3 extensions to be defined by** setting _WIN32_WINNT to NT 4.0 for winsock.h, winbase.h, winnt.h.*/ #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0400#elif (_WIN32_WINNT < 0x0400) #undef _WIN32_WINNT #define _WIN32_WINNT 0x0400#endif /* _WIN32_WINNT */#include <windows.h>#include <winsock.h>#include <errno.h>#include "prio.h"#include "prclist.h"/* * Internal configuration macros */#define PR_LINKER_ARCH "win32"#define _PR_SI_SYSNAME "WINNT"#define _PR_SI_ARCHITECTURE "x86" /* XXXMB hardcode for now */#define HAVE_DLL#define HAVE_CUSTOM_USER_THREADS#define HAVE_THREAD_AFFINITY#define _PR_HAVE_ATOMIC_OPS#define _PR_HAVE_ATOMIC_CAS#define PR_HAVE_WIN32_NAMED_SHARED_MEMORY#define _PR_HAVE_PEEK_BUFFER#define _PR_PEEK_BUFFER_MAX (32 * 1024)#define _PR_FD_NEED_EMULATE_MSG_PEEK(fd) \ (!(fd)->secret->nonblocking && (fd)->secret->inheritable != _PR_TRI_TRUE)/* --- 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 0x00FFFFFF#define _MD_MAGIC_THREAD 0x22222222#define _MD_MAGIC_THREADSTACK 0x33333333#define _MD_MAGIC_SEGMENT 0x44444444#define _MD_MAGIC_DIR 0x55555555struct _MDCPU { int unused;};enum _MDIOModel { _MD_BlockingIO = 0x38, _MD_MultiWaitIO = 0x49};typedef struct _MDOverlapped { OVERLAPPED overlapped; /* Used for async I/O */ enum _MDIOModel ioModel; /* The I/O model to implement * using overlapped I/O. */ union { struct _MDThread *mdThread; /* For blocking I/O, this structure * is embedded in the _MDThread * structure. */ struct { PRCList links; /* for group->io_ready list */ struct PRRecvWait *desc; /* For multiwait I/O, this structure * is associated with a PRRecvWait * structure. */ struct PRWaitGroup *group; struct TimerEvent *timer; DWORD error; } mw; } data;} _MDOverlapped;struct _MDThread { /* The overlapped structure must be first! */ struct _MDOverlapped overlapped; /* Used for async IO for this thread */ void *acceptex_buf; /* Used for AcceptEx() */ TRANSMIT_FILE_BUFFERS *xmit_bufs; /* Used for TransmitFile() */ HANDLE blocked_sema; /* Threads block on this when waiting * for IO or CondVar. */ PRInt32 blocked_io_status; /* Status of the completed IO */ PRInt32 blocked_io_bytes; /* Bytes transferred for completed IO */ PRInt32 blocked_io_error; /* Save error if status is FALSE */ HANDLE handle; PRUint32 id; void *sp; /* only valid when suspended */ PRUint32 magic; /* for debugging */ PR_CONTEXT_TYPE gcContext; /* Thread context for GC */ struct _PRCPU *thr_bound_cpu; /* thread bound to cpu */ PRBool interrupt_disabled;/* thread cannot be interrupted */ HANDLE thr_event; /* For native-threads-only support, thread blocks on this event */ /* The following are used only if this is a fiber */ void *fiber_id; /* flag whether or not this is a fiber*/ FiberFunc fiber_fn; /* main fiber routine */ void *fiber_arg; /* arg to main fiber routine */ PRUint32 fiber_stacksize; /* stacksize for fiber */ PRInt32 fiber_last_error; /* last error for the fiber */};struct _MDThreadStack { PRUint32 magic; /* for debugging */};struct _MDSegment { PRUint32 magic; /* for debugging */};#undef PROFILE_LOCKSstruct _MDLock { CRITICAL_SECTION mutex; /* this is recursive on NT */#ifdef PROFILE_LOCKS PRInt32 hitcount; PRInt32 misscount;#endif};struct _MDDir { HANDLE d_hdl; WIN32_FIND_DATA d_entry; PRBool firstEntry; /* Is this the entry returned * by FindFirstFile()? */ PRUint32 magic; /* for debugging */};struct _MDCVar { PRUint32 unused;};struct _MDSemaphore { HANDLE sem;};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 Win32 HANDLE, * which is a void*. * - For sockets, we are using Winsock SOCKET, which * is a u_int. */ PRBool io_model_committed; /* The io model (blocking or nonblocking) * for this osfd has been committed and * cannot be changed. The osfd has been * either associated with the io * completion port or made nonblocking. */ PRBool sync_file_io; /* Use synchronous file I/O on the osfd * (a file handle) */ PRBool accepted_socket; /* Is this an accepted socket (on the * server side)? */ PRNetAddr peer_addr; /* If this is an accepted socket, cache * the peer's address returned by * AcceptEx(). This is to work around * the bug that getpeername() on an * socket accepted by AcceptEx() returns * an all-zero net address. */};struct _MDProcess { HANDLE handle; DWORD id;};/* --- Misc stuff --- */#define _MD_GET_SP(thread) (thread)->md.gcContext[6]/* --- NT security stuff --- */extern void _PR_NT_InitSids(void);extern void _PR_NT_FreeSids(void);extern PRStatus _PR_NT_MakeSecurityDescriptorACL( PRIntn mode, DWORD accessTable[], PSECURITY_DESCRIPTOR *resultSD, PACL *resultACL);extern void _PR_NT_FreeSecurityDescriptorACL( PSECURITY_DESCRIPTOR pSD, PACL pACL);/* --- IO stuff --- */extern PRInt32 _md_Associate(HANDLE);extern PRInt32 _PR_MD_CLOSE(PRInt32 osfd, PRBool socket);#define _MD_OPEN _PR_MD_OPEN#define _MD_OPEN_FILE _PR_MD_OPEN_FILE#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(f) _PR_MD_CLOSE(f, PR_FALSE)#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_MAKE_DIR#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_GET_SOCKET_ERROR() WSAGetLastError()#define _MD_SET_SOCKET_ERROR(_err) WSASetLastError(_err)#define _MD_INIT_FILEDESC(fd)#define _MD_MAKE_NONBLOCK _PR_MD_MAKE_NONBLOCK#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_LISTEN#define _MD_CLOSE_SOCKET(s) _PR_MD_CLOSE(s, PR_TRUE)#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#define _MD_GETSOCKOPT _PR_MD_GETSOCKOPT#define _MD_SETSOCKOPT _PR_MD_SETSOCKOPT#define _MD_SELECT select
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -