From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zimbra.cs.ucla.edu (zimbra.cs.ucla.edu [131.179.128.68]) by sourceware.org (Postfix) with ESMTPS id A88643858D3C for ; Tue, 26 Oct 2021 01:50:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A88643858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cs.ucla.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.ucla.edu Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id EC1E6160051; Mon, 25 Oct 2021 18:50:45 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 3GvpPCRgQnFz; Mon, 25 Oct 2021 18:50:45 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id F0390160071; Mon, 25 Oct 2021 18:50:44 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id RhTH5m0-4wDt; Mon, 25 Oct 2021 18:50:44 -0700 (PDT) Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id BF4FB160051; Mon, 25 Oct 2021 18:50:44 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------B26Q01AKVEJT1ABj0o0A1MCj" Message-ID: Date: Mon, 25 Oct 2021 18:50:44 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH] manual: remove an obsolete requirement on aligned_alloc() usage Content-Language: en-US To: Martin Sebor References: <33ec9e0c1e587813b90e8aa771c2c8e6e379dd48.camel@posteo.net> <11bc87c2-d59c-0e32-79a4-68bf7d01a2b8@gmail.com> From: Paul Eggert Organization: UCLA Computer Science Department Cc: John Scott , libc-alpha@sourceware.org In-Reply-To: <11bc87c2-d59c-0e32-79a4-68bf7d01a2b8@gmail.com> X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP 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-List-Received-Date: Tue, 26 Oct 2021 01:50:48 -0000 This is a multi-part message in MIME format. --------------B26Q01AKVEJT1ABj0o0A1MCj Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 10/25/21 08:45, Martin Sebor via Libc-alpha wrote: > Based on my code inspection of _mid_memalign in malloc.c I think > a change that would more accurately reflect the implementation > is one that described that when alignment is not a power of two > it's bumped up to next larger power of two, and adjusted > the EINVAL condition appropriately. Let's not document this implementation detail, as it might tie us down unnecessarily in the future. > I believe the DR460 change went into C17. Here's an early C2x > draft from 2018 publicly available on the WG14 site that should > still be very close to C17: > > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf This says that aligned_alloc "shall fail" if the alignment is not a valid alignment supported by the implementation. This means the current glibc alloc_aligned behavior does not conform to C17 and should be fixed so that it does. Something like the attached (untested) patch, say. --------------B26Q01AKVEJT1ABj0o0A1MCj Content-Type: text/x-patch; charset=UTF-8; name="align.patch" Content-Disposition: attachment; filename="align.patch" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL21hbGxvYy9tYWxsb2MuYyBiL21hbGxvYy9tYWxsb2MuYwppbmRleCAy YmExZmVlM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