headers: Fix intsafe.h.

Fix ULongToChar to return -1 on overflow, like it does in the SDK.

Fix LongLongToUIntPtr and LongLongToULongPtr so they work on 32-bit.

Remove about 150 macros added this year that just redefine an existing function.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
David Grayson 2024-10-20 12:13:11 -07:00 committed by Jacek Caban
parent ac299df46a
commit 33d403802a

View File

@ -138,7 +138,7 @@ __MINGW_INTSAFE_API __MINGW_INTSAFE_CONV(ULongToIntPtr, ULONG, INT_PTR)
__MINGW_INTSAFE_API __MINGW_INTSAFE_CONV(ULongToPtrdiffT, ULONG, ptrdiff_t)
__MINGW_INTSAFE_API __MINGW_INTSAFE_CONV(ULongToLongPtr, ULONG, LONG_PTR)
__MINGW_INTSAFE_API __MINGW_INTSAFE_CONV(ULongToSSIZET, ULONG, SSIZE_T)
__MINGW_INTSAFE_CHAR_API __MINGW_INTSAFE_CONV(ULongToChar, ULONG, CHAR)
__MINGW_INTSAFE_CHAR_API __MINGW_INTSAFE_CONV_CHAR(ULongToChar, ULONG, CHAR)
__MINGW_INTSAFE_API __MINGW_INTSAFE_CONV_UCHAR(DWordToUChar, DWORD, UCHAR)
__MINGW_INTSAFE_API __MINGW_INTSAFE_CONV(DWordToByte, DWORD, BYTE)
__MINGW_INTSAFE_API __MINGW_INTSAFE_CONV(DWordToUShort, DWORD, USHORT)
@ -426,9 +426,7 @@ __MINGW_INTSAFE_API __MINGW_INTSAFE_MATH(LongLongMult, LONGLONG, mul)
#define Int8ToUInt64 Int8ToULongLong
#define Int8ToSizeT Int8ToUIntPtr
#define Int8ToSIZET Int8ToULongPtr
#define ShortToByte ShortToUInt8
#define ShortToUInt16 ShortToUShort
#define ShortToWord ShortToUShort
#define ShortToUInt32 ShortToUInt
#define ShortToDWord ShortToULong
#define ShortToDWordLong ShortToULongLong
@ -459,7 +457,6 @@ __MINGW_INTSAFE_API __MINGW_INTSAFE_MATH(LongLongMult, LONGLONG, mul)
#define Int16ToUInt64 ShortToULongLong
#define Int16ToSizeT ShortToUIntPtr
#define Int16ToSIZET ShortToULongPtr
#define UShortToByte UShortToUInt8
#define UShortToInt16 UShortToShort
#define UInt16ToChar UShortToChar
#define UInt16ToInt8 UShortToInt8
@ -469,27 +466,14 @@ __MINGW_INTSAFE_API __MINGW_INTSAFE_MATH(LongLongMult, LONGLONG, mul)
#define UInt16ToShort UShortToShort
#define UInt16ToInt16 UShortToShort
#define WordToInt8 UShortToInt8
#define WordToChar UShortToChar
#define WordToUChar UShortToUChar
#define WordToUInt8 UShortToUInt8
#define WordToByte UShortToUInt8
#define WordToShort UShortToShort
#define WordToInt16 UShortToShort
#define IntToByte IntToUInt8
#define IntToInt16 IntToShort
#define IntToUInt16 IntToUShort
#define IntToWord IntToUShort
#define IntToUIntPtr IntToULongLong
#define IntToUIntPtr IntToUInt
#define IntToULongPtr IntToULongLong
#define IntToULongPtr IntToULong
#define IntToDWord IntToULong
#define IntToDWordPtr IntToULongPtr
#define IntToDWordLong IntToULongLong
#define IntToULong64 IntToULongLong
#define IntToDWord64 IntToULongLong
#define IntToUInt64 IntToULongLong
#define IntToSizeT IntToUIntPtr
#define IntToSIZET IntToULongPtr
#define Int32ToChar IntToChar
#define Int32ToInt8 IntToInt8
@ -519,32 +503,16 @@ __MINGW_INTSAFE_API __MINGW_INTSAFE_MATH(LongLongMult, LONGLONG, mul)
#define IntPtrToInt16 IntPtrToShort
#define IntPtrToUInt16 IntPtrToUShort
#define IntPtrToWord IntPtrToUShort
#define IntPtrToInt LongLongToInt
#define IntPtrToInt32 IntPtrToInt
#define IntPtrToUInt LongLongToUInt
#define IntPtrToUInt32 IntPtrToUInt
#define IntPtrToUIntPtr LongLongToULongLong
#define IntPtrToLong LongLongToLong
#define IntPtrToULong LongLongToULong
#define IntPtrToULongPtr LongLongToULongLong
#define IntPtrToDWord IntPtrToULong
#define IntPtrToDWordPtr IntPtrToULongPtr
#define IntPtrToULongLong LongLongToULongLong
#define IntPtrToDWordLong IntPtrToULongLong
#define IntPtrToULong64 IntPtrToULongLong
#define IntPtrToDWord64 IntPtrToULongLong
#define IntPtrToUInt64 IntPtrToULongLong
#define IntPtrToSizeT IntPtrToUIntPtr
#define IntPtrToSIZET IntPtrToULongPtr
#define UIntToByte UIntToUInt8
#define UIntToInt16 UIntToShort
#define UIntToUInt16 UIntToUShort
#define UIntToWord UIntToUShort
#define UIntToInt32 UIntToInt
#define UIntToIntPtr UIntToInt
#define UIntToLongPtr UIntToLong
#define UIntToPtrdiffT UIntToIntPtr
#define UIntToSSIZET UIntToLongPtr
#define UInt32ToChar UIntToChar
#define UInt32ToInt8 UIntToInt8
#define UInt32ToUChar UIntToUChar
@ -565,96 +533,46 @@ __MINGW_INTSAFE_API __MINGW_INTSAFE_MATH(LongLongMult, LONGLONG, mul)
#define UIntPtrToByte UIntPtrToUInt8
#define UIntPtrToWord UIntPtrToUShort
#define UIntPtrToInt32 UIntPtrToInt
#define UIntPtrToUInt ULongLongToUInt
#define UIntPtrToUInt32 UIntPtrToUInt
#define UIntPtrToULong ULongLongToULong
#define UIntPtrToDWord UIntPtrToULong
#define UIntPtrToLongLong ULongLongToLongLong
#define UIntPtrToLong64 UIntPtrToLongLong
#define UIntPtrToInt64 UIntPtrToLongLong
#define UIntPtrToPtrdiffT UIntPtrToIntPtr
#define UIntPtrToSSIZET UIntPtrToLongPtr
#define LongToByte LongToUInt8
#define LongToInt16 LongToShort
#define LongToUInt16 LongToUShort
#define LongToWord LongToUShort
#define LongToInt32 LongToInt
#define LongToIntPtr LongToInt
#define LongToUInt32 LongToUInt
#define LongToUIntPtr LongToUInt
#define LongToULongPtr LongToULong
#define LongToDWord LongToULong
#define LongToDWordPtr LongToULongPtr
#define LongToDWordLong LongToULongLong
#define LongToULong64 LongToULongLong
#define LongToDWord64 LongToULongLong
#define LongToUInt64 LongToULongLong
#define LongToPtrdiffT LongToIntPtr
#define LongToSizeT LongToUIntPtr
#define LongToSIZET LongToULongPtr
#define LongPtrToByte LongPtrToUInt8
#define LongPtrToInt16 LongPtrToShort
#define LongPtrToUInt16 LongPtrToUShort
#define LongPtrToWord LongPtrToUShort
#define LongPtrToInt LongLongToInt
#define LongPtrToInt32 LongPtrToInt
#define LongPtrToUInt LongLongToUInt
#define LongPtrToUInt32 LongPtrToUInt
#define LongPtrToLong LongLongToLong
#define LongPtrToULong LongLongToULong
#define LongPtrToDWord LongPtrToULong
#define LongPtrToDWordPtr LongPtrToULongPtr
#define LongPtrToDWordLong LongPtrToULongLong
#define LongPtrToULong64 LongPtrToULongLong
#define LongPtrToDWord64 LongPtrToULongLong
#define LongPtrToUInt64 LongPtrToULongLong
#define LongPtrToSizeT LongPtrToUIntPtr
#define LongPtrToSIZET LongPtrToULongPtr
#define ULongToByte ULongToUInt8
#define ULongToInt16 ULongToShort
#define ULongToUInt16 ULongToUShort
#define ULongToWord ULongToUShort
#define ULongToInt32 ULongToInt
#define ULongToIntPtr ULongToInt
#define ULongToUInt32 ULongToUInt
#define ULongToUIntPtr ULongToUInt
#define ULongToLongPtr ULongToLong
#define ULongToPtrdiffT ULongToIntPtr
#define ULongToSSIZET ULongToLongPtr
#define ULongPtrToByte ULongPtrToUInt8
#define ULongPtrToInt16 ULongPtrToShort
#define ULongPtrToUInt16 ULongPtrToUShort
#define ULongPtrToWord ULongPtrToUShort
#define ULongPtrToInt32 ULongPtrToInt
#define ULongPtrToUInt ULongLongToUInt
#define ULongPtrToUInt32 ULongPtrToUInt
#define ULongPtrToULong ULongLongToULong
#define ULongPtrToDWord ULongPtrToULong
#define ULongPtrToLongLong ULongLongToLongLong
#define ULongPtrToLong64 ULongPtrToLongLong
#define ULongPtrToInt64 ULongPtrToLongLong
#define ULongPtrToPtrdiffT ULongPtrToIntPtr
#define ULongPtrToSSIZET ULongPtrToLongPtr
#define DWordToInt8 ULongToInt8
#define DWordToChar ULongToChar
#define DWordToUChar ULongToUChar
#define DWordToUInt8 ULongToUInt8
#define DWordToByte ULongToUInt8
#define DWordToShort ULongToShort
#define DWordToInt16 ULongToShort
#define DWordToUShort ULongToUShort
#define DWordToUInt16 ULongToUShort
#define DWordToWord ULongToUShort
#define DWordToInt ULongToInt
#define DWordToInt32 ULongToInt
#define DWordToIntPtr ULongToIntPtr
#define DWordToUInt ULongToUInt
#define DWordToUInt32 ULongToUInt
#define DWordToUIntPtr ULongToUIntPtr
#define DWordToLong ULongToLong
#define DWordToLongPtr ULongToLongPtr
#define DWordToPtrdiffT ULongToIntPtr
#define DWordToSSIZET ULongToLongPtr
#define DWordPtrToInt8 ULongPtrToInt8
#define DWordPtrToUChar ULongPtrToUChar
#define DWordPtrToChar ULongPtrToChar
@ -665,33 +583,18 @@ __MINGW_INTSAFE_API __MINGW_INTSAFE_MATH(LongLongMult, LONGLONG, mul)
#define DWordPtrToUShort ULongPtrToUShort
#define DWordPtrToUInt16 ULongPtrToUShort
#define DWordPtrToWord ULongPtrToUShort
#define DWordPtrToInt ULongPtrToInt
#define DWordPtrToInt32 ULongPtrToInt
#define DWordPtrToIntPtr ULongPtrToIntPtr
#define DWordPtrToUInt ULongPtrToUInt
#define DWordPtrToUInt32 ULongPtrToUInt
#define DWordPtrToUIntPtr ULongPtrToUIntPtr
#define DWordPtrToLong ULongPtrToLong
#define DWordPtrToLongPtr ULongPtrToLongPtr
#define DWordPtrToULong ULongPtrToULong
#define DWordPtrToDWord ULongPtrToULong
#define DWordPtrToLongLong ULongPtrToLongLong
#define DWordPtrToLong64 ULongPtrToLongLong
#define DWordPtrToInt64 ULongPtrToLongLong
#define DWordPtrToPtrdiffT ULongPtrToIntPtr
#define DWordPtrToSSIZET ULongPtrToLongPtr
#define LongLongToByte LongLongToUInt8
#define LongLongToInt16 LongLongToShort
#define LongLongToUInt16 LongLongToUShort
#define LongLongToWord LongLongToUShort
#define LongLongToInt32 LongLongToInt
#define LongLongToIntPtr LongLongToInt
#define LongLongToUInt32 LongLongToUInt
#define LongLongToUIntPtr LongLongToULongLong
#define LongLongToUIntPtr LongLongToUInt
#define LongLongToLongPtr LongLongToLong
#define LongLongToULongPtr LongLongToULongLong
#define LongLongToULongPtr LongLongToULong
#define LongLongToUIntPtr Int64ToUIntPtr
#define LongLongToULongPtr Int64ToULongPtr
#define LongLongToDWord LongLongToULong
#define LongLongToDWordPtr LongLongToULongPtr
#define LongLongToDWordLong LongLongToULongLong
@ -739,44 +642,20 @@ __MINGW_INTSAFE_API __MINGW_INTSAFE_MATH(LongLongMult, LONGLONG, mul)
#define Int64ToUShort LongLongToUShort
#define Int64ToUInt16 LongLongToUShort
#define Int64ToWord LongLongToUShort
#define Int64ToInt LongLongToInt
#define Int64ToInt32 LongLongToInt
#define Int64ToIntPtr LongLongToIntPtr
#define Int64ToUInt LongLongToUInt
#define Int64ToUInt32 LongLongToUInt
#define Int64ToUIntPtr LongLongToUIntPtr
#define Int64ToLong LongLongToLong
#define Int64ToLongPtr LongLongToLongPtr
#define Int64ToULong LongLongToULong
#define Int64ToULongPtr LongLongToULongPtr
#define Int64ToDWord LongLongToULong
#define Int64ToDWordPtr LongLongToULongPtr
#define Int64ToULongLong LongLongToULongLong
#define Int64ToDWordLong LongLongToULongLong
#define Int64ToULong64 LongLongToULongLong
#define Int64ToDWord64 LongLongToULongLong
#define Int64ToUInt64 LongLongToULongLong
#define Int64ToPtrdiffT LongLongToIntPtr
#define Int64ToSizeT LongLongToUIntPtr
#define Int64ToSSIZET LongLongToLongPtr
#define Int64ToSIZET LongLongToULongPtr
#define ULongLongToByte ULongLongToUInt8
#define ULongLongToInt16 ULongLongToShort
#define ULongLongToUInt16 ULongLongToUShort
#define ULongLongToWord ULongLongToUShort
#define ULongLongToInt32 ULongLongToInt
#define ULongLongToIntPtr ULongLongToLongLong
#define ULongLongToIntPtr ULongLongToInt
#define ULongLongToUInt32 ULongLongToUInt
#define ULongLongToUIntPtr ULongLongToUInt
#define ULongLongToULongPtr ULongLongToULong
#define ULongLongToDWord ULongLongToULong
#define ULongLongToDWordPtr ULongLongToULongPtr
#define ULongLongToInt64 ULongLongToLongLong
#define ULongLongToLong64 ULongLongToLongLong
#define ULongLongToPtrdiffT ULongLongToIntPtr
#define ULongLongToSizeT ULongLongToUIntPtr
#define ULongLongToSSIZET ULongLongToLongPtr
#define ULongLongToSIZET ULongLongToULongPtr
#define DWordLongToChar ULongLongToChar
#define DWordLongToInt8 ULongLongToInt8
@ -904,23 +783,14 @@ __MINGW_INTSAFE_API __MINGW_INTSAFE_MATH(LongLongMult, LONGLONG, mul)
#define PtrdiffTToUShort IntPtrToUShort
#define PtrdiffTToUInt16 IntPtrToUShort
#define PtrdiffTToWord IntPtrToUShort
#define PtrdiffTToInt IntPtrToInt
#define PtrdiffTToInt32 IntPtrToInt
#define PtrdiffTToUInt IntPtrToUInt
#define PtrdiffTToUInt32 IntPtrToUInt
#define PtrdiffTToUIntPtr IntPtrToUIntPtr
#define PtrdiffTToLong IntPtrToLong
#define PtrdiffTToLongPtr IntPtrToLongPtr
#define PtrdiffTToULong IntPtrToULong
#define PtrdiffTToULongPtr IntPtrToULongPtr
#define PtrdiffTToDWord IntPtrToULong
#define PtrdiffTToDWordPtr IntPtrToULongPtr
#define PtrdiffTToULongLong IntPtrToULongLong
#define PtrdiffTToDWordLong IntPtrToULongLong
#define PtrdiffTToULong64 IntPtrToULongLong
#define PtrdiffTToDWord64 IntPtrToULongLong
#define PtrdiffTToUInt64 IntPtrToULongLong
#define PtrdiffTToSizeT IntPtrToUIntPtr
#define PtrdiffTToSIZET IntPtrToULongPtr
#define SizeTToInt8 UIntPtrToInt8
#define SizeTToUChar UIntPtrToUChar
@ -932,20 +802,9 @@ __MINGW_INTSAFE_API __MINGW_INTSAFE_MATH(LongLongMult, LONGLONG, mul)
#define SizeTToUShort UIntPtrToUShort
#define SizeTToUInt16 UIntPtrToUShort
#define SizeTToWord UIntPtrToUShort
#define SizeTToInt UIntPtrToInt
#define SizeTToInt32 UIntPtrToInt
#define SizeTToIntPtr UIntPtrToIntPtr
#define SizeTToUInt UIntPtrToUInt
#define SizeTToUInt32 UIntPtrToUInt
#define SizeTToLong UIntPtrToLong
#define SizeTToLongPtr UIntPtrToLongPtr
#define SizeTToULong UIntPtrToULong
#define SizeTToDWord UIntPtrToULong
#define SizeTToLongLong UIntPtrToLongLong
#define SizeTToLong64 UIntPtrToLongLong
#define SizeTToInt64 UIntPtrToLongLong
#define SizeTToPtrdiffT UIntPtrToIntPtr
#define SizeTToSSIZET UIntPtrToLongPtr
#define SSIZETToInt8 LongPtrToInt8
#define SSIZETToUChar LongPtrToUChar
#define SSIZETToChar LongPtrToChar
@ -956,23 +815,13 @@ __MINGW_INTSAFE_API __MINGW_INTSAFE_MATH(LongLongMult, LONGLONG, mul)
#define SSIZETToUShort LongPtrToUShort
#define SSIZETToUInt16 LongPtrToUShort
#define SSIZETToWord LongPtrToUShort
#define SSIZETToInt LongPtrToInt
#define SSIZETToInt32 LongPtrToInt
#define SSIZETToIntPtr LongPtrToIntPtr
#define SSIZETToUInt LongPtrToUInt
#define SSIZETToUInt32 LongPtrToUInt
#define SSIZETToUIntPtr LongPtrToUIntPtr
#define SSIZETToLong LongPtrToLong
#define SSIZETToULong LongPtrToULong
#define SSIZETToULongPtr LongPtrToULongPtr
#define SSIZETToDWord LongPtrToULong
#define SSIZETToDWordPtr LongPtrToULongPtr
#define SSIZETToULongLong LongPtrToULongLong
#define SSIZETToDWordLong LongPtrToULongLong
#define SSIZETToULong64 LongPtrToULongLong
#define SSIZETToDWord64 LongPtrToULongLong
#define SSIZETToUInt64 LongPtrToULongLong
#define SSIZETToSizeT LongPtrToUIntPtr
#define SSIZETToSIZET LongPtrToULongPtr
#define SIZETToInt8 ULongPtrToInt8
#define SIZETToUChar ULongPtrToUChar
@ -1001,25 +850,19 @@ __MINGW_INTSAFE_API __MINGW_INTSAFE_MATH(LongLongMult, LONGLONG, mul)
#define SIZETToSSIZET ULongPtrToLongPtr
#define UInt16Add UShortAdd
#define WordAdd UShortAdd
#define UInt32Add UIntAdd
#define DWordAdd ULongAdd
#define DWordLongAdd ULongLongAdd
#define ULong64Add ULongLongAdd
#define DWord64Add ULongLongAdd
#define UInt64Add ULongLongAdd
#define UInt16Sub UShortSub
#define WordSub UShortSub
#define UInt32Sub UIntSub
#define DWordSub ULongSub
#define DWordLongSub ULongLongSub
#define ULong64Sub ULongLongSub
#define DWord64Sub ULongLongSub
#define UInt64Sub ULongLongSub
#define UInt16Mult UShortMult
#define WordMult UShortMult
#define UInt32Mult UIntMult
#define DWordMult ULongMult
#define DWordLongMult ULongLongMult
#define ULong64Mult ULongLongMult
#define DWord64Mult ULongLongMult
@ -1040,6 +883,6 @@ __MINGW_INTSAFE_API __MINGW_INTSAFE_MATH(LongLongMult, LONGLONG, mul)
#define Long64Mult LongLongMult
#define Int64Mult LongLongMult
#endif /* __GNUC__ >= 5 */
#endif /* __MINGW_INTSAFE_WORKS */
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
#endif /* _INTSAFE_H_INCLUDED_ */