summaryrefslogtreecommitdiff
path: root/src/thread/sh/clone.s
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014-02-27 22:03:25 -0500
committerRich Felker <dalias@aerifal.cx>2014-02-27 22:03:25 -0500
commitaacd348637e38795dd7ae3c7c8c908d8c0cd24fd (patch)
tree3055797eea08dafe99dcdbd1e7efabd44bcb723b /src/thread/sh/clone.s
parentb9f7f2e8762922a1a24d41358164ebe9ae437e31 (diff)
downloadmusl-aacd348637e38795dd7ae3c7c8c908d8c0cd24fd.tar.gz
rename superh port to "sh" for consistency
linux, gcc, etc. all use "sh" as the name for the superh arch. there was already some inconsistency internally in musl: the dynamic linker was searching for "ld-musl-sh.path" as its path file despite its own name being "ld-musl-superh.so.1". there was some sentiment in both directions as to how to resolve the inconsistency, but overall "sh" was favored.
Diffstat (limited to 'src/thread/sh/clone.s')
-rw-r--r--src/thread/sh/clone.s47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/thread/sh/clone.s b/src/thread/sh/clone.s
new file mode 100644
index 00000000..d6c9184d
--- /dev/null
+++ b/src/thread/sh/clone.s
@@ -0,0 +1,47 @@
+.text
+.global __clone
+.type __clone, @function
+__clone:
+! incoming: fn stack flags arg ptid tls ctid
+! r4 r5 r6 r7 @r15 @(4,r15) @(8,r15)
+
+ mov #-16, r0
+ and r0, r5
+
+ mov r4, r1 ! r1 = fn
+ mov r7, r2 ! r2 = arg
+
+ mov #120, r3 ! r3 = __NR_clone
+ mov r6, r4 ! r4 = flags
+ !mov r5, r5 ! r5 = stack
+ mov.l @r15, r6 ! r6 = ptid
+ mov.l @(8,r15), r7 ! r7 = ctid
+ mov.l @(4,r15), r0 ! r0 = tls
+ trapa #21
+
+ or r0, r0
+ or r0, r0
+ or r0, r0
+ or r0, r0
+ or r0, r0
+
+ cmp/eq #0, r0
+ bt 1f
+
+ ! we are the parent, return
+ rts
+ nop
+
+1: ! we are the child, call fn(arg)
+ jsr @r1
+ mov r2, r4
+
+ mov #1, r3 ! __NR_exit
+ mov r0, r4
+ trapa #17
+
+ or r0, r0
+ or r0, r0
+ or r0, r0
+ or r0, r0
+ or r0, r0