]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
process-util: use clone2 on ia64
authorLuca Boccassi <bluca@debian.org>
Sat, 8 Jul 2023 15:43:28 +0000 (16:43 +0100)
committerLuca Boccassi <bluca@debian.org>
Mon, 10 Jul 2023 10:39:35 +0000 (11:39 +0100)
glibc does not provide clone() on ia64, only clone2. But only as a
symbol in the shared library, there's no prototype in the gblic
headers, so we have to define it, copied from the manpage.

src/basic/missing_syscall.h
src/basic/process-util.c

index 062decaff6234bb9a9f2ec2d9604e7f1d25ad3ba..ddee457f4449d710f531368c8de42e75358e6a22 100644 (file)
@@ -654,3 +654,17 @@ static inline ssize_t missing_getdents64(int fd, void *buffer, size_t length) {
 
 #  define getdents64 missing_getdents64
 #endif
+
+/* ======================================================================= */
+
+/* glibc does not provide clone() on ia64, only clone2(). Not only that, but it also doesn't provide a
+ * prototype, only the symbol in the shared library (it provides a prototype for clone(), but not the
+ * symbol in the shared library). */
+#if defined(__ia64__)
+int __clone2(int (*fn)(void *), void *stack_base, size_t stack_size, int flags, void *arg);
+#define HAVE_CLONE 0
+#else
+/* We know that everywhere else clone() is available, so we don't bother with a meson check (that takes time
+ * at build time) and just define it. Once the kernel drops ia64 support, we can drop this too. */
+#define HAVE_CLONE 1
+#endif
index 6cf882866fd755000da742f85d4921b15009dab2..7182e15b61046307ffacef0ec55101ca2fbb2524 100644 (file)
@@ -1177,7 +1177,11 @@ pid_t clone_with_nested_stack(int (*fn)(void *), int flags, void *userdata) {
         mystack = (uint8_t*) mystack + ps; /* move pointer one page ahead since stacks usually grow backwards */
         mystack = (void*) ALIGN_TO((uintptr_t) mystack, ps); /* align to page size (moving things further ahead) */
 
+#if HAVE_CLONE
         pid = clone(fn, mystack, flags, userdata);
+#else
+        pid = __clone2(fn, mystack, ps, flags, userdata);
+#endif
         if (pid < 0)
                 return -errno;