summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/sparc64/fork.S
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/sparc64/fork.S')
-rw-r--r--libc/sysdeps/linux/sparc64/fork.S32
1 files changed, 32 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/sparc64/fork.S b/libc/sysdeps/linux/sparc64/fork.S
new file mode 100644
index 000000000..55c5e8d5c
--- /dev/null
+++ b/libc/sysdeps/linux/sparc64/fork.S
@@ -0,0 +1,32 @@
+/*
+ * The fork and vfork system calls are special on sparc64:
+ * they return the "other process" pid in %o0 and the
+ * "is child" flag in %o1
+ */
+
+#include <features.h>
+#include <sys/syscall.h>
+
+.text
+.global fork
+.type fork, @function
+.align 4
+
+fork:
+ mov __NR_fork, %g1
+ ta 0x6d
+ sub %o1, 1, %o1
+ bcc,pt %xcc, 1f
+ and %o0, %o1, %o0
+ sethi %hi(errno), %g4
+ or %g4, %lo(errno), %g4
+ st %o0, [%g4]
+ retl
+ mov -1, %o0
+1:
+ retl
+ nop
+
+.size fork, . - fork
+
+libc_hidden_def(fork)