Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157914041
D54898.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D54898.diff
View Options
diff --git a/lib/libsys/Symbol.sys.map b/lib/libsys/Symbol.sys.map
--- a/lib/libsys/Symbol.sys.map
+++ b/lib/libsys/Symbol.sys.map
@@ -182,6 +182,7 @@
rename;
revoke;
rfork;
+ rfork_thread;
rmdir;
rtprio;
rtprio_thread;
@@ -391,6 +392,7 @@
FBSD_1.9 {
pdrfork;
+ pdrfork_thread;
};
FBSDprivate_1.0 {
diff --git a/lib/libsys/aarch64/Makefile.sys b/lib/libsys/aarch64/Makefile.sys
--- a/lib/libsys/aarch64/Makefile.sys
+++ b/lib/libsys/aarch64/Makefile.sys
@@ -1,6 +1,8 @@
MIASM:= ${MIASM:Nfreebsd[467]_*}
SRCS+= __vdso_gettc.c \
+ pdrfork_thread_gen.c \
+ rfork_thread_gen.c \
sched_getcpu_gen.c
MDASM= cerror.S \
diff --git a/lib/libsys/amd64/Symbol.sys.map b/lib/libsys/amd64/Symbol.sys.map
--- a/lib/libsys/amd64/Symbol.sys.map
+++ b/lib/libsys/amd64/Symbol.sys.map
@@ -1,5 +1,4 @@
FBSD_1.0 {
- rfork_thread;
amd64_get_fsbase;
amd64_get_gsbase;
amd64_set_fsbase;
@@ -17,10 +16,6 @@
amd64_set_tlsbase;
};
-FBSD_1.9 {
- pdrfork_thread;
-};
-
FBSDprivate_1.0 {
_vfork;
};
diff --git a/lib/libsys/arm/Makefile.sys b/lib/libsys/arm/Makefile.sys
--- a/lib/libsys/arm/Makefile.sys
+++ b/lib/libsys/arm/Makefile.sys
@@ -1,4 +1,6 @@
SRCS+= __vdso_gettc.c \
+ pdrfork_thread_gen.c \
+ rfork_thread_gen.c \
sched_getcpu_gen.c
MDASM= \
diff --git a/lib/libsys/i386/Symbol.sys.map b/lib/libsys/i386/Symbol.sys.map
--- a/lib/libsys/i386/Symbol.sys.map
+++ b/lib/libsys/i386/Symbol.sys.map
@@ -10,7 +10,6 @@
i386_set_ldt;
i386_set_watch;
i386_vm86;
- rfork_thread;
};
FBSD_1.6 {
@@ -20,10 +19,6 @@
x86_pkru_unprotect_range;
};
-FBSD_1.9 {
- pdrfork_thread;
-};
-
FBSDprivate_1.0 {
_vfork;
};
diff --git a/lib/libsys/pdrfork_thread_gen.c b/lib/libsys/pdrfork_thread_gen.c
new file mode 100644
--- /dev/null
+++ b/lib/libsys/pdrfork_thread_gen.c
@@ -0,0 +1,34 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright 2026 The FreeBSD Foundation
+ *
+ * This software were developed by
+ * Konstantin Belousov <kib@FreeBSD.org> under sponsorship from
+ * the FreeBSD Foundation.
+ */
+
+#include <sys/types.h>
+#include <sys/procdesc.h>
+#include <errno.h>
+#include <unistd.h>
+
+pid_t
+pdrfork_thread(int *fdp, int pdflags, int rfflags, void *stack_addr,
+ int (*start_fn)(void *), void *arg)
+{
+ pid_t res;
+ int ret;
+
+ /* See comment in rfork_thread_gen.c. */
+ if (stack_addr != NULL) {
+ errno = EOPNOTSUPP;
+ return (-1);
+ }
+ res = pdrfork(fdp, pdflags, rfflags);
+ if (res == 0) {
+ ret = start_fn(arg);
+ _exit(ret);
+ }
+ return (res);
+}
diff --git a/lib/libsys/powerpc/Makefile.sys b/lib/libsys/powerpc/Makefile.sys
--- a/lib/libsys/powerpc/Makefile.sys
+++ b/lib/libsys/powerpc/Makefile.sys
@@ -1,4 +1,6 @@
SRCS+= __vdso_gettc.c \
+ pdrfork_thread_gen.c \
+ rfork_thread_gen.c \
sched_getcpu_gen.c
MDASM+= cerror.S
diff --git a/lib/libsys/powerpc64/Makefile.sys b/lib/libsys/powerpc64/Makefile.sys
--- a/lib/libsys/powerpc64/Makefile.sys
+++ b/lib/libsys/powerpc64/Makefile.sys
@@ -1,4 +1,6 @@
SRCS+= __vdso_gettc.c \
+ pdrfork_thread_gen.c \
+ rfork_thread_gen.c \
sched_getcpu_gen.c
MDASM+= cerror.S
diff --git a/lib/libsys/rfork_thread_gen.c b/lib/libsys/rfork_thread_gen.c
new file mode 100644
--- /dev/null
+++ b/lib/libsys/rfork_thread_gen.c
@@ -0,0 +1,40 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright 2026 The FreeBSD Foundation
+ *
+ * This software were developed by
+ * Konstantin Belousov <kib@FreeBSD.org> under sponsorship from
+ * the FreeBSD Foundation.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+
+pid_t
+rfork_thread(int flags, void *stack_addr, int (*start_fn)(void *), void *arg)
+{
+ pid_t res;
+ int ret;
+
+ /*
+ * Generic implementation cannot switch stacks. Only
+ * architecture-specific code knows how to do it. Require
+ * that caller knows that, and refuse to do operate if the
+ * stack was supplied.
+ *
+ * Note that implementations that do switch stack, would fault
+ * immediately if the passed stack is NULL. They do not need to
+ * specifically check for the NULL stack value.
+ */
+ if (stack_addr != NULL) {
+ errno = EOPNOTSUPP;
+ return (-1);
+ }
+ res = rfork(flags);
+ if (res == 0) {
+ ret = start_fn(arg);
+ _exit(ret);
+ }
+ return (res);
+}
diff --git a/lib/libsys/riscv/Makefile.sys b/lib/libsys/riscv/Makefile.sys
--- a/lib/libsys/riscv/Makefile.sys
+++ b/lib/libsys/riscv/Makefile.sys
@@ -1,4 +1,6 @@
SRCS+= __vdso_gettc.c \
+ pdrfork_thread_gen.c \
+ rfork_thread_gen.c \
sched_getcpu_gen.c
MDASM= cerror.S \
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, May 27, 10:54 AM (20 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33554396
Default Alt Text
D54898.diff (4 KB)
Attached To
Mode
D54898: libsys, libc: provide rfork_thread() and pdrfork_thread() on all arches
Attached
Detach File
Event Timeline
Log In to Comment