stdlib: Improve fortify with clang
[glibc.git] / include / clone_internal.h
blob567160ebb59cdb9eac8bb28f3e66bfce0ac31e12
1 #ifndef _CLONE_INTERNAL_H
2 #define _CLONE_INTERNAL_H
4 #include <clone3.h>
6 /* The clone3 syscall provides a superset of the functionality of the clone
7 interface. The kernel might extend __CL_ARGS struct in the future, with
8 each version with a different __SIZE. If the child is created, it will
9 start __FUNC function with __ARG arguments.
11 Different than kernel, the implementation also returns EINVAL for an
12 invalid NULL __CL_ARGS or __FUNC (similar to __clone).
14 All callers are responsible for correctly aligning the stack. The stack is
15 not aligned prior to the syscall (this differs from the exported __clone).
17 This function is only implemented if the ABI defines HAVE_CLONE3_WRAPPER.
19 extern int __clone3 (struct clone_args *__cl_args, size_t __size,
20 int (*__func) (void *__arg), void *__arg);
22 /* The internal wrapper of clone/clone2 and clone3. Different than __clone3,
23 it will align the stack if required. If __clone3 returns -1 with ENOSYS,
24 fall back to clone or clone2. */
25 extern int __clone_internal (struct clone_args *__cl_args,
26 int (*__func) (void *__arg), void *__arg);
27 /* clone3 wrapper with a sticky check to avoid re-issuing the syscall if
28 it fails with ENOSYS. */
29 extern int __clone3_internal (struct clone_args *cl_args,
30 int (*func) (void *args), void *arg)
31 attribute_hidden;
32 /* The fallback code which calls clone/clone2 based on clone3 arguments. */
33 extern int __clone_internal_fallback (struct clone_args *__cl_args,
34 int (*__func) (void *__arg),
35 void *__arg)
36 attribute_hidden;
38 /* Return whether the kernel supports pid file descriptor, including clone
39 with CLONE_PIDFD and waitid with P_PIDFD. */
40 extern bool __clone_pidfd_supported (void) attribute_hidden;
42 #ifndef _ISOMAC
43 libc_hidden_proto (__clone3)
44 libc_hidden_proto (__clone_internal)
45 #endif
47 #endif