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  <hainque@adacore.com>

fixincludes/
	* inclhack.def (vxworks_posix_mkdir): Refine to expose a
	varargs interface.
	* tests/base/sys/stat.h: Update expected results.
	* fixincl.x: Regenerate.
This commit is contained in:
Olivier Hainque 2020-01-14 10:25:35 +00:00
parent 48e2d9b7b8
commit a54d11749f
3 changed files with 27 additions and 28 deletions

View File

@ -2,11 +2,11 @@
* *
* DO NOT EDIT THIS FILE (fixincl.x) * 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 * From the definitions inclhack.def
* and the template file fixincl * 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. * 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[] = tSCC zVxworks_Posix_MkdirName[] =
"vxworks_mkdir_macro"; "vxworks_posix_mkdir";
/* /*
* File name selection pattern * File name selection pattern
*/ */
tSCC zVxworks_Mkdir_MacroList[] = tSCC zVxworks_Posix_MkdirList[] =
"sys/stat.h\0"; "sys/stat.h\0";
/* /*
* Machine/OS name selection pattern * Machine/OS name selection pattern
*/ */
tSCC* apzVxworks_Mkdir_MacroMachs[] = { tSCC* apzVxworks_Posix_MkdirMachs[] = {
"*-*-vxworks*", "*-*-vxworks*",
(const char*)NULL }; (const char*)NULL };
#define VXWORKS_MKDIR_MACRO_TEST_CT 0 #define VXWORKS_POSIX_MKDIR_TEST_CT 0
#define aVxworks_Mkdir_MacroTests (tTestDesc*)NULL #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", "format",
"%0\n\ "extern STATUS mkdir(const char *dir, ...);",
#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n",
"extern[\t ]+STATUS[\t ]+mkdir[\t ]*\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*(|[_[:alpha:]][_[:alnum:]]*)\\)[\t ]*;", "extern[\t ]+STATUS[\t ]+mkdir[\t ]*\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*(|[_[:alpha:]][_[:alnum:]]*)\\)[\t ]*;",
(char*)NULL }; (char*)NULL };
@ -10908,7 +10907,7 @@ typedef enum {
VOID_NULL_FIXIDX, VOID_NULL_FIXIDX,
VXWORKS_GCC_PROBLEM_FIXIDX, VXWORKS_GCC_PROBLEM_FIXIDX,
VXWORKS_IOCTL_MACRO_FIXIDX, VXWORKS_IOCTL_MACRO_FIXIDX,
VXWORKS_MKDIR_MACRO_FIXIDX, VXWORKS_POSIX_MKDIR_FIXIDX,
VXWORKS_NEEDS_VXTYPES_FIXIDX, VXWORKS_NEEDS_VXTYPES_FIXIDX,
VXWORKS_NEEDS_VXWORKS_FIXIDX, VXWORKS_NEEDS_VXWORKS_FIXIDX,
VXWORKS_REGS_FIXIDX, VXWORKS_REGS_FIXIDX,
@ -12177,10 +12176,10 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
VXWORKS_IOCTL_MACRO_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, VXWORKS_IOCTL_MACRO_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
aVxworks_Ioctl_MacroTests, apzVxworks_Ioctl_MacroPatch, 0 }, aVxworks_Ioctl_MacroTests, apzVxworks_Ioctl_MacroPatch, 0 },
{ zVxworks_Mkdir_MacroName, zVxworks_Mkdir_MacroList, { zVxworks_Posix_MkdirName, zVxworks_Posix_MkdirList,
apzVxworks_Mkdir_MacroMachs, apzVxworks_Posix_MkdirMachs,
VXWORKS_MKDIR_MACRO_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, VXWORKS_POSIX_MKDIR_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
aVxworks_Mkdir_MacroTests, apzVxworks_Mkdir_MacroPatch, 0 }, aVxworks_Posix_MkdirTests, apzVxworks_Posix_MkdirPatch, 0 },
{ zVxworks_Needs_VxtypesName, zVxworks_Needs_VxtypesList, { zVxworks_Needs_VxtypesName, zVxworks_Needs_VxtypesList,
apzVxworks_Needs_VxtypesMachs, apzVxworks_Needs_VxtypesMachs,

View File

@ -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 = { fix = {
hackname = vxworks_mkdir_macro; hackname = vxworks_posix_mkdir;
files = sys/stat.h; files = sys/stat.h;
mach = "*-*-vxworks*"; mach = "*-*-vxworks*";
c_fix = format; c_fix = format;
c_fix_arg = "%0\n" c_fix_arg = "extern STATUS mkdir(const char *dir, ...);";
"#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*" c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
"\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */ "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
"(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */ "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
"\\)[\t ]*;"; "\\)[\t ]*;";
test_text = "extern STATUS mkdir (const char * _qwerty) ;"; test_text = "extern STATUS mkdir (const char * _qwerty) ;";
}; };

View File

@ -28,11 +28,9 @@ extern int fchmod(int, mode_t);
#endif /* RS6000_FCHMOD_CHECK */ #endif /* RS6000_FCHMOD_CHECK */
#if defined( VXWORKS_MKDIR_MACRO_CHECK ) #if defined( VXWORKS_POSIX_MKDIR_CHECK )
extern STATUS mkdir (const char * _qwerty) ; extern STATUS mkdir(const char *dir, ...);
#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir)) #endif /* VXWORKS_POSIX_MKDIR_CHECK */
#endif /* VXWORKS_MKDIR_MACRO_CHECK */
#if defined( VXWORKS_NEEDS_VXWORKS_CHECK ) #if defined( VXWORKS_NEEDS_VXWORKS_CHECK )