diff options
author | Manuel Bentele | 2020-10-23 15:18:01 +0200 |
---|---|---|
committer | Manuel Bentele | 2020-10-23 15:18:01 +0200 |
commit | dbb41ce2b7f309d394054a6bd1e33afd578798a5 (patch) | |
tree | 6a31092063d9f2fb5ac5720ec6759040e793c3d5 /src/kernel/tests/include/lapi/clone.h | |
parent | Set Linux kernel version to unknown if it is not detectable (diff) | |
download | xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.gz xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.xz xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.zip |
Move the source code of all xloop components to the common 'src' directory
Diffstat (limited to 'src/kernel/tests/include/lapi/clone.h')
-rw-r--r-- | src/kernel/tests/include/lapi/clone.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/kernel/tests/include/lapi/clone.h b/src/kernel/tests/include/lapi/clone.h new file mode 100644 index 0000000..2b8cbdb --- /dev/null +++ b/src/kernel/tests/include/lapi/clone.h @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Linaro Limited. All rights reserved. + * Author: Viresh Kumar <viresh.kumar@linaro.org> + */ + +#ifndef LAPI_CLONE_H__ +#define LAPI_CLONE_H__ + +#include <sys/syscall.h> +#include <linux/types.h> +#include <sched.h> + +#include "config.h" +#include "lapi/syscalls.h" + +#ifndef HAVE_CLONE3 +struct clone_args { + uint64_t __attribute__((aligned(8))) flags; + uint64_t __attribute__((aligned(8))) pidfd; + uint64_t __attribute__((aligned(8))) child_tid; + uint64_t __attribute__((aligned(8))) parent_tid; + uint64_t __attribute__((aligned(8))) exit_signal; + uint64_t __attribute__((aligned(8))) stack; + uint64_t __attribute__((aligned(8))) stack_size; + uint64_t __attribute__((aligned(8))) tls; +}; + +int clone3(struct clone_args *args, size_t size) +{ + return tst_syscall(__NR_clone3, args, size); +} +#endif + +#ifndef CLONE_PIDFD +#define CLONE_PIDFD 0x00001000 /* set if a pidfd should be placed in parent */ +#endif + +void clone3_supported_by_kernel(void) +{ + if ((tst_kvercmp(5, 3, 0)) < 0) { + /* Check if the syscall is backported on an older kernel */ + TEST(syscall(__NR_clone3, NULL, 0)); + if (TST_RET == -1 && TST_ERR == ENOSYS) + tst_brk(TCONF, "Test not supported on kernel version < v5.3"); + } +} + +#endif /* LAPI_CLONE_H__ */ |