123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709 |
- //
- // Copyright (c) Microsoft. All rights reserved.
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
- //
- /*++
- --*/
- ////////////////////////////////////////////////////////////////////////
- // Extensions to the usual posix header files
- ////////////////////////////////////////////////////////////////////////
- #ifndef __PAL_MSTYPES_H__
- #define __PAL_MSTYPES_H__
- #define __MSTYPES_DEFINED
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define BIGENDIAN 0
- ////////////////////////////////////////////////////////////////////////
- // calling convention stuff
- ////////////////////////////////////////////////////////////////////////
- #ifdef __cplusplus
- #define EXTERN_C extern "C"
- #else
- #define EXTERN_C
- #endif // __cplusplus
- // Note: Win32-hosted GCC predefines __stdcall and __cdecl, but Unix-
- // hosted GCC does not.
- #ifdef __i386__
- #define __stdcall
- #define _stdcall
- #define __cdecl
- #define _cdecl
- #define CDECL
- #ifndef PAL_STDCPP_COMPAT
- #undef __fastcall
- #define __fastcall __stdcall
- #undef _fastcall
- #define _fastcall __fastcall
- #endif // PAL_STDCPP_COMPAT
- #else // !defined(__i386__)
- #define __stdcall
- #define _stdcall
- #define __cdecl
- #define _cdecl
- #define CDECL
- // On ARM __fastcall is ignored and causes a compile error
- #if !defined(PAL_STDCPP_COMPAT) || defined(__arm__)
- # undef __fastcall
- # undef _fastcall
- # define __fastcall
- # define _fastcall
- #endif // !defined(PAL_STDCPP_COMPAT) || defined(__arm__)
- #endif // !defined(__i386__)
- #define CALLBACK __stdcall
- #if !defined(_declspec)
- #define _declspec(e) __declspec(e)
- #endif
- #if defined(_VAC_) && defined(__cplusplus)
- #define __inline inline
- #endif
- #define PALIMPORT
- #define PAL_NORETURN __attribute__((noreturn))
- #define PALAPI __stdcall
- #define PALAPIV __cdecl
- ////////////////////////////////////////////////////////////////////////
- // Type attribute stuff
- ////////////////////////////////////////////////////////////////////////
- #define CONST const
- #define IN
- #define OUT
- #define OPTIONAL
- #define FAR
- #ifdef UNICODE
- #define __TEXT(x) L##x
- #else
- #define __TEXT(x) x
- #endif
- #define TEXT(x) __TEXT(x)
- ////////////////////////////////////////////////////////////////////////
- // Some special values
- ////////////////////////////////////////////////////////////////////////
- #ifndef TRUE
- #define TRUE 1
- #endif
- #ifndef FALSE
- #define FALSE 0
- #endif
- ////////////////////////////////////////////////////////////////////////
- // Misc. type helpers
- ////////////////////////////////////////////////////////////////////////
- // GCC's way of declaring large integer constants
- // If you define these in one step, without the _HELPER macros, you
- // get extra whitespace when composing these with other concatenating macros.
- #define I64_HELPER(x) x ## LL
- #define I64(x) I64_HELPER(x)
- #define UI64_HELPER(x) x ## ULL
- #define UI64(x) UI64_HELPER(x)
- ////////////////////////////////////////////////////////////////////////
- // Misc. types
- ////////////////////////////////////////////////////////////////////////
- // A bunch of source files (e.g. most of the ndp tree) include pal.h
- // but are written to be LLP64, not LP64. (LP64 => long = 64 bits
- // LLP64 => longs = 32 bits, long long = 64 bits)
- //
- // To handle this difference, we #define long to be int (and thus 32 bits) when
- // compiling those files. (See the bottom of this file or search for
- // #define long to see where we do this.)
- //
- // But this fix is more complicated than it seems, because we also use the
- // preprocessor to #define __int64 to long for LP64 architectures (__int64
- // isn't a builtin in gcc). We don't want __int64 to be an int (by cascading
- // macro rules). So we play this little trick below where we add
- // __cppmungestrip before "long", which is what we're really #defining __int64
- // to. The preprocessor sees __cppmungestriplong as something different than
- // long, so it doesn't replace it with int. The during the cppmunge phase, we
- // remove the __cppmungestrip part, leaving long for the compiler to see.
- //
- // Note that we can't just use a typedef to define __int64 as long before
- // #defining long because typedefed types can't be signedness-agnostic (i.e.
- // they must be either signed or unsigned) and we want to be able to use
- // __int64 as though it were intrinsic
- #ifdef BIT64
- #define __int64 long
- #else // BIT64
- #define __int64 long long
- #endif // BIT64
- #define __int32 int
- #define __int16 short int
- #define __int8 char // assumes char is signed
- #ifndef _LIBSAFECRT_SGX_CONFIG
- #ifndef PAL_STDCPP_COMPAT
- // Defined in gnu's types.h. For non PAL_IMPLEMENTATION system
- // includes are not included, so we need to define them.
- // Types below are already defined by stdint.h on __APPLE__.
- #if !defined(PAL_IMPLEMENTATION) && !defined(__APPLE__)
- typedef __int64 int64_t;
- typedef unsigned __int64 uint64_t;
- typedef __int32 int32_t;
- typedef unsigned __int32 uint32_t;
- typedef __int16 int16_t;
- typedef unsigned __int16 uint16_t;
- typedef __int8 int8_t;
- #define __int8_t_defined
- typedef unsigned __int8 uint8_t;
- #endif // PAL_IMPLEMENTATION
- #if _WIN64
- typedef long double LONG_DOUBLE;
- #endif
- #endif // !PAL_STDCPP_COMPAT
- #endif
- typedef void VOID;
- #ifndef PLATFORM_UNIX
- typedef long LONG;
- typedef unsigned long ULONG;
- #else
- typedef int LONG; // NOTE: diff from windows.h, for LP64 compat
- typedef unsigned int ULONG; // NOTE: diff from windows.h, for LP64 compat
- #endif
- typedef __int64 LONGLONG;
- typedef unsigned __int64 ULONGLONG;
- typedef ULONGLONG DWORD64;
- typedef DWORD64 *PDWORD64;
- typedef LONGLONG *PLONG64;
- typedef ULONGLONG *PULONG64;
- typedef ULONGLONG *PULONGLONG;
- typedef ULONG *PULONG;
- typedef short SHORT;
- typedef SHORT *PSHORT;
- typedef unsigned short USHORT;
- typedef USHORT *PUSHORT;
- typedef unsigned char UCHAR;
- typedef UCHAR *PUCHAR;
- typedef char *PSZ;
- typedef ULONGLONG DWORDLONG;
- #ifndef PLATFORM_UNIX
- typedef unsigned long DWORD;
- #else
- typedef unsigned int DWORD; // NOTE: diff from windows.h, for LP64 compat
- #endif
- typedef unsigned int DWORD32, *PDWORD32;
- typedef int BOOL;
- typedef unsigned char BYTE;
- typedef unsigned short WORD;
- typedef float FLOAT;
- typedef double DOUBLE;
- typedef BOOL *PBOOL;
- typedef BOOL *LPBOOL;
- typedef BYTE *PBYTE;
- typedef BYTE *LPBYTE;
- typedef const BYTE *LPCBYTE;
- typedef int *PINT;
- typedef int *LPINT;
- typedef WORD *PWORD;
- typedef WORD *LPWORD;
- typedef LONG *LPLONG;
- typedef LPLONG PLONG;
- typedef DWORD *PDWORD;
- typedef DWORD *LPDWORD;
- typedef void *PVOID;
- typedef void *LPVOID;
- typedef CONST void *LPCVOID;
- typedef int INT;
- typedef unsigned int UINT;
- typedef unsigned int *PUINT;
- typedef BYTE BOOLEAN;
- typedef BOOLEAN *PBOOLEAN;
- typedef unsigned __int8 UINT8;
- typedef signed __int8 INT8;
- typedef unsigned __int16 UINT16;
- typedef signed __int16 INT16;
- typedef unsigned __int32 UINT32, *PUINT32;
- typedef signed __int32 INT32, *PINT32;
- typedef unsigned __int64 UINT64, *PUINT64;
- typedef signed __int64 INT64, *PINT64;
- typedef unsigned __int32 ULONG32, *PULONG32;
- typedef signed __int32 LONG32, *PLONG32;
- typedef unsigned __int64 ULONG64;
- typedef signed __int64 LONG64;
- #define _W64
- #ifdef BIT64
- #define _atoi64 (__int64)atoll
- typedef __int64 INT_PTR, *PINT_PTR;
- typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
- typedef __int64 LONG_PTR, *PLONG_PTR;
- typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
- typedef unsigned __int64 DWORD_PTR, *PDWORD_PTR;
- /* maximum signed 64 bit value */
- #define LONG_PTR_MAX I64(9223372036854775807)
- /* maximum unsigned 64 bit value */
- #define ULONG_PTR_MAX UI64(0xffffffffffffffff)
- #ifndef SIZE_MAX
- #define SIZE_MAX _UI64_MAX
- #endif
- #define __int3264 __int64
- #if !defined(BIT64)
- __inline
- unsigned long
- HandleToULong(
- const void *h
- )
- {
- return((unsigned long) (ULONG_PTR) h );
- }
- __inline
- long
- HandleToLong(
- const void *h
- )
- {
- return((long) (LONG_PTR) h );
- }
- __inline
- void *
- ULongToHandle(
- const unsigned long h
- )
- {
- return((void *) (UINT_PTR) h );
- }
- __inline
- void *
- LongToHandle(
- const long h
- )
- {
- return((void *) (INT_PTR) h );
- }
- __inline
- unsigned long
- PtrToUlong(
- const void *p
- )
- {
- return((unsigned long) (ULONG_PTR) p );
- }
- __inline
- unsigned int
- PtrToUint(
- const void *p
- )
- {
- return((unsigned int) (UINT_PTR) p );
- }
- __inline
- unsigned short
- PtrToUshort(
- const void *p
- )
- {
- return((unsigned short) (unsigned long) (ULONG_PTR) p );
- }
- __inline
- long
- PtrToLong(
- const void *p
- )
- {
- return((long) (LONG_PTR) p );
- }
- __inline
- int
- PtrToInt(
- const void *p
- )
- {
- return((int) (INT_PTR) p );
- }
- __inline
- short
- PtrToShort(
- const void *p
- )
- {
- return((short) (long) (LONG_PTR) p );
- }
- __inline
- void *
- IntToPtr(
- const int i
- )
- // Caution: IntToPtr() sign-extends the int value.
- {
- return( (void *)(INT_PTR)i );
- }
- __inline
- void *
- UIntToPtr(
- const unsigned int ui
- )
- // Caution: UIntToPtr() zero-extends the unsigned int value.
- {
- return( (void *)(UINT_PTR)ui );
- }
- __inline
- void *
- LongToPtr(
- const long l
- )
- // Caution: LongToPtr() sign-extends the long value.
- {
- return( (void *)(LONG_PTR)l );
- }
- __inline
- void *
- ULongToPtr(
- const unsigned long ul
- )
- // Caution: ULongToPtr() zero-extends the unsigned long value.
- {
- return( (void *)(ULONG_PTR)ul );
- }
- __inline
- void *
- ShortToPtr(
- const short s
- )
- // Caution: ShortToPtr() sign-extends the short value.
- {
- return( (void *)(INT_PTR)s );
- }
- __inline
- void *
- UShortToPtr(
- const unsigned short us
- )
- // Caution: UShortToPtr() zero-extends the unsigned short value.
- {
- return( (void *)(UINT_PTR)us );
- }
- #else // !defined(BIT64)
- #define HandleToULong( h ) ((ULONG)(ULONG_PTR)(h) )
- #define HandleToLong( h ) ((LONG)(LONG_PTR) (h) )
- #define ULongToHandle( ul ) ((HANDLE)(ULONG_PTR) (ul) )
- #define LongToHandle( h ) ((HANDLE)(LONG_PTR) (h) )
- #define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) )
- #define PtrToLong( p ) ((LONG)(LONG_PTR) (p) )
- #define PtrToUint( p ) ((UINT)(UINT_PTR) (p) )
- #define PtrToInt( p ) ((INT)(INT_PTR) (p) )
- #define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) )
- #define PtrToShort( p ) ((short)(LONG_PTR)(p) )
- #define IntToPtr( i ) ((VOID *)(INT_PTR)((int)(i)))
- #define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)(ui)))
- #define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)(l)))
- #define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)(ul)))
- #define ShortToPtr( s ) ((VOID *)(INT_PTR)((short)(s)))
- #define UShortToPtr( us ) ((VOID *)(UINT_PTR)((unsigned short)(s)))
- #endif // !defined(BIT64)
- #else
- typedef _W64 __int32 INT_PTR;
- typedef _W64 unsigned __int32 UINT_PTR;
- typedef _W64 __int32 LONG_PTR;
- typedef _W64 unsigned __int32 ULONG_PTR, *PULONG_PTR;
- typedef _W64 unsigned __int32 DWORD_PTR, *PDWORD_PTR;
- /* maximum signed 32 bit value */
- #define LONG_PTR_MAX 2147483647L
- /* maximum unsigned 32 bit value */
- #define ULONG_PTR_MAX 0xffffffffUL
- #define SIZE_MAX UINT_MAX
- #define __int3264 __int32
- #define HandleToULong( h ) ((ULONG)(ULONG_PTR)(h) )
- #define HandleToLong( h ) ((LONG)(LONG_PTR) (h) )
- #define ULongToHandle( ul ) ((HANDLE)(ULONG_PTR) (ul) )
- #define LongToHandle( h ) ((HANDLE)(LONG_PTR) (h) )
- #define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) )
- #define PtrToLong( p ) ((LONG)(LONG_PTR) (p) )
- #define PtrToUint( p ) ((UINT)(UINT_PTR) (p) )
- #define PtrToInt( p ) ((INT)(INT_PTR) (p) )
- #define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) )
- #define PtrToShort( p ) ((short)(LONG_PTR)(p) )
- #define IntToPtr( i ) ((VOID *)(INT_PTR)((int)i))
- #define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)ui))
- #define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)l))
- #define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)ul))
- #define ShortToPtr( s ) ((VOID *)(INT_PTR)((short)s))
- #define UShortToPtr( us ) ((VOID *)(UINT_PTR)((unsigned short)s))
- #endif
- #define HandleToUlong(h) HandleToULong(h)
- #define UlongToHandle(ul) ULongToHandle(ul)
- #define UlongToPtr(ul) ULongToPtr(ul)
- #define UintToPtr(ui) UIntToPtr(ui)
- typedef ULONG_PTR SIZE_T, *PSIZE_T;
- typedef LONG_PTR SSIZE_T, *PSSIZE_T;
- #ifndef SIZE_T_MAX
- #define SIZE_T_MAX ULONG_PTR_MAX
- #endif // SIZE_T_MAX
- #ifndef SSIZE_T_MAX
- #define SSIZE_T_MAX LONG_PTR_MAX
- #endif
- #ifndef SSIZE_T_MIN
- #define SSIZE_T_MIN I64(-9223372036854775808)
- #endif
- #ifndef _LIBSAFECRT_SGX_CONFIG
- #ifndef PAL_STDCPP_COMPAT
- #if defined(__APPLE__) || defined(__LINUX__)
- #ifdef BIT64
- typedef unsigned long size_t;
- typedef long ptrdiff_t;
- #else // !BIT64
- typedef unsigned int size_t;
- typedef int ptrdiff_t;
- #endif // !BIT64
- #else
- typedef ULONG_PTR size_t;
- typedef LONG_PTR ptrdiff_t;
- #endif
- #endif // !PAL_STDCPP_COMPAT
- #define _SIZE_T_DEFINED
- typedef LONG_PTR LPARAM;
- #define _PTRDIFF_T_DEFINED
- #ifdef _MINGW_
- // We need to define _PTRDIFF_T to make sure ptrdiff_t doesn't get defined
- // again by system headers - but only for MinGW.
- #define _PTRDIFF_T
- #endif
- #endif
- #ifndef _LIBSAFECRT_SGX_CONFIG
- #if !defined(__cplusplus)
- #include <wchar.h>
- typedef wchar_t char16_t;
- #endif // __cplusplus
- typedef char16_t char16;
- typedef char16_t WCHAR;
- #ifdef PAL_STDCPP_COMPAT
- #ifdef __APPLE__
- static_assert(sizeof(unsigned long) == sizeof(void*), "This platform is not supported");
- #else
- #ifdef BIT64
- typedef unsigned long int uintptr_t;
- #else // !BIT64
- typedef unsigned int uintptr_t;
- #endif // !BIT64
- #endif
- #else // !PAL_STDCPP_COMPAT
- #if defined(__LINUX__)
- #ifdef BIT64
- typedef long int intptr_t;
- typedef unsigned long int uintptr_t;
- #else // !BIT64
- typedef int intptr_t;
- typedef unsigned int uintptr_t;
- #endif // !BIT64
- #else
- typedef INT_PTR intptr_t;
- typedef UINT_PTR uintptr_t;
- #endif
- #endif // PAL_STDCPP_COMPAT
- #define _INTPTR_T_DEFINED
- #define _UINTPTR_T_DEFINED
- #else
- #include "mbusafecrt.h"
- #if !defined(__cplusplus)
- typedef wchar_t char16_t;
- #endif // __cplusplus
- #endif
- typedef DWORD LCID;
- typedef PDWORD PLCID;
- typedef WORD LANGID;
- typedef DWORD LCTYPE;
- typedef WCHAR *PWCHAR;
- typedef WCHAR *LPWCH, *PWCH;
- typedef CONST WCHAR *LPCWCH, *PCWCH;
- typedef WCHAR *NWPSTR;
- typedef WCHAR *LPWSTR, *PWSTR;
- typedef CONST WCHAR *LPCWSTR, *PCWSTR;
- typedef char CHAR;
- typedef CHAR *PCHAR;
- typedef CHAR *LPCH, *PCH;
- typedef CONST CHAR *LPCCH, *PCCH;
- typedef CHAR *NPSTR;
- typedef CHAR *LPSTR, *PSTR;
- typedef CONST CHAR *LPCSTR, *PCSTR;
- #ifdef UNICODE
- typedef WCHAR TCHAR;
- typedef WCHAR _TCHAR;
- #else
- typedef CHAR TCHAR;
- typedef CHAR _TCHAR;
- #endif
- typedef TCHAR *PTCHAR;
- typedef TCHAR *LPTSTR, *PTSTR;
- typedef CONST TCHAR *LPCTSTR;
- #define MAKEWORD(a, b) ((WORD)(((BYTE)((DWORD_PTR)(a) & 0xff)) | ((WORD)((BYTE)((DWORD_PTR)(b) & 0xff))) << 8))
- #define MAKELONG(a, b) ((LONG)(((WORD)((DWORD_PTR)(a) & 0xffff)) | ((DWORD)((WORD)((DWORD_PTR)(b) & 0xffff))) << 16))
- #define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xffff))
- #define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16))
- #define LOBYTE(w) ((BYTE)((DWORD_PTR)(w) & 0xff))
- #define HIBYTE(w) ((BYTE)((DWORD_PTR)(w) >> 8))
- typedef VOID *HANDLE;
- typedef HANDLE HWND;
- typedef struct __PAL_RemoteHandle__ { HANDLE h; } *RHANDLE;
- typedef HANDLE *PHANDLE;
- typedef HANDLE *LPHANDLE;
- #define INVALID_HANDLE_VALUE ((VOID *)(-1))
- #define INVALID_FILE_SIZE ((DWORD)0xFFFFFFFF)
- #define INVALID_FILE_ATTRIBUTES ((DWORD) -1)
- typedef HANDLE HMODULE;
- typedef HANDLE HINSTANCE;
- typedef HANDLE HGLOBAL;
- typedef HANDLE HLOCAL;
- typedef HANDLE HRSRC;
- typedef LONG HRESULT;
- typedef LONG NTSTATUS;
- typedef union _LARGE_INTEGER {
- struct {
- #if BIGENDIAN
- LONG HighPart;
- DWORD LowPart;
- #else
- DWORD LowPart;
- LONG HighPart;
- #endif
- };
- struct {
- #if BIGENDIAN
- LONG HighPart;
- DWORD LowPart;
- #else
- DWORD LowPart;
- LONG HighPart;
- #endif
- } u;
- LONGLONG QuadPart;
- } LARGE_INTEGER, *PLARGE_INTEGER;
- #ifndef GUID_DEFINED
- typedef struct _GUID {
- ULONG Data1; // NOTE: diff from Win32, for LP64
- USHORT Data2;
- USHORT Data3;
- UCHAR Data4[ 8 ];
- } GUID;
- typedef const GUID *LPCGUID;
- #define GUID_DEFINED
- #endif // !GUID_DEFINED
- typedef struct _FILETIME {
- DWORD dwLowDateTime;
- DWORD dwHighDateTime;
- } FILETIME, *PFILETIME, *LPFILETIME;
- /* Code Page Default Values */
- #define CP_ACP 0 /* default to ANSI code page */
- #define CP_OEMCP 1 /* default to OEM code page */
- #define CP_MACCP 2 /* default to MAC code page */
- #define CP_THREAD_ACP 3 /* current thread's ANSI code page */
- #define CP_WINUNICODE 1200
- #define CP_UNICODE 1200 /* Unicode */
- #define CP_UNICODESWAP 1201 /* Unicode Big-Endian */
- #define CP_UTF7 65000 /* UTF-7 translation */
- #define CP_UTF8 65001 /* UTF-8 translation */
- typedef PVOID PSID;
- #ifdef __cplusplus
- }
- #endif
- #endif // __PAL_MSTYPES_H__
|