From: villemoes Date: Mon, 3 Sep 2018 13:26:45 +0000 (+0000) Subject: fixincludes: vxworks: remove unnecessary parentheses in ioctl wrapper macro X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43125e2974d3d819cd226c4b56eec9d48d8d120d;p=thirdparty%2Fgcc.git fixincludes: vxworks: remove unnecessary parentheses in ioctl wrapper macro The rationale for the fixinclude ioctl macro wrapper is, as far as I can tell (https://gcc.gnu.org/ml/gcc-patches/2012-09/msg01619.html) Fix 2: Add hack for ioctl() on VxWorks. ioctl() is supposed to be variadic, but VxWorks only has a three argument version with the third argument of type int. This messes up when the third argument is not implicitly convertible to int. This adds a macro which wraps around ioctl() and explicitly casts the third argument to an int. This way, the most common use case of ioctl (with a const char * for the third argument) will compile in C++, where pointers must be explicitly casted to int. However, we have existing C++ code that calls the ioctl function via ::ioctl(foo, bar, baz) and obviously this breaks when it gets expanded to ::(ioctl)(foo, bar, (int)(baz)) Since the GNU C preprocessor already prevents recursive expansion of function-like macros, the parentheses around ioctl are unnecessary. Incidentally, there is also a macro sioIoctl() in the vxworks sioLib.h header that expands to ((pSioChan)->pDrvFuncs->ioctl (pSioChan, cmd, arg)) which also breaks when that gets further expanded to ((pSioChan)->pDrvFuncs->(ioctl) (pSioChan, cmd, (int)(arg))) This patch partly fixes that issue as well, but the third argument to the pDrvFuncs->ioctl method should be void*, so the cast to (int) is slightly annoying. Internally, we've simply patched the sioIoctl macro: (((pSioChan)->pDrvFuncs->ioctl) (pSioChan, cmd, arg)) git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@264056 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/fixincludes/ChangeLog b/fixincludes/ChangeLog index 03b459c3db81..4f5f1fefb674 100644 --- a/fixincludes/ChangeLog +++ b/fixincludes/ChangeLog @@ -1,3 +1,9 @@ +2018-09-03 Rasmus Villemoes + + * inclhack.def (vxworks_ioctl_macro): Remove parentheses from + expansion of ioctl macro. + * fixincl.x: Regenerate. + 2018-07-23 David Edelsohn * inclhack.def (aix_unistd): New. diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x index a5d7884a62ae..733242115349 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 July 23, 2018 at 07:27:34 PM by AutoGen 5.18 + * It has been AutoGen-ed September 3, 2018 at 03:24:05 PM by AutoGen 5.18.7 * From the definitions inclhack.def * and the template file fixincl */ -/* DO NOT SVN-MERGE THIS FILE, EITHER Mon Jul 23 19:27:34 UTC 2018 +/* DO NOT SVN-MERGE THIS FILE, EITHER Mon Sep 3 15:24:05 CEST 2018 * * You must regenerate it. Use the ./genfixes script. * @@ -9737,7 +9737,7 @@ tSCC* apzVxworks_Ioctl_MacroMachs[] = { static const char* apzVxworks_Ioctl_MacroPatch[] = { "format", "%0\n\ -#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n", +#define ioctl(fd, func, arg) ioctl(fd, func, (int)(arg))\n", "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);", (char*)NULL }; diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def index 4ce8b16e0a63..f9ba9774f32c 100644 --- a/fixincludes/inclhack.def +++ b/fixincludes/inclhack.def @@ -4916,7 +4916,7 @@ fix = { c_fix = format; c_fix_arg = "%0\n" - "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n"; + "#define ioctl(fd, func, arg) ioctl(fd, func, (int)(arg))\n"; c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);"; test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";