From patchwork Thu Jan 18 17:53:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 124996 Delivered-To: patch@linaro.org Received: by 10.46.64.27 with SMTP id n27csp228311lja; Thu, 18 Jan 2018 09:53:52 -0800 (PST) X-Google-Smtp-Source: ACJfBosHVBxlWNMJ5OWHmjNYz1IqDL2qShY5rcjk7HdpWngGZIL1cXXoivaaocX215wrctjePTlz X-Received: by 2002:a17:902:d90a:: with SMTP id c10-v6mr175875plz.200.1516298032645; Thu, 18 Jan 2018 09:53:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516298032; cv=none; d=google.com; s=arc-20160816; b=OFQG34o1git+06WJU77winVg3IBh7k+b+JD2sAdeAofi6dsf4kDNUewn6yPYtpwxhW j2ocQt4w59oG63ukM427QyU4s/AsuXK1QghifDFnYlL/WDGy/6Z5sJ8lmWsxziEv99rc OH2bS0HS/vlMFp1vEdSoPgtyBrPHOiUp/3xZzxjKykbIie9fzQlNWAJ+pSI0+CqxGYRV gto/XNOBqpFP2YIP1uqqnksFhr5W/qN65V18NTBfpG3/tAou96seYXQrPl37YIfBsdu6 oo3L9t1p5wuK2e3Zwmkrn/wollWgNFxijgrYCSs2PK9HMk7SWlfjPrQluNxdQCd7n+N4 OImw== 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: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=2KqttKVz2kzitFzn0WgJ5D+8o8IB1V2pE3mMpog+3uo=; b=wcET3FXTrY3BC/ZOxOibfRFbPqL4OimZZuWCvA8SCgapmt4gOPI5nTrDhQuwXT0qT9 FUOkOA0QE0JAehJbL1mtiUcP4UYWSE/C0t9L83VYWnrraxHfbzqUz7ZG4BjHW2T3ZHOZ Kcvh1EWTV/aNsA1+6Z+gXDteiKK+EeUQZobBx5A2zqh8LdCnm4Lr+6Rui7jZJrQ0tafi HyCfglwgS+WtHB8zgbdbgL6XD95faa3j87h73HwFlBtxpGqcceSRoXWDHaN9gAALTDIH NQg5nWYSFcawtid5Adda0h5dyJeIjM/vpmOqtr/nhQMXl2fqu2Wv0WR3PTb86381p4KL jZtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=yyAfebZT; spf=pass (google.com: domain of libc-alpha-return-89323-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-89323-patch=linaro.org@sourceware.org; dmarc=fail (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 b36-v6si76063pli.740.2018.01.18.09.53.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 09:53:52 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-89323-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=yyAfebZT; spf=pass (google.com: domain of libc-alpha-return-89323-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-89323-patch=linaro.org@sourceware.org; dmarc=fail (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=arV3/MOHA0yvZXEgJUEtZlwgGFRDKrx 4DA96YPrOrQ+9RIFGFO8rqYydD4wtSps9sdjYwv34jlQE6B/oiffqbUFyhaLvMiS nb3tUWLTOa7/Eox+iTuPlpLunhjjAfG0Ap4mAoqtvR30jdx06qu/Ba5HtfO2EORJ YFryPEzViBbU= 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=yu2bd+3ySBTMNQKVzc9wW8RJDFs=; b=yyAfe bZThe4qY3u8sGvf+fXv/UCNBSYywupkcWJ+cKMThVzeut/pzH2/TGX/7jDatp4GZ wSShGMyVNuircbO9XE79tozfmcQn/sYOrF3Z0v001W0ueW37F5oOFVhjZ/w+ZpQT ZJdZ09wOZk+ZZtQFvM44h2X3POa3uC50syr4zs= Received: (qmail 78648 invoked by alias); 18 Jan 2018 17:53:34 -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 78617 invoked by uid 89); 18 Jan 2018 17:53:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:209.85.216.193, H*RU:209.85.216.193 X-HELO: mail-qt0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=2KqttKVz2kzitFzn0WgJ5D+8o8IB1V2pE3mMpog+3uo=; b=EpJUI1urOPThPPwa1paLhCSy0oTW7Dno9XNPdH6GYd1t8Lz4Z524v+k/deQUYcw+Qs 70fg+FvJPJvXMKpUsOFnx+KliyTY4OXtPPJDMV5eJuQe7+UuzTmUuG3aOZQbGIVSuBx4 mOXZaIWdo9JcubEJdKkB9gqBBRLfH5+drl05cxHKgQP7AHd6mPElJZ7b3GNrpxlySXcf 6cibIjtdOZuOinxo+3fnDz7l6Bvv2/rRi8Mm3lbSaOT3pQvs3jz/46X2qqQqXSE64pqQ Yzj1BsGpi0cGUDc2ANB9q6/K2PtHhJrDnqlDtsLpEoTGHqKMdMZIcBPiCDxj7s0gigxq B90A== X-Gm-Message-State: AKwxytc3qD85BYMtgLbupuQFc+KFp2VET1kooT1fJjIMjT0ydxfrqxrs WRrznyHPfsFXGnFXcKXjlrASMtK3al8= X-Received: by 10.200.15.141 with SMTP id b13mr26769245qtk.301.1516298010632; Thu, 18 Jan 2018 09:53:30 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/7] stdlib: Adjust tst-qsort{2} to libsupport Date: Thu, 18 Jan 2018 15:53:16 -0200 Message-Id: <1516298002-4618-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1516298002-4618-1-git-send-email-adhemerval.zanella@linaro.org> References: <1516298002-4618-1-git-send-email-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.7.4 diff --git a/stdlib/tst-qsort.c b/stdlib/tst-qsort.c index 2b26e74..c3230fd 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 10d1685..595875d 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