From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70042.outbound.protection.outlook.com [40.107.7.42]) by sourceware.org (Postfix) with ESMTPS id A6B7D383F856 for ; Fri, 22 May 2020 15:22:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A6B7D383F856 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WOVU7i1jsTnp7+tq9MY1iFGkAzLoNnXCuJWkzvI8iVs=; b=MXrvu1sBYbrdbqYmiWGiXxsVrQVe8vn8OqlZfSnKOV0b0FCwMx2/qQt5OE5OW5RiSahaa61PJPJZOl8jW6FLLYk/dPW3l/U46VXvieoLT+ZX/Ssascb6GFdqk2nkz6EMkKxTW8A9q39kz9y0eDgaap8RxvX/X6oPsyfkrBknZF8= Received: from AM6P192CA0068.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::45) by DB6PR08MB2679.eurprd08.prod.outlook.com (2603:10a6:6:25::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.33; Fri, 22 May 2020 15:22:48 +0000 Received: from AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:82:cafe::67) by AM6P192CA0068.outlook.office365.com (2603:10a6:209:82::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Fri, 22 May 2020 15:22:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT021.mail.protection.outlook.com (10.152.16.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Fri, 22 May 2020 15:22:48 +0000 Received: ("Tessian outbound facc38080784:v57"); Fri, 22 May 2020 15:22:48 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4a7bafe242c3af32 X-CR-MTA-TID: 64aa7808 Received: from df05bc190f3b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 53DE1815-2012-46B1-812A-29142ACEBBD5.1; Fri, 22 May 2020 15:22:42 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id df05bc190f3b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 22 May 2020 15:22:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=am0Eo0wzr1GD026SAJwoRAqukAFx0iX/5mma4YN3gXnOLRGSKFwJybhrgqxYEmRswXPGUlCvyrnD2NJAr+EUFi94MXvU07bIAhYubdILbtC4UZKhdViv7eHKgCIUvFPFtz6BJj4MIzK2Vlvftg50tssv+jWFhhHPLW8l0C9EWvTUMLE+oMWpXNupgTqknAihtw07nOH7Zp5pthEF6CTfTkfk6IFw3ViJuJN3R1N1TlgNt9fqM97jzpwj8wQF3o00UDnnENdU8Nxyr/e4OhIQtrTO+3k5Of75lRpzEozEzvWi4i7Lv/Rtyl3M36OkcNovHwMqGYaAyKIgYKBvyDsvlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WOVU7i1jsTnp7+tq9MY1iFGkAzLoNnXCuJWkzvI8iVs=; b=ghr05kBfDea/V+STeXF18O1jOVvHAJXvmOVtGYb1kjSeEV48f1nJ0lAidZS4HgZb7tsB19/MhL2Hf1AUruptzdSc9oxKyX0cBbA0P6ZMWeMxB/DDQbUR84dVu/69FARuPaGtdZ0WOnW7fWlE4kpTGmELIDY3gqgvVEZQxk3koY0frhws3Yg6/TVZZL8gi7cYfGnIlzqlIC0BIxeWJh6hPmAqWHiU6m5oZi5os6vzonT5Yadf2he/OqPETrmHOSIlvoZ5W23QTIbZkAskZgBEFqtOuxPr7dwEnt7NwRQfhbG5t2vhE9jYPRuZUcHB+LLrFLT4HZRLwwNqdSB0zpktXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WOVU7i1jsTnp7+tq9MY1iFGkAzLoNnXCuJWkzvI8iVs=; b=MXrvu1sBYbrdbqYmiWGiXxsVrQVe8vn8OqlZfSnKOV0b0FCwMx2/qQt5OE5OW5RiSahaa61PJPJZOl8jW6FLLYk/dPW3l/U46VXvieoLT+ZX/Ssascb6GFdqk2nkz6EMkKxTW8A9q39kz9y0eDgaap8RxvX/X6oPsyfkrBknZF8= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB3000.eurprd08.prod.outlook.com (2603:10a6:209:43::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.25; Fri, 22 May 2020 15:22:41 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::49fd:6ded:4da7:8862]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::49fd:6ded:4da7:8862%7]) with mapi id 15.20.3021.020; Fri, 22 May 2020 15:22:41 +0000 Date: Fri, 22 May 2020 16:22:35 +0100 From: Szabolcs Nagy To: newlib@sourceware.org Subject: Re: [PATCH] Reimplement aligned_alloc Message-ID: <20200522152235.GB24880@arm.com> References: <20200519095249.22326-1-szabolcs.nagy@arm.com> <54ce748b-051a-ac74-dd3e-c5e461289eae@embedded-brains.de> <20200520085438.GK27289@arm.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-ClientProxiedBy: SN6PR04CA0093.namprd04.prod.outlook.com (2603:10b6:805:f2::34) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from arm.com (217.140.106.55) by SN6PR04CA0093.namprd04.prod.outlook.com (2603:10b6:805:f2::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.24 via Frontend Transport; Fri, 22 May 2020 15:22:40 +0000 X-Originating-IP: [217.140.106.55] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 595eb198-93c8-4706-ec85-08d7fe63fc60 X-MS-TrafficTypeDiagnostic: AM6PR08MB3000:|DB6PR08MB2679: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-Forefront-PRVS: 04111BAC64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: CPe+0k4TkewVshv+KZFIwZ7dka0xpYJJeEbwmbma0EcZLjTclvEYMvaouJHtjAUONWBGGfvxWIIoVwHyyldQLaa6ngMr0+coXgWalC125HV1/OaA1NiHcVKCsy1jdf0qyj0aFCN7iUvU1Lzup4oJ1xnNvdNDGFwyWTnKQHFpQ6rQkL52Lqsp/rDpEIjmGXsWwR95XAwpc+3OnIsGUajVyeRW9L6auK4SGpjJvdjPGKnnyda0rJ//f2HKR0nj1vNkAwe3d4pWh0GMrA5vVsFYfP5ZLYwL9iXjzcyzTS/aXDiAyx7orvlO8ab8mxw1I5HhnTdrpF2PQx+uQE0M2ln2RQsgIZnA/r6KILDUFKZCDPu3gUAUiruUy1JwpMdTFlF2qXfYJFlkdBUSpodXfbFAe8kVAho5aIWYs6xh0nU2GrKWJnSZcklYS1Vjb0Mb6l+0 X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(346002)(376002)(396003)(366004)(136003)(39860400002)(6666004)(2906002)(6916009)(316002)(26005)(36756003)(53546011)(44832011)(16526019)(186003)(8886007)(66946007)(66556008)(66476007)(956004)(2616005)(8676002)(8936002)(55016002)(33656002)(86362001)(478600001)(1076003)(7696005)(5660300002)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: QyfjhfUmEm3j1e2N32Ywv3ebAOM9HBgZ+SDtJ1H8Ps8OKCKbQaOXqun09TTdRnF4sgUl+jotBmO4YPldC1dT0uRzrmXwn4SEFREAcaaN7w2f14SigaFUhBkNfdaZzvSg5FtqU7k2+Te7oQqAiwS6L1tzIcrcRyae045E0k/8g5QXiZVCRtd7qHqepxdnL7n1J+5efLOXLNzuAwAZl0wX9NKc261SrDm90A9Jpi46DIUTMX+vid7IuiGCJi2UkRaym5DXB2SClEP6movVjOcpYyFXtzwxuU54VKRcgXBA24haGn0V+aOru81BtDWjo1iURG24loxl+OD+UQ7hQ8z4MAO2vY02VWzcle0jhf4tvnP0H/RCxym/A14hiNdHwHeFw/CNTe7iaQqXPCZfVFy6Fjp++Rj8p48/hoju4zMrzJSNSNVrCUfEt8GM9k28eZHGAhxf+NJB1d4pip3NeFNUfskLQrzRXi11QL0RlMhypp002ohTLGLQIGOkDObTcHvY X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3000 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:; SFS:(4636009)(136003)(346002)(39860400002)(376002)(396003)(46966005)(53546011)(2906002)(478600001)(8886007)(82310400002)(8676002)(336012)(82740400003)(7696005)(16526019)(55016002)(186003)(26005)(316002)(6666004)(86362001)(8936002)(356005)(33656002)(1076003)(36756003)(44832011)(956004)(2616005)(5660300002)(6916009)(70586007)(47076004)(81166007)(36906005)(70206006); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: cfa03330-ceb8-4dae-e4c5-08d7fe63f825 X-Forefront-PRVS: 04111BAC64 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l+2tuLC1NDSFJRXDTx7I0DcQzLEYP92TG8bPtxTfTyIdCJXtKDh6JPFkkiTvCdvP53nTZ92BzgFIIbikVGAy+JIfSwQy7w4n6jTRMSPqYMLjVXcfCzXBxPLb3EypDJ8n+PKTUFO47DiwCwbOWHBzHv95upFSWdv9U+TqgetvOMNRPg/voMOiLbLfBeQDDckRiHoq+q/WbgwJuG/vjT6Q9nZFPcOyf6u4WQF9D5u03rUjXOBo5TmEZrDxfd5ELPboJC8iKiUsWHS0ClLPh8BcCefIj9aaVcuMTv+0+JX0p3xRS2BXciIpLHhvpDOffR+mRvm9UAD35OLZzKA3XjcKk3hWLESrpr1HkYT8wK+PxcjSi1M5uBPVrxoCtg9oVGqJzbQmJheH7/xJwWoUTrmifbXUGUwIaTLrH0DB3RaGsKRbY4RxHexfZdTNoWKsLf9SuChj0p9dtgHDnT5zJHHjmQBaZjjax2/KWrokjxjeLSJ/DeH2ehk2IWkYCx8nms41YrIiC8uO1gWdWXVLYQYMLw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2020 15:22:48.5062 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 595eb198-93c8-4706-ec85-08d7fe63fc60 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2679 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham 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: Fri, 22 May 2020 15:22:52 -0000 The 05/20/2020 08:32, Brian Inglis wrote: > >> 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. note that posix_memalign does not set errno, but returns an error value. in principle aligned_alloc could check its alignement argument too and set errno to EINVAL, but to me that case seems less important in practice: it's not a dynamic runtime failure like running out of memory, but wrong argument bug in user code that should be fixed statically instead of checking errno. if posix is updated to cover aligned_alloc and requires EINVAL for this case, then newlib can be updated.