From patchwork Mon Feb 7 20:16:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 1589560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=ktPCNN4I; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jsy8x2qrQz9sFN for ; Tue, 8 Feb 2022 07:16:49 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F1287385841C for ; Mon, 7 Feb 2022 20:16:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F1287385841C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1644265007; bh=XTnQYM9m0cfhXhwg1JzhCRxVGeKM9NaHiaMBtacvwYs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ktPCNN4Iz5k2fffh7v99HPQNkUq2TtxsEc7Z9KtaBK2er/2Xc7AhzQGqxq3t1vSk3 ShkePIoL9i7K9NahZaPz3LaWKXjs57e+N2w/wE7l2mpeHVasBjY3rHPS8mfG/dpGF5 Ugqq557zVCY0wzdLVsDG1kGiGmtfvnh8THP3NKpQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id 397DB3858C83 for ; Mon, 7 Feb 2022 20:16:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 397DB3858C83 Received: by mail-il1-x12a.google.com with SMTP id z18so12124359ilp.3 for ; Mon, 07 Feb 2022 12:16:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XTnQYM9m0cfhXhwg1JzhCRxVGeKM9NaHiaMBtacvwYs=; b=zhZCtZuXx3gnnW42QZh1oOydmj6UjcS9tWAAOtMKIzLeOqo6ttHEaplRQ9AhydjeM8 CWlCaaTA7tshol6ONC0WfNOJ3B7mpYFMjXY8J1V+pp5yZ+x6iI36Pc2H4bcxNCQ9NyNZ vWhlHHSzkaOvUuQtb16wxXmj3iOyzWa6GfebkYJmkZafMdf2gzCQJZWt15KLVNhQTZ1N 2D05f2DIXzB586digc9t/REMHt2ZvcIc27b3hwbgThpzNXX/8TJldO3tL/JeBLk32l1F c59KMPk9B2XnXjNq7z2oHroRwrurGOjZu/9aGwu3TAh/mnrGQlTh3XG0/2jhPOA9bUsk k2Ow== X-Gm-Message-State: AOAM531/mc7DLjEDmzS1d6t2z9cvMUHiWAHnWc/+HApSBZKGFWBKsXDs Kn+y1F22hxf4pg+BLVMcApOqPV5MibM= X-Google-Smtp-Source: ABdhPJzFf/o6kmGStrON0ItH8d1CwSufEaZHP3JxXHf8sBVNnBMtVRfko4bMr8/EjTkPRUjgbbVAKA== X-Received: by 2002:a05:6e02:180f:: with SMTP id a15mr600829ilv.8.1644264991404; Mon, 07 Feb 2022 12:16:31 -0800 (PST) Received: from localhost.localdomain (node-17-161.flex.volo.net. [76.191.17.161]) by smtp.googlemail.com with ESMTPSA id m5sm6504228iov.36.2022.02.07.12.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 12:16:30 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v1] String: Ensure 'MIN_PAGE_SIZE' is factor of 'getpagesize' Date: Mon, 7 Feb 2022 14:16:24 -0600 Message-Id: <20220207201624.601598-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.25.1 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, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Noah Goldstein via Libc-alpha From: Noah Goldstein Reply-To: Noah Goldstein Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" When 'TEST_LEN' was defined as (4096 * 3) the allocation size Would not be a factor of system page size if it was > 4096. --- string/test-strcmp.c | 14 +++++++------- string/test-strncmp.c | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/string/test-strcmp.c b/string/test-strcmp.c index eacbdc8857..0abce769d0 100644 --- a/string/test-strcmp.c +++ b/string/test-strcmp.c @@ -16,7 +16,7 @@ License along with the GNU C Library; if not, see . */ -#define TEST_LEN (4096 * 3) +#define TEST_LEN (getpagesize () * 3) #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ()) #define TEST_MAIN @@ -393,7 +393,7 @@ int test_main (void) { size_t i, j; - + const size_t test_len = MIN(TEST_LEN, 3 * 4096); test_init (); check(); check2 (); @@ -435,7 +435,7 @@ test_main (void) for (j = 0; j < 160; ++j) { - for (i = 0; i < TEST_LEN;) + for (i = 0; i < test_len;) { do_test (getpagesize () - j - 1, 0, i, 127, 0); do_test (getpagesize () - j - 1, 0, i, 127, 1); @@ -461,17 +461,17 @@ test_main (void) { i += 7; } - else if (i + 161 < TEST_LEN) + else if (i + 161 < test_len) { i += 31; i *= 17; i /= 16; - if (i + 161 > TEST_LEN) + if (i + 161 > test_len) { - i = TEST_LEN - 160; + i = test_len - 160; } } - else if (i + 32 < TEST_LEN) + else if (i + 32 < test_len) { i += 7; } diff --git a/string/test-strncmp.c b/string/test-strncmp.c index 1a3cee1792..1966bde3fe 100644 --- a/string/test-strncmp.c +++ b/string/test-strncmp.c @@ -16,7 +16,7 @@ License along with the GNU C Library; if not, see . */ -#define TEST_LEN (4096 * 3) +#define TEST_LEN (getpagesize () * 3) #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ()) #define TEST_MAIN @@ -430,7 +430,7 @@ check_overflow (void) const size_t of_masks[] = { ULONG_MAX, LONG_MIN, ULONG_MAX - (ULONG_MAX >> 2), ((size_t)LONG_MAX) >> 1 }; - + const size_t test_len = MIN(test_len, 3 * 4096); for (of_idx = 0; of_idx < sizeof (of_masks) / sizeof (of_masks[0]); ++of_idx) { of_mask = of_masks[of_idx]; @@ -484,7 +484,7 @@ check_overflow (void) of_mask - j * 2, 0, 127, -1); } - for (i = 1; i < TEST_LEN; i += i) + for (i = 1; i < test_len; i += i) { do_test_n (j, 0, i - 1, of_mask, 0, 127, 0); do_test_n (j, 0, i - 1, of_mask, 0, 127, 1); @@ -540,7 +540,7 @@ int test_main (void) { size_t i, j; - + const size_t test_len = MIN(test_len, 3 * 4096); test_init (); check1 (); @@ -608,7 +608,7 @@ test_main (void) for (j = 0; j < 160; ++j) { - for (i = 0; i < TEST_LEN;) + for (i = 0; i < test_len;) { do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 0); do_test_n (getpagesize () - j - 1, 0, i, i + 1, 0, 127, 1); @@ -677,17 +677,17 @@ test_main (void) { i += 7; } - else if (i + 161 < TEST_LEN) + else if (i + 161 < test_len) { i += 31; i *= 17; i /= 16; - if (i + 161 > TEST_LEN) + if (i + 161 > test_len) { - i = TEST_LEN - 160; + i = test_len - 160; } } - else if (i + 32 < TEST_LEN) + else if (i + 32 < test_len) { i += 7; }