From patchwork Thu Jul 10 08:25:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 33407 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f198.google.com (mail-ig0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8A27B203F4 for ; Thu, 10 Jul 2014 08:26:06 +0000 (UTC) Received: by mail-ig0-f198.google.com with SMTP id h18sf1308294igc.1 for ; Thu, 10 Jul 2014 01:26:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-subscribe:list-archive :list-post:list-help:sender:delivered-to:from:to:subject:date :message-id:x-original-sender:x-original-authentication-results; bh=v8Ds3pzwURRDtSMBWYQskOme/B5VMjJF6RsgbGNK+2A=; b=BIEFz3/QskeAAPHZsncee6RSm1qXFU0djW29J1YsESuwQSTpzD01ZETYGSKNF0Qdrm ZW0dvCcQ7b3VQRfXLNVEx1QX0+TA+/42YM8kprs7I9NGSxTH0yzV5DGkWYs7BHDxzbuJ fRRW9qGinXOCxAI1VpIeNZvAqhhHsb+9K3uejfk+3sLD5AP7W9cuBgv71bVU61nOeCAn oTHkVFZuXBfV43DWJG5o1TnrpyMcNdEWw12LGIQQwVpZ6ejwnFi651vEBRXf4YQb+5QB Zlguy+LQMr7k0iIPmfnQMmVwdnr6lqVMOMsXEo47S/TZRctmnkQqhHL63u2yLYUNMmmI HLGA== X-Gm-Message-State: ALoCoQmAXuKPSL6UZE3OF7AKSq3jJOKqlZlUTf0AS0jGdpjCWfWDfuugXy/8CJ5Cdlz9PtqSxauI X-Received: by 10.42.62.202 with SMTP id z10mr21918987ich.7.1404980766082; Thu, 10 Jul 2014 01:26:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.198 with SMTP id h64ls2895752qgf.66.gmail; Thu, 10 Jul 2014 01:26:06 -0700 (PDT) X-Received: by 10.52.232.200 with SMTP id tq8mr15776182vdc.32.1404980765967; Thu, 10 Jul 2014 01:26:05 -0700 (PDT) Received: from mail-vc0-x229.google.com (mail-vc0-x229.google.com [2607:f8b0:400c:c03::229]) by mx.google.com with ESMTPS id yq7si22697672veb.28.2014.07.10.01.26.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Jul 2014 01:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::229 as permitted sender) client-ip=2607:f8b0:400c:c03::229; Received: by mail-vc0-f169.google.com with SMTP id la4so10058475vcb.28 for ; Thu, 10 Jul 2014 01:26:05 -0700 (PDT) X-Received: by 10.220.250.203 with SMTP id mp11mr43643302vcb.2.1404980765861; Thu, 10 Jul 2014 01:26:05 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp114361vcb; Thu, 10 Jul 2014 01:26:05 -0700 (PDT) X-Received: by 10.70.129.81 with SMTP id nu17mr12170588pdb.56.1404980765072; Thu, 10 Jul 2014 01:26:05 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ha1si47976892pbc.104.2014.07.10.01.26.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jul 2014 01:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-51662-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 28868 invoked by alias); 10 Jul 2014 08:25:55 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list List-Id: List-Unsubscribe: , List-Subscribe: List-Archive: List-Post: , List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 28852 invoked by uid 89); 10 Jul 2014 08:25:54 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f45.google.com X-Received: by 10.180.89.69 with SMTP id bm5mr17491353wib.41.1404980749602; Thu, 10 Jul 2014 01:25:49 -0700 (PDT) From: Will Newton To: libc-alpha@sourceware.org Subject: [PATCH] iconv/loop.c: Fix -Wundef warning with !_STRING_ARCH_unaligned Date: Thu, 10 Jul 2014 09:25:44 +0100 Message-Id: <1404980744-22418-1-git-send-email-will.newton@linaro.org> X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::229 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 If code is required to handle the unaligned case then loop.c includes itself and relies on the #undefs at the end of the file to avoid outputting two copies of LOOPFCT and gconv_btowc. However MAX_NEEDED_INPUT is tested with #if so this causes a warning. Reorder the code so that the function definitions are in an #else block to make the behaviour clearer and fix the warning. Verified that code is unchanged on x86_64 and arm. ChangeLog: 2014-07-10 Will Newton * iconv/loop.c: Move definition of LOOPFCT and gconv_btowc into an #else block. --- iconv/loop.c | 59 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/iconv/loop.c b/iconv/loop.c index f86f627..a480c0c 100644 --- a/iconv/loop.c +++ b/iconv/loop.c @@ -354,12 +354,10 @@ FCTNAME (LOOPFCT) (struct __gconv_step *step, # define DEFINE_UNALIGNED # include "loop.c" # undef DEFINE_UNALIGNED -#endif - - -#if MAX_NEEDED_INPUT > 1 -# define SINGLE(fct) SINGLE2 (fct) -# define SINGLE2(fct) fct##_single +#else +# if MAX_NEEDED_INPUT > 1 +# define SINGLE(fct) SINGLE2 (fct) +# define SINGLE2(fct) fct##_single static inline int __attribute ((always_inline)) SINGLE(LOOPFCT) (struct __gconv_step *step, @@ -369,37 +367,37 @@ SINGLE(LOOPFCT) (struct __gconv_step *step, size_t *irreversible EXTRA_LOOP_DECLS) { mbstate_t *state = step_data->__statep; -#ifdef LOOP_NEED_FLAGS +# ifdef LOOP_NEED_FLAGS int flags = step_data->__flags; -#endif -#ifdef LOOP_NEED_DATA +# endif +# ifdef LOOP_NEED_DATA void *data = step->__data; -#endif +# endif int result = __GCONV_OK; unsigned char bytebuf[MAX_NEEDED_INPUT]; const unsigned char *inptr = *inptrp; unsigned char *outptr = *outptrp; size_t inlen; -#ifdef INIT_PARAMS +# ifdef INIT_PARAMS INIT_PARAMS; -#endif +# endif -#ifdef UNPACK_BYTES +# ifdef UNPACK_BYTES UNPACK_BYTES -#else +# else /* Add the bytes from the state to the input buffer. */ assert ((state->__count & 7) <= sizeof (state->__value)); for (inlen = 0; inlen < (size_t) (state->__count & 7); ++inlen) bytebuf[inlen] = state->__value.__wchb[inlen]; -#endif +# endif /* Are there enough bytes in the input buffer? */ if (MIN_NEEDED_INPUT > 1 && __builtin_expect (inptr + (MIN_NEEDED_INPUT - inlen) > inend, 0)) { *inptrp = inend; -#ifdef STORE_REST +# ifdef STORE_REST while (inptr < inend) bytebuf[inlen++] = *inptr++; @@ -408,12 +406,12 @@ SINGLE(LOOPFCT) (struct __gconv_step *step, inend = &bytebuf[inlen]; STORE_REST -#else +# else /* We don't have enough input for another complete input character. */ while (inptr < inend) state->__value.__wchb[inlen++] = *inptr++; -#endif +# endif return __GCONV_INCOMPLETE_INPUT; } @@ -453,11 +451,11 @@ SINGLE(LOOPFCT) (struct __gconv_step *step, result = __GCONV_OK; /* Clear the state buffer. */ -#ifdef CLEAR_STATE +# ifdef CLEAR_STATE CLEAR_STATE; -#else +# else state->__count &= ~7; -#endif +# endif } else if (result == __GCONV_INCOMPLETE_INPUT) { @@ -466,11 +464,11 @@ SINGLE(LOOPFCT) (struct __gconv_step *step, assert (inend != &bytebuf[MAX_NEEDED_INPUT]); *inptrp += inend - bytebuf - (state->__count & 7); -#ifdef STORE_REST +# ifdef STORE_REST inptrp = &inptr; STORE_REST -#else +# else /* We don't have enough input for another complete input character. */ assert (inend - inptr > (state->__count & ~7)); @@ -479,24 +477,25 @@ SINGLE(LOOPFCT) (struct __gconv_step *step, inlen = 0; while (inptr < inend) state->__value.__wchb[inlen++] = *inptr++; -#endif +# endif } return result; } -# undef SINGLE -# undef SINGLE2 -#endif +# undef SINGLE +# undef SINGLE2 +# endif -#ifdef ONEBYTE_BODY +# ifdef ONEBYTE_BODY /* Define the shortcut function for btowc. */ static wint_t gconv_btowc (struct __gconv_step *step, unsigned char c) ONEBYTE_BODY -# define FROM_ONEBYTE gconv_btowc -#endif +# define FROM_ONEBYTE gconv_btowc +# endif +#endif /* We remove the macro definitions so that we can include this file again for the definition of another function. */