From a54d11749f0ce98192cfe28e5ccc0633d4db3982 Mon Sep 17 00:00:00 2001 From: Olivier Hainque Date: Tue, 14 Jan 2020 10:25:35 +0000 Subject: [PATCH] Adjust VxWorks fixincludes hack for mkdir to work for C++ For VxWorks, replace an attempt at providing a posix API for mkdir via macro by a varargs prototype, which works better for C++ references like std::mkdir(arg1, arg2). 2021-12-16 Olivier Hainque fixincludes/ * inclhack.def (vxworks_posix_mkdir): Refine to expose a varargs interface. * tests/base/sys/stat.h: Update expected results. * fixincl.x: Regenerate. --- fixincludes/fixincl.x | 35 +++++++++++++++---------------- fixincludes/inclhack.def | 12 ++++++----- fixincludes/tests/base/sys/stat.h | 8 +++---- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x index cb83f012a2f..16b15c045d0 100644 --- a/fixincludes/fixincl.x +++ b/fixincludes/fixincl.x @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (fixincl.x) * - * It has been AutoGen-ed January 1, 2022 at 11:58:02 AM by AutoGen 5.18.16 + * It has been AutoGen-ed January 4, 2022 at 10:24:34 AM by AutoGen 5.18.16 * From the definitions inclhack.def * and the template file fixincl */ -/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Jan 1 11:58:02 CET 2022 +/* DO NOT SVN-MERGE THIS FILE, EITHER Tue Jan 4 10:24:34 UTC 2022 * * You must regenerate it. Use the ./genfixes script. * @@ -10214,32 +10214,31 @@ static const char* apzVxworks_Ioctl_MacroPatch[] = { /* * * * * * * * * * * * * * * * * * * * * * * * * * * - * Description of Vxworks_Mkdir_Macro fix + * Description of Vxworks_Posix_Mkdir fix */ -tSCC zVxworks_Mkdir_MacroName[] = - "vxworks_mkdir_macro"; +tSCC zVxworks_Posix_MkdirName[] = + "vxworks_posix_mkdir"; /* * File name selection pattern */ -tSCC zVxworks_Mkdir_MacroList[] = +tSCC zVxworks_Posix_MkdirList[] = "sys/stat.h\0"; /* * Machine/OS name selection pattern */ -tSCC* apzVxworks_Mkdir_MacroMachs[] = { +tSCC* apzVxworks_Posix_MkdirMachs[] = { "*-*-vxworks*", (const char*)NULL }; -#define VXWORKS_MKDIR_MACRO_TEST_CT 0 -#define aVxworks_Mkdir_MacroTests (tTestDesc*)NULL +#define VXWORKS_POSIX_MKDIR_TEST_CT 0 +#define aVxworks_Posix_MkdirTests (tTestDesc*)NULL /* - * Fix Command Arguments for Vxworks_Mkdir_Macro + * Fix Command Arguments for Vxworks_Posix_Mkdir */ -static const char* apzVxworks_Mkdir_MacroPatch[] = { +static const char* apzVxworks_Posix_MkdirPatch[] = { "format", - "%0\n\ -#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n", + "extern STATUS mkdir(const char *dir, ...);", "extern[\t ]+STATUS[\t ]+mkdir[\t ]*\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*(|[_[:alpha:]][_[:alnum:]]*)\\)[\t ]*;", (char*)NULL }; @@ -10908,7 +10907,7 @@ typedef enum { VOID_NULL_FIXIDX, VXWORKS_GCC_PROBLEM_FIXIDX, VXWORKS_IOCTL_MACRO_FIXIDX, - VXWORKS_MKDIR_MACRO_FIXIDX, + VXWORKS_POSIX_MKDIR_FIXIDX, VXWORKS_NEEDS_VXTYPES_FIXIDX, VXWORKS_NEEDS_VXWORKS_FIXIDX, VXWORKS_REGS_FIXIDX, @@ -12177,10 +12176,10 @@ tFixDesc fixDescList[ FIX_COUNT ] = { VXWORKS_IOCTL_MACRO_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, aVxworks_Ioctl_MacroTests, apzVxworks_Ioctl_MacroPatch, 0 }, - { zVxworks_Mkdir_MacroName, zVxworks_Mkdir_MacroList, - apzVxworks_Mkdir_MacroMachs, - VXWORKS_MKDIR_MACRO_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, - aVxworks_Mkdir_MacroTests, apzVxworks_Mkdir_MacroPatch, 0 }, + { zVxworks_Posix_MkdirName, zVxworks_Posix_MkdirList, + apzVxworks_Posix_MkdirMachs, + VXWORKS_POSIX_MKDIR_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aVxworks_Posix_MkdirTests, apzVxworks_Posix_MkdirPatch, 0 }, { zVxworks_Needs_VxtypesName, zVxworks_Needs_VxtypesList, apzVxworks_Needs_VxtypesMachs, diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def index e2987c9c2ff..8f056adef68 100644 --- a/fixincludes/inclhack.def +++ b/fixincludes/inclhack.def @@ -5159,21 +5159,23 @@ fix = { }; /* - * Wrap VxWorks mkdir to be posix compliant + * mkdir's posix interface expects two arguments. While the RTP VxWorks + * API is fine, the kernel version handles only one. We used to expose + * a macro and this didn't play nice with uses such as posix:mkdir(x, y) + * in libstdc++, so we expose a vararg prototype instead. */ fix = { - hackname = vxworks_mkdir_macro; + hackname = vxworks_posix_mkdir; files = sys/stat.h; mach = "*-*-vxworks*"; c_fix = format; - c_fix_arg = "%0\n" - "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n"; + c_fix_arg = "extern STATUS mkdir(const char *dir, ...);"; c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*" "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */ "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */ "\\)[\t ]*;"; - + test_text = "extern STATUS mkdir (const char * _qwerty) ;"; }; diff --git a/fixincludes/tests/base/sys/stat.h b/fixincludes/tests/base/sys/stat.h index 9c81cff94bd..cf86e5d169e 100644 --- a/fixincludes/tests/base/sys/stat.h +++ b/fixincludes/tests/base/sys/stat.h @@ -28,11 +28,9 @@ extern int fchmod(int, mode_t); #endif /* RS6000_FCHMOD_CHECK */ -#if defined( VXWORKS_MKDIR_MACRO_CHECK ) -extern STATUS mkdir (const char * _qwerty) ; -#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir)) - -#endif /* VXWORKS_MKDIR_MACRO_CHECK */ +#if defined( VXWORKS_POSIX_MKDIR_CHECK ) +extern STATUS mkdir(const char *dir, ...); +#endif /* VXWORKS_POSIX_MKDIR_CHECK */ #if defined( VXWORKS_NEEDS_VXWORKS_CHECK )