From patchwork Mon Aug 19 19:47:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 19338 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gh0-f198.google.com (mail-gh0-f198.google.com [209.85.160.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 981EC2469E for ; Mon, 19 Aug 2013 19:47:24 +0000 (UTC) Received: by mail-gh0-f198.google.com with SMTP id r13sf3012184ghr.9 for ; Mon, 19 Aug 2013 12:47:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=lDzI89DpW+0qLZulHk9oDNQua33Pqh4SuE437+WVZog=; b=gPSIH2DHPmKA0q7ENjP0dAOHeSFaGPrUyx8bHW1jdg+2iAV3XKUD9hY4B5PLRFnCNu rQriXczJO/dCEL9YMVcQ7xbyJnT78tO1tdA/oMnmAwgM2+Ux/w9ETm9wiVrAr5lYgCJP mnBpcSXcGpZVfE6E2Rpp0/uNL1RnJKsnC/ovH16AGNXyvHp7qJqgHhgWvHIU3iXh7ses cd/AiYRe6EO1FCDq2v66b6kToCh9LVeOl/50afUuyCU+p/sb8/kHmmlEpeTEKI/E6L8W U9dUFsWo63QWMQ4xRTWvUiB6trqjAhf87PxvW6ApQXZrTAiN3ET0rLevjlNCnzvd/YPO GN+g== X-Received: by 10.236.30.129 with SMTP id k1mr747145yha.56.1376941644391; Mon, 19 Aug 2013 12:47:24 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.48.49 with SMTP id i17ls1921971qen.44.gmail; Mon, 19 Aug 2013 12:47:24 -0700 (PDT) X-Received: by 10.220.11.7 with SMTP id r7mr14994015vcr.12.1376941644265; Mon, 19 Aug 2013 12:47:24 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id se5si2737143vdc.23.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Aug 2013 12:47:24 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id hz10so3438618vcb.12 for ; Mon, 19 Aug 2013 12:47:24 -0700 (PDT) X-Gm-Message-State: ALoCoQkhLWmuIZr2byPRaUPA2EKTpAN7e19q3FGd4vzXEuk6ky01o4QiX/FOks+6F6+GQa9pWLKQ X-Received: by 10.58.146.71 with SMTP id ta7mr3735090veb.23.1376941644154; Mon, 19 Aug 2013 12:47:24 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp114196vcz; Mon, 19 Aug 2013 12:47:23 -0700 (PDT) X-Received: by 10.15.34.65 with SMTP id d41mr7258185eev.45.1376941643085; Mon, 19 Aug 2013 12:47:23 -0700 (PDT) Received: from mail-ee0-f46.google.com (mail-ee0-f46.google.com [74.125.83.46]) by mx.google.com with ESMTPS id z8si11030807eee.293.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Aug 2013 12:47:23 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.46 is neither permitted nor denied by best guess record for domain of will.newton@linaro.org) client-ip=74.125.83.46; Received: by mail-ee0-f46.google.com with SMTP id c13so2330287eek.19 for ; Mon, 19 Aug 2013 12:47:22 -0700 (PDT) X-Received: by 10.14.200.130 with SMTP id z2mr6148263een.14.1376941642567; Mon, 19 Aug 2013 12:47:22 -0700 (PDT) Received: from localhost.localdomain (cpc6-seac21-2-0-cust453.7-2.cable.virginmedia.com. [82.1.113.198]) by mx.google.com with ESMTPSA id l47sm19504888eex.15.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 19 Aug 2013 12:47:21 -0700 (PDT) Message-ID: <52127647.6050509@linaro.org> Date: Mon, 19 Aug 2013 20:47:19 +0100 From: Will Newton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 MIME-Version: 1.0 To: libc-alpha@sourceware.org CC: patches@linaro.org Subject: [PATCH 7/7] malloc: Add memalign test. X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , ChangeLog: 2013-08-16 Will Newton * malloc/Makefile: Add tst-memalign. * malloc/tst-memalign.c: New file. --- malloc/Makefile | 2 +- malloc/tst-memalign.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 malloc/tst-memalign.c diff --git a/malloc/Makefile b/malloc/Makefile index 17d146b..d482879 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -27,7 +27,7 @@ headers := $(dist-headers) obstack.h mcheck.h tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \ tst-mallocstate tst-mcheck tst-mallocfork tst-trim1 \ tst-malloc-usable tst-realloc tst-posix_memalign \ - tst-pvalloc + tst-pvalloc tst-memalign test-srcs = tst-mtrace routines = malloc morecore mcheck mtrace obstack diff --git a/malloc/tst-memalign.c b/malloc/tst-memalign.c new file mode 100644 index 0000000..eff47d8 --- /dev/null +++ b/malloc/tst-memalign.c @@ -0,0 +1,73 @@ +/* Copyright (C) 2013 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 + . */ + +#include +#include +#include +#include +#include + +static int errors = 0; + +static void +merror (const char *msg) +{ + ++errors; + printf ("Error: %s\n", msg); +} + +static int +do_test (void) +{ + void *p; + unsigned long pagesize = getpagesize(); + unsigned long ptrval; + + p = memalign (sizeof (void *), -1); + + if (p != NULL) + merror ("memalign (sizeof (void *), -1) succeeded."); + + p = memalign (pagesize, -pagesize); + + if (p != NULL) + merror ("memalign (pagesize, -pagesize) succeeded."); + + p = memalign (sizeof (void *), 0); + + if (p == NULL) + merror ("memalign (sizeof (void *), 0) failed."); + + free (p); + + p = memalign (0x100, 10); + + if (p == NULL) + merror ("memalign (0x100, 10) failed."); + + ptrval = (unsigned long)p; + + if (ptrval & 0xff) + merror ("pointer is not aligned to 0x100"); + + free (p); + + return errors != 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c"