headers: stdlib.h: fix #pragma pack `#pragma pop()` restores to "default packing" instead of "previous packing", which can potentially cause problems and/or generate warnings. Signed-off-by: Zhongteng Gui <dragon-archer@outlook.com> Signed-off-by: LIU Hao <lh_mouse@126.com>
diff --git a/mingw-w64-crt/configure.ac b/mingw-w64-crt/configure.ac index c71d1b7..dd73c33 100644 --- a/mingw-w64-crt/configure.ac +++ b/mingw-w64-crt/configure.ac
@@ -439,15 +439,6 @@ ) saved_CFLAGS="$CFLAGS" -AC_MSG_CHECKING([whether the compiler supports -Wpragma-pack]) -CFLAGS="$CFLAGS -Wpragma-pack" -AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])], - [supports_wpragma_pack=yes],[supports_wpragma_pack=no]) -AC_MSG_RESULT([$supports_wpragma_pack]) -if test "$supports_wpragma_pack" = "yes"; then - ADD_C_CXX_WARNING_FLAGS="$ADD_C_CXX_WARNING_FLAGS -Wno-pragma-pack" -fi -CFLAGS="$saved_CFLAGS" AC_MSG_CHECKING([whether the compiler supports -Warray-bounds]) CFLAGS="$CFLAGS -Warray-bounds" AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
diff --git a/mingw-w64-crt/math/DFP/dfp_internal.h b/mingw-w64-crt/math/DFP/dfp_internal.h index 32d81ce..4408037 100644 --- a/mingw-w64-crt/math/DFP/dfp_internal.h +++ b/mingw-w64-crt/math/DFP/dfp_internal.h
@@ -117,7 +117,7 @@ */ -#include <pshpack1.h> +#pragma pack(push, 1) #ifdef __GNUC__ #define structpack __attribute__((gcc_struct)) #else @@ -202,7 +202,7 @@ typedef type0d128 _Decimal128; #endif /* _MSC_VER */ -#include <poppack.h> +#pragma pack(pop) typedef union ud32 { _Decimal32 d;
diff --git a/mingw-w64-crt/stdio/mingw_pformat.c b/mingw-w64-crt/stdio/mingw_pformat.c index 84e62f5..2bbe520 100644 --- a/mingw-w64-crt/stdio/mingw_pformat.c +++ b/mingw-w64-crt/stdio/mingw_pformat.c
@@ -84,7 +84,7 @@ * is better to just keep these definitions here. */ -#include <pshpack1.h> +#pragma pack(push, 1) /* workaround gcc bug */ #if defined(__GNUC__) && !defined(__clang__) #define ATTRIB_GCC_STRUCT __attribute__((gcc_struct)) @@ -103,7 +103,7 @@ __tI128 t128; __tI128_2 t128_2; } __uI128; -#include <poppack.h> +#pragma pack(pop) #ifndef _VALUES_H /*
diff --git a/mingw-w64-headers/crt/stdlib.h b/mingw-w64-headers/crt/stdlib.h index 3962822..c4c2ff0 100644 --- a/mingw-w64-headers/crt/stdlib.h +++ b/mingw-w64-headers/crt/stdlib.h
@@ -39,11 +39,11 @@ #ifndef _CRT_DOUBLE_DEC #define _CRT_DOUBLE_DEC -#pragma pack(4) +#pragma pack(push, 4) typedef struct { unsigned char ld[10]; } _LDOUBLE; -#pragma pack() +#pragma pack(pop) #define _PTR_LD(x) ((unsigned char *)(&(x)->ld)) @@ -64,11 +64,11 @@ #pragma pop_macro("long") -#pragma pack(4) +#pragma pack(push, 4) typedef struct { unsigned char ld12[12]; } _LDBL12; -#pragma pack() +#pragma pack(pop) #endif #define RAND_MAX 0x7fff