From patchwork Thu Apr 3 10:06:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 2068371 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=NFQKuBF3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org (client-ip=2a00:1828:2000:679::23; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org) Received: from helium.openadk.org (helium.openadk.org [IPv6:2a00:1828:2000:679::23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4ZTDnw0dwRz1yHF for ; Fri, 4 Apr 2025 08:07:13 +1100 (AEDT) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=NFQKuBF3; dkim-atps=neutral Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id C4509352FE9E; Thu, 3 Apr 2025 23:07:22 +0200 (CEST) Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by helium.openadk.org (Postfix) with ESMTPS id 7090C352FE98 for ; Thu, 3 Apr 2025 23:06:56 +0200 (CEST) Received: by mail.gandi.net (Postfix) with ESMTPA id E0E3943421; Thu, 3 Apr 2025 21:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1743714416; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6M+9QgF7SvPblnMZGN7IkRq0UuVUO7Y1l0CGBDtHXi8=; b=NFQKuBF3le82ng/EjiSvXLJA4548dNIrSe+KWs2P0ED4sOGYQ1IZS47cbTvMnWGnOk6pMt almttrGUBjv+awoHtjPv2pOYa/jyhPLcAEOoBgEfCxJhDmWtqgZTUHPvJiQCUaTYYu0LSJ CRvD7tcLq+bhNdTQPaHZ1hWteyYRB5LXHyqj3stvf3WxB+SSjMs7j8HVEeyLQi3ckuDKHu OXsnk/JHpmCwV25A9y5FL6Oug6/MaI2J0MdxJHiA9+e1JOvzQ+zGwChlzMkAD2rM9X5zgi w0YzIf0RWVMGBlS/HSmZfKIkbRo8DIYogkaPmPfnR4AuBsFka1Ph52Pe2NUHgQ== From: Thomas Petazzoni To: devel@uclibc-ng.org Date: Thu, 3 Apr 2025 23:06:54 +0200 Message-ID: <20250403210654.2407231-1-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-GND-State: clean X-GND-Score: 0 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddukeeliedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecunecujfgurhephffvvefufffkofggtgfgsehtkeertdertdejnecuhfhrohhmpefvhhhomhgrshcurfgvthgriiiiohhnihcuoehthhhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepfeegheekveettedvhfdvvdekieeugfdthffgleeukeefleeiieetfffhteefuefgnecukfhppedvrgdtudemtggsudelmeekleegsgemheehtddtmedvudgtvgemsggvheeimegrsgefvdemtggrrggvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdgrtddumegtsgduleemkeelgegsmeehhedttdemvddutggvmegsvgehieemrggsfedvmegtrggrvgdphhgvlhhopeifihhnughsuhhrfhdrhhhomhgvpdhmrghilhhfrhhomhepthhhohhmrghsrdhpvghtrgiiiihonhhisegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepuggvvhgvlhesuhgtlhhisggtqdhnghdrohhrghdprhgtphhtthhopehthhhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomh X-GND-Sasl: thomas.petazzoni@bootlin.com Message-ID-Hash: BX4ENNZYO23YQJQF5XITW7TETSJHEFK5 X-Message-ID-Hash: BX4ENNZYO23YQJQF5XITW7TETSJHEFK5 X-MailFrom: thomas.petazzoni@bootlin.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list Subject: [uclibc-ng-devel] [PATCH] include/stdlib.h: only expose reallocarray() prototype when implementation is available List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The reallocarray() primitive is only provided by the malloc-standard implementation: neither malloc nor malloc-simple provide it. This causes issues when building for example util-linux on noMMU platforms as: - noMMU platforms can't use malloc-standard, so either malloc or malloc-simple are used, which means reallocarray() is not implemented - util-linux detects the absence of reallocarray(), and provides its own implementation, but the prototype clashes with the prototype in uClibc's The combination of which causes the following build failure: In file included from lib/color-names.c:7: ./include/c.h:586:21: error: static declaration of ‘reallocarray’ follows non-static declaration 586 | static inline void *reallocarray(void *ptr, size_t nmemb, size_t size) | ^~~~~~~~~~~~ In file included from ./include/c.h:16: /home/thomas/projets/buildroot/output/host/arm-buildroot-uclinux-uclibcgnueabi/sysroot/usr/include/stdlib.h:898:14: note: previous declaration of ‘reallocarray’ with type ‘void *(void *, size_t, size_t)’ {aka ‘void *(void *, unsigned int, unsigned int)’} 898 | extern void *reallocarray (void *__ptr, size_t __m, size_t __n); | ^~~~~~~~~~~~ make[3]: *** [Makefile:12354: lib/libtcolors_la-color-names.lo] Error 1 To fix this, let's not expose the prototype of reallocarray() if we don't provide the implementation for it. Signed-off-by: Thomas Petazzoni --- include/stdlib.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/stdlib.h b/include/stdlib.h index d4e0b75e7..448c5e336 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -986,9 +986,13 @@ extern int getpt (void); extern int getloadavg (double __loadavg[], int __nelem) __THROW __nonnull ((1)); +/* reallocarray() only provided by the malloc-standard implementation */ +#if defined(__MALLOC_STANDARD__) extern void *reallocarray (void *__ptr, size_t __m, size_t __n); #endif +#endif + #ifdef _LIBC extern int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer) attribute_hidden;