Skip to content

Commit a215747

Browse files
committed
Fix clone3 build failure with older toolchain kernel headers
Define __NR_clone3 (435) ourselves when not provided by the toolchain headers. The syscall number is stable kernel ABI and the same on all architectures since Linux 5.3. The existing runtime fallback to fork() handles older kernels that don't support the syscall. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
1 parent dacda5a commit a215747

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/clone3.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
#include "finit.h"
3838
#include "log.h"
3939

40+
/* clone3() was added in Linux 5.3, syscall number 435 on all archs */
41+
#ifndef __NR_clone3
42+
#define __NR_clone3 435
43+
#endif
44+
4045
/* Clone3 flags from linux/sched.h */
4146
#ifndef CLONE_INTO_CGROUP
4247
#define CLONE_INTO_CGROUP 0x200000000ULL
@@ -57,11 +62,7 @@ struct clone3_args {
5762
uint64_t cgroup; /* Cgroup file descriptor */
5863
} __attribute__((aligned(8)));
5964

60-
#ifdef __NR_clone3
6165
static int use_clone3 = 1;
62-
#else
63-
static int use_clone3 = 0;
64-
#endif
6566

6667
int has_clone3(void)
6768
{

0 commit comments

Comments
 (0)