From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oo1-xc2b.google.com with SMTP id r192-20020a4a37c9000000b00517677496d0so1181566oor.13 for ; Mon, 13 Feb 2023 05:56:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=5X3V4gc/RB6i4215oZIIHFeCMg277b5TgmujLqutqoQ=; b=oydb7vRntrbttgF4iuOzxPmUGgovpvwqSFW1mSwWq/BTjcDNX1xpkU9hgLefR4uZAM 1thP/eRnG0MddRRf12xQniLQI1bgzuFHTLBLuNufWo5tLt2hbQKF1IYZY1tYlbcuAi6M MqqsWCk1mjIHfukm8JB4goCJDrxHWZk+t6i/tHi2AbN3LSh9K5BpkI7upq1ERFqH5hvQ 6tANkJjKPMOLNgERD2f4o6T3Nu+9G2OWoT/4mTcjYA8xFUl/8FQSkn3pi7FI/yJXhsUL FYejsbiZNkdHAK2Zz7rVX+v5gbd6fx/aF5MzUmKgA5otSIX0MLKbu10418VPiVLY9mky izwA== 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) From: Adhemerval Zanella 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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. --- 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; -- 2.34.1