• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright (c) 2016 Xiao Yang <yangx.jy@cn.fujitsu.com>
3  */
4 
5 #ifndef TST_CLONE_H__
6 #define TST_CLONE_H__
7 
8 #ifdef TST_TEST_H__
9 
10 /* The parts of clone3's clone_args we support */
11 struct tst_clone_args {
12 	uint64_t flags;
13 	uint64_t exit_signal;
14 };
15 
16 /* clone3 with fallbacks to clone when possible. Be aware that it
17  * returns -1 if clone3 fails (except ENOSYS), but -2 if clone fails.
18  *
19  * Without CLONE_VM this acts like fork so you may want to set
20  * tst_test.forks_child (safe_clone requires this).
21  *
22  * You should set exit_signal to SIGCHLD for
23  * tst_reap_children. Otherwise you must call wait with the
24  * appropriate parameters.
25  */
26 pid_t tst_clone(const struct tst_clone_args *args);
27 
28 pid_t safe_clone(const char *file, const int lineno,
29 		 const struct tst_clone_args *args);
30 
31 /* "Safe" version of tst_clone */
32 #define SAFE_CLONE(args) safe_clone(__FILE__, __LINE__, args)
33 
34 #endif	/* TST_TEST_H__ */
35 
36 /* Functions from lib/cloner.c */
37 int ltp_clone(unsigned long flags, int (*fn)(void *arg), void *arg,
38 		size_t stack_size, void *stack);
39 int ltp_clone7(unsigned long flags, int (*fn)(void *arg), void *arg,
40 		size_t stack_size, void *stack, ...);
41 int ltp_clone_alloc(unsigned long clone_flags, int (*fn)(void *arg),
42 		void *arg, size_t stacksize);
43 int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg),
44 		void *arg);
45 void *ltp_alloc_stack(size_t size);
46 
47 #define clone(...) (use_the_ltp_clone_functions__do_not_use_clone)
48 
49 #endif	/* TST_CLONE_H__ */
50