From nobody Wed Dec 17 05:47:40 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF7962472B9 for ; Wed, 16 Apr 2025 12:06:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805184; cv=none; b=pSW4YcW+aVqqcx/rKTQaci5TYxxAkorwqUbgc5vvT6hdG9p52edfBLN9/9zrcEQZil4J/Gyu5sbXXElsZSomj6r06n1glHJmzBRdKbiGFeOyRSPJWirLFES0CJT+ugI+0+1PDsT6L8V9w2JZpfI7ybZr3iGoBTT5byMALuFh+4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805184; c=relaxed/simple; bh=ot/+PyeGwuyyUs+gU8Wc/UIvFw7kPfIN4dAGn9oleWc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p6bi7z75zJ4qN1uOoV6DleJUk/lTZZGL6JlghpSOZZkLFaaCjdUmvNRyFgQTlossqr+8RtJUPsBR21St/MOd9voL+PvJB3kpch/G26RFZ50DkIni7VVscOprYW3hebp/XMWDSHKuBF6F03ttYZLY3xmWdGbyfP41Lsppf04dC2A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CGzl7AHe; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=hM7oCfPb; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CGzl7AHe"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="hM7oCfPb" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744805180; 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: in-reply-to:in-reply-to:references:references; bh=BsdrjnU+KlfPiSRZqC16cDEfipEEX3WwwiF3Xi9A28U=; b=CGzl7AHezGeHhjJIYFMYX+/0B/EYAFAi+rTR5cQlCMVoqSZXXrpAG+Dn7cEUQNtDlJ/IfR t6DbAT9KVn/D51DgVhixK118+hXiobZV2NgzFK8nRYjX0FrKb15/SW4kPZ9+8lZv3dBUIq +oy26OnyWE71rkKZzD2H+A0DRQF4sbgUxnSIhDLZeSYFf/2Cdr1gNA+rl0E7x+NEQXRAlA T1l43HkYFXhzrX9Wri2wgoTJhquBgbt+zFLSJ74yTyVAx4goih8qUbOA/I5pvLEOltTi6l nTEzyj2oqINr2Dp3+Upj2AX+zwb05qFUxXbohU8x5h6aOUANfWQ+Gz5bMxk+aw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744805180; 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: in-reply-to:in-reply-to:references:references; bh=BsdrjnU+KlfPiSRZqC16cDEfipEEX3WwwiF3Xi9A28U=; b=hM7oCfPbB29hIzGfxXxAYfhtiXT/CNEHlSoKZnysh5nPrnTcQLpd1Eiys0rJCD/VBoWiJy kU+GBeUQjOT4C8Bw== Date: Wed, 16 Apr 2025 14:06:16 +0200 Subject: [PATCH 01/10] tools/nolibc: prepare for headers in subdirectories Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250416-nolibc-split-sys-v1-1-a069a3f1d145@linutronix.de> References: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> In-Reply-To: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1744805177; l=963; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=ot/+PyeGwuyyUs+gU8Wc/UIvFw7kPfIN4dAGn9oleWc=; b=lpwIFxmA7PQHnMoVrfFbuJzfQflZ334iqi9RmwVx8P2PdLkQHRSzBdcYWelVYB/iUlp0uQ6bR SAsOphBmvHtC/L/EaSLdmGAJkB2L5Th6+UMYFF70rB6yaqUxle1UvK4 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= To support headers in subdirectories (like sys/), their subdirectory needs to be preserved during installation into the sysroot. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index f9702877ac21ab5ad30df1740e40e67f477f3824..f562cb53be10efc4e0758b8836c= f3ace5b3c151f 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -72,7 +72,7 @@ help: headers: $(Q)mkdir -p $(OUTPUT)sysroot $(Q)mkdir -p $(OUTPUT)sysroot/include - $(Q)cp $(all_files) $(OUTPUT)sysroot/include/ + $(Q)cp --parents $(all_files) $(OUTPUT)sysroot/include/ $(Q)if [ "$(ARCH)" =3D "x86" ]; then \ sed -e \ 's,^#ifndef _NOLIBC_ARCH_X86_64_H,#if !defined(_NOLIBC_ARCH_X86_64_H) = \&\& defined(__x86_64__),' \ --=20 2.49.0 From nobody Wed Dec 17 05:47:40 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80A4224A055 for ; Wed, 16 Apr 2025 12:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805185; cv=none; b=jO4jKeslbhT+ajhRebBnGRTwCvsnc7AMLR1c/1px2cYBK6gVnmMG1fl98yuAZ3D8oHkoDbOyxrQGW6eBEYkA28kMKB7JICjIozYERkwUcDh1vQ3woL8c6wZJ+u0hzbGxaBFKdVSbeXGxjEBs5BdNquw6Ta8LG0PgybZ3kAiyfDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805185; c=relaxed/simple; bh=/v1YZLb5r0nwuzBwXN9pK+KCnV1nO/MMUBtr8E5Yrus=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pX3+SNsI06Jy715uQV5gSA0+2fGTvKjOc+AGh3P+20MpfXkiTnUZeSfIhpxkcYTdAv+wNMX6sRw2Z++Ge5Q6f/v+PiKVTmdtsAITGD1pCD9mcoJlERkVIVTE6nKAS3rI9QaJ9JPqagrYtKBhIy62GePVRdAoDAqpNoRbHf9F7CQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JBlsWcpe; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kV4dRiKD; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JBlsWcpe"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kV4dRiKD" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744805181; 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: in-reply-to:in-reply-to:references:references; bh=OtHlFmG4xMfevK368geVp5vwSOOouC9xi41I1IozzwI=; b=JBlsWcpeztaI1nc0zF//sewYNrKtHRXzi58qL3SNexi/byDvrGdfu0asPhmShink3Lfpa9 IM9x/9G3YX850gGt7XUPsaMiobKSFtA86zZmgOWkbogrxIitbw3epFNoftcUdT9A7SwW67 5qsVwVkf3nR4Rx9F60xmWRiCV91rniPNUjYrW2uUd3gq1QPseGjAyFt5LX9KFbopxVnUVV Y91eOPxClOCYcN19P6E16n48zS230kfR6TFQtIUP3YAd3CfNZ6tFDvSw9aE5M/RVT/n6TX V7SbZBOFmziSTNOq1tpxGiH2SfeZMT2K3XpTg5MN2dEtoEpnN37ZTI2r0Bu6ew== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744805181; 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: in-reply-to:in-reply-to:references:references; bh=OtHlFmG4xMfevK368geVp5vwSOOouC9xi41I1IozzwI=; b=kV4dRiKDz5DQHEpwBrkgpNlvTx0fV/A/GKdyywn3NkB/IO9JjEV5ZO/SPYhFpE4+2Hk4WE usz8H422JvmKlzAg== Date: Wed, 16 Apr 2025 14:06:17 +0200 Subject: [PATCH 02/10] tools/nolibc: add elf.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250416-nolibc-split-sys-v1-2-a069a3f1d145@linutronix.de> References: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> In-Reply-To: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1744805177; l=1759; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=/v1YZLb5r0nwuzBwXN9pK+KCnV1nO/MMUBtr8E5Yrus=; b=5urcga8JNB3Agfa0IMvsjpbtvE2GaILFFYBH/5wBZ8bt/eADjYapbnRcgcL4K2e0UBATT70/y wvHwLUOTD4MBXK2OdWSzB/SmsXeDavUra7zes98PIj+1dhONjlWivoN X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The UAPI header do already provide an elf.h implementation. Reexport it under its libc name. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/elf.h | 15 +++++++++++++++ tools/include/nolibc/nolibc.h | 1 + 3 files changed, 17 insertions(+) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index f562cb53be10efc4e0758b8836cf3ace5b3c151f..fd76d267d79a8533b7e78375c30= 324c962b01973 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -30,6 +30,7 @@ all_files :=3D \ crt.h \ ctype.h \ dirent.h \ + elf.h \ errno.h \ limits.h \ nolibc.h \ diff --git a/tools/include/nolibc/elf.h b/tools/include/nolibc/elf.h new file mode 100644 index 0000000000000000000000000000000000000000..beb0b3a87569a3037055c8fe7e9= b086a26ca7d13 --- /dev/null +++ b/tools/include/nolibc/elf.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * Shim elf.h header for NOLIBC. + * Copyright (C) 2025 Thomas Wei=C3=9Fschuh + */ + +#ifndef _NOLIBC_SYS_ELF_H +#define _NOLIBC_SYS_ELF_H + +#include + +/* make sure to include all global symbols */ +#include "nolibc.h" + +#endif /* _NOLIBC_SYS_ELF_H */ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index 70872401aca8d5aa37b12ee585193353f692576d..127f0d9068c6508bd45acfe0ebf= 2ce15acc422b0 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -97,6 +97,7 @@ #include "types.h" #include "sys.h" #include "ctype.h" +#include "elf.h" #include "signal.h" #include "unistd.h" #include "stdio.h" --=20 2.49.0 From nobody Wed Dec 17 05:47:40 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15DB424A05A for ; Wed, 16 Apr 2025 12:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805186; cv=none; b=lWcGSRJah96xlt6bJ0EK2L5rH1C2SKOTIP+Wdu6/w6ev7tNX8nRQOSEzLWfvPgjGJL/gDiUqg87dsUyvL6y/rxPuYgQZYTHQs8kkumc32unufvq04fPbURDiG6rj9NvHsnzV5dSEKFvWD1SJdnFJ6b+BwH9nBhXGVHt0CGqX8oE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805186; c=relaxed/simple; bh=HmLYaF6k75emMNYuVKPaAVfZFtSclPYYeJ0ZzkL/MFw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nqy9FuVhZZMwydTOZs59SgC4ES2cCmRtHgCHXolAxWUcj2BC5t6wC69MRyP/rRqnQzMPikHC0mw3KXHB+LQNm66PlSaCsfu7pUsERBkG0wDIvb2kYIHDZHViSs5x10rEbl6ywH5B7xT/xZ4t774xeQ1sKJwaFjHvDpZFCnhJ1+I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=luYtl5qE; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cnOJl8gq; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="luYtl5qE"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cnOJl8gq" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744805182; 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: in-reply-to:in-reply-to:references:references; bh=1TF1+UPseHbLqKixvEBKKrw7HcxtjV+VM41Hak2YZ+c=; b=luYtl5qEIb2GAfRMoftqlCTkRiTeQPvlrqLZ1czJH1+lRv/jN+Da6YfXppbEfergLaZ0Qq KeadDVBArKN0lG2mPm/qPZGr/kUVR0/xJqUwme2gBLQL7jdo9fIWAXEPXWW5VFQCg7dcuh 0o1V7ic7h6huB2uhbrec3gVhlkTHeao/oiqLF7/ZqfL8vUM9iug77vY+GGDBJZPcyPssuj 1s+I4aTbsX5qPmf8ZxrARmrd2w5XgkM/7lOZWXKyEdaSlEnpRfOYdJucoysd5K+rDHLjDz Rttxfmd1B6qg1MFEkEakHl7SgaEVQu4hLpVYDB3ZfPESfsrniyK91ELrqDZrnw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744805182; 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: in-reply-to:in-reply-to:references:references; bh=1TF1+UPseHbLqKixvEBKKrw7HcxtjV+VM41Hak2YZ+c=; b=cnOJl8gqhzoQ4YMtor8pID9qmiX88Nd9OZTgMPVO2SI3Rx25UnMimu5C37aazq9JXGLpmr x+SJJjLjxI1B5sCA== Date: Wed, 16 Apr 2025 14:06:18 +0200 Subject: [PATCH 03/10] tools/nolibc: move open() and friends to fcntl.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250416-nolibc-split-sys-v1-3-a069a3f1d145@linutronix.de> References: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> In-Reply-To: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1744805177; l=4920; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=HmLYaF6k75emMNYuVKPaAVfZFtSclPYYeJ0ZzkL/MFw=; b=ijLcVYHNTKCnJgCuZGgQlgtAZAhqppbY5Qu9VfTdmT+n5wRcCYpqex2BnAc7dg5uDaO6j19CJ nWbc3f5h70GBon6sXZIKENxu1TDSkdUQKRF5Kz+N0LY9cH1OjUlCWpb X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= This is the location regular userspace expects these definitions. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/dirent.h | 1 + tools/include/nolibc/fcntl.h | 69 +++++++++++++++++++++++++++++++++++++++= ++++ tools/include/nolibc/nolibc.h | 1 + tools/include/nolibc/sys.h | 52 -------------------------------- 5 files changed, 72 insertions(+), 52 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index fd76d267d79a8533b7e78375c30324c962b01973..2132e4f4d2165729ec6d10860d0= 586f1b71ee0fb 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -32,6 +32,7 @@ all_files :=3D \ dirent.h \ elf.h \ errno.h \ + fcntl.h \ limits.h \ nolibc.h \ signal.h \ diff --git a/tools/include/nolibc/dirent.h b/tools/include/nolibc/dirent.h index c5c30d0dd6806b1bec2fa8120a3df29aaa201393..d3fb9500c60a31bc1b75601d788= 71df82ca75f7d 100644 --- a/tools/include/nolibc/dirent.h +++ b/tools/include/nolibc/dirent.h @@ -9,6 +9,7 @@ =20 #include "stdint.h" #include "types.h" +#include "fcntl.h" =20 #include =20 diff --git a/tools/include/nolibc/fcntl.h b/tools/include/nolibc/fcntl.h new file mode 100644 index 0000000000000000000000000000000000000000..5feb08ad54a7d943b8100eac21f= 4058310efea91 --- /dev/null +++ b/tools/include/nolibc/fcntl.h @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * fcntl definition for NOLIBC + * Copyright (C) 2017-2021 Willy Tarreau + */ + +#ifndef _NOLIBC_FCNTL_H +#define _NOLIBC_FCNTL_H + +#include "arch.h" +#include "types.h" +#include "sys.h" + +/* + * int openat(int dirfd, const char *path, int flags[, mode_t mode]); + */ + +static __attribute__((unused)) +int sys_openat(int dirfd, const char *path, int flags, mode_t mode) +{ + return my_syscall4(__NR_openat, dirfd, path, flags, mode); +} + +static __attribute__((unused)) +int openat(int dirfd, const char *path, int flags, ...) +{ + mode_t mode =3D 0; + + if (flags & O_CREAT) { + va_list args; + + va_start(args, flags); + mode =3D va_arg(args, mode_t); + va_end(args); + } + + return __sysret(sys_openat(dirfd, path, flags, mode)); +} + +/* + * int open(const char *path, int flags[, mode_t mode]); + */ + +static __attribute__((unused)) +int sys_open(const char *path, int flags, mode_t mode) +{ + return my_syscall4(__NR_openat, AT_FDCWD, path, flags, mode); +} + +static __attribute__((unused)) +int open(const char *path, int flags, ...) +{ + mode_t mode =3D 0; + + if (flags & O_CREAT) { + va_list args; + + va_start(args, flags); + mode =3D va_arg(args, mode_t); + va_end(args); + } + + return __sysret(sys_open(path, flags, mode)); +} + +/* make sure to include all global symbols */ +#include "nolibc.h" + +#endif /* _NOLIBC_FCNTL_H */ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index 127f0d9068c6508bd45acfe0ebf2ce15acc422b0..bb4183a8fdc41023d9b8b37fe35= ec37ca408b4c6 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -106,6 +106,7 @@ #include "time.h" #include "stackprotector.h" #include "dirent.h" +#include "fcntl.h" =20 /* Used by programs to avoid std includes */ #define NOLIBC diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 08c1c074bec89a27e53e5d461a3ebbf71ec323d1..5fa351e6a3512a3d0c609867244= ac91e8563ab2a 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -764,58 +764,6 @@ int mount(const char *src, const char *tgt, return __sysret(sys_mount(src, tgt, fst, flags, data)); } =20 -/* - * int openat(int dirfd, const char *path, int flags[, mode_t mode]); - */ - -static __attribute__((unused)) -int sys_openat(int dirfd, const char *path, int flags, mode_t mode) -{ - return my_syscall4(__NR_openat, dirfd, path, flags, mode); -} - -static __attribute__((unused)) -int openat(int dirfd, const char *path, int flags, ...) -{ - mode_t mode =3D 0; - - if (flags & O_CREAT) { - va_list args; - - va_start(args, flags); - mode =3D va_arg(args, mode_t); - va_end(args); - } - - return __sysret(sys_openat(dirfd, path, flags, mode)); -} - -/* - * int open(const char *path, int flags[, mode_t mode]); - */ - -static __attribute__((unused)) -int sys_open(const char *path, int flags, mode_t mode) -{ - return my_syscall4(__NR_openat, AT_FDCWD, path, flags, mode); -} - -static __attribute__((unused)) -int open(const char *path, int flags, ...) -{ - mode_t mode =3D 0; - - if (flags & O_CREAT) { - va_list args; - - va_start(args, flags); - mode =3D va_arg(args, mode_t); - va_end(args); - } - - return __sysret(sys_open(path, flags, mode)); -} - =20 /* * int pipe2(int pipefd[2], int flags); --=20 2.49.0 From nobody Wed Dec 17 05:47:40 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D86024A062 for ; Wed, 16 Apr 2025 12:06:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805186; cv=none; b=Haq2ABNKFGlWCqIdIrYEGUmonFyWPVjWQ3U0yqTlDt7xLfFRgOZiV6cNxIMdC74tMKD9zDZF0VV5f/iSwfc5gxsDcxqrT8CcIvcH+ZMm4n+LAi3/mLO4QuFWF2RgW4ZVCwBpXly88CRy+yejegN41DVDJd3GmJ8DePf9e+fqi1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805186; c=relaxed/simple; bh=jcMAMRnolUY1bDZt4MbiC8UWAP3z6gSGbjezDeJ4Z4c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=culmVFKBx3NDroHyPytzSM5oLCXfXi8L/1QwXhkoNDBvmEqWADbm21MSJPyXrOsGg+S8B9BG+7NBdIzucdZ+fe2L9wGH0hzNa1nprSre8hqXkMj1oafa3UjsJtNWaVyk/a2qkKfavM5qJguGKCsFz1gx5VuhMwdJFH2QvvrKgkc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=aAPCOmpU; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=443wkJ2F; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="aAPCOmpU"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="443wkJ2F" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744805182; 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: in-reply-to:in-reply-to:references:references; bh=O47BuNNWp13z6juq4IINR3lK0GsXcN1rSFQjsRGU+oc=; b=aAPCOmpUbmUfN9GU8cEWehRy1RLDxdKpmrR9o1hWfEZ0IJ8GSs5bFaMm4I4qvIzTdcsVO2 1AQJgPGn+KSISGXYfAmHZfwC0hbh02dzqnyb5LjMfpUEn3cV8Kmt9yxRSuEk01eW2NUTsz FIknA1Jl17tNWXLHogV+s9myUqAZ+xpcgxuRsQ2vrvN6m4AcwGG4ocG8DeLNVD/61NNtbZ FkGZNWkBeMrqM1CmncoohLhO7yEUMX7J2n1hNgxFccwmlSjB4IfKegxMeZ5pIoot76P4s+ 8GGI4rdQasbWe5nIO1jbt2Jlvk0ex4Flm1GrKKkVtEwzxxGH7wtja4zRJqwImQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744805182; 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: in-reply-to:in-reply-to:references:references; bh=O47BuNNWp13z6juq4IINR3lK0GsXcN1rSFQjsRGU+oc=; b=443wkJ2Fx2h89663rwxjRCIaGkba4s5yUfFWm3hFbSGtNoJdbH5sSvBB04uBXH7aH99DKt tmMdL1A5bud7AlCw== Date: Wed, 16 Apr 2025 14:06:19 +0200 Subject: [PATCH 04/10] tools/nolibc: move getauxval() to sys/auxv.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250416-nolibc-split-sys-v1-4-a069a3f1d145@linutronix.de> References: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> In-Reply-To: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1744805177; l=2973; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=jcMAMRnolUY1bDZt4MbiC8UWAP3z6gSGbjezDeJ4Z4c=; b=3AV1pfbj5N0QXHOFyF/zUAhXlsECD95xWZG41NbJ2748ZJt517h179aONPmKxhK6NlOdCheNp XwfpxGZxs0WCvWqkVlDxgDbFWwJPK08aXchT3k/4gz1Z+i/8ceQ9UcZ X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= This is the location regular userspace expects the definition. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/nolibc.h | 1 + tools/include/nolibc/stdlib.h | 26 -------------------------- tools/include/nolibc/sys/auxv.h | 41 +++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 43 insertions(+), 26 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 2132e4f4d2165729ec6d10860d0586f1b71ee0fb..a3781f39692532fb75c7aaf70f6= 5b2d5bf7c7abd 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -44,6 +44,7 @@ all_files :=3D \ stdlib.h \ string.h \ sys.h \ + sys/auxv.h \ time.h \ types.h \ unistd.h \ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index bb4183a8fdc41023d9b8b37fe35ec37ca408b4c6..0d8c49e0dddc595c2f029788ecb= 5b51231e2695a 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -96,6 +96,7 @@ #include "arch.h" #include "types.h" #include "sys.h" +#include "sys/auxv.h" #include "ctype.h" #include "elf.h" #include "signal.h" diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib.h index 86ad378ab1ea220559d5ab1adc4bb9972977ba9e..ba8a1427121fc543fc83646e510= 8c645cbdd62a2 100644 --- a/tools/include/nolibc/stdlib.h +++ b/tools/include/nolibc/stdlib.h @@ -102,32 +102,6 @@ char *getenv(const char *name) return NULL; } =20 -static __attribute__((unused)) -unsigned long getauxval(unsigned long type) -{ - const unsigned long *auxv =3D _auxv; - unsigned long ret; - - if (!auxv) - return 0; - - while (1) { - if (!auxv[0] && !auxv[1]) { - ret =3D 0; - break; - } - - if (auxv[0] =3D=3D type) { - ret =3D auxv[1]; - break; - } - - auxv +=3D 2; - } - - return ret; -} - static __attribute__((unused)) void *malloc(size_t len) { diff --git a/tools/include/nolibc/sys/auxv.h b/tools/include/nolibc/sys/aux= v.h new file mode 100644 index 0000000000000000000000000000000000000000..04c2b9cbe51a262025bbbc7c74a= 0640c71529eab --- /dev/null +++ b/tools/include/nolibc/sys/auxv.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * auxv definitions for NOLIBC + * Copyright (C) 2017-2021 Willy Tarreau + */ + +#ifndef _NOLIBC_SYS_AUXV_H +#define _NOLIBC_SYS_AUXV_H + +#include "../crt.h" + +static __attribute__((unused)) +unsigned long getauxval(unsigned long type) +{ + const unsigned long *auxv =3D _auxv; + unsigned long ret; + + if (!auxv) + return 0; + + while (1) { + if (!auxv[0] && !auxv[1]) { + ret =3D 0; + break; + } + + if (auxv[0] =3D=3D type) { + ret =3D auxv[1]; + break; + } + + auxv +=3D 2; + } + + return ret; +} + +/* make sure to include all global symbols */ +#include "../nolibc.h" + +#endif /* _NOLIBC_SYS_AUXV_H */ --=20 2.49.0 From nobody Wed Dec 17 05:47:40 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4FF224BBE2 for ; Wed, 16 Apr 2025 12:06:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805188; cv=none; b=WX6T+F+P9bxck+DF8cxDt+DD0yrf3vpwjTxOSk98MrH5UrWP/DTN8hJLGo4d8TvHKaWf8BMVT5Xtgq3g/e60H9W2/kDm8R1LaYGSTO8tzDwyqaVBEVFxMyLzpPdbPbwr6KQtdnP66uE9ZgrgAFbKtCXsVoTve4u2BomO/rtMoIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805188; c=relaxed/simple; bh=VlCWVBZLPVVDDzV0ZU+ZVnBVcZRtRE3tN9Wy+3iVLq0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MkwrU/jgYkjXGqYJnYMOZFr0QM3odQ9CrrNvG0z8SzQYrgdlVK7MUVF6tbK7muePdqs/S7rDSocJDlBOAXRhQZi4ZrWJ5CGchb1UFSwUC53m5xDfwT7EY32fpR4XQdJx9evgQryTLQDsxvm1Y8WsjgqipSQBqOw9D/x5fsCbAIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=MRPib1Ct; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=is3vmZSG; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="MRPib1Ct"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="is3vmZSG" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744805183; 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: in-reply-to:in-reply-to:references:references; bh=tGrQuRPsSyUXfEKNZ/KdVH5q6P06Sel2Spt2RFQ0F4w=; b=MRPib1CtYBgXt8raTSuqHqLgKIw6zW2ByeYK3V/JCFdmDoZLdEf1cCEYZngAY3TS12jKZY nQkvYsOduZnucsUYBX8CLHdRN2u38V+hNOiVxbKBhfgXJ27hhHlGS90W3fjMzbxdO4QvMv uKbYHIdcBhUWR+DAeRSKMbS4G1Z/o9B+Wec5PVdBcws1FPQgZnrYJp64UR+Q/Hox5cgxbH VasTLdBBSDcG8sJxI+Aek8idhBeXqwi0O7Baxzqh9Bp0Hv84UzBnZTFJeF2MzX/doRpebX rSGE5Z9lDUXaWCoqkwe/LlawAtR5ihue0v83iI6bmNxukAtc7zKnbQlq3IqVSQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744805183; 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: in-reply-to:in-reply-to:references:references; bh=tGrQuRPsSyUXfEKNZ/KdVH5q6P06Sel2Spt2RFQ0F4w=; b=is3vmZSGIw0C+zXyS+Z8DPrGoyiabEiktOla1Nq1PG2oS6GyJB1rr8fgtW6E+R9U/ynP6n Vd4xrAZUFZeK7vAg== Date: Wed, 16 Apr 2025 14:06:20 +0200 Subject: [PATCH 05/10] tools/nolibc: move mmap() and friends to sys/mman.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250416-nolibc-split-sys-v1-5-a069a3f1d145@linutronix.de> References: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> In-Reply-To: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1744805177; l=4739; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=VlCWVBZLPVVDDzV0ZU+ZVnBVcZRtRE3tN9Wy+3iVLq0=; b=qtMimDZyY1+rv4Fn7OqvAHkuoKno1OqNr2l2ZguoFMNCXtddkdskuZ9FNki0RVDTB2+eIZdGW iA3588v0NiqC11uDndeXnofHtH1rYQmPxYJXL5SYXM2FvnfodADAVHe X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= This is the location regular userspace expects these definitions. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/nolibc.h | 1 + tools/include/nolibc/sys.h | 48 ------------------------------- tools/include/nolibc/sys/mman.h | 63 +++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 65 insertions(+), 48 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index a3781f39692532fb75c7aaf70f65b2d5bf7c7abd..ca8817e84c3a5b4df3d373e60a9= 56945d2665b94 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -45,6 +45,7 @@ all_files :=3D \ string.h \ sys.h \ sys/auxv.h \ + sys/mman.h \ time.h \ types.h \ unistd.h \ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index 0d8c49e0dddc595c2f029788ecb5b51231e2695a..ffdf501db1b6faebe2f0d5f56bd= 3c31c1a8ec164 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -97,6 +97,7 @@ #include "types.h" #include "sys.h" #include "sys/auxv.h" +#include "sys/mman.h" #include "ctype.h" #include "elf.h" #include "signal.h" diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 5fa351e6a3512a3d0c609867244ac91e8563ab2a..13e6b2479fbf8bcb36843072665= e50046c5f41eb 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -24,7 +24,6 @@ #include #include =20 -#include "arch.h" #include "errno.h" #include "stdarg.h" #include "types.h" @@ -697,53 +696,6 @@ int mknod(const char *path, mode_t mode, dev_t dev) return __sysret(sys_mknod(path, mode, dev)); } =20 -#ifndef sys_mmap -static __attribute__((unused)) -void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd, - off_t offset) -{ - int n; - -#if defined(__NR_mmap2) - n =3D __NR_mmap2; - offset >>=3D 12; -#else - n =3D __NR_mmap; -#endif - - return (void *)my_syscall6(n, addr, length, prot, flags, fd, offset); -} -#endif - -/* Note that on Linux, MAP_FAILED is -1 so we can use the generic __sysret= () - * which returns -1 upon error and still satisfy user land that checks for - * MAP_FAILED. - */ - -static __attribute__((unused)) -void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t o= ffset) -{ - void *ret =3D sys_mmap(addr, length, prot, flags, fd, offset); - - if ((unsigned long)ret >=3D -4095UL) { - SET_ERRNO(-(long)ret); - ret =3D MAP_FAILED; - } - return ret; -} - -static __attribute__((unused)) -int sys_munmap(void *addr, size_t length) -{ - return my_syscall2(__NR_munmap, addr, length); -} - -static __attribute__((unused)) -int munmap(void *addr, size_t length) -{ - return __sysret(sys_munmap(addr, length)); -} - /* * int mount(const char *source, const char *target, * const char *fstype, unsigned long flags, diff --git a/tools/include/nolibc/sys/mman.h b/tools/include/nolibc/sys/mma= n.h new file mode 100644 index 0000000000000000000000000000000000000000..ad9d06b6b7919ec76a065226615= 8366cf639a77a --- /dev/null +++ b/tools/include/nolibc/sys/mman.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * mm definition for NOLIBC + * Copyright (C) 2017-2021 Willy Tarreau + */ + +#ifndef _NOLIBC_SYS_MMAN_H +#define _NOLIBC_SYS_MMAN_H + +#include "../arch.h" +#include "../sys.h" + +#ifndef sys_mmap +static __attribute__((unused)) +void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd, + off_t offset) +{ + int n; + +#if defined(__NR_mmap2) + n =3D __NR_mmap2; + offset >>=3D 12; +#else + n =3D __NR_mmap; +#endif + + return (void *)my_syscall6(n, addr, length, prot, flags, fd, offset); +} +#endif + +/* Note that on Linux, MAP_FAILED is -1 so we can use the generic __sysret= () + * which returns -1 upon error and still satisfy user land that checks for + * MAP_FAILED. + */ + +static __attribute__((unused)) +void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t o= ffset) +{ + void *ret =3D sys_mmap(addr, length, prot, flags, fd, offset); + + if ((unsigned long)ret >=3D -4095UL) { + SET_ERRNO(-(long)ret); + ret =3D MAP_FAILED; + } + return ret; +} + +static __attribute__((unused)) +int sys_munmap(void *addr, size_t length) +{ + return my_syscall2(__NR_munmap, addr, length); +} + +static __attribute__((unused)) +int munmap(void *addr, size_t length) +{ + return __sysret(sys_munmap(addr, length)); +} + +/* make sure to include all global symbols */ +#include "../nolibc.h" + +#endif /* _NOLIBC_SYS_MMAN_H */ --=20 2.49.0 From nobody Wed Dec 17 05:47:40 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEAFB24BBE8 for ; Wed, 16 Apr 2025 12:06:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805188; cv=none; b=sCcr2rkxPUZTWeE8h10AoKZiM5iHfK0jKdwCmlMGiv52G+Dejkb8C5nFtc8Z2e2WN6PSMUxviKHR0eF4xjDgZMz0yE8Ct76pKciFhuYjqhU+zloKYGPltChSnEMG1RNJMldI/rZcxBX6gUP0vQlvtBl1AdBm9o+oQ2rbYnwswU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805188; c=relaxed/simple; bh=f7J3bfWoyvlM97cQCSmrDgCuvCxwgYPCmYmCfAG0YyM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XAS9fq5KowHFEs+PV9m6fObFm+hg+284vIOasevp5325pStoJnBt4ayKlkck2k7WemWEW4PNkdFS2/AL4O6o5mnsxjMkRoz1UG/WqDI/PdfApMD3ST2XejQy+M/tjpqfeGTCSTZqtYiiOBU0q3t3dFgbu85+F2FYHZkr3Q58br4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dlavbNfE; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=SKk4BNiT; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dlavbNfE"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="SKk4BNiT" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744805183; 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: in-reply-to:in-reply-to:references:references; bh=aoGf611ZvRtfc18ew3SA5tA32H9JNlt/cfHJAKwalvQ=; b=dlavbNfExsmj+Hkbh14tAsQv1YURES8zQXWpsiC6pWSyC0bJjAlHwiIGz8F5tgi5h/ccKL ZxtYt+x10KWnMS3hCwLdwca5bGQReLoKmbns9DNoLJlu3ZdH9wFDp3bmLqd1+m4lUh1sHN aT938br7hAUe8A0V4cWMf2QUYri8BJqMFr/pwll5c12Q2ZwX5Mp1dCVhHhBBN2erSSDM/B cTSqJgYL2aNHRm5oSo9R10Rw01wwggbSvUoOWKikbFkVlDODnLNCdU1KzHzRT1QkCNeKZC 7hv/cemMkHozbwYVF+LAoNJ0RdmSWAgitSxBCcFvUH4DPAlo3aAenXZZWCAZPA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744805183; 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: in-reply-to:in-reply-to:references:references; bh=aoGf611ZvRtfc18ew3SA5tA32H9JNlt/cfHJAKwalvQ=; b=SKk4BNiT5lu4LOkrIH7LB+uxiFxq2yzM0C3lB9BJXZRix2aPpFDTt//jlpVt8rFUfEXU0U nrRiGM0HKUouAIBA== Date: Wed, 16 Apr 2025 14:06:21 +0200 Subject: [PATCH 06/10] tools/nolibc: move stat() and friends to sys/stat.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250416-nolibc-split-sys-v1-6-a069a3f1d145@linutronix.de> References: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> In-Reply-To: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1744805177; l=6025; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=f7J3bfWoyvlM97cQCSmrDgCuvCxwgYPCmYmCfAG0YyM=; b=5xuEiTku8nx3EX4vF/qDjsrTFxXZLixMffWjJ17lbihOL2ufqg2I7FDbYXjxpYwshdpz3S201 yghMA2H4VG/DDYry97yXRVKRWiVkoUlnRMf6pn46BhVdIhWZQJhVUps X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= This is the location regular userspace expects these definitions. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/nolibc.h | 1 + tools/include/nolibc/sys.h | 56 ------------------------------- tools/include/nolibc/sys/stat.h | 74 +++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 76 insertions(+), 56 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index ca8817e84c3a5b4df3d373e60a956945d2665b94..747d73b453680a32d1b8748640f= 2ebd1ae9b1fb4 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -46,6 +46,7 @@ all_files :=3D \ sys.h \ sys/auxv.h \ sys/mman.h \ + sys/stat.h \ time.h \ types.h \ unistd.h \ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index ffdf501db1b6faebe2f0d5f56bd3c31c1a8ec164..8296cbbeebe994aa335b561a2d9= 986e529e001a6 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -98,6 +98,7 @@ #include "sys.h" #include "sys/auxv.h" #include "sys/mman.h" +#include "sys/stat.h" #include "ctype.h" #include "elf.h" #include "signal.h" diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 13e6b2479fbf8bcb36843072665e50046c5f41eb..c76dc80147281041afa1cb443d0= 1897d186f7168 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -968,62 +968,6 @@ pid_t setsid(void) return __sysret(sys_setsid()); } =20 -/* - * int statx(int fd, const char *path, int flags, unsigned int mask, struc= t statx *buf); - * int stat(const char *path, struct stat *buf); - */ - -static __attribute__((unused)) -int sys_statx(int fd, const char *path, int flags, unsigned int mask, stru= ct statx *buf) -{ -#ifdef __NR_statx - return my_syscall5(__NR_statx, fd, path, flags, mask, buf); -#else - return __nolibc_enosys(__func__, fd, path, flags, mask, buf); -#endif -} - -static __attribute__((unused)) -int statx(int fd, const char *path, int flags, unsigned int mask, struct s= tatx *buf) -{ - return __sysret(sys_statx(fd, path, flags, mask, buf)); -} - - -static __attribute__((unused)) -int stat(const char *path, struct stat *buf) -{ - struct statx statx; - long ret; - - ret =3D __sysret(sys_statx(AT_FDCWD, path, AT_NO_AUTOMOUNT, STATX_BASIC_S= TATS, &statx)); - if (ret =3D=3D -1) - return ret; - - buf->st_dev =3D ((statx.stx_dev_minor & 0xff) - | (statx.stx_dev_major << 8) - | ((statx.stx_dev_minor & ~0xff) << 12)); - buf->st_ino =3D statx.stx_ino; - buf->st_mode =3D statx.stx_mode; - buf->st_nlink =3D statx.stx_nlink; - buf->st_uid =3D statx.stx_uid; - buf->st_gid =3D statx.stx_gid; - buf->st_rdev =3D ((statx.stx_rdev_minor & 0xff) - | (statx.stx_rdev_major << 8) - | ((statx.stx_rdev_minor & ~0xff) << 12)); - buf->st_size =3D statx.stx_size; - buf->st_blksize =3D statx.stx_blksize; - buf->st_blocks =3D statx.stx_blocks; - buf->st_atim.tv_sec =3D statx.stx_atime.tv_sec; - buf->st_atim.tv_nsec =3D statx.stx_atime.tv_nsec; - buf->st_mtim.tv_sec =3D statx.stx_mtime.tv_sec; - buf->st_mtim.tv_nsec =3D statx.stx_mtime.tv_nsec; - buf->st_ctim.tv_sec =3D statx.stx_ctime.tv_sec; - buf->st_ctim.tv_nsec =3D statx.stx_ctime.tv_nsec; - - return 0; -} - =20 /* * int symlink(const char *old, const char *new); diff --git a/tools/include/nolibc/sys/stat.h b/tools/include/nolibc/sys/sta= t.h new file mode 100644 index 0000000000000000000000000000000000000000..0eaf5496ce233a4d8b5a239eef5= ecefe05a39dd6 --- /dev/null +++ b/tools/include/nolibc/sys/stat.h @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * stat definition for NOLIBC + * Copyright (C) 2017-2021 Willy Tarreau + */ + +#ifndef _NOLIBC_SYS_STAT_H +#define _NOLIBC_SYS_STAT_H + +#include "../arch.h" +#include "../types.h" +#include "../sys.h" + +/* + * int statx(int fd, const char *path, int flags, unsigned int mask, struc= t statx *buf); + * int stat(const char *path, struct stat *buf); + */ + +static __attribute__((unused)) +int sys_statx(int fd, const char *path, int flags, unsigned int mask, stru= ct statx *buf) +{ +#ifdef __NR_statx + return my_syscall5(__NR_statx, fd, path, flags, mask, buf); +#else + return __nolibc_enosys(__func__, fd, path, flags, mask, buf); +#endif +} + +static __attribute__((unused)) +int statx(int fd, const char *path, int flags, unsigned int mask, struct s= tatx *buf) +{ + return __sysret(sys_statx(fd, path, flags, mask, buf)); +} + + +static __attribute__((unused)) +int stat(const char *path, struct stat *buf) +{ + struct statx statx; + long ret; + + ret =3D __sysret(sys_statx(AT_FDCWD, path, AT_NO_AUTOMOUNT, STATX_BASIC_S= TATS, &statx)); + if (ret =3D=3D -1) + return ret; + + buf->st_dev =3D ((statx.stx_dev_minor & 0xff) + | (statx.stx_dev_major << 8) + | ((statx.stx_dev_minor & ~0xff) << 12)); + buf->st_ino =3D statx.stx_ino; + buf->st_mode =3D statx.stx_mode; + buf->st_nlink =3D statx.stx_nlink; + buf->st_uid =3D statx.stx_uid; + buf->st_gid =3D statx.stx_gid; + buf->st_rdev =3D ((statx.stx_rdev_minor & 0xff) + | (statx.stx_rdev_major << 8) + | ((statx.stx_rdev_minor & ~0xff) << 12)); + buf->st_size =3D statx.stx_size; + buf->st_blksize =3D statx.stx_blksize; + buf->st_blocks =3D statx.stx_blocks; + buf->st_atim.tv_sec =3D statx.stx_atime.tv_sec; + buf->st_atim.tv_nsec =3D statx.stx_atime.tv_nsec; + buf->st_mtim.tv_sec =3D statx.stx_mtime.tv_sec; + buf->st_mtim.tv_nsec =3D statx.stx_mtime.tv_nsec; + buf->st_ctim.tv_sec =3D statx.stx_ctime.tv_sec; + buf->st_ctim.tv_nsec =3D statx.stx_ctime.tv_nsec; + + return 0; +} + + +/* make sure to include all global symbols */ +#include "../nolibc.h" + +#endif /* _NOLIBC_SYS_STAT_H */ --=20 2.49.0 From nobody Wed Dec 17 05:47:40 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7E3224BBE5 for ; Wed, 16 Apr 2025 12:06:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805187; cv=none; b=PR4GvOzm3A3RAl763MDj43wMaYaXlwiYj9u9rt2aMccTpaCwKqpZcGEHDgU84mxKLWh4CpdAhMuUgIyvHfMueBAtDVNwo0abGxEZ3A4Ziq0js7eh3HABVHQFJ2V5jbHnDw17Yb9Knd9zKGLTKhJlT9prUdgjTBB1dJ1pksMMkS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805187; c=relaxed/simple; bh=FchtojOjPkGYdbnwmQqwZdtrSm/2Z02HmaMULIjplwc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jR192Ct4CPYeEMstzLHVjpvdbt/xVFnhRE9vVSXFumVgKQ8aTvCX1x4efzX88fGr7BTphoN/qng06SLUzUb7D3PCK0g+7cHzaQcnOs2CtRvVUXe1i6X5ZgLkFGeN16QnKqKP/q0xr8m4Ki9DHaLsudGnRc6Z771+zn6uYhnaJ2Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nxgOtkLf; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=W6KzcOi0; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nxgOtkLf"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="W6KzcOi0" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744805184; 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: in-reply-to:in-reply-to:references:references; bh=r7vr4Sv5pmESa96XKUbIYNisncnTruOja70mEsfDPFM=; b=nxgOtkLf9Yr31pgOWb+yvzNts1n+w4JE94KBWW+vj6GTOFYn4JNd+B6EuV4shPf2aWeABE U0KI3oRrzQRHSEseUKZWXlMQXWcHBU09k9Xhh9G5R+O8dqll00PN+RWE9O9t2rg1vF7Ms+ FZMn4lnch8xzokOJLdYG7MJ3TSTksjl1E9FhXC9x8YeubtDlBytLmYz9ZK13Qmes/jqmEF BMd55xUo6rfjnpl+uW5K0BopdGZ610su92jusESTUPX6Ih+dK4Am3sWOW7RxJMmf8JxMcq /WR/38kbcwwzX/o3y0qW3wNIHT0/CF7yt26vjOGGhhXSKH8JxUgHfZvcyuxN+A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744805184; 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: in-reply-to:in-reply-to:references:references; bh=r7vr4Sv5pmESa96XKUbIYNisncnTruOja70mEsfDPFM=; b=W6KzcOi0HsMCltmUL0DvmUikZqtrySrY5oT/W8VlobgsfudWE6aHj9rks0UrtUNHNN6K73 XZ+lUaGPEBe5deDQ== Date: Wed, 16 Apr 2025 14:06:22 +0200 Subject: [PATCH 07/10] tools/nolibc: move syscall() to sys/syscall.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250416-nolibc-split-sys-v1-7-a069a3f1d145@linutronix.de> References: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> In-Reply-To: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1744805177; l=2942; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=FchtojOjPkGYdbnwmQqwZdtrSm/2Z02HmaMULIjplwc=; b=Y6WqBgfFqxvWRG3qq2IsZytxMJN1ffR3DPg/1wjop89zKK6J+bhL+LrxalNjsOGI1Ur7+8rqB W4/j7rwKrXTDRKWzV111gW0NbsHe5h+0QqL8bMZH8dB+pc9fQy35vFU X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= This is the location regular userspace expects the definition. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/nolibc.h | 1 + tools/include/nolibc/sys/syscall.h | 19 +++++++++++++++++++ tools/include/nolibc/unistd.h | 6 ------ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 747d73b453680a32d1b8748640f2ebd1ae9b1fb4..65c3b90f8ba9213401900a85684= 69bb2c5770dd6 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -47,6 +47,7 @@ all_files :=3D \ sys/auxv.h \ sys/mman.h \ sys/stat.h \ + sys/syscall.h \ time.h \ types.h \ unistd.h \ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index 8296cbbeebe994aa335b561a2d9986e529e001a6..cb5705d55d80862b0c942bffb6c= 38db7626aac86 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -99,6 +99,7 @@ #include "sys/auxv.h" #include "sys/mman.h" #include "sys/stat.h" +#include "sys/syscall.h" #include "ctype.h" #include "elf.h" #include "signal.h" diff --git a/tools/include/nolibc/sys/syscall.h b/tools/include/nolibc/sys/= syscall.h new file mode 100644 index 0000000000000000000000000000000000000000..59efdec8fd1c8cd9f282d1e9ea5= 2431003342a7f --- /dev/null +++ b/tools/include/nolibc/sys/syscall.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * syscall() definition for NOLIBC + * Copyright (C) 2024 Thomas Wei=C3=9Fschuh + */ + +#ifndef _NOLIBC_SYS_SYSCALL_H +#define _NOLIBC_SYS_SYSCALL_H + +#define __syscall_narg(_0, _1, _2, _3, _4, _5, _6, N, ...) N +#define _syscall_narg(...) __syscall_narg(__VA_ARGS__, 6, 5, 4, 3, 2, 1, 0) +#define _syscall(N, ...) __sysret(my_syscall##N(__VA_ARGS__)) +#define _syscall_n(N, ...) _syscall(N, __VA_ARGS__) +#define syscall(...) _syscall_n(_syscall_narg(__VA_ARGS__), ##__VA_ARGS__) + +/* make sure to include all global symbols */ +#include "../nolibc.h" + +#endif /* _NOLIBC_SYS_SYSCALL_H */ diff --git a/tools/include/nolibc/unistd.h b/tools/include/nolibc/unistd.h index e38f3660c0517d757de1ae497b61c4f61b9f1cdc..ac7d53d986cd11ac84dd0a17e5a= 7055c779b2b10 100644 --- a/tools/include/nolibc/unistd.h +++ b/tools/include/nolibc/unistd.h @@ -56,12 +56,6 @@ int tcsetpgrp(int fd, pid_t pid) return ioctl(fd, TIOCSPGRP, &pid); } =20 -#define __syscall_narg(_0, _1, _2, _3, _4, _5, _6, N, ...) N -#define _syscall_narg(...) __syscall_narg(__VA_ARGS__, 6, 5, 4, 3, 2, 1, 0) -#define _syscall(N, ...) __sysret(my_syscall##N(__VA_ARGS__)) -#define _syscall_n(N, ...) _syscall(N, __VA_ARGS__) -#define syscall(...) _syscall_n(_syscall_narg(__VA_ARGS__), ##__VA_ARGS__) - /* make sure to include all global symbols */ #include "nolibc.h" =20 --=20 2.49.0 From nobody Wed Dec 17 05:47:40 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 717F124BC00 for ; Wed, 16 Apr 2025 12:06:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805188; cv=none; b=CNQnl+2Huulnrs+/GwUzpn88ay6TjzbAJitHePEXu5X3d59crfNFtOQBMQQFUh/ctFUIXzBSFFeI6bKleojDmcUY77fbufcwGpwb/uEE3mprOBgQ5cwr2HYXNaYQH+qNG/YqRW/A3TEr4KmKNrpTzkB0bBk8cpN1lG2vJKAhrks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805188; c=relaxed/simple; bh=1Qnrc6rAw5hJRam6pGN88aEHp/LPtZpgzUasKky/zvs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XBqHoKSmr4/OJddw/GqzRpA2Jy7Z8VcxVp+a5G2cI7tg1965ii+UcdqovWsVi1+n3/wYF9aLeOLxKOfixxqnb65qd8zR77iJfQ9iPB77deGsO50GF0D9Marzxde2N90rx8uuioAzBTVgavabbT2VLJCffh1aynPqUsIYMh1DOYg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JlNSglxj; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HKK77xW2; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JlNSglxj"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HKK77xW2" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744805184; 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: in-reply-to:in-reply-to:references:references; bh=EsZfCVPNTklu2oJUJZUYoKj73ykVR4loztF04/oA3HA=; b=JlNSglxjqjpBWDev9KWSBkblNI8agW0Q3116ud5PIxp0sNloW9Ja+3CpxdZAl45Pl8jV6f qQz6EEu/6pNuDrkmk49qpgUpj6WjHU9HvYiZabKG4kmNs2h+CvseBI3Y75ej80vCENKzx8 MHieSu7DxDN05qro0Xldethidkn0A0iTRtTlKwqyrePldbzDTS2mi2MVcWUQLFFhfdNrTz zyd0tK6LfCbSI2FWuheBFcMBJqm89SKz5c5fUxSZ9CIvDJAfPtmUW0He2tEwOyMAInlQsj pAVwtPtItgDmrc+/fUnDm7jEGn7tPlG8LTl0hUQRWlCF4Wg2rvYpYqvlZ0MFRQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744805184; 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: in-reply-to:in-reply-to:references:references; bh=EsZfCVPNTklu2oJUJZUYoKj73ykVR4loztF04/oA3HA=; b=HKK77xW2PhxzwcMgNM3WW+YdL+tl0/Tefyv0b73NhaRoP9w6s5oBZesn7WxdGYcZkZauof EF/91Z7rGgw9QCAA== Date: Wed, 16 Apr 2025 14:06:23 +0200 Subject: [PATCH 08/10] tools/nolibc: move gettimeofday() to sys/time.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250416-nolibc-split-sys-v1-8-a069a3f1d145@linutronix.de> References: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> In-Reply-To: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1744805177; l=3163; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=1Qnrc6rAw5hJRam6pGN88aEHp/LPtZpgzUasKky/zvs=; b=EYgoyrPEYV9bJwgytoIVdD21+tmnPXyhDJejyKqExoVoSVSSF2+B29E3nmrwWDsD2IoYHE7st k5o5ndNFWvbDOSWdy+jOcptRGMX/J6NW99jyAr3ybL1N9bzeKa05bJ+ X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= This is the location regular userspace expects this definition. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/nolibc.h | 1 + tools/include/nolibc/sys.h | 21 --------------------- tools/include/nolibc/sys/time.h | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 21 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 65c3b90f8ba9213401900a8568469bb2c5770dd6..fd1fc769cbbea7c6af998630020= d6d621505f2a1 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -48,6 +48,7 @@ all_files :=3D \ sys/mman.h \ sys/stat.h \ sys/syscall.h \ + sys/time.h \ time.h \ types.h \ unistd.h \ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index cb5705d55d80862b0c942bffb6c38db7626aac86..d84e8610bf1081bc92d969ab760= d8277e25a5174 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -100,6 +100,7 @@ #include "sys/mman.h" #include "sys/stat.h" #include "sys/syscall.h" +#include "sys/time.h" #include "ctype.h" #include "elf.h" #include "signal.h" diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index c76dc80147281041afa1cb443d01897d186f7168..aab0685af84f46298aae37e5a1b= fecb07861db33 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -487,27 +487,6 @@ int getpagesize(void) } =20 =20 -/* - * int gettimeofday(struct timeval *tv, struct timezone *tz); - */ - -static __attribute__((unused)) -int sys_gettimeofday(struct timeval *tv, struct timezone *tz) -{ -#ifdef __NR_gettimeofday - return my_syscall2(__NR_gettimeofday, tv, tz); -#else - return __nolibc_enosys(__func__, tv, tz); -#endif -} - -static __attribute__((unused)) -int gettimeofday(struct timeval *tv, struct timezone *tz) -{ - return __sysret(sys_gettimeofday(tv, tz)); -} - - /* * uid_t getuid(void); */ diff --git a/tools/include/nolibc/sys/time.h b/tools/include/nolibc/sys/tim= e.h new file mode 100644 index 0000000000000000000000000000000000000000..1d326c05ee627b6bdb7d2777cbb= 11eea385f2407 --- /dev/null +++ b/tools/include/nolibc/sys/time.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * time definitions for NOLIBC + * Copyright (C) 2017-2021 Willy Tarreau + */ + +#ifndef _NOLIBC_SYS_TIME_H +#define _NOLIBC_SYS_TIME_H + +#include "../arch.h" +#include "../sys.h" + +/* + * int gettimeofday(struct timeval *tv, struct timezone *tz); + */ + +static __attribute__((unused)) +int sys_gettimeofday(struct timeval *tv, struct timezone *tz) +{ +#ifdef __NR_gettimeofday + return my_syscall2(__NR_gettimeofday, tv, tz); +#else + return __nolibc_enosys(__func__, tv, tz); +#endif +} + +static __attribute__((unused)) +int gettimeofday(struct timeval *tv, struct timezone *tz) +{ + return __sysret(sys_gettimeofday(tv, tz)); +} + +/* make sure to include all global symbols */ +#include "../nolibc.h" + +#endif /* _NOLIBC_SYS_TIME_H */ --=20 2.49.0 From nobody Wed Dec 17 05:47:40 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86CEE24BC05 for ; Wed, 16 Apr 2025 12:06:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805188; cv=none; b=aeNrKXyRcq3mmaVI1F4T1CrHQt412ZvqJejK+Q5vf0CFo15v6zy68xphu86ZKZ5qcsVOSi9AdnDArhROGYttUOEL90fzNJaXxsbvRrI7JA0Txku5qlHfLXAtTQHcgTMWngk7rZYHKUeWnPXex59fGSxvPHvD+XAhaqM1wMeBUFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805188; c=relaxed/simple; bh=LrHZmBSjZyJtBwi7Xec5/FgQGau4RHBwW5b5Qv66hLc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TROWDbmL6MhTSXezJT5NjEqWCYTyB/kIbiDknf3OIFUDKVPNScgvH72AWRXvERLt0cV1vqjQ1pGuwyfOMj6hKS2CtgYXfh8jBa4k5xEp0tWgn6hHn5JZw1HjM0jpN+crAcy7+sS6/frlNQrsiiebMQjaFbYtLSRBl7FkWytnKAg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=GHfUsUSh; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=BhrNHaP5; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="GHfUsUSh"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="BhrNHaP5" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744805185; 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: in-reply-to:in-reply-to:references:references; bh=+O/lR8DudN7PYqjkHN9bqWoJLyoECOmuCmKyj9nlMf8=; b=GHfUsUSh96+0mn0gY2mB8rfvTaHn1TN0Z/pgOisyVpwDmE3Nrj0b/jNtPjvqrSTdPGc1FI TBp4ijr5Dl3woIXyu2c0JGsnabhaRiw3Tc50zbLpXiwUetUIGae/CtITTEAcdDwMvmrJT0 gYRjeQuJvVaX4iAOU1kbkx//6N6+LIgv7UxFYle53UIbxBEP9pTdW/Em0KTqvI0cGnlLGv D+TZpGQMZ43WgzC9U9BrbD0kPm5H8nahwPcBxo8KPRJ72lXmHiUJYU0jA8PTB1GGYpskR/ FL3MeDnBct8vGC3+EyDsPStrHo61cwVGo5/Sgjin0ukZi6UUSTzkyOIS3ervwA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744805185; 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: in-reply-to:in-reply-to:references:references; bh=+O/lR8DudN7PYqjkHN9bqWoJLyoECOmuCmKyj9nlMf8=; b=BhrNHaP578C3qmvxovOmMHJArMpMYvsFO24WO9OF0h+jc8GSLTi8v6Yx/14h49zBr2asBX elbMhkRGDZ1eBECg== Date: Wed, 16 Apr 2025 14:06:24 +0200 Subject: [PATCH 09/10] tools/nolibc: add sys/types.h shim Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250416-nolibc-split-sys-v1-9-a069a3f1d145@linutronix.de> References: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> In-Reply-To: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1744805177; l=1132; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=LrHZmBSjZyJtBwi7Xec5/FgQGau4RHBwW5b5Qv66hLc=; b=0Jgg1AlI7SqVNN60rDdXiQ2EWk+N0dStEc06lXeMcSkxP1Y3ffXIbnTlF76BZjy6uT8nOz04X JkWItv6/ZoiCfPZAkhZAcU7vhypbZlAvLrZp6iL0zTvSVm1WkL3ewpW X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= This is the location regular userspace expects the header. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/sys/types.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index fd1fc769cbbea7c6af998630020d6d621505f2a1..fec0d4eb2119c8ad2bf65d386b8= b5799adf0be5c 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -49,6 +49,7 @@ all_files :=3D \ sys/stat.h \ sys/syscall.h \ sys/time.h \ + sys/types.h \ time.h \ types.h \ unistd.h \ diff --git a/tools/include/nolibc/sys/types.h b/tools/include/nolibc/sys/ty= pes.h new file mode 100644 index 0000000000000000000000000000000000000000..8a264a13275c4ad72cd0345368d= c00a731f88cc0 --- /dev/null +++ b/tools/include/nolibc/sys/types.h @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * sys/types.h shim for NOLIBC + * Copyright (C) 2025 Thomas Wei=C3=9Fschuh + */ + +#include "../types.h" --=20 2.49.0 From nobody Wed Dec 17 05:47:40 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEBD724C069 for ; Wed, 16 Apr 2025 12:06:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805189; cv=none; b=b1EhS9rL2UruCyYfJ4nHPmb5GuERAL9xb421aUk1JFxrc96ntXQKMVp3uSi9nI6obMadeqQ5nuizF2l6JQ4Um7o4Pf9MptQgWqljhht1k4Xv1lQ75wh6uDCLL9xvDcV1wKdAKvmeA2P3xRwzeYF3bDC3wcCDjkm3H9olLNdECVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744805189; c=relaxed/simple; bh=bUqetqfqugUph9SnRQpvh9vvZUw+iWnE9v6heKbB7vU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f3kiuvunjS5Xooh/3TtHAzkNDfabtmoYIu1rX1SRTaqt3c0+UWer25gBi7dMcCB7d99F2FcUFAoQVHWYYVXwEYjDHrdJcz+G9yIr/HUAoog5Chv6UHtaqGf1VWnf3htCSNp1Wo4HFM+7Wng++DQjUB7EjOdezI/AmiMDNFodPoA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=h8bL7wpO; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=N7SzhCyM; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="h8bL7wpO"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="N7SzhCyM" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744805185; 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: in-reply-to:in-reply-to:references:references; bh=6Td79ungl+z18GYzQJHk6JryrllOjSBev7euiR9Nk08=; b=h8bL7wpOJdCbMf8fezgd5NRVd1Dx+sVH9JtQfUTgwwkzQBHYavLhe8D+Nx53robHIMuDAW eHB4q0Soyb9HicJ4mkVmimP2NF9gKIycmD+PYUZ0dkHa0ldD8jsGV/zApGhA5xYxB4FwRE kZChxXtXoc+YmBrNuur8Nj51ABnpxGICCqp0KYFaYn+1l1EMyKAG7ZiEq7UhNgwzAURZpb 7XqAxCUqmO7vh6uUBKPMwbrL6Gs1rK9QeZNzDFROOgUm3C7+C5hFZKdve3lyPaLqCCYIfT 1UTD/ndqRzjjRk2/0Cs8DkvShHiGrS8c8m27u9I7BRbF5furFAZsHzNCBlNwig== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744805185; 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: in-reply-to:in-reply-to:references:references; bh=6Td79ungl+z18GYzQJHk6JryrllOjSBev7euiR9Nk08=; b=N7SzhCyMAe9uZDpQ9U4lf9F0mK+50HVIT4P/pRG3X3jQdoXdzCDAHr/lUaQCzrk65SkmaQ r6NLVJnQv04uTgCQ== Date: Wed, 16 Apr 2025 14:06:25 +0200 Subject: [PATCH 10/10] tools/nolibc: move wait() and friends to sys/wait.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250416-nolibc-split-sys-v1-10-a069a3f1d145@linutronix.de> References: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> In-Reply-To: <20250416-nolibc-split-sys-v1-0-a069a3f1d145@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1744805177; l=5115; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=bUqetqfqugUph9SnRQpvh9vvZUw+iWnE9v6heKbB7vU=; b=PYrGK/0nggOcCYqTqtBGP0f1FpbkkLemmGfpnxDMJNnOseK5KQ4FGmFATxHT13jf+FBcNZ/04 wyS9zA3FxntDMb/see64Hv88GBvmWm2fjEpnt0il4uh3TJzfaK5Sris X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= This is the location regular userspace expects these definitions. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/nolibc.h | 1 + tools/include/nolibc/sys.h | 53 ------------------------------ tools/include/nolibc/sys/wait.h | 71 +++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 73 insertions(+), 53 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index fec0d4eb2119c8ad2bf65d386b8b5799adf0be5c..b5d4479abc3b727b6260b9c6ecd= 34d2b25906c2b 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -50,6 +50,7 @@ all_files :=3D \ sys/syscall.h \ sys/time.h \ sys/types.h \ + sys/wait.h \ time.h \ types.h \ unistd.h \ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index d84e8610bf1081bc92d969ab760d8277e25a5174..e8843880e4dfca54dcd3f2aec33= dab83cb25c17c 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -101,6 +101,7 @@ #include "sys/stat.h" #include "sys/syscall.h" #include "sys/time.h" +#include "sys/wait.h" #include "ctype.h" #include "elf.h" #include "signal.h" diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index aab0685af84f46298aae37e5a1bfecb07861db33..d07456d6e5727cdcb2d4f49c0de= 73568207a6331 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -1054,59 +1054,6 @@ int unlink(const char *path) } =20 =20 -/* - * pid_t wait(int *status); - * pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage); - * pid_t waitpid(pid_t pid, int *status, int options); - */ - -static __attribute__((unused)) -pid_t sys_wait4(pid_t pid, int *status, int options, struct rusage *rusage) -{ -#ifdef __NR_wait4 - return my_syscall4(__NR_wait4, pid, status, options, rusage); -#else - return __nolibc_enosys(__func__, pid, status, options, rusage); -#endif -} - -static __attribute__((unused)) -pid_t wait(int *status) -{ - return __sysret(sys_wait4(-1, status, 0, NULL)); -} - -static __attribute__((unused)) -pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage) -{ - return __sysret(sys_wait4(pid, status, options, rusage)); -} - - -static __attribute__((unused)) -pid_t waitpid(pid_t pid, int *status, int options) -{ - return __sysret(sys_wait4(pid, status, options, NULL)); -} - - -/* - * int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options); - */ - -static __attribute__((unused)) -int sys_waitid(int which, pid_t pid, siginfo_t *infop, int options, struct= rusage *rusage) -{ - return my_syscall5(__NR_waitid, which, pid, infop, options, rusage); -} - -static __attribute__((unused)) -int waitid(int which, pid_t pid, siginfo_t *infop, int options) -{ - return __sysret(sys_waitid(which, pid, infop, options, NULL)); -} - - /* * ssize_t write(int fd, const void *buf, size_t count); */ diff --git a/tools/include/nolibc/sys/wait.h b/tools/include/nolibc/sys/wai= t.h new file mode 100644 index 0000000000000000000000000000000000000000..1af366a63f2079af587d7438953= 0dbcc9cfb588a --- /dev/null +++ b/tools/include/nolibc/sys/wait.h @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * wait definitions for NOLIBC + * Copyright (C) 2017-2021 Willy Tarreau + */ + +#ifndef _NOLIBC_SYS_WAIT_H +#define _NOLIBC_SYS_WAIT_H + +#include "../arch.h" +#include "../std.h" +#include "../types.h" + +/* + * pid_t wait(int *status); + * pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage); + * pid_t waitpid(pid_t pid, int *status, int options); + */ + +static __attribute__((unused)) +pid_t sys_wait4(pid_t pid, int *status, int options, struct rusage *rusage) +{ +#ifdef __NR_wait4 + return my_syscall4(__NR_wait4, pid, status, options, rusage); +#else + return __nolibc_enosys(__func__, pid, status, options, rusage); +#endif +} + +static __attribute__((unused)) +pid_t wait(int *status) +{ + return __sysret(sys_wait4(-1, status, 0, NULL)); +} + +static __attribute__((unused)) +pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage) +{ + return __sysret(sys_wait4(pid, status, options, rusage)); +} + + +static __attribute__((unused)) +pid_t waitpid(pid_t pid, int *status, int options) +{ + return __sysret(sys_wait4(pid, status, options, NULL)); +} + + +/* + * int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options); + */ + +static __attribute__((unused)) +int sys_waitid(int which, pid_t pid, siginfo_t *infop, int options, struct= rusage *rusage) +{ + return my_syscall5(__NR_waitid, which, pid, infop, options, rusage); +} + +static __attribute__((unused)) +int waitid(int which, pid_t pid, siginfo_t *infop, int options) +{ + return __sysret(sys_waitid(which, pid, infop, options, NULL)); +} + + + +/* make sure to include all global symbols */ +#include "../nolibc.h" + +#endif /* _NOLIBC_SYS_WAIT_H */ --=20 2.49.0