From patchwork Fri Aug 31 20:42:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 145691 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1210305ljw; Fri, 31 Aug 2018 13:43:09 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaAP4/unVOTCPlRzYK2azOeMCRAzK7GR4YzBWBvX9LLxq0Cx/o7kQR5wYN2OFYFn38smQH2 X-Received: by 2002:a62:280a:: with SMTP id o10-v6mr17549513pfo.129.1535748189585; Fri, 31 Aug 2018 13:43:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535748189; cv=none; d=google.com; s=arc-20160816; b=IwGgRBzNInHhQWoCtjIVJfFtCA1VPfMgIBa9yoaqRerpoMQqI90/RwbBhfGXEsXb9y cPgqGSyJae0UqpkaZ6QMJtSV7geHLeuaIOPqVXMSzp2g4/U4qISj76ZWrV6LWmq8axSZ ODfXuqCowjW/XbS+ZYS9BMKm98CxZpaBUX2A2UKpFRi0FTdQC8NslB7/oIhzQfr6XfC3 Rufo7vJgKXv1iMR/ikHjYiqjA2bP3+ZKCiDGwGmkfEs6atdfitltbjkNZ3qZMvSiX0WT AsTMRoApyC8LsE+Rw5NtMXLEVgprH9DLVXHjJSS8FbDhaVMDOcv0AX6W/Z+K0Zi4lTDf 76Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature:arc-authentication-results; bh=3OAapWYG61530zC9wJnnE1vm2sV/0r5pO7729wZYFWE=; b=dml07VROJyuctFP+08svNB+w9JqB3tWqYrsRC3wrIogi3lj0HuFd7pbM++ASs9kf9Y LKl6zZ4qHEyet75jFrSUITlpjo06L6Y52O7Jxl8tqXkvblNZCBJmplwGbjl+pz1gnarG O/B7JXxDQyoIEhYaknnumgss+CQtxdHaDHRU3FcNC7ohgHGWAuhZOi1c+E0zi/sONYxA w9DX5LkbuPlretBG7BW4SdERn4ny4BjcI2jiw46fB6r4NhATA+b/e5H5cFDl7n2H04kW ylMD4hTK40jRbEN9mINTAyw9ZN7Dn/ln1gdXaFFR4wOIyHGyqfwzlmGb+jed1Wietzfx YgwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=rTxyjBuO; dkim=pass header.i=@linaro.org header.s=google header.b=AQxePXhD; spf=pass (google.com: domain of libc-alpha-return-95623-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95623-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id c133-v6si11114678pfb.296.2018.08.31.13.43.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Aug 2018 13:43:09 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-95623-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=rTxyjBuO; dkim=pass header.i=@linaro.org header.s=google header.b=AQxePXhD; spf=pass (google.com: domain of libc-alpha-return-95623-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-95623-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Yk6q4oPRKIP0NUkG4HPbM5xLch8VzcP NGlB+4Bj6wQZJy8nWsKjfdoPYSaJcqpje069di5olD3Y1CMc4maQHCOZk/Fcf++q erGFJK44h7KREO+GYnyO4jbDH3wD+rxXPji81TIf51MnB29QmOk1MXN6OGy64DRv E0RvsScR4LMs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=5R2fV5aR3SXPfNVFOFxefoKnsY0=; b=rTxyj BuOluQeVskLG14m6qGZl7otz551y1se9vx8CEZ+0tF/I3HHzzo8dfzUPPHt9FaNN 1glrB6tJjgLH4/K32iOpGQ0SgIJk7XQQlfijoZS6n64C2pssVmzPM/qPue1Twug0 mIeKggFZ4ZFrihWApXMAtes/vy0SDgijSxHfIg= Received: (qmail 53915 invoked by alias); 31 Aug 2018 20:42:51 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk 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 53803 invoked by uid 89); 31 Aug 2018 20:42:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SEM_URI, SEM_URIRED, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Received:sk:b15-v6m, 1024 X-HELO: mail-qt0-f182.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=3OAapWYG61530zC9wJnnE1vm2sV/0r5pO7729wZYFWE=; b=AQxePXhDMUt5ErJv6w3Ovob4vS2Ido66mNtfXLCex904zV7S/6voXEXEeTfI5l+HA0 A3+q1BM8LLkgWIyNuvWS63pwBJ0rchbRozuLuAi9WYkQR3VSVVzSrrW0LNdYpciviRV2 NthETA5miNHelAiUiurStH1SnrBQiibqKRWGo= Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 1/7] stdlib: Adjust tst-qsort{2} to libsupport Date: Fri, 31 Aug 2018 17:42:32 -0300 Message-Id: <20180831204238.10626-2-adhemerval.zanella@linaro.org> In-Reply-To: <20180831204238.10626-1-adhemerval.zanella@linaro.org> References: <20180831204238.10626-1-adhemerval.zanella@linaro.org> * stdlib/tst-qsort.c: Use libsupport. * stdlib/tst-qsort2.c: Likewise. --- stdlib/tst-qsort.c | 45 ++++++++++++++++++++++----------------------- stdlib/tst-qsort2.c | 44 +++++++++++++++++++++----------------------- 2 files changed, 43 insertions(+), 46 deletions(-) -- 2.17.1 diff --git a/stdlib/tst-qsort.c b/stdlib/tst-qsort.c index 2b26e74d0b..c3230fd10e 100644 --- a/stdlib/tst-qsort.c +++ b/stdlib/tst-qsort.c @@ -3,6 +3,8 @@ #include #include +#include + struct big { char c[4 * 1024]; }; struct big *array; @@ -10,7 +12,7 @@ struct big *array_end; static int align_check; -int +static int compare (void const *a1, void const *b1) { struct big const *a = a1; @@ -19,37 +21,34 @@ compare (void const *a1, void const *b1) if (!align_check) align_check = TEST_STACK_ALIGN () ? -1 : 1; - if (! (array <= a && a < array_end - && array <= b && b < array_end)) - { - exit (EXIT_FAILURE); - } - return b->c[0] - a->c[0]; + TEST_VERIFY_EXIT (array <= a && a < array_end + && array <= b && b < array_end); + + return (b->c[0] - a->c[0]) > 0; } int -main (int argc, char **argv) +do_test (void) { - size_t i; - size_t array_members = argv[1] ? atoi (argv[1]) : 50; - array = (struct big *) malloc (array_members * sizeof *array); - if (array == NULL) + const size_t sizes[] = { 8, 16, 24, 48, 96, 192, 384 }; + const size_t sizes_len = sizeof (sizes) / sizeof (sizes[0]); + + for (size_t s = 0; s < sizes_len; s++) { - puts ("no memory"); - exit (EXIT_FAILURE); - } + array = (struct big *) malloc (sizes[s] * sizeof *array); + TEST_VERIFY_EXIT (array != NULL); - array_end = array + array_members; - for (i = 0; i < array_members; i++) - array[i].c[0] = i % 128; + array_end = array + sizes[s]; + for (size_t i = 0; i < sizes[s]; i++) + array[i].c[0] = i % 128; - qsort (array, array_members, sizeof *array, compare); + qsort (array, sizes[s], sizeof *array, compare); + TEST_VERIFY_EXIT (align_check != -1); - if (align_check == -1) - { - puts ("stack not sufficiently aligned"); - exit (EXIT_FAILURE); + free (array); } return 0; } + +#include diff --git a/stdlib/tst-qsort2.c b/stdlib/tst-qsort2.c index 10d16852b0..595875dcae 100644 --- a/stdlib/tst-qsort2.c +++ b/stdlib/tst-qsort2.c @@ -1,11 +1,13 @@ #include #include -char *array; -char *array_end; -size_t member_size; +#include -int +static char *array; +static char *array_end; +static size_t member_size; + +static int compare (const void *a1, const void *b1) { const char *a = a1; @@ -25,7 +27,7 @@ compare (const void *a1, const void *b1) return 0; } -int +static int test (size_t nmemb, size_t size) { array = malloc (nmemb * size); @@ -66,24 +68,20 @@ test (size_t nmemb, size_t size) return 0; } -int -main (int argc, char **argv) +static int +do_test (void) { - int ret = 0; - if (argc >= 3) - ret |= test (atoi (argv[1]), atoi (argv[2])); - else - { - ret |= test (10000, 1); - ret |= test (200000, 2); - ret |= test (2000000, 3); - ret |= test (2132310, 4); - ret |= test (1202730, 7); - ret |= test (1184710, 8); - ret |= test (272710, 12); - ret |= test (14170, 32); - ret |= test (4170, 320); - } + test (10000, 1); + test (200000, 2); + test (2000000, 3); + test (2132310, 4); + test (1202730, 7); + test (1184710, 8); + test (272710, 12); + test (14170, 32); + test (4170, 320); - return ret; + return 0; } + +#include