From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AED7C433DB for ; Thu, 21 Jan 2021 07:28:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0654923884 for ; Thu, 21 Jan 2021 07:28:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727755AbhAUH2f (ORCPT ); Thu, 21 Jan 2021 02:28:35 -0500 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:49258 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727357AbhAUHVx (ORCPT ); Thu, 21 Jan 2021 02:21:53 -0500 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 10L7KgLB023830; Thu, 21 Jan 2021 08:20:42 +0100 From: Willy Tarreau To: "Paul E. McKenney" Cc: Mark Rutland , valentin.schneider@arm.com, linux-kernel@vger.kernel.org, Willy Tarreau Subject: [PATCH 4/9] tools/nolibc: implement fork() based on clone() Date: Thu, 21 Jan 2021 08:20:26 +0100 Message-Id: <20210121072031.23777-5-w@1wt.eu> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20210121072031.23777-1-w@1wt.eu> References: <20210121072031.23777-1-w@1wt.eu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some archs such as arm64 do not have fork() and have to use clone() instead so let's make fork() always use clone() when available. This requires to include signal.h to get the definition of SIGCHLD. [This is nolibc's upstream commit d2dc42fd6149] Signed-off-by: Willy Tarreau --- tools/include/nolibc/nolibc.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index 9209da89044a..fdd5524e0e54 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -271,6 +271,8 @@ struct stat { #define WEXITSTATUS(status) (((status) & 0xff00) >> 8) #define WIFEXITED(status) (((status) & 0x7f) == 0) +/* for SIGCHLD */ +#include /* Below comes the architecture-specific code. For each architecture, we have * the syscall declarations and the _start code definition. This is the only @@ -1529,7 +1531,15 @@ int sys_execve(const char *filename, char *const argv[], char *const envp[]) static __attribute__((unused)) pid_t sys_fork(void) { +#ifdef __NR_clone + /* note: some archs only have clone() and not fork(). Different archs + * have a different API, but most archs have the flags on first arg and + * will not use the rest with no other flag. + */ + return my_syscall5(__NR_clone, SIGCHLD, 0, 0, 0, 0); +#else return my_syscall0(__NR_fork); +#endif } static __attribute__((unused)) -- 2.28.0