Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 #include <_mingw.h>
      7 
      8 #ifndef _BASETSD_H_
      9 #define _BASETSD_H_
     10 
     11 #if (defined(__x86_64) || defined(__ia64__)) && !defined(RC_INVOKED)
     12 __MINGW_EXTENSION typedef unsigned __int64 POINTER_64_INT;
     13 #else
     14 typedef unsigned long POINTER_64_INT;
     15 #endif
     16 
     17 #define POINTER_32
     18 #define POINTER_64
     19 #define FIRMWARE_PTR
     20 
     21 #define POINTER_SIGNED
     22 #define POINTER_UNSIGNED
     23 #define SPOINTER_32 POINTER_SIGNED POINTER_32
     24 #define UPOINTER_32 POINTER_UNSIGNED POINTER_32
     25 
     26 #ifdef __cplusplus
     27 extern "C" {
     28 #endif
     29 
     30   typedef signed char INT8,*PINT8;
     31   typedef signed short INT16,*PINT16;
     32   typedef signed int INT32,*PINT32;
     33   __MINGW_EXTENSION typedef signed __int64 INT64,*PINT64;
     34   typedef unsigned char UINT8,*PUINT8;
     35   typedef unsigned short UINT16,*PUINT16;
     36   typedef unsigned int UINT32,*PUINT32;
     37   __MINGW_EXTENSION typedef unsigned __int64 UINT64,*PUINT64;
     38   typedef signed int LONG32,*PLONG32;
     39   typedef unsigned int ULONG32,*PULONG32;
     40   typedef unsigned int DWORD32,*PDWORD32;
     41 
     42 #ifndef _W64
     43 #define _W64
     44 #endif
     45 
     46 #ifdef _WIN64
     47   __MINGW_EXTENSION typedef __int64 INT_PTR,*PINT_PTR;
     48   __MINGW_EXTENSION typedef unsigned __int64 UINT_PTR,*PUINT_PTR;
     49   __MINGW_EXTENSION typedef __int64 LONG_PTR,*PLONG_PTR;
     50   __MINGW_EXTENSION typedef unsigned __int64 ULONG_PTR,*PULONG_PTR;
     51 #define __int3264 __int64
     52 #else
     53   typedef int INT_PTR,*PINT_PTR;
     54   typedef unsigned int UINT_PTR,*PUINT_PTR;
     55   typedef long LONG_PTR,*PLONG_PTR;
     56   typedef unsigned long ULONG_PTR,*PULONG_PTR;
     57 #define __int3264 __int32
     58 #endif
     59 
     60 #ifdef _WIN64
     61 #define ADDRESS_TAG_BIT 0x40000000000ULL
     62   __MINGW_EXTENSION typedef __int64 SHANDLE_PTR;
     63   __MINGW_EXTENSION typedef unsigned __int64 HANDLE_PTR;
     64   typedef unsigned int UHALF_PTR,*PUHALF_PTR;
     65   typedef int HALF_PTR,*PHALF_PTR;
     66 
     67 #ifndef __WIDL__
     68   static __inline unsigned __LONG32 HandleToULong(const void *h) { return((unsigned __LONG32) (ULONG_PTR) h); }
     69   static __inline __LONG32 HandleToLong(const void *h) { return((__LONG32) (LONG_PTR) h); }
     70   static __inline void *ULongToHandle(const unsigned __LONG32 h) { return((void *) (UINT_PTR) h); }
     71   static __inline void *LongToHandle(const __LONG32 h) { return((void *) (INT_PTR) h); }
     72   static __inline unsigned __LONG32 PtrToUlong(const void *p) { return((unsigned __LONG32) (ULONG_PTR) p); }
     73   static __inline unsigned int PtrToUint(const void *p) { return((unsigned int) (UINT_PTR) p); }
     74   static __inline unsigned short PtrToUshort(const void *p) { return((unsigned short) (unsigned __LONG32) (ULONG_PTR) p); }
     75   static __inline __LONG32 PtrToLong(const void *p) { return((__LONG32) (LONG_PTR) p); }
     76   static __inline int PtrToInt(const void *p) { return((int) (INT_PTR) p); }
     77   static __inline short PtrToShort(const void *p) { return((short) (__LONG32) (LONG_PTR) p); }
     78   static __inline void *IntToPtr(const int i) { return((void *)(INT_PTR)i); }
     79   static __inline void *UIntToPtr(const unsigned int ui) { return((void *)(UINT_PTR)ui); }
     80   static __inline void *LongToPtr(const __LONG32 l) { return((void *)(LONG_PTR)l); }
     81   static __inline void *ULongToPtr(const unsigned __LONG32 ul) { return((void *)(ULONG_PTR)ul); }
     82 
     83 #define PtrToPtr64(p) ((void *) (ULONG_PTR) p)
     84 #define Ptr64ToPtr(p) ((void *) (ULONG_PTR) p)
     85 #define HandleToHandle64(h) (PtrToPtr64(h))
     86 #define Handle64ToHandle(h) (Ptr64ToPtr(h))
     87 
     88   static __inline void *Ptr32ToPtr(const void *p) { return (void *) (ULONG_PTR) p; }
     89   static __inline void *Handle32ToHandle(const void *h) { return((void *) (ULONG_PTR) h); }
     90   static __inline void *PtrToPtr32(const void *p) { return((void *) (ULONG_PTR) p); }
     91 
     92 #define HandleToHandle32(h) (PtrToPtr32(h))
     93 #endif
     94 
     95 #else
     96 
     97 #define ADDRESS_TAG_BIT __MSABI_LONG(0x80000000U)
     98 
     99   typedef unsigned short UHALF_PTR,*PUHALF_PTR;
    100   typedef short HALF_PTR,*PHALF_PTR;
    101   typedef long SHANDLE_PTR;
    102   typedef unsigned long HANDLE_PTR;
    103 
    104 #ifndef __WIDL__
    105 #define HandleToULong(h) ((ULONG)(ULONG_PTR)(h))
    106 #define HandleToLong(h) ((LONG)(LONG_PTR) (h))
    107 #define ULongToHandle(ul) ((HANDLE)(ULONG_PTR) (ul))
    108 #define LongToHandle(h) ((HANDLE)(LONG_PTR) (h))
    109 #define PtrToUlong(p) ((ULONG)(ULONG_PTR) (p))
    110 #define PtrToLong(p) ((LONG)(LONG_PTR) (p))
    111 #define PtrToUint(p) ((UINT)(UINT_PTR) (p))
    112 #define PtrToInt(p) ((INT)(INT_PTR) (p))
    113 #define PtrToUshort(p) ((unsigned short)(ULONG_PTR)(p))
    114 #define PtrToShort(p) ((short)(LONG_PTR)(p))
    115 #define IntToPtr(i) ((VOID *)(INT_PTR)((int)i))
    116 #define UIntToPtr(ui) ((VOID *)(UINT_PTR)((unsigned int)ui))
    117 #define LongToPtr(l) ((VOID *)(LONG_PTR)((long)l))
    118 #define ULongToPtr(ul) ((VOID *)(ULONG_PTR)((unsigned long)ul))
    119 
    120   static __inline void *PtrToPtr64(const void *p) { return((void *) (ULONG_PTR)p); }
    121   static __inline void *Ptr64ToPtr(const void *p) { return((void *) (ULONG_PTR) p); }
    122   static __inline void *HandleToHandle64(const void *h) { return((void *) (ULONG_PTR) h); }
    123   static __inline void *Handle64ToHandle(const void *h) { return((void *) (ULONG_PTR) h); }
    124 
    125 #define Ptr32ToPtr(p) ((void *) (ULONG_PTR) p)
    126 #define Handle32ToHandle(h) (Ptr32ToPtr(h))
    127 #define PtrToPtr32(p) ((void *) (ULONG_PTR) p)
    128 #define HandleToHandle32(h) (PtrToPtr32(h))
    129 #endif
    130 #endif
    131 
    132 #define HandleToUlong(h) HandleToULong(h)
    133 #define UlongToHandle(ul) ULongToHandle(ul)
    134 #define UlongToPtr(ul) ULongToPtr(ul)
    135 #define UintToPtr(ui) UIntToPtr(ui)
    136 
    137 #define MAXUINT_PTR (~((UINT_PTR)0))
    138 #define MAXINT_PTR ((INT_PTR)(MAXUINT_PTR >> 1))
    139 #define MININT_PTR (~MAXINT_PTR)
    140 
    141 #define MAXULONG_PTR (~((ULONG_PTR)0))
    142 #define MAXLONG_PTR ((LONG_PTR)(MAXULONG_PTR >> 1))
    143 #define MINLONG_PTR (~MAXLONG_PTR)
    144 
    145 #define MAXUHALF_PTR ((UHALF_PTR)~0)
    146 #define MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1))
    147 #define MINHALF_PTR (~MAXHALF_PTR)
    148 
    149   __MINGW_EXTENSION typedef ULONG_PTR SIZE_T,*PSIZE_T;
    150   __MINGW_EXTENSION typedef LONG_PTR SSIZE_T,*PSSIZE_T;
    151   __MINGW_EXTENSION typedef ULONG_PTR DWORD_PTR,*PDWORD_PTR;
    152   __MINGW_EXTENSION typedef __int64 LONG64,*PLONG64;
    153   __MINGW_EXTENSION typedef unsigned __int64 ULONG64,*PULONG64;
    154   __MINGW_EXTENSION typedef unsigned __int64 DWORD64,*PDWORD64;
    155   __MINGW_EXTENSION typedef ULONG_PTR KAFFINITY;
    156   __MINGW_EXTENSION typedef KAFFINITY *PKAFFINITY;
    157 
    158 #ifdef __cplusplus
    159 }
    160 #endif
    161 #endif
    162