From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.9]) by sourceware.org (Postfix) with ESMTPS id A412A383F86D for ; Wed, 20 May 2020 14:32:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A412A383F86D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=SystematicSw.ab.ca Authentication-Results: sourceware.org; spf=none smtp.mailfrom=brian.inglis@systematicsw.ab.ca Received: from [192.168.1.104] ([24.64.172.44]) by shaw.ca with ESMTP id bPm7jQ68462brbPm8j98BM; Wed, 20 May 2020 08:32:52 -0600 X-Authority-Analysis: v=2.3 cv=LKf9vKe9 c=1 sm=1 tr=0 a=kiZT5GMN3KAWqtYcXc+/4Q==:117 a=kiZT5GMN3KAWqtYcXc+/4Q==:17 a=IkcTkHD0fZMA:10 a=JZeu4sPTHj9YQVegERsA:9 a=QEXdDO2ut3YA:10 From: Brian Inglis Subject: Re: [PATCH] Reimplement aligned_alloc Reply-To: newlib@sourceware.org To: newlib@sourceware.org References: <20200519095249.22326-1-szabolcs.nagy@arm.com> <54ce748b-051a-ac74-dd3e-c5e461289eae@embedded-brains.de> <20200520085438.GK27289@arm.com> Autocrypt: addr=Brian.Inglis@SystematicSw.ab.ca; prefer-encrypt=mutual; keydata= mDMEXopx8xYJKwYBBAHaRw8BAQdAnCK0qv/xwUCCZQoA9BHRYpstERrspfT0NkUWQVuoePa0 LkJyaWFuIEluZ2xpcyA8QnJpYW4uSW5nbGlzQFN5c3RlbWF0aWNTdy5hYi5jYT6IlgQTFggA PhYhBMM5/lbU970GBS2bZB62lxu92I8YBQJeinHzAhsDBQkJZgGABQsJCAcCBhUKCQgLAgQW AgMBAh4BAheAAAoJEB62lxu92I8Y0ioBAI8xrggNxziAVmr+Xm6nnyjoujMqWcq3oEhlYGAO WacZAQDFtdDx2koSVSoOmfaOyRTbIWSf9/Cjai29060fsmdsDLg4BF6KcfMSCisGAQQBl1UB BQEBB0Awv8kHI2PaEgViDqzbnoe8B9KMHoBZLS92HdC7ZPh8HQMBCAeIfgQYFggAJhYhBMM5 /lbU970GBS2bZB62lxu92I8YBQJeinHzAhsMBQkJZgGAAAoJEB62lxu92I8YZwUBAJw/74rF IyaSsGI7ewCdCy88Lce/kdwX7zGwid+f8NZ3AQC/ezTFFi5obXnyMxZJN464nPXiggtT9gN5 RSyTY8X+AQ== Organization: Systematic Software Message-ID: Date: Wed, 20 May 2020 08:32:51 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200520085438.GK27289@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfJIwFCPbQbWZaHWvnzn7XA/Nvg9YFZxMjXNztE0mMqB7k95o5Q3+9ro4OPpYuIYqpBsK+Y92+eZACmLxR8lghb7kvIvKVae4sKaigM5WpXBLrcpGLb1G uFslMqQia0Z854gXyS7sKRX3kFaQnzHPeY4BVDIlgOx5oJpRRV3tr5Z3Eg4ujkHRMZTmLIa8AljdZw== X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2020 14:33:04 -0000 >> On 19/05/2020 11:52, Szabolcs Nagy wrote: >>> - Failed to set errno on error. > The 05/19/2020 19:41, Sebastian Huber wrote: >> why should aligned_alloc() set errno on error? On 2020-05-20 02:54, Szabolcs Nagy wrote: > iso c allows standard api calls to set errno > (except not to 0) but usually does not specify > error conditions, however posix does and > requires allocation functions to set errno > to ENOMEM on failure. > > posix is not yet aligned with c11 so there is > no errno specification for aligned_alloc but > that does not mean newlib should make it > deliberately inconsistent with other allocation > functions, users will try to use perror or > strerror when calls fail that may internally > use aligned_alloc and expect reasonable error > message. IEC 9899-2011[2012] specifies no errno values for any of the 7.22.3 Memory management functions, and under Annex J.1 Unspecified behaviour and J.2 Undefined behaviour, omits aligned_alloc from issues of related functions, but under J.2 specifies as a portability issue only: -- The alignment requested of the aligned_alloc function is not valid or not supported by the implementation, or the size requested is not an integral multiple of the alignment (7.22.3.1). POSIX posix_memalign specifies errno = EINVAL for this case and errno = ENOMEM for the OoM case. It seems more useful to set errno to POSIX compatible values when returning a NULL pointer than attempt nasal demon emission. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. [Data in IEC units and prefixes, physical quantities in SI.]