From patchwork Mon Feb 13 13:55:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 64891 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 254B03887F60 for ; Mon, 13 Feb 2023 13:57:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 254B03887F60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676296638; bh=xQ+vGF12wv5GTU13ypjjo3+Fm3vsWH4OxazGFdIyshc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=CF4ySp6o5uAuT4+bZrvptY8B3ZvKaIO962LgnA57IZm97x36oVmaLcikA+PQkOokV 9MS4wdu70PgVfEKEANfPcDk6DLbblcKOCOW4uCJhxhpR0KpEovKt7RFMJgIcrj0j/4 vhp2u14HGqkhssU62wj0bn71OnmB+oC6mEOvTAjw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by sourceware.org (Postfix) with ESMTPS id C9265383FB93 for ; Mon, 13 Feb 2023 13:56:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9265383FB93 Received: by mail-oo1-xc32.google.com with SMTP id z138-20020a4a4990000000b005175b8ae66cso1186821ooa.6 for ; Mon, 13 Feb 2023 05:56:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xQ+vGF12wv5GTU13ypjjo3+Fm3vsWH4OxazGFdIyshc=; b=HKd7nOjuaCIZz1nLbA+VHEgF7MAlT8SK9kzJSyFW0smj7rc80jjVcsX5weznq+SYjL Vpq4jKxYAIUs8GVgN1FZUYTsp8GEN768EZMbw3Yweq+/nqovFEc1iHiBo4Ix2Xa0TODN hvrkytIqjyCyMnLSvktiBd9qZGz3LGajI6qU89INtFEJGae5vJh8p7Dc6waZpFvArJrg 6AUO0ZJnGarAsbR6gQecnA8XGAw1jwhmDtfPYi6jOBoGwR4tjW0Tm0anIA72fnXoKsWT aXZZnluTO4llCjRIqGYvfo7uFzFADlkLDL18+buTewb+dIwMPZ1guZeuhBw+VQEt6jsT iIow== X-Gm-Message-State: AO0yUKW1tJgr8hvaukAjiYy9pcUUPyl9he+9gae9ce7pI/LjVwnkor5k zHcVbUasi4nl5eU312UbFCJH3WSxTwMb1d/pmGw= X-Google-Smtp-Source: AK7set/n/HSJNFhJ/GHOvGEb9GI37fBWvKA5JqxkwFFzYggkAnxxWx3+l4RB8/EAuaEbj8Cdv3q/2Q== X-Received: by 2002:a4a:6342:0:b0:517:752d:678a with SMTP id r2-20020a4a6342000000b00517752d678amr10558360oof.1.1676296564561; Mon, 13 Feb 2023 05:56:04 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:f662:138b:cd0c:7b7a:8860]) by smtp.gmail.com with ESMTPSA id y11-20020a4ade0b000000b0051762a73553sm4797168oot.18.2023.02.13.05.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 05:56:04 -0800 (PST) To: libc-alpha@sourceware.org, Wilco Dijkstra Subject: [PATCH 1/7] crypto: Remove _STRING_ARCH_unaligned usage Date: Mon, 13 Feb 2023 10:55:52 -0300 Message-Id: <20230213135558.3328727-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> References: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Assume unaligned inputs on all cases. The code is built and used only in compat mode. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Wilco Dijkstra --- crypt/md5.c | 24 ++++-------------------- crypt/sha256.c | 28 ++++------------------------ crypt/sha512.c | 26 +++++--------------------- 3 files changed, 13 insertions(+), 65 deletions(-) diff --git a/crypt/md5.c b/crypt/md5.c index c7a232ad38..03240a9a36 100644 --- a/crypt/md5.c +++ b/crypt/md5.c @@ -229,27 +229,11 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) /* Process available complete blocks. */ if (len >= 64) { -#if !_STRING_ARCH_unaligned -/* To check alignment gcc has an appropriate operator. Other - compilers don't. */ -# if __GNUC__ >= 2 -# define UNALIGNED_P(p) (((md5_uintptr) p) % __alignof__ (md5_uint32) != 0) -# else -# define UNALIGNED_P(p) (((md5_uintptr) p) % sizeof (md5_uint32) != 0) -# endif - if (UNALIGNED_P (buffer)) - while (len > 64) - { - __md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); - buffer = (const char *) buffer + 64; - len -= 64; - } - else -#endif + while (len > 64) { - __md5_process_block (buffer, len & ~63, ctx); - buffer = (const char *) buffer + (len & ~63); - len &= 63; + __md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); + buffer = (const char *) buffer + 64; + len -= 64; } } diff --git a/crypt/sha256.c b/crypt/sha256.c index 93b73997c7..96153d67dc 100644 --- a/crypt/sha256.c +++ b/crypt/sha256.c @@ -120,13 +120,9 @@ __sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf) memcpy (&ctx->buffer[bytes], fillbuf, pad); /* Put the 64-bit file length in *bits* at the end of the buffer. */ -#if _STRING_ARCH_unaligned - ctx->buffer64[(bytes + pad) / 8] = SWAP64 (ctx->total64 << 3); -#else ctx->buffer32[(bytes + pad + 4) / 4] = SWAP (ctx->total[TOTAL64_low] << 3); ctx->buffer32[(bytes + pad) / 4] = SWAP ((ctx->total[TOTAL64_high] << 3) | (ctx->total[TOTAL64_low] >> 29)); -#endif /* Process last bytes. */ __sha256_process_block (ctx->buffer, bytes + pad + 8, ctx); @@ -169,27 +165,11 @@ __sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx) /* Process available complete blocks. */ if (len >= 64) { -#if !_STRING_ARCH_unaligned -/* To check alignment gcc has an appropriate operator. Other - compilers don't. */ -# if __GNUC__ >= 2 -# define UNALIGNED_P(p) (((uintptr_t) p) % __alignof__ (uint32_t) != 0) -# else -# define UNALIGNED_P(p) (((uintptr_t) p) % sizeof (uint32_t) != 0) -# endif - if (UNALIGNED_P (buffer)) - while (len > 64) - { - __sha256_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); - buffer = (const char *) buffer + 64; - len -= 64; - } - else -#endif + while (len > 64) { - __sha256_process_block (buffer, len & ~63, ctx); - buffer = (const char *) buffer + (len & ~63); - len &= 63; + __sha256_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); + buffer = (const char *) buffer + 64; + len -= 64; } } diff --git a/crypt/sha512.c b/crypt/sha512.c index d7e51b3604..ceabad1bf7 100644 --- a/crypt/sha512.c +++ b/crypt/sha512.c @@ -192,28 +192,12 @@ __sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx) /* Process available complete blocks. */ if (len >= 128) { -#if !_STRING_ARCH_unaligned -/* To check alignment gcc has an appropriate operator. Other - compilers don't. */ -# if __GNUC__ >= 2 -# define UNALIGNED_P(p) (((uintptr_t) p) % __alignof__ (uint64_t) != 0) -# else -# define UNALIGNED_P(p) (((uintptr_t) p) % sizeof (uint64_t) != 0) -# endif - if (UNALIGNED_P (buffer)) - while (len > 128) - { - __sha512_process_block (memcpy (ctx->buffer, buffer, 128), 128, - ctx); - buffer = (const char *) buffer + 128; - len -= 128; - } - else -#endif + while (len > 128) { - __sha512_process_block (buffer, len & ~127, ctx); - buffer = (const char *) buffer + (len & ~127); - len &= 127; + __sha512_process_block (memcpy (ctx->buffer, buffer, 128), 128, + ctx); + buffer = (const char *) buffer + 128; + len -= 128; } } From patchwork Mon Feb 13 13:55:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 64888 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 78F4C3886C53 for ; Mon, 13 Feb 2023 13:56:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78F4C3886C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676296597; bh=ZVWq7zAWbA5/oYRxY+9yU9yA7zGCWzAZRvU9UjtdPUM=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=no4y5dS9SbKQoDkndVsX8V+UFRV8ZwwSJqoQGrNrOdr1O7XAqnFaf/iWSEoB/sMls F7KCAv+kgH6bKkIx9J4eRJsSHFD1CEahblLR+WzMKHm7VsdrQqO7f8D0GiIXpnoNh2 StVm9J9y5/g3qWm69ePxyAADcZ1Rxac6N2SjEVQw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) by sourceware.org (Postfix) with ESMTPS id 9593E383FBAE for ; Mon, 13 Feb 2023 13:56:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9593E383FBAE Received: by mail-oo1-xc31.google.com with SMTP id i17-20020a4adf11000000b0051abd9835d4so1191352oou.1 for ; Mon, 13 Feb 2023 05:56:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZVWq7zAWbA5/oYRxY+9yU9yA7zGCWzAZRvU9UjtdPUM=; b=b9nwBdNlXEvvdZxCmydOtIMeu5DcFnSdwIike/tPMDK1pVTF+V/4qb3fOD9TDBtL31 hKXzzw5SW8+bl339pSB+XSkMSLSiflv20487Du2mSWexdqkAPyWYsPofuWc93HggRxRW 0pupooVkyHwm1dQk7vBjPGUNLz6mkJ+J1tF07q6KrtkV+4uDVrCfRf9Ru4vIo5i/LcmQ MtziQzUXjZN39L6ay+Iduz6IWmfFVGOm2Wee9T/5FfaaLJu3k7PMOlrB9rxHD7byom4v 02s9X1hrcXRTkQavg/8K8oLknlMDxAm4vGh3XoZybiddk74a3yuggwIwKbwEVHN7VanZ LlCQ== X-Gm-Message-State: AO0yUKVBdpFxY+sk5ZVFmUPGCGcO1FuWA+tXP/izuwC0zbrkIs4c1AQ6 T3js6Yp62WQnvUPsB1GV335LQscEVa4EZWimvPo= X-Google-Smtp-Source: AK7set/xDZm6bojREBjkslphWXqIIx3D6dppDPuCXz5OJNQSIWWrntUD4K1+CGf350JXRGMtbdf+4w== X-Received: by 2002:a05:6820:198d:b0:51a:186f:88c4 with SMTP id bp13-20020a056820198d00b0051a186f88c4mr14025144oob.0.1676296566235; Mon, 13 Feb 2023 05:56:06 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:f662:138b:cd0c:7b7a:8860]) by smtp.gmail.com with ESMTPSA id y11-20020a4ade0b000000b0051762a73553sm4797168oot.18.2023.02.13.05.56.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 05:56:05 -0800 (PST) To: libc-alpha@sourceware.org, Wilco Dijkstra Subject: [PATCH 2/7] stdlib: Simplify getenv Date: Mon, 13 Feb 2023 10:55:53 -0300 Message-Id: <20230213135558.3328727-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> References: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" And remove _STRING_ARCH_unaligned usage. The small size optimization just adds boilerplate code. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Wilco Dijkstra --- stdlib/getenv.c | 63 ++++--------------------------------------------- 1 file changed, 4 insertions(+), 59 deletions(-) diff --git a/stdlib/getenv.c b/stdlib/getenv.c index e3157ce2f3..449bba1e16 100644 --- a/stdlib/getenv.c +++ b/stdlib/getenv.c @@ -15,76 +15,21 @@ License along with the GNU C Library; if not, see . */ -#include -#include -#include #include #include #include - -/* Return the value of the environment variable NAME. This implementation - is tuned a bit in that it assumes no environment variable has an empty - name which of course should always be true. We have a special case for - one character names so that for the general case we can assume at least - two characters which we can access. By doing this we can avoid using the - `strncmp' most of the time. */ char * getenv (const char *name) { - char **ep; - uint16_t name_start; - if (__environ == NULL || name[0] == '\0') return NULL; - if (name[1] == '\0') - { - /* The name of the variable consists of only one character. Therefore - the first two characters of the environment entry are this character - and a '=' character. */ -#if __BYTE_ORDER == __LITTLE_ENDIAN || !_STRING_ARCH_unaligned - name_start = ('=' << 8) | *(const unsigned char *) name; -#else - name_start = '=' | ((*(const unsigned char *) name) << 8); -#endif - for (ep = __environ; *ep != NULL; ++ep) - { -#if _STRING_ARCH_unaligned - uint16_t ep_start = *(uint16_t *) *ep; -#else - uint16_t ep_start = (((unsigned char *) *ep)[0] - | (((unsigned char *) *ep)[1] << 8)); -#endif - if (name_start == ep_start) - return &(*ep)[2]; - } - } - else + size_t len = __strchrnul (name, '=') - name; + for (char **ep = __environ; *ep != NULL; ++ep) { - size_t len = strlen (name); -#if _STRING_ARCH_unaligned - name_start = *(const uint16_t *) name; -#else - name_start = (((const unsigned char *) name)[0] - | (((const unsigned char *) name)[1] << 8)); -#endif - len -= 2; - name += 2; - - for (ep = __environ; *ep != NULL; ++ep) - { -#if _STRING_ARCH_unaligned - uint16_t ep_start = *(uint16_t *) *ep; -#else - uint16_t ep_start = (((unsigned char *) *ep)[0] - | (((unsigned char *) *ep)[1] << 8)); -#endif - - if (name_start == ep_start && !strncmp (*ep + 2, name, len) - && (*ep)[len + 2] == '=') - return &(*ep)[len + 3]; - } + if (strncmp (name, *ep, len) == 0 && (*ep)[len] == '=') + return *ep + len + 1; } return NULL; From patchwork Mon Feb 13 13:55:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 64893 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 77B963896C17 for ; Mon, 13 Feb 2023 13:58:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77B963896C17 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676296680; bh=5X3V4gc/RB6i4215oZIIHFeCMg277b5TgmujLqutqoQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Y9UkQJxodv/nOOTD4YfTao0bAYu8zarAMMM8AmwhaQa/lhQNCkz/cwgm94zIVEqj7 sllPgbPUGUANi1pGtnbnU19Dr9cb9GAC8BX2f316EX425ppvD0+cOEIrQP50zgMgfp gnpvkCvWeLITYetY0iyBnoHsrFAhEWjnO43zI1W0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc2b.google.com (mail-oo1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) by sourceware.org (Postfix) with ESMTPS id 4CBBB383FBAF for ; Mon, 13 Feb 2023 13:56:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4CBBB383FBAF Received: by mail-oo1-xc2b.google.com with SMTP id r192-20020a4a37c9000000b00517677496d0so1181566oor.13 for ; Mon, 13 Feb 2023 05:56:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5X3V4gc/RB6i4215oZIIHFeCMg277b5TgmujLqutqoQ=; b=JFe07yKVgnlD/TIJyovJI4CNAQ3UW2UV8wHSqv9pf+1xhPTtRImwrd73NCSj/F4W2Z I1/xgK1xdiptSiHM2dOLfrpJmwMu2nbi7Z/6hZ2+iRQ4uDmJljz6vy2AJdvKSQxsTcId J/eGPvpmkmteNQPTLu+qn99KMmbkzxW9xOxE338IuooXC1MMwoD5/NGah6R2EfWlaCyI 70bYiT7fXqnzf8x48BYfXIDD8kzkN14pwl+xclKBnW83shq26yt0T5S/NYHFk92gJiqS ltajordnjtnTnSm6eSnuTleSzIrdm2xSTEc1TqFGc3bgxua0hoCpOmJfn8tLl7XmS9nk z6Gw== X-Gm-Message-State: AO0yUKW/QYNFlKinrWL6Hmlt74v0UD3ANBQPXOmoNqA+7vT+RCCuSimc /WyGek2aB9z8aNPQICphVeDCSiEaal2vdyEaI/A= X-Google-Smtp-Source: AK7set+4S66hcayVTx7d5VgRbKud1aMkxkVoosRAcntYBEX2SmJkLR7OKKFcQXXw/koXU7sNPNfPXw== X-Received: by 2002:a4a:2c51:0:b0:517:67ba:586 with SMTP id o78-20020a4a2c51000000b0051767ba0586mr11336037ooo.3.1676296567978; Mon, 13 Feb 2023 05:56:07 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:f662:138b:cd0c:7b7a:8860]) by smtp.gmail.com with ESMTPSA id y11-20020a4ade0b000000b0051762a73553sm4797168oot.18.2023.02.13.05.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 05:56:07 -0800 (PST) To: libc-alpha@sourceware.org, Wilco Dijkstra Subject: [PATCH 3/7] nscd: Remove _STRING_ARCH_unaligned usage Date: Mon, 13 Feb 2023 10:55:54 -0300 Message-Id: <20230213135558.3328727-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> References: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" It only adds a small overhead for unaligned inputs (which should not be common) and unify the code. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Wilco Dijkstra   --- nscd/nscd_gethst_r.c | 2 -- nscd/nscd_getserv_r.c | 2 -- nscd/nscd_helper.c | 6 ------ 3 files changed, 10 deletions(-) diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c index 7950ed695c..153194ad04 100644 --- a/nscd/nscd_gethst_r.c +++ b/nscd/nscd_gethst_r.c @@ -185,7 +185,6 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type, goto out; } -#if !_STRING_ARCH_unaligned /* The aliases_len array in the mapped database might very well be unaligned. We will access it word-wise so on platforms which do not tolerate unaligned accesses we @@ -199,7 +198,6 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type, hst_resp.h_aliases_cnt * sizeof (uint32_t)); } -#endif if (type != GETHOSTBYADDR && type != GETHOSTBYNAME) { if (hst_resp.h_length == INADDRSZ) diff --git a/nscd/nscd_getserv_r.c b/nscd/nscd_getserv_r.c index 752ae1115e..0ee83ff88c 100644 --- a/nscd/nscd_getserv_r.c +++ b/nscd/nscd_getserv_r.c @@ -140,7 +140,6 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto, > recend, 0)) goto out; -#if !_STRING_ARCH_unaligned /* The aliases_len array in the mapped database might very well be unaligned. We will access it word-wise so on platforms which do not tolerate unaligned accesses we @@ -170,7 +169,6 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto, serv_resp.s_aliases_cnt * sizeof (uint32_t)); } -#endif } } diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index fdd555ea66..6a498b363c 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -465,7 +465,6 @@ __nscd_cache_search (request_type type, const char *key, size_t keylen, struct hashentry *here = (struct hashentry *) (mapped->data + work); ref_t here_key, here_packet; -#if !_STRING_ARCH_unaligned /* Although during garbage collection when moving struct hashentry records around we first copy from old to new location and then adjust pointer from previous hashentry to it, there is no barrier @@ -474,7 +473,6 @@ __nscd_cache_search (request_type type, const char *key, size_t keylen, application. */ if ((uintptr_t) here & (__alignof__ (*here) - 1)) return NULL; -#endif if (type == here->type && keylen == here->len @@ -487,10 +485,8 @@ __nscd_cache_search (request_type type, const char *key, size_t keylen, struct datahead *dh = (struct datahead *) (mapped->data + here_packet); -#if !_STRING_ARCH_unaligned if ((uintptr_t) dh & (__alignof__ (*dh) - 1)) return NULL; -#endif /* See whether we must ignore the entry or whether something is wrong because garbage collection is in progress. */ @@ -511,11 +507,9 @@ __nscd_cache_search (request_type type, const char *key, size_t keylen, struct hashentry *trailelem; trailelem = (struct hashentry *) (mapped->data + trail); -#if !_STRING_ARCH_unaligned /* We have to redo the checks. Maybe the data changed. */ if ((uintptr_t) trailelem & (__alignof__ (*trailelem) - 1)) return NULL; -#endif if (trail + MINIMUM_HASHENTRY_SIZE > datasize) return NULL; From patchwork Mon Feb 13 13:55:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 64889 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9DD973889E12 for ; Mon, 13 Feb 2023 13:56:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9DD973889E12 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676296605; bh=LnQHGuJRuPK6Q02vGLi8c7TjYocWOm+hPY7zU1wnad4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=N2secFvqJ04TXifmLK7wWpPRlxcFTcwS9XWUlb77JMiVfdGZQdFNKCvP+qzt7h6AA THRhH6/YFmn04s8arv1sDLHZVgn6J9oDBiqYx8IGu17Dc/rWZcsxDDpDA2Dj38fWRu hnJpxCRNIBaQKm9Q5GvMj1RCQJ6DaEqOX1DDwmDo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by sourceware.org (Postfix) with ESMTPS id 17E043839DF6 for ; Mon, 13 Feb 2023 13:56:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 17E043839DF6 Received: by mail-oo1-xc2c.google.com with SMTP id r192-20020a4a37c9000000b00517677496d0so1181576oor.13 for ; Mon, 13 Feb 2023 05:56:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LnQHGuJRuPK6Q02vGLi8c7TjYocWOm+hPY7zU1wnad4=; b=32K3M45rvb1h1ifZ7iOTa2s65s2i/AwQ2X4vqYTYlG+B8UlqVtof8S0CLElFZxkCY9 +vTm8Z7lr1pZHROt0Wqn736/IUELZsrllrK+RxUCChJa/KbD8z27HTg1g6tdthJKnvb+ YMCj0lKOWkvsd7llg4rLlulbyL/c92SJeV97Wfut/Ykd2Eq3+/gkKF+XMuQz5LviXBPA nbTanaCccH6GeB0aX/syJWD8Y8NvnfkbeOo8bnykI8dxDwzdFZRchdi3x+nr6Ei6BAUn /Vyl9z15+gKTuCWcTEM0PP5WNBfbvcNfPKqw+Ry7lnujMO5ewD0qN3A7RDKE2sFJg3cx 9YJg== X-Gm-Message-State: AO0yUKVrngdFCc7KiRGKsPnuvqAf8c/0SphbFqJkxfe/wGUGFAndOaV8 FRt2oL36T4Bli1jHzaY628FR7pq9G+STPeLARws= X-Google-Smtp-Source: AK7set+bqFnv1jvGxBiV/6+PbwCGPiY9rzptU7n/fk0BMWEjfBbDCrvVJ1jI6Yv4jmaQE4vPb2XFBg== X-Received: by 2002:a4a:e2c6:0:b0:51a:a3fd:69d3 with SMTP id l6-20020a4ae2c6000000b0051aa3fd69d3mr12087095oot.2.1676296569772; Mon, 13 Feb 2023 05:56:09 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:f662:138b:cd0c:7b7a:8860]) by smtp.gmail.com with ESMTPSA id y11-20020a4ade0b000000b0051762a73553sm4797168oot.18.2023.02.13.05.56.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 05:56:09 -0800 (PST) To: libc-alpha@sourceware.org, Wilco Dijkstra Subject: [PATCH 4/7] resolv: Remove _STRING_ARCH_unaligned usage Date: Mon, 13 Feb 2023 10:55:55 -0300 Message-Id: <20230213135558.3328727-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> References: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" GCC with default implementation already generates optimized code. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Wilco Dijkstra --- include/arpa/nameser.h | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/include/arpa/nameser.h b/include/arpa/nameser.h index c27e7886b7..0ef5ab409f 100644 --- a/include/arpa/nameser.h +++ b/include/arpa/nameser.h @@ -13,42 +13,6 @@ extern const struct _ns_flagdata _ns_flagdata[] attribute_hidden; -#if _STRING_ARCH_unaligned - -# undef NS_GET16 -# define NS_GET16(s, cp) \ - do { \ - const uint16_t *t_cp = (const uint16_t *) (cp); \ - (s) = ntohs (*t_cp); \ - (cp) += NS_INT16SZ; \ - } while (0) - -# undef NS_GET32 -# define NS_GET32(l, cp) \ - do { \ - const uint32_t *t_cp = (const uint32_t *) (cp); \ - (l) = ntohl (*t_cp); \ - (cp) += NS_INT32SZ; \ - } while (0) - -# undef NS_PUT16 -# define NS_PUT16(s, cp) \ - do { \ - uint16_t *t_cp = (uint16_t *) (cp); \ - *t_cp = htons (s); \ - (cp) += NS_INT16SZ; \ - } while (0) - -# undef NS_PUT32 -# define NS_PUT32(l, cp) \ - do { \ - uint32_t *t_cp = (uint32_t *) (cp); \ - *t_cp = htonl (l); \ - (cp) += NS_INT32SZ; \ - } while (0) - -#endif - extern unsigned int __ns_get16 (const unsigned char *) __THROW; extern unsigned long __ns_get32 (const unsigned char *) __THROW; int __ns_name_ntop (const unsigned char *, char *, size_t) __THROW; From patchwork Mon Feb 13 13:55:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 64892 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 168E73885523 for ; Mon, 13 Feb 2023 13:57:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 168E73885523 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676296648; bh=WurL0aNkRnLhAK4x3Yx6Pr+C6l/fU/krEgITuYCkCNY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=DAbecq4tujQDV2WijQ/BBWE6PDIOCmaGrndHCGOLN8ZEx/oRpgKfQqh8S6WeaYtUA 2goY7OzKZ9jtd8Arz4+y81YkeknOJSeLaSs83A9Wd6PNZ9XNF89XNLVLkZzw3qBrSy 1Vw1qmG+18WNF3V/Jx7/lmmDLd6Ei6X0/apy87gs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by sourceware.org (Postfix) with ESMTPS id BA2BE388302F for ; Mon, 13 Feb 2023 13:56:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BA2BE388302F Received: by mail-oo1-xc32.google.com with SMTP id z138-20020a4a4990000000b005175b8ae66cso1186857ooa.6 for ; Mon, 13 Feb 2023 05:56:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WurL0aNkRnLhAK4x3Yx6Pr+C6l/fU/krEgITuYCkCNY=; b=kNMb5LCEALd2/xU4LoiXrWJE8r4+hiyUbB55VvooOPu/Q2UAKaeIaJom6HR0iJ4z/n PoC5yGufAilVffhJisY31axUg9s0EwcR7FsKsQnGqYuegz0y1Nr6yGq+HrZf+h/Uvdfl CneIPaQQkcICNVHt/nFycusHjXZsmH2wx/3VcyvX29WrKz+zrQSfVn5TIPr+jBl35XVT 2kOkNdsNuW740HOCBb6yWijpAPKtaNmzKkTrKXUmfnhAVgbfFyxXR0zX29zpOAvefiRs cNYdTMUj5Cl4nXmDQmXGWtbQoXN5sy9ui39Ik4bg2EplP79W5HbVGjVMEmhKYnhjA3Wd wF6w== X-Gm-Message-State: AO0yUKVirdBxUcEQx9yc481kZTXLOaEC7pmlp+vgrvPDsEllcY89cC/5 PGzUqWJMxrv1m0w5tzvxuQE8MuadZ9eb+ZFzvNs= X-Google-Smtp-Source: AK7set81CABnwiMPxnmt2Z3LAWeF4DPTcm4xcS5grTTfDAVbDs7Em9PourDpUD41hc5W7/aBbtWgZQ== X-Received: by 2002:a4a:868f:0:b0:517:4b3a:8066 with SMTP id x15-20020a4a868f000000b005174b3a8066mr12097453ooh.6.1676296571814; Mon, 13 Feb 2023 05:56:11 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:f662:138b:cd0c:7b7a:8860]) by smtp.gmail.com with ESMTPSA id y11-20020a4ade0b000000b0051762a73553sm4797168oot.18.2023.02.13.05.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 05:56:11 -0800 (PST) To: libc-alpha@sourceware.org, Wilco Dijkstra Subject: [PATCH 5/7] iconv: Remove _STRING_ARCH_unaligned usage for get/set macros Date: Mon, 13 Feb 2023 10:55:56 -0300 Message-Id: <20230213135558.3328727-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> References: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" And use a packet structure instead. The compiler generates optimized unaligned code if the architecture supports it. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Wilco Dijkstra --- iconv/gconv_int.h | 28 ++++++++++++++ iconv/loop.c | 73 ----------------------------------- iconv/skeleton.c | 67 -------------------------------- iconvdata/iso-2022-jp-3.c | 2 +- iconvdata/unicode.c | 6 +-- iconvdata/utf-16.c | 6 +-- iconvdata/utf-32.c | 6 +-- sysdeps/s390/utf16-utf32-z9.c | 4 +- sysdeps/s390/utf8-utf16-z9.c | 2 +- sysdeps/s390/utf8-utf32-z9.c | 2 +- 10 files changed, 42 insertions(+), 154 deletions(-) diff --git a/iconv/gconv_int.h b/iconv/gconv_int.h index da792a95f5..4b247a815f 100644 --- a/iconv/gconv_int.h +++ b/iconv/gconv_int.h @@ -26,6 +26,34 @@ __BEGIN_DECLS +/* We have to provide support for machines which are not able to handled + unaligned memory accesses. Some of the character encodings have + representations with a fixed width of 2 or 4 bytes. */ +#define get16(addr) \ +({ \ + const struct { uint16_t r; } __attribute__ ((__packed__)) *__ptr \ + = (__typeof(__ptr))(addr); \ + __ptr->r; \ +}) +#define get32(addr) \ +({ \ + const struct { uint32_t r; } __attribute__ ((__packed__)) *__ptr \ + = (__typeof(__ptr))(addr); \ + __ptr->r; \ +}) + +#define put16(addr, val) \ +do { \ + struct { uint16_t r; } __attribute__ ((__packed__)) *__ptr \ + = (__typeof(__ptr))(addr); \ + __ptr->r = val; \ +} while (0) +#define put32(addr, val) \ +do { \ + struct { uint32_t r; } __attribute__ ((__packed__)) *__ptr \ + = (__typeof(__ptr))(addr); \ + __ptr->r = val; \ +} while (0) /* Structure for alias definition. Simply two strings. */ struct gconv_alias diff --git a/iconv/loop.c b/iconv/loop.c index 963c59ca9a..9d8a7cceb3 100644 --- a/iconv/loop.c +++ b/iconv/loop.c @@ -57,75 +57,10 @@ #include #include -/* We have to provide support for machines which are not able to handled - unaligned memory accesses. Some of the character encodings have - representations with a fixed width of 2 or 4 bytes. But if we cannot - access unaligned memory we still have to read byte-wise. */ #undef FCTNAME2 #if _STRING_ARCH_unaligned || !defined DEFINE_UNALIGNED -/* We can handle unaligned memory access. */ -# define get16(addr) *((const uint16_t *) (addr)) -# define get32(addr) *((const uint32_t *) (addr)) - -/* We need no special support for writing values either. */ -# define put16(addr, val) *((uint16_t *) (addr)) = (val) -# define put32(addr, val) *((uint32_t *) (addr)) = (val) - # define FCTNAME2(name) name #else -/* Distinguish between big endian and little endian. */ -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define get16(addr) \ - (((const unsigned char *) (addr))[1] << 8 \ - | ((const unsigned char *) (addr))[0]) -# define get32(addr) \ - (((((const unsigned char *) (addr))[3] << 8 \ - | ((const unsigned char *) (addr))[2]) << 8 \ - | ((const unsigned char *) (addr))[1]) << 8 \ - | ((const unsigned char *) (addr))[0]) - -# define put16(addr, val) \ - ({ uint16_t __val = (val); \ - ((unsigned char *) (addr))[0] = __val; \ - ((unsigned char *) (addr))[1] = __val >> 8; \ - (void) 0; }) -# define put32(addr, val) \ - ({ uint32_t __val = (val); \ - ((unsigned char *) (addr))[0] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[1] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[2] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[3] = __val; \ - (void) 0; }) -# else -# define get16(addr) \ - (((const unsigned char *) (addr))[0] << 8 \ - | ((const unsigned char *) (addr))[1]) -# define get32(addr) \ - (((((const unsigned char *) (addr))[0] << 8 \ - | ((const unsigned char *) (addr))[1]) << 8 \ - | ((const unsigned char *) (addr))[2]) << 8 \ - | ((const unsigned char *) (addr))[3]) - -# define put16(addr, val) \ - ({ uint16_t __val = (val); \ - ((unsigned char *) (addr))[1] = __val; \ - ((unsigned char *) (addr))[0] = __val >> 8; \ - (void) 0; }) -# define put32(addr, val) \ - ({ uint32_t __val = (val); \ - ((unsigned char *) (addr))[3] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[2] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[1] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[0] = __val; \ - (void) 0; }) -# endif - # define FCTNAME2(name) name##_unaligned #endif #define FCTNAME(name) FCTNAME2(name) @@ -349,10 +284,6 @@ FCTNAME (LOOPFCT) (struct __gconv_step *step, #if !defined DEFINE_UNALIGNED && !_STRING_ARCH_unaligned \ && MIN_NEEDED_INPUT != 1 && MAX_NEEDED_INPUT % MIN_NEEDED_INPUT == 0 \ && MIN_NEEDED_OUTPUT != 1 && MAX_NEEDED_OUTPUT % MIN_NEEDED_OUTPUT == 0 -# undef get16 -# undef get32 -# undef put16 -# undef put32 # undef unaligned # define DEFINE_UNALIGNED @@ -540,8 +471,4 @@ gconv_btowc (struct __gconv_step *step, unsigned char c) #undef LOOP_NEED_STATE #undef LOOP_NEED_FLAGS #undef LOOP_NEED_DATA -#undef get16 -#undef get32 -#undef put16 -#undef put32 #undef unaligned diff --git a/iconv/skeleton.c b/iconv/skeleton.c index 673b474134..9423d3fc5a 100644 --- a/iconv/skeleton.c +++ b/iconv/skeleton.c @@ -204,73 +204,6 @@ #endif -/* Define macros which can access unaligned buffers. These macros are - supposed to be used only in code outside the inner loops. For the inner - loops we have other definitions which allow optimized access. */ -#if _STRING_ARCH_unaligned -/* We can handle unaligned memory access. */ -# define get16u(addr) *((const uint16_t *) (addr)) -# define get32u(addr) *((const uint32_t *) (addr)) - -/* We need no special support for writing values either. */ -# define put16u(addr, val) *((uint16_t *) (addr)) = (val) -# define put32u(addr, val) *((uint32_t *) (addr)) = (val) -#else -/* Distinguish between big endian and little endian. */ -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define get16u(addr) \ - (((const unsigned char *) (addr))[1] << 8 \ - | ((const unsigned char *) (addr))[0]) -# define get32u(addr) \ - (((((const unsigned char *) (addr))[3] << 8 \ - | ((const unsigned char *) (addr))[2]) << 8 \ - | ((const unsigned char *) (addr))[1]) << 8 \ - | ((const unsigned char *) (addr))[0]) - -# define put16u(addr, val) \ - ({ uint16_t __val = (val); \ - ((unsigned char *) (addr))[0] = __val; \ - ((unsigned char *) (addr))[1] = __val >> 8; \ - (void) 0; }) -# define put32u(addr, val) \ - ({ uint32_t __val = (val); \ - ((unsigned char *) (addr))[0] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[1] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[2] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[3] = __val; \ - (void) 0; }) -# else -# define get16u(addr) \ - (((const unsigned char *) (addr))[0] << 8 \ - | ((const unsigned char *) (addr))[1]) -# define get32u(addr) \ - (((((const unsigned char *) (addr))[0] << 8 \ - | ((const unsigned char *) (addr))[1]) << 8 \ - | ((const unsigned char *) (addr))[2]) << 8 \ - | ((const unsigned char *) (addr))[3]) - -# define put16u(addr, val) \ - ({ uint16_t __val = (val); \ - ((unsigned char *) (addr))[1] = __val; \ - ((unsigned char *) (addr))[0] = __val >> 8; \ - (void) 0; }) -# define put32u(addr, val) \ - ({ uint32_t __val = (val); \ - ((unsigned char *) (addr))[3] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[2] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[1] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[0] = __val; \ - (void) 0; }) -# endif -#endif - - /* For conversions from a fixed width character set to another fixed width character set we can define RESET_INPUT_BUFFER in a very fast way. */ #if !defined RESET_INPUT_BUFFER && !defined SAVE_RESET_STATE diff --git a/iconvdata/iso-2022-jp-3.c b/iconvdata/iso-2022-jp-3.c index 4a4d5a3046..d341a14f51 100644 --- a/iconvdata/iso-2022-jp-3.c +++ b/iconvdata/iso-2022-jp-3.c @@ -91,7 +91,7 @@ enum if (__glibc_likely (outbuf + 4 <= outend)) \ { \ /* Write out the last character. */ \ - put32u (outbuf, ch); \ + put32 (outbuf, ch); \ outbuf += 4; \ data->__statep->__count &= 7; \ data->__statep->__count |= ASCII_set; \ diff --git a/iconvdata/unicode.c b/iconvdata/unicode.c index 2d131270b9..cc7999e36c 100644 --- a/iconvdata/unicode.c +++ b/iconvdata/unicode.c @@ -51,10 +51,10 @@ return (inptr == inend \ ? __GCONV_EMPTY_INPUT : __GCONV_INCOMPLETE_INPUT); \ \ - if (get16u (inptr) == BOM) \ + if (get16 (inptr) == BOM) \ /* Simply ignore the BOM character. */ \ *inptrp = inptr += 2; \ - else if (get16u (inptr) == BOM_OE) \ + else if (get16 (inptr) == BOM_OE) \ { \ data->__flags |= __GCONV_SWAP; \ *inptrp = inptr += 2; \ @@ -67,7 +67,7 @@ if (__glibc_unlikely (outbuf + 2 > outend)) \ return __GCONV_FULL_OUTPUT; \ \ - put16u (outbuf, BOM); \ + put16 (outbuf, BOM); \ outbuf += 2; \ } \ swap = data->__flags & __GCONV_SWAP; diff --git a/iconvdata/utf-16.c b/iconvdata/utf-16.c index ad7dfa1a5c..edd1816c9d 100644 --- a/iconvdata/utf-16.c +++ b/iconvdata/utf-16.c @@ -55,10 +55,10 @@ return (inptr == inend \ ? __GCONV_EMPTY_INPUT : __GCONV_INCOMPLETE_INPUT); \ \ - if (get16u (inptr) == BOM) \ + if (get16 (inptr) == BOM) \ /* Simply ignore the BOM character. */ \ *inptrp = inptr += 2; \ - else if (get16u (inptr) == BOM_OE) \ + else if (get16 (inptr) == BOM_OE) \ { \ data->__flags |= __GCONV_SWAP; \ *inptrp = inptr += 2; \ @@ -70,7 +70,7 @@ if (__glibc_unlikely (outbuf + 2 > outend)) \ return __GCONV_FULL_OUTPUT; \ \ - put16u (outbuf, BOM); \ + put16 (outbuf, BOM); \ outbuf += 2; \ } \ } \ diff --git a/iconvdata/utf-32.c b/iconvdata/utf-32.c index 01b6d95018..41be52bb3a 100644 --- a/iconvdata/utf-32.c +++ b/iconvdata/utf-32.c @@ -52,10 +52,10 @@ return (inptr == inend \ ? __GCONV_EMPTY_INPUT : __GCONV_INCOMPLETE_INPUT); \ \ - if (get32u (inptr) == BOM) \ + if (get32 (inptr) == BOM) \ /* Simply ignore the BOM character. */ \ *inptrp = inptr += 4; \ - else if (get32u (inptr) == BOM_OE) \ + else if (get32 (inptr) == BOM_OE) \ { \ data->__flags |= __GCONV_SWAP; \ *inptrp = inptr += 4; \ @@ -69,7 +69,7 @@ if (__glibc_unlikely (outbuf + 4 > outend)) \ return __GCONV_FULL_OUTPUT; \ \ - put32u (outbuf, BOM); \ + put32 (outbuf, BOM); \ outbuf += 4; \ } \ else if (__builtin_expect (data->__invocation_counter == 0, 0) \ diff --git a/sysdeps/s390/utf16-utf32-z9.c b/sysdeps/s390/utf16-utf32-z9.c index d87eac0bdf..36c56ccbf7 100644 --- a/sysdeps/s390/utf16-utf32-z9.c +++ b/sysdeps/s390/utf16-utf32-z9.c @@ -171,7 +171,7 @@ gconv_end (struct __gconv_step *data) if (__glibc_unlikely (outbuf + 2 > outend)) \ return __GCONV_FULL_OUTPUT; \ \ - put16u (outbuf, BOM_UTF16); \ + put16 (outbuf, BOM_UTF16); \ outbuf += 2; \ } \ else \ @@ -180,7 +180,7 @@ gconv_end (struct __gconv_step *data) if (__glibc_unlikely (outbuf + 4 > outend)) \ return __GCONV_FULL_OUTPUT; \ \ - put32u (outbuf, BOM_UTF32); \ + put32 (outbuf, BOM_UTF32); \ outbuf += 4; \ } \ } diff --git a/sysdeps/s390/utf8-utf16-z9.c b/sysdeps/s390/utf8-utf16-z9.c index 4d5510335e..33f7c64da4 100644 --- a/sysdeps/s390/utf8-utf16-z9.c +++ b/sysdeps/s390/utf8-utf16-z9.c @@ -211,7 +211,7 @@ gconv_end (struct __gconv_step *data) if (__glibc_unlikely (outbuf + 2 > outend)) \ return __GCONV_FULL_OUTPUT; \ \ - put16u (outbuf, BOM_UTF16); \ + put16 (outbuf, BOM_UTF16); \ outbuf += 2; \ } diff --git a/sysdeps/s390/utf8-utf32-z9.c b/sysdeps/s390/utf8-utf32-z9.c index c3a431d0a9..55321c519a 100644 --- a/sysdeps/s390/utf8-utf32-z9.c +++ b/sysdeps/s390/utf8-utf32-z9.c @@ -211,7 +211,7 @@ gconv_end (struct __gconv_step *data) if (__glibc_unlikely (outbuf + 4 > outend)) \ return __GCONV_FULL_OUTPUT; \ \ - put32u (outbuf, BOM); \ + put32 (outbuf, BOM); \ outbuf += 4; \ } From patchwork Mon Feb 13 13:55:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 64890 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6C7D4388B6BD for ; Mon, 13 Feb 2023 13:56:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C7D4388B6BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676296611; bh=h0OyEF7arFfqJI506yZsJuH3xu0OSVFuK7wTvh9sYu8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=D0L/ha6VQSZJYIgMXbn0YnQSrboByLJ0I+m7NCofvEqoKKYxTynr7hBgfOVc+UuVF WQNbeQip0SqpE60UJxgE2optBF8KBmO3ob9ppiip7b4rsU6XBr/C3AzrTVuv+MtP8Z fsHx2q83TWWdxjOudMTMwN+xY50wD923SXBeSBNw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) by sourceware.org (Postfix) with ESMTPS id 1EE6B382E693 for ; Mon, 13 Feb 2023 13:56:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1EE6B382E693 Received: by mail-oo1-xc29.google.com with SMTP id y17-20020a4ade11000000b0051762fdf955so1189139oot.3 for ; Mon, 13 Feb 2023 05:56:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h0OyEF7arFfqJI506yZsJuH3xu0OSVFuK7wTvh9sYu8=; b=PYyYbg4DuMLt3tATD/VkfHj+ZZU7yhwqlv8tJDaE5dXs3+HDyKj7ZMGFtg0xzDMWZ7 d+ONplCz5KGZYJlV4XODnW3URHJ9EkjEFabPW7T3zHTGxH52JJ5BxKLjBt9cmmJZtCdu h3/Ah21EejwWYjpY9Bqp7Bfnj7stpyiougGyQtkq96O9GD18gdTnGvbQNzxGjsPnobbC y47fjS2YI+dhCm6XfETkyzmTxBGSt8/Tn82brvWmrqi7JqoCXOyPVUEfig52/AdoHCnY xW2DRaS+Xl+UCgyMqaBhQ5coFtm89DOQR528Ct00olRg+T5TAG2pBLRR1FHluso05FQy selg== X-Gm-Message-State: AO0yUKV9gIN7ZgJv16InHB3O2bjJ8mttaljO9yTkIeRPvWmW69EyZPjF fcvEFqYJSk4HyAYlWqn4t+FpIdTWb0MolivKi/M= X-Google-Smtp-Source: AK7set9ZfqTNnepk4AmqpRlbFFPYEvv397LnnQ6Oo/0pA1ln4x1GsTiIJVF40LO7XyhB2LDPIKgP4A== X-Received: by 2002:a05:6820:813:b0:517:5714:8355 with SMTP id bg19-20020a056820081300b0051757148355mr14457987oob.9.1676296573623; Mon, 13 Feb 2023 05:56:13 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:f662:138b:cd0c:7b7a:8860]) by smtp.gmail.com with ESMTPSA id y11-20020a4ade0b000000b0051762a73553sm4797168oot.18.2023.02.13.05.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 05:56:13 -0800 (PST) To: libc-alpha@sourceware.org, Wilco Dijkstra Subject: [PATCH 6/7] iconv: Remove _STRING_ARCH_unaligned usage Date: Mon, 13 Feb 2023 10:55:57 -0300 Message-Id: <20230213135558.3328727-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> References: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Use put/get macros __builtin_bswap32 instead. It allows to remove the unaligned routines, the compiler will generate unaligned access if the ABI allows it. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Wilco Dijkstra --- iconv/gconv_simple.c | 282 +++---------------------------------------- iconv/loop.c | 66 ++++------ iconv/skeleton.c | 118 +++--------------- 3 files changed, 59 insertions(+), 407 deletions(-) diff --git a/iconv/gconv_simple.c b/iconv/gconv_simple.c index c50ffd3bf0..c60cffad4c 100644 --- a/iconv/gconv_simple.c +++ b/iconv/gconv_simple.c @@ -86,69 +86,22 @@ internal_ucs4_loop (struct __gconv_step *step, #if __BYTE_ORDER == __LITTLE_ENDIAN /* Sigh, we have to do some real work. */ size_t cnt; - uint32_t *outptr32 = (uint32_t *) outptr; - - for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4) - *outptr32++ = bswap_32 (*(const uint32_t *) inptr); - - *inptrp = inptr; - *outptrp = (unsigned char *) outptr32; -#elif __BYTE_ORDER == __BIG_ENDIAN - /* Simply copy the data. */ - *inptrp = inptr + n_convert * 4; - *outptrp = __mempcpy (outptr, inptr, n_convert * 4); -#else -# error "This endianess is not supported." -#endif - - /* Determine the status. */ - if (*inptrp == inend) - result = __GCONV_EMPTY_INPUT; - else if (*outptrp + 4 > outend) - result = __GCONV_FULL_OUTPUT; - else - result = __GCONV_INCOMPLETE_INPUT; - - return result; -} - -#if !_STRING_ARCH_unaligned -static inline int -__attribute ((always_inline)) -internal_ucs4_loop_unaligned (struct __gconv_step *step, - struct __gconv_step_data *step_data, - const unsigned char **inptrp, - const unsigned char *inend, - unsigned char **outptrp, - const unsigned char *outend, - size_t *irreversible) -{ - const unsigned char *inptr = *inptrp; - unsigned char *outptr = *outptrp; - size_t n_convert = MIN (inend - inptr, outend - outptr) / 4; - int result; - -# if __BYTE_ORDER == __LITTLE_ENDIAN - /* Sigh, we have to do some real work. */ - size_t cnt; for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4, outptr += 4) { - outptr[0] = inptr[3]; - outptr[1] = inptr[2]; - outptr[2] = inptr[1]; - outptr[3] = inptr[0]; + uint32_t val = get32 (inptr); + put32 (outptr, __builtin_bswap32 (val)); } *inptrp = inptr; *outptrp = outptr; -# elif __BYTE_ORDER == __BIG_ENDIAN +#elif __BYTE_ORDER == __BIG_ENDIAN /* Simply copy the data. */ *inptrp = inptr + n_convert * 4; *outptrp = __mempcpy (outptr, inptr, n_convert * 4); -# else -# error "This endianess is not supported." -# endif +#else +# error "This endianess is not supported." +#endif /* Determine the status. */ if (*inptrp == inend) @@ -160,7 +113,6 @@ internal_ucs4_loop_unaligned (struct __gconv_step *step, return result; } -#endif static inline int @@ -242,12 +194,9 @@ ucs4_internal_loop (struct __gconv_step *step, for (; inptr + 4 <= inend && outptr + 4 <= outend; inptr += 4) { - uint32_t inval; - + uint32_t inval = get32 (inptr); #if __BYTE_ORDER == __LITTLE_ENDIAN - inval = bswap_32 (*(const uint32_t *) inptr); -#else - inval = *(const uint32_t *) inptr; + inval = __builtin_bswap32 (inval); #endif if (__glibc_unlikely (inval > 0x7fffffff)) @@ -272,7 +221,7 @@ ucs4_internal_loop (struct __gconv_step *step, return __GCONV_ILLEGAL_INPUT; } - *((uint32_t *) outptr) = inval; + put32 (outptr, inval); outptr += sizeof (uint32_t); } @@ -290,75 +239,6 @@ ucs4_internal_loop (struct __gconv_step *step, return result; } -#if !_STRING_ARCH_unaligned -static inline int -__attribute ((always_inline)) -ucs4_internal_loop_unaligned (struct __gconv_step *step, - struct __gconv_step_data *step_data, - const unsigned char **inptrp, - const unsigned char *inend, - unsigned char **outptrp, - const unsigned char *outend, - size_t *irreversible) -{ - int flags = step_data->__flags; - const unsigned char *inptr = *inptrp; - unsigned char *outptr = *outptrp; - int result; - - for (; inptr + 4 <= inend && outptr + 4 <= outend; inptr += 4) - { - if (__glibc_unlikely (inptr[0] > 0x80)) - { - /* The value is too large. We don't try transliteration here since - this is not an error because of the lack of possibilities to - represent the result. This is a genuine bug in the input since - UCS4 does not allow such values. */ - if (irreversible == NULL) - /* We are transliterating, don't try to correct anything. */ - return __GCONV_ILLEGAL_INPUT; - - if (flags & __GCONV_IGNORE_ERRORS) - { - /* Just ignore this character. */ - ++*irreversible; - continue; - } - - *inptrp = inptr; - *outptrp = outptr; - return __GCONV_ILLEGAL_INPUT; - } - -# if __BYTE_ORDER == __LITTLE_ENDIAN - outptr[3] = inptr[0]; - outptr[2] = inptr[1]; - outptr[1] = inptr[2]; - outptr[0] = inptr[3]; -# else - outptr[0] = inptr[0]; - outptr[1] = inptr[1]; - outptr[2] = inptr[2]; - outptr[3] = inptr[3]; -# endif - outptr += 4; - } - - *inptrp = inptr; - *outptrp = outptr; - - /* Determine the status. */ - if (*inptrp == inend) - result = __GCONV_EMPTY_INPUT; - else if (*outptrp + 4 > outend) - result = __GCONV_FULL_OUTPUT; - else - result = __GCONV_INCOMPLETE_INPUT; - - return result; -} -#endif - static inline int __attribute ((always_inline)) @@ -453,11 +333,12 @@ internal_ucs4le_loop (struct __gconv_step *step, #if __BYTE_ORDER == __BIG_ENDIAN /* Sigh, we have to do some real work. */ size_t cnt; - uint32_t *outptr32 = (uint32_t *) outptr; - for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4) - *outptr32++ = bswap_32 (*(const uint32_t *) inptr); - outptr = (unsigned char *) outptr32; + for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4, outptr += 4) + { + uint32_t val = get32 (inptr); + put32 (outptr, __builtin_bswap32 (val)); + } *inptrp = inptr; *outptrp = outptr; @@ -480,59 +361,6 @@ internal_ucs4le_loop (struct __gconv_step *step, return result; } -#if !_STRING_ARCH_unaligned -static inline int -__attribute ((always_inline)) -internal_ucs4le_loop_unaligned (struct __gconv_step *step, - struct __gconv_step_data *step_data, - const unsigned char **inptrp, - const unsigned char *inend, - unsigned char **outptrp, - const unsigned char *outend, - size_t *irreversible) -{ - const unsigned char *inptr = *inptrp; - unsigned char *outptr = *outptrp; - size_t n_convert = MIN (inend - inptr, outend - outptr) / 4; - int result; - -# if __BYTE_ORDER == __BIG_ENDIAN - /* Sigh, we have to do some real work. */ - size_t cnt; - - for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4, outptr += 4) - { - outptr[0] = inptr[3]; - outptr[1] = inptr[2]; - outptr[2] = inptr[1]; - outptr[3] = inptr[0]; - } - - *inptrp = inptr; - *outptrp = outptr; -# elif __BYTE_ORDER == __LITTLE_ENDIAN - /* Simply copy the data. */ - *inptrp = inptr + n_convert * 4; - *outptrp = __mempcpy (outptr, inptr, n_convert * 4); -# else -# error "This endianess is not supported." -# endif - - /* Determine the status. */ - if (*inptrp == inend) - result = __GCONV_EMPTY_INPUT; - else if (*inptrp + 4 > inend) - result = __GCONV_INCOMPLETE_INPUT; - else - { - assert (*outptrp + 4 > outend); - result = __GCONV_FULL_OUTPUT; - } - - return result; -} -#endif - static inline int __attribute ((always_inline)) @@ -612,12 +440,9 @@ ucs4le_internal_loop (struct __gconv_step *step, for (; inptr + 4 <= inend && outptr + 4 <= outend; inptr += 4) { - uint32_t inval; - + uint32_t inval = get32 (inptr); #if __BYTE_ORDER == __BIG_ENDIAN - inval = bswap_32 (*(const uint32_t *) inptr); -#else - inval = *(const uint32_t *) inptr; + inval = __builtin_bswap32 (inval); #endif if (__glibc_unlikely (inval > 0x7fffffff)) @@ -642,7 +467,7 @@ ucs4le_internal_loop (struct __gconv_step *step, return __GCONV_ILLEGAL_INPUT; } - *((uint32_t *) outptr) = inval; + put32 (outptr, inval); outptr += sizeof (uint32_t); } @@ -663,79 +488,6 @@ ucs4le_internal_loop (struct __gconv_step *step, return result; } -#if !_STRING_ARCH_unaligned -static inline int -__attribute ((always_inline)) -ucs4le_internal_loop_unaligned (struct __gconv_step *step, - struct __gconv_step_data *step_data, - const unsigned char **inptrp, - const unsigned char *inend, - unsigned char **outptrp, - const unsigned char *outend, - size_t *irreversible) -{ - int flags = step_data->__flags; - const unsigned char *inptr = *inptrp; - unsigned char *outptr = *outptrp; - int result; - - for (; inptr + 4 <= inend && outptr + 4 <= outend; inptr += 4) - { - if (__glibc_unlikely (inptr[3] > 0x80)) - { - /* The value is too large. We don't try transliteration here since - this is not an error because of the lack of possibilities to - represent the result. This is a genuine bug in the input since - UCS4 does not allow such values. */ - if (irreversible == NULL) - /* We are transliterating, don't try to correct anything. */ - return __GCONV_ILLEGAL_INPUT; - - if (flags & __GCONV_IGNORE_ERRORS) - { - /* Just ignore this character. */ - ++*irreversible; - continue; - } - - *inptrp = inptr; - *outptrp = outptr; - return __GCONV_ILLEGAL_INPUT; - } - -# if __BYTE_ORDER == __BIG_ENDIAN - outptr[3] = inptr[0]; - outptr[2] = inptr[1]; - outptr[1] = inptr[2]; - outptr[0] = inptr[3]; -# else - outptr[0] = inptr[0]; - outptr[1] = inptr[1]; - outptr[2] = inptr[2]; - outptr[3] = inptr[3]; -# endif - - outptr += 4; - } - - *inptrp = inptr; - *outptrp = outptr; - - /* Determine the status. */ - if (*inptrp == inend) - result = __GCONV_EMPTY_INPUT; - else if (*inptrp + 4 > inend) - result = __GCONV_INCOMPLETE_INPUT; - else - { - assert (*outptrp + 4 > outend); - result = __GCONV_FULL_OUTPUT; - } - - return result; -} -#endif - static inline int __attribute ((always_inline)) diff --git a/iconv/loop.c b/iconv/loop.c index 9d8a7cceb3..b2a1727ad4 100644 --- a/iconv/loop.c +++ b/iconv/loop.c @@ -58,12 +58,7 @@ #include #undef FCTNAME2 -#if _STRING_ARCH_unaligned || !defined DEFINE_UNALIGNED -# define FCTNAME2(name) name -#else -# define FCTNAME2(name) name##_unaligned -#endif -#define FCTNAME(name) FCTNAME2(name) +#define FCTNAME(name) name /* We need at least one byte for the next round. */ @@ -279,20 +274,9 @@ FCTNAME (LOOPFCT) (struct __gconv_step *step, } -/* Include the file a second time to define the function to handle - unaligned access. */ -#if !defined DEFINE_UNALIGNED && !_STRING_ARCH_unaligned \ - && MIN_NEEDED_INPUT != 1 && MAX_NEEDED_INPUT % MIN_NEEDED_INPUT == 0 \ - && MIN_NEEDED_OUTPUT != 1 && MAX_NEEDED_OUTPUT % MIN_NEEDED_OUTPUT == 0 -# undef unaligned - -# define DEFINE_UNALIGNED -# include "loop.c" -# undef DEFINE_UNALIGNED -#else -# if MAX_NEEDED_INPUT > 1 -# define SINGLE(fct) SINGLE2 (fct) -# define SINGLE2(fct) fct##_single +#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, @@ -302,37 +286,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 /* Building with -O3 GCC emits a `array subscript is above array bounds' warning. GCC BZ #64739 has been opened for this. */ @@ -347,14 +331,14 @@ SINGLE(LOOPFCT) (struct __gconv_step *step, inend = &bytebuf[inlen]; STORE_REST -# else +# else /* We don't have enough input for another complete input character. */ size_t inlen_after = inlen + (inend - inptr); assert (inlen_after <= sizeof (state->__value.__wchb)); for (; inlen < inlen_after; inlen++) state->__value.__wchb[inlen] = *inptr++; -# endif +# endif return __GCONV_INCOMPLETE_INPUT; } @@ -406,11 +390,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) { @@ -419,11 +403,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)); @@ -432,14 +416,13 @@ SINGLE(LOOPFCT) (struct __gconv_step *step, for (inlen = 0; inlen < inend - inptr; inlen++) state->__value.__wchb[inlen] = inptr[inlen]; inptr = inend; -# endif +# endif } return result; } -# undef SINGLE -# undef SINGLE2 -# endif +# undef SINGLE +# undef SINGLE2 # ifdef ONEBYTE_BODY @@ -471,4 +454,3 @@ gconv_btowc (struct __gconv_step *step, unsigned char c) #undef LOOP_NEED_STATE #undef LOOP_NEED_FLAGS #undef LOOP_NEED_DATA -#undef unaligned diff --git a/iconv/skeleton.c b/iconv/skeleton.c index 9423d3fc5a..61cff234ac 100644 --- a/iconv/skeleton.c +++ b/iconv/skeleton.c @@ -448,33 +448,6 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, size_t lirreversible = 0; size_t *lirreversiblep = irreversible ? &lirreversible : NULL; - /* The following assumes that encodings, which have a variable length - what might unalign a buffer even though it is an aligned in the - beginning, either don't have the minimal number of bytes as a divisor - of the maximum length or have a minimum length of 1. This is true - for all known and supported encodings. - We use && instead of || to combine the subexpression for the FROM - encoding and for the TO encoding, because usually one of them is - INTERNAL, for which the subexpression evaluates to 1, but INTERNAL - buffers are always aligned correctly. */ -#define POSSIBLY_UNALIGNED \ - (!_STRING_ARCH_unaligned \ - && (((FROM_LOOP_MIN_NEEDED_FROM != 1 \ - && FROM_LOOP_MAX_NEEDED_FROM % FROM_LOOP_MIN_NEEDED_FROM == 0) \ - && (FROM_LOOP_MIN_NEEDED_TO != 1 \ - && FROM_LOOP_MAX_NEEDED_TO % FROM_LOOP_MIN_NEEDED_TO == 0)) \ - || ((TO_LOOP_MIN_NEEDED_FROM != 1 \ - && TO_LOOP_MAX_NEEDED_FROM % TO_LOOP_MIN_NEEDED_FROM == 0) \ - && (TO_LOOP_MIN_NEEDED_TO != 1 \ - && TO_LOOP_MAX_NEEDED_TO % TO_LOOP_MIN_NEEDED_TO == 0)))) -#if POSSIBLY_UNALIGNED - int unaligned; -# define GEN_unaligned(name) GEN_unaligned2 (name) -# define GEN_unaligned2(name) name##_unaligned -#else -# define unaligned 0 -#endif - #ifdef PREPARE_LOOP PREPARE_LOOP #endif @@ -514,18 +487,6 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, } #endif -#if POSSIBLY_UNALIGNED - unaligned = - ((FROM_DIRECTION - && ((uintptr_t) inptr % FROM_LOOP_MIN_NEEDED_FROM != 0 - || ((data->__flags & __GCONV_IS_LAST) - && (uintptr_t) outbuf % FROM_LOOP_MIN_NEEDED_TO != 0))) - || (!FROM_DIRECTION - && (((data->__flags & __GCONV_IS_LAST) - && (uintptr_t) outbuf % TO_LOOP_MIN_NEEDED_TO != 0) - || (uintptr_t) inptr % TO_LOOP_MIN_NEEDED_FROM != 0))); -#endif - while (1) { /* Remember the start value for this round. */ @@ -543,34 +504,14 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, SAVE_RESET_STATE (1); #endif - if (__glibc_likely (!unaligned)) - { - if (FROM_DIRECTION) - /* Run the conversion loop. */ - status = FROM_LOOP (step, data, inptrp, inend, &outbuf, outend, - lirreversiblep EXTRA_LOOP_ARGS); - else - /* Run the conversion loop. */ - status = TO_LOOP (step, data, inptrp, inend, &outbuf, outend, - lirreversiblep EXTRA_LOOP_ARGS); - } -#if POSSIBLY_UNALIGNED + if (FROM_DIRECTION) + /* Run the conversion loop. */ + status = FROM_LOOP (step, data, inptrp, inend, &outbuf, outend, + lirreversiblep EXTRA_LOOP_ARGS); else - { - if (FROM_DIRECTION) - /* Run the conversion loop. */ - status = GEN_unaligned (FROM_LOOP) (step, data, inptrp, inend, - &outbuf, outend, - lirreversiblep - EXTRA_LOOP_ARGS); - else - /* Run the conversion loop. */ - status = GEN_unaligned (TO_LOOP) (step, data, inptrp, inend, - &outbuf, outend, - lirreversiblep - EXTRA_LOOP_ARGS); - } -#endif + /* Run the conversion loop. */ + status = TO_LOOP (step, data, inptrp, inend, &outbuf, outend, + lirreversiblep EXTRA_LOOP_ARGS); /* If we were called as part of an error handling module we don't do anything else here. */ @@ -635,41 +576,18 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data, SAVE_RESET_STATE (0); #endif - if (__glibc_likely (!unaligned)) - { - if (FROM_DIRECTION) - /* Run the conversion loop. */ - nstatus = FROM_LOOP (step, data, inptrp, inend, - &outbuf, outerr, - lirreversiblep - EXTRA_LOOP_ARGS); - else - /* Run the conversion loop. */ - nstatus = TO_LOOP (step, data, inptrp, inend, - &outbuf, outerr, - lirreversiblep - EXTRA_LOOP_ARGS); - } -#if POSSIBLY_UNALIGNED + if (FROM_DIRECTION) + /* Run the conversion loop. */ + nstatus = FROM_LOOP (step, data, inptrp, inend, + &outbuf, outerr, + lirreversiblep + EXTRA_LOOP_ARGS); else - { - if (FROM_DIRECTION) - /* Run the conversion loop. */ - nstatus = GEN_unaligned (FROM_LOOP) (step, data, - inptrp, inend, - &outbuf, - outerr, - lirreversiblep - EXTRA_LOOP_ARGS); - else - /* Run the conversion loop. */ - nstatus = GEN_unaligned (TO_LOOP) (step, data, - inptrp, inend, - &outbuf, outerr, - lirreversiblep - EXTRA_LOOP_ARGS); - } -#endif + /* Run the conversion loop. */ + nstatus = TO_LOOP (step, data, inptrp, inend, + &outbuf, outerr, + lirreversiblep + EXTRA_LOOP_ARGS); /* We must run out of output buffer space in this rerun. */ From patchwork Mon Feb 13 13:55:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 64894 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1155A388B694 for ; Mon, 13 Feb 2023 13:58:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1155A388B694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676296691; bh=UikypltsBW9EQv2i6Q9kmDGEzAhzKIIaZkGxyrzI6ew=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=MefAsfHhlP6zNWHpte6lk/cqruN2muTM7M7FmmexUsiG+WzPXfTKI3Dhzg4oeIH/6 l/5mWgRBqdap42hcI2Aa4PAreLUF9JngT1npiNHhFo7VbIZaPW6yfMDEB2vOxxxI3t 1Y9Dky6akoYlyufatKz2y9ZFtmnIEq82X9vAgUng= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc34.google.com (mail-oo1-xc34.google.com [IPv6:2607:f8b0:4864:20::c34]) by sourceware.org (Postfix) with ESMTPS id 12B00382E6AB for ; Mon, 13 Feb 2023 13:56:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 12B00382E6AB Received: by mail-oo1-xc34.google.com with SMTP id k15-20020a4adfaf000000b00517450f9bd7so1186591ook.8 for ; Mon, 13 Feb 2023 05:56:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UikypltsBW9EQv2i6Q9kmDGEzAhzKIIaZkGxyrzI6ew=; b=jAe1x5A0o5hWQNwKB55imigRM39aAHzscrDfV/UQSKegfR7n1m+pv4MeGwIlnlBE6h AnZjZkspK3K9fjWjDEZaw5d5P027igTygAAm4DkSjo7G/EslRJVnDbNAsPfTustQf+8L 94feo8eqEyo+pUAdnbgjAbIUI+pE+Z9Xa8TTpKiZGcoP01tRmjJ7ZA4fSbAlSmnDl/iA nYKQBn0hKntGZ8RI4S6vuWrzvTG49wHhwvrm5fOSYjbMEt5KThKGc/WeqPY/2qhZ6xAw LxcVypuoLWrxjJPpc/HRs1QqfAIuNsFMZd/5jygWco0by9MHdgHCJmiK9BUbB12LXeOG HRQg== X-Gm-Message-State: AO0yUKUPEF+pxXhshAD0DhV4U3TA1DrvBLh04jKnaYZbmcxZRndJBZjE wXeHOUtlKNvuEEVDjdHxxAZZ8Rl35ftiJAWK06U= X-Google-Smtp-Source: AK7set91xe8SkienO1bXtUVSoqWThjcrYplfMm43r2FHn8YfnCTYNF8Q/ZkN8OibOzpA2Goc5hfkOA== X-Received: by 2002:a4a:255b:0:b0:51a:cab:cbef with SMTP id v27-20020a4a255b000000b0051a0cabcbefmr11041453ooe.4.1676296575692; Mon, 13 Feb 2023 05:56:15 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:f662:138b:cd0c:7b7a:8860]) by smtp.gmail.com with ESMTPSA id y11-20020a4ade0b000000b0051762a73553sm4797168oot.18.2023.02.13.05.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 05:56:15 -0800 (PST) To: libc-alpha@sourceware.org, Wilco Dijkstra Subject: [PATCH 7/7] string: Remove string_private.h Date: Mon, 13 Feb 2023 10:55:58 -0300 Message-Id: <20230213135558.3328727-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> References: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Now that _STRING_ARCH_unaligned is not used anymore. Reviewed-by: Wilco Dijkstra --- include/string.h | 3 --- sysdeps/aarch64/string_private.h | 20 -------------------- sysdeps/generic/string_private.h | 21 --------------------- sysdeps/m68k/m680x0/m68020/string_private.h | 21 --------------------- sysdeps/s390/string_private.h | 20 -------------------- sysdeps/x86/string_private.h | 20 -------------------- 6 files changed, 105 deletions(-) delete mode 100644 sysdeps/aarch64/string_private.h delete mode 100644 sysdeps/generic/string_private.h delete mode 100644 sysdeps/m68k/m680x0/m68020/string_private.h delete mode 100644 sysdeps/s390/string_private.h delete mode 100644 sysdeps/x86/string_private.h diff --git a/include/string.h b/include/string.h index a9120ff37c..673cfd7272 100644 --- a/include/string.h +++ b/include/string.h @@ -55,9 +55,6 @@ extern char *__strerror_l (int __errnum, locale_t __loc); extern const char *__sigdescr_np (int __errnum); libc_hidden_proto (__sigdescr_np) - -/* Get _STRING_ARCH_unaligned. */ -#include #endif #include diff --git a/sysdeps/aarch64/string_private.h b/sysdeps/aarch64/string_private.h deleted file mode 100644 index 8fdfcdf44b..0000000000 --- a/sysdeps/aarch64/string_private.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Define _STRING_ARCH_unaligned. AArch64 version. - Copyright (C) 2016-2023 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* AArch64 implementations support efficient unaligned access. */ -#define _STRING_ARCH_unaligned 1 diff --git a/sysdeps/generic/string_private.h b/sysdeps/generic/string_private.h deleted file mode 100644 index a1a62b3a46..0000000000 --- a/sysdeps/generic/string_private.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Define _STRING_ARCH_unaligned. Generic version. - Copyright (C) 2016-2023 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* Define to 1 if architecture can access unaligned multi-byte - variables. */ -#define _STRING_ARCH_unaligned 0 diff --git a/sysdeps/m68k/m680x0/m68020/string_private.h b/sysdeps/m68k/m680x0/m68020/string_private.h deleted file mode 100644 index 04c4800244..0000000000 --- a/sysdeps/m68k/m680x0/m68020/string_private.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Define _STRING_ARCH_unaligned. m680x0 version, x >= 2. - Copyright (C) 2016-2023 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* Tell the generic inline macros that unaligned memory access is - possible. */ -#define _STRING_ARCH_unaligned 1 diff --git a/sysdeps/s390/string_private.h b/sysdeps/s390/string_private.h deleted file mode 100644 index 3591f83878..0000000000 --- a/sysdeps/s390/string_private.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Define _STRING_ARCH_unaligned. S/390 version. - Copyright (C) 2016-2023 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* The s390 processors can access unaligned multi-byte variables. */ -#define _STRING_ARCH_unaligned 1 diff --git a/sysdeps/x86/string_private.h b/sysdeps/x86/string_private.h deleted file mode 100644 index c6a9d9bef9..0000000000 --- a/sysdeps/x86/string_private.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Define _STRING_ARCH_unaligned. i486/x86-64 version. - Copyright (C) 2016-2023 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* The ix86 processors can access unaligned multi-byte variables. */ -#define _STRING_ARCH_unaligned 1