From 2b82f39f67faf57e0eb6a902881ae9a874fd33b4 Mon Sep 17 00:00:00 2001 From: David Edelsohn Date: Thu, 17 Sep 2020 15:18:48 +0000 Subject: [PATCH] aix: Fix _STDC_FORMAT_MACROS in inttypes.h AIX protects the STDC Format Macros in a manner that can prevent the definition of the macros depending on the order of header inclusion. The protection of the macros was referenced in C99, removed in C11, and never specified in any C++ standard. Also, the macros are in the namespace reserved to the implementation (compiler) so the compiler is permitted to choose to inject those names. fixincludes/ChangeLog: 2020-09-17 David Edelsohn * inclhack.def (aix_inttypes): New fix. * fixincl.x: Regenerate. * tests/base/sys/inttypes.h: New file. --- fixincludes/fixincl.x | 53 +++++++++++++++++++++++++++++++---- fixincludes/inclhack.def | 13 +++++++++ fixincludes/tests/base/sys/inttypes.h | 14 +++++++++ 3 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 fixincludes/tests/base/sys/inttypes.h diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x index bf54305..cb96682 100644 --- a/fixincludes/fixincl.x +++ b/fixincludes/fixincl.x @@ -885,6 +885,43 @@ static const char* apzAix_Externcpp2Patch[] = { /* * * * * * * * * * * * * * * * * * * * * * * * * * * + * Description of Aix_Inttypes fix + */ +tSCC zAix_InttypesName[] = + "aix_inttypes"; + +/* + * File name selection pattern + */ +tSCC zAix_InttypesList[] = + "sys/inttypes.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzAix_InttypesMachs[] = { + "*-*-aix*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zAix_InttypesSelect0[] = + "#if !defined\\(__cplusplus\\) \\|\\| defined\\(__STDC_FORMAT_MACROS\\)"; + +#define AIX_INTTYPES_TEST_CT 1 +static tTestDesc aAix_InttypesTests[] = { + { TT_EGREP, zAix_InttypesSelect0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Aix_Inttypes + */ +static const char* apzAix_InttypesPatch[] = { + "format", + "#if 1", + (char*)NULL }; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * * Description of Aix_Malloc fix */ tSCC zAix_MallocName[] = @@ -10480,9 +10517,9 @@ static const char* apzX11_SprintfPatch[] = { * * List of all fixes */ -#define REGEX_COUNT 287 +#define REGEX_COUNT 288 #define MACH_LIST_SIZE_LIMIT 187 -#define FIX_COUNT 249 +#define FIX_COUNT 250 /* * Enumerate the fixes @@ -10505,6 +10542,7 @@ typedef enum { AIX_EXTERNC_FIXIDX, AIX_EXTERNCPP1_FIXIDX, AIX_EXTERNCPP2_FIXIDX, + AIX_INTTYPES_FIXIDX, AIX_MALLOC_FIXIDX, AIX_NET_IF_ARP_FIXIDX, AIX_NULL_FIXIDX, @@ -10834,6 +10872,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = { AIX_EXTERNCPP2_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, aAix_Externcpp2Tests, apzAix_Externcpp2Patch, 0 }, + { zAix_InttypesName, zAix_InttypesList, + apzAix_InttypesMachs, + AIX_INTTYPES_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aAix_InttypesTests, apzAix_InttypesPatch, 0 }, + { zAix_MallocName, zAix_MallocList, apzAix_MallocMachs, AIX_MALLOC_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def index 3b39742..6e59be9 100644 --- a/fixincludes/inclhack.def +++ b/fixincludes/inclhack.def @@ -578,6 +578,19 @@ fix = { }; /* + * inttypes.h STDC_FORMAT_MACROS + */ +fix = { + hackname = aix_inttypes; + mach = "*-*-aix*"; + files = "sys/inttypes.h"; + select = "#if !defined\\(__cplusplus\\) \\|\\| defined\\(__STDC_FORMAT_MACROS\\)"; + c_fix = format; + c_fix_arg = "#if 1"; + test_text = "#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)"; +}; + +/* * malloc.h on AIX6 uses XLC++ specific builtin syntax */ fix = { diff --git a/fixincludes/tests/base/sys/inttypes.h b/fixincludes/tests/base/sys/inttypes.h new file mode 100644 index 0000000..f349bda --- /dev/null +++ b/fixincludes/tests/base/sys/inttypes.h @@ -0,0 +1,14 @@ +/* DO NOT EDIT THIS FILE. + + It has been auto-edited by fixincludes from: + + "fixinc/tests/inc/sys/inttypes.h" + + This had to be done to correct non-standard usages in the + original, manufacturer supplied header file. */ + + + +#if defined( AIX_INTTYPES_CHECK ) +#if 1 +#endif /* AIX_INTTYPES_CHECK */ -- 1.8.3.1