From patchwork Fri Jun 29 09:47:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 936753 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480745-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rasmusvillemoes.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="cJGDZDuo"; dkim=pass (1024-bit key; unprotected) header.d=rasmusvillemoes.dk header.i=@rasmusvillemoes.dk header.b="VjqDZO/Z"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41HBdJ2TMyz9s01 for ; Fri, 29 Jun 2018 19:47:16 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=ryA6uGcZ2YzC gZVWT/1iDIaWzNsGwNEPxDZnMl5d5tVF+pN1HfA3ntf0trzK1MZQlH4TGdxpfeWs GYYnV9OT6pCiLd8Ym4vKHojOlsxKgOpW5gbzMa2oKoh2ZFv1NUHINZVfM7Kzmm06 c8zQ44w64KBf8P0gNR9jeGdCe2PRjYg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; s=default; bh=dI/tQxKdGN1aqHx6Yu qzcaeA+x4=; b=cJGDZDuoPMZ+ESM4BfBtUg04BHWkUm7P4y6TqOX9iP0lPaWxXB ggF2EFAEhQHa/VICTk9y4xPWb7MnjQVnxXYGb8pHKfc+Jewj3O/FRcWVgbFdBGMn GcHmxeYVDalS90wB3qDYoihfN8t7RsiCY2PhHknx6sH5LJMV4Wkd677BA= Received: (qmail 3160 invoked by alias); 29 Jun 2018 09:47:09 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 3134 invoked by uid 89); 29 Jun 2018 09:47:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=H*RU:209.85.208.65, Hx-spam-relays-external:209.85.208.65, HX-Received:sk:s9-v6mr, HX-Received:dac9 X-HELO: mail-ed1-f65.google.com Received: from mail-ed1-f65.google.com (HELO mail-ed1-f65.google.com) (209.85.208.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 29 Jun 2018 09:47:06 +0000 Received: by mail-ed1-f65.google.com with SMTP id b12-v6so6838784edt.8 for ; Fri, 29 Jun 2018 02:47:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id; bh=PoTZmVfzu3QDJb6Umvr2NPmI+pmaDVf1POu9Czgu1v0=; b=VjqDZO/Zg4usejWmQCs6JtCSGgtSs5RH8a0a2QdbWJfSkKewwMkdKIUGBQIZ9H+tto JmEcJFLwDpHIcQM0ERbVDNZ7d/UN7Vb3ijDJ6l8Bhv+CS5wyaDJu7ODdmMQvrX+91o7k cw3HIcrqbFLXMeuww6OJAnmDLHCP8ZZ+4ozeg= Received: from prevas-ravi.vestasvisitor.net ([193.47.71.171]) by smtp.gmail.com with ESMTPSA id w17-v6sm3780147edr.30.2018.06.29.02.47.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jun 2018 02:47:03 -0700 (PDT) From: Rasmus Villemoes To: gcc-patches@gcc.gnu.org Cc: bkorb@gnu.org, Olivier Hainque , Rasmus Villemoes Subject: [PATCH] fixincludes: vxworks: remove unnecessary parentheses in ioctl wrapper macro Date: Fri, 29 Jun 2018 11:47:00 +0200 Message-Id: <20180629094700.5445-1-rv@rasmusvillemoes.dk> 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)) ==changelog== fixincludes/ * inclhack.def (vxworks_ioctl_macro): Remove parentheses from expansion of ioctl macro. * fixincl.x: Regenerate. --- fixincludes/inclhack.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def index c1f5a13eda4..f7d2124ba74 100644 --- a/fixincludes/inclhack.def +++ b/fixincludes/inclhack.def @@ -4902,7 +4902,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 ) ;";