From patchwork Tue Feb 14 17:56:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aaron Sawdey X-Patchwork-Id: 727936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vN99W1Lmjz9ryv for ; Wed, 15 Feb 2017 04:57:18 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="H9QdZoBq"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:date:content-type:mime-version:message-id; q=dns; s=default; b=Z5+vgrLyhpF7/2FjdGeVaSfunedq6wR5LeKMZA8Knlp k31ECmYSw8ryh7v3YoGb1UVc3kH4FEy40E6BH8Vi/LyYPhRTssVOwQU8Tx19UzLW oex48pwE8wgkWo2ObaANU2prEDvNmzPj5qRPAL9Aroh0EQ6RT+B00J+4MCYseaOo = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:date:content-type:mime-version:message-id; s=default; bh=TvBn7DdGloXQeOcQY9HYuoOOAVI=; b=H9QdZoBq7YRd2Hq0V fryC21JTabLkxMabdWVr9IPBJInGEe7dQctlf9QWq/EwoyGVPAlfO+vsZPFfVCD4 NJ/T3c/Z5NIIbp9pIpVbtkTOTmR09/AqPfDwYyDQHnyOJThK09S/IphBAs6vpx4Y wrwMA+eMYJetkm2ie94gn35Nmo= Received: (qmail 87784 invoked by alias); 14 Feb 2017 17:57:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 87771 invoked by uid 89); 14 Feb 2017 17:57:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=1912, Toolchain, Technology X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 Feb 2017 17:57:05 +0000 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1EHnGH6014885 for ; Tue, 14 Feb 2017 12:57:02 -0500 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 28m2kgkyu7-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 14 Feb 2017 12:57:01 -0500 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 14 Feb 2017 10:57:01 -0700 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 14 Feb 2017 10:56:57 -0700 Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id EEEDC19D803F; Tue, 14 Feb 2017 10:56:09 -0700 (MST) Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1EHuvf310420598; Tue, 14 Feb 2017 10:56:57 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E20A8136043; Tue, 14 Feb 2017 10:56:56 -0700 (MST) Received: from ragesh3a (unknown [9.80.203.82]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id 21A5B13603A; Tue, 14 Feb 2017 10:56:55 -0700 (MST) Subject: [PATCH] portability fix for gcc.dg/strncmp-2.c testcase From: Aaron Sawdey To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool , David Edelsohn , Jeff Law Date: Tue, 14 Feb 2017 11:56:50 -0600 Mime-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17021417-0004-0000-0000-00001195993C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006616; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000203; SDB=6.00821907; UDB=6.00402031; IPR=6.00599360; BA=6.00005137; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014280; XFM=3.00000011; UTC=2017-02-14 17:56:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17021417-0005-0000-0000-00007D0FB756 Message-Id: <1487095010.5165.4.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-14_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702140171 X-IsSubscribed: yes This testcase I added failed to compile on AIX or older linux due to the use of aligned_alloc(). Now fixed to use posix_memalign if available, and valloc otherwise. Now it compiles and passes on x86_64 (fedora 25), ppc64 (RHEL6.8), and AIX. OK for trunk? 2017-02-14  Aaron Sawdey   * gcc.dg/strncmp-2.c: Portability fixes. Index: strncmp-2.c =================================================================== --- strncmp-2.c (revision 245439) +++ strncmp-2.c (working copy) @@ -19,7 +19,12 @@ { long pgsz = sysconf(_SC_PAGESIZE); char buf1[sz+1]; - char *buf2 = aligned_alloc(pgsz,2*pgsz); + char *buf2; +#if _POSIX_C_SOURCE >= 200112L + if ( posix_memalign ((void **)&buf2, pgsz, 2*pgsz) ) abort (); +#else + if ( !(buf2 = valloc(2*pgsz))) abort (); +#endif char *p2; int r,i,e; @@ -35,6 +40,7 @@ e = lib_memcmp(buf1,p2,sz); (*test_memcmp)(buf1,p2,e); } + free(buf2); } #define RUN_TEST(SZ) test_driver_strncmp (test_strncmp_ ## SZ, test_memcmp_ ## SZ, SZ);