[v5,11/35] clone.2: Use syscall(SYS_...); for system calls without a wrapper

Message ID 20210404115847.78166-12-alx.manpages@gmail.com
State New
Headers show
Series
  • Untitled series #36394
Related show

Commit Message

Vitaly Buka via Libc-alpha April 4, 2021, 11:58 a.m.
The CLONE_* constants seem to be available from either
<linux/sched.h> or <sched.h>, and since clone3() already
includes <linux/sched.h> for 'struct clone_args', <sched.h>
is not really needed, AFAICS; however, to avoid confussion,
I also included <sched.h> for clone3() for consistency:

clone() is getting CLONE_* from <sched.h>, and it would confuse
the reader if clone3() got the same CLONE_* constants from a
different header.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>

---
 man2/clone.2 | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

-- 
2.31.0

Comments

Vitaly Buka via Libc-alpha April 5, 2021, 11:31 a.m. | #1
Hi Alex,

On 4/4/21 1:58 PM, Alejandro Colomar wrote:
> The CLONE_* constants seem to be available from either

> <linux/sched.h> or <sched.h>, and since clone3() already

> includes <linux/sched.h> for 'struct clone_args', <sched.h>

> is not really needed, AFAICS; however, to avoid confussion,

> I also included <sched.h> for clone3() for consistency:


I think that's a good decision.

> clone() is getting CLONE_* from <sched.h>, and it would confuse

> the reader if clone3() got the same CLONE_* constants from a

> different header.


Agreed.

Patch applied.

Thanks,

Michael


> 

> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>

> ---

>  man2/clone.2 | 17 ++++++-----------

>  1 file changed, 6 insertions(+), 11 deletions(-)

> 

> diff --git a/man2/clone.2 b/man2/clone.2

> index fa7d1103e..f455c97d8 100644

> --- a/man2/clone.2

> +++ b/man2/clone.2

> @@ -56,13 +56,13 @@ clone, __clone2, clone3 \- create a child process

>  .PP

>  /* For the prototype of the raw clone() system call, see NOTES */

>  .PP

> -.BI "long clone3(struct clone_args *" cl_args ", size_t " size );

> -.fi

> +.BR "#include <linux/sched.h>" "    /* Definition of " "struct clone_args" " */"

> +.BR "#include <sched.h>" "          /* Definition of " CLONE_* " constants */"

> +.BR "#include <sys/syscall.h>" "    /* Definition of " SYS_* " constants */"

> +.B #include <unistd.h>

>  .PP

> -.IR Note :

> -There is no glibc wrapper for

> -.BR clone3 ();

> -see NOTES.

> +.BI "long syscall(SYS_clone3, struct clone_args *" cl_args ", size_t " size );

> +.fi

>  .SH DESCRIPTION

>  These system calls

>  create a new ("child") process, in a manner similar to

> @@ -1541,11 +1541,6 @@ One use of these systems calls

>  is to implement threads: multiple flows of control in a program that

>  run concurrently in a shared address space.

>  .PP

> -Glibc does not provide a wrapper for

> -.BR clone3 ();

> -call it using

> -.BR syscall (2).

> -.PP

>  Note that the glibc

>  .BR clone ()

>  wrapper function makes some changes

> 



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

Patch

diff --git a/man2/clone.2 b/man2/clone.2
index fa7d1103e..f455c97d8 100644
--- a/man2/clone.2
+++ b/man2/clone.2
@@ -56,13 +56,13 @@  clone, __clone2, clone3 \- create a child process
 .PP
 /* For the prototype of the raw clone() system call, see NOTES */
 .PP
-.BI "long clone3(struct clone_args *" cl_args ", size_t " size );
-.fi
+.BR "#include <linux/sched.h>" "    /* Definition of " "struct clone_args" " */"
+.BR "#include <sched.h>" "          /* Definition of " CLONE_* " constants */"
+.BR "#include <sys/syscall.h>" "    /* Definition of " SYS_* " constants */"
+.B #include <unistd.h>
 .PP
-.IR Note :
-There is no glibc wrapper for
-.BR clone3 ();
-see NOTES.
+.BI "long syscall(SYS_clone3, struct clone_args *" cl_args ", size_t " size );
+.fi
 .SH DESCRIPTION
 These system calls
 create a new ("child") process, in a manner similar to
@@ -1541,11 +1541,6 @@  One use of these systems calls
 is to implement threads: multiple flows of control in a program that
 run concurrently in a shared address space.
 .PP
-Glibc does not provide a wrapper for
-.BR clone3 ();
-call it using
-.BR syscall (2).
-.PP
 Note that the glibc
 .BR clone ()
 wrapper function makes some changes