unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
To: libc-alpha@sourceware.org, Szabolcs Nagy <szabolcs.nagy@arm.com>,
	"H . J . Lu" <hjl.tools@gmail.com>
Cc: Christian Brauner <brauner@kernel.org>
Subject: [PATCH v2 02/11] linux: Extend internal clone3 documentation
Date: Fri,  4 Nov 2022 16:01:03 -0300	[thread overview]
Message-ID: <20221104190112.2566409-3-adhemerval.zanella@linaro.org> (raw)
In-Reply-To: <20221104190112.2566409-1-adhemerval.zanella@linaro.org>

Different than kernel, clone3 returns EINVAL for NULL struct
clone_args or function pointer.  This is similar to clone
interface that return EINVAL for NULL function argument.

It also clean up the Linux clone3.h interface, since it not
currently exported.

Checked on x86_64-linux-gnu.
---
 include/clone_internal.h         | 24 +++++++++++++++++++-----
 sysdeps/unix/sysv/linux/clone3.h | 10 +---------
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/include/clone_internal.h b/include/clone_internal.h
index 4b23ef33ce..73b8114df4 100644
--- a/include/clone_internal.h
+++ b/include/clone_internal.h
@@ -1,10 +1,24 @@
-#ifndef _CLONE3_H
-#include_next <clone3.h>
+#ifndef _CLONE_INTERNAL_H
+#define _CLONE_INTERNAL_H
 
-extern __typeof (clone3) __clone3;
+#include <clone3.h>
 
-/* The internal wrapper of clone/clone2 and clone3.  If __clone3 returns
-   -1 with ENOSYS, fall back to clone or clone2.  */
+/* The clone3 syscall provides a superset of the functionality of the clone
+   interface.  The kernel might extend __CL_ARGS struct in the future, with
+   each version with a diffent __SIZE.  If the child is created, it will
+   start __FUNC function with __ARG arguments.
+
+   Different than kernel, the implementation also returns EINVAL for an
+   invalid NULL __CL_ARGS or __FUNC (similar to __clone).
+
+   This function is only implemented if the ABI defines HAVE_CLONE3_WRAPPER.
+*/
+extern int __clone3 (struct clone_args *__cl_args, size_t __size,
+		     int (*__func) (void *__arg), void *__arg);
+
+/* The internal wrapper of clone/clone2 and clone3.  Different than __clone3,
+   it will align the stack if required.  If __clone3 returns -1 with ENOSYS,
+   fall back to clone or clone2.  */
 extern int __clone_internal (struct clone_args *__cl_args,
 			     int (*__func) (void *__arg), void *__arg);
 
diff --git a/sysdeps/unix/sysv/linux/clone3.h b/sysdeps/unix/sysv/linux/clone3.h
index 889014a6a9..7c7e2cdcb0 100644
--- a/sysdeps/unix/sysv/linux/clone3.h
+++ b/sysdeps/unix/sysv/linux/clone3.h
@@ -1,4 +1,4 @@
-/* The wrapper of clone3.
+/* The clone3 kernel interface definitions.
    Copyright (C) 2021-2022 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -23,8 +23,6 @@
 #include <stddef.h>
 #include <bits/types.h>
 
-__BEGIN_DECLS
-
 /* The unsigned 64-bit and 8-byte aligned integer type.  */
 typedef __U64_TYPE __aligned_uint64_t __attribute__ ((__aligned__ (8)));
 
@@ -58,10 +56,4 @@ struct clone_args
   __aligned_uint64_t cgroup;
 };
 
-/* The wrapper of clone3.  */
-extern int clone3 (struct clone_args *__cl_args, size_t __size,
-		   int (*__func) (void *__arg), void *__arg);
-
-__END_DECLS
-
 #endif /* clone3.h */
-- 
2.34.1


  parent reply	other threads:[~2022-11-04 19:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04 19:01 [PATCH v2 00/11] Optimize posix_spawn signal setup with clone3 Adhemerval Zanella via Libc-alpha
2022-11-04 19:01 ` [PATCH v2 01/11] linux: Do not reset signal handler in posix_spawn if it is already SIG_DFL Adhemerval Zanella via Libc-alpha
2023-01-11 21:27   ` Carlos O'Donell via Libc-alpha
2022-11-04 19:01 ` Adhemerval Zanella via Libc-alpha [this message]
2022-11-07 16:40   ` [PATCH v2 02/11] linux: Extend internal clone3 documentation Szabolcs Nagy via Libc-alpha
2023-01-11 21:35   ` Carlos O'Donell via Libc-alpha
2022-11-04 19:01 ` [PATCH v2 03/11] Linux: Do not align the stack for __clone3 Adhemerval Zanella via Libc-alpha
2023-01-11 21:43   ` Carlos O'Donell via Libc-alpha
2022-11-04 19:01 ` [PATCH v2 04/11] linux: Add clone3 CLONE_CLEAR_SIGHAND optimization to posix_spawn Adhemerval Zanella via Libc-alpha
2023-01-11 21:44   ` Carlos O'Donell via Libc-alpha
2022-11-04 19:01 ` [PATCH v2 05/11] powerpc64: Add the clone3 wrapper Adhemerval Zanella via Libc-alpha
2022-11-28 16:38   ` Paul E Murphy via Libc-alpha
2022-11-29 20:43     ` Adhemerval Zanella Netto via Libc-alpha
2022-11-04 19:01 ` [PATCH v2 06/11] aarch64: " Adhemerval Zanella via Libc-alpha
2022-11-07 16:14   ` Szabolcs Nagy via Libc-alpha
2022-11-04 19:01 ` [PATCH v2 07/11] s390x: " Adhemerval Zanella via Libc-alpha
2022-11-04 19:01 ` [PATCH v2 08/11] riscv: " Adhemerval Zanella via Libc-alpha
2022-11-04 19:01 ` [PATCH v2 09/11] arm: " Adhemerval Zanella via Libc-alpha
2022-11-04 19:01 ` [PATCH v2 10/11] mips: " Adhemerval Zanella via Libc-alpha
2022-11-04 19:01 ` [PATCH v2 11/11] Linux: optimize clone3 internal usage Adhemerval Zanella via Libc-alpha
2023-01-11 21:45   ` Carlos O'Donell via Libc-alpha
2023-01-11 21:24 ` [PATCH v2 00/11] Optimize posix_spawn signal setup with clone3 Carlos O'Donell via Libc-alpha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221104190112.2566409-3-adhemerval.zanella@linaro.org \
    --to=libc-alpha@sourceware.org \
    --cc=adhemerval.zanella@linaro.org \
    --cc=brauner@kernel.org \
    --cc=hjl.tools@gmail.com \
    --cc=szabolcs.nagy@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).