Caught by tst-getpid1 test from uClibc's test-suite.
It looks like original implementation was not correct.
The code in question is supposed to recover PID of the new
thread. And by no means that could happen with clone() syscall
while getpid() does exactly this.
Signed-off-by: Alexey Brodkin <abrodkin(a)synopsys.com>
Acked-by: Vineet Gupta <vgupta(a)synopsys.com>
Reported-by: Eugeniy Paltsev <paltsev(a)synopsys.com>
---
libc/sysdeps/linux/arc/clone.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/sysdeps/linux/arc/clone.S b/libc/sysdeps/linux/arc/clone.S
index 3c1388e..dbb3fa7 100644
--- a/libc/sysdeps/linux/arc/clone.S
+++ b/libc/sysdeps/linux/arc/clone.S
@@ -72,7 +72,7 @@ ENTRY(clone)
and_s r2, r2, r12
brne r2, r12, .Lgo_thread
- mov r8, __NR_clone
+ mov r8, __NR_getpid
ARC_TRAP_INSN ; r0 has PID
THREAD_SELF r1 ; Get to struct pthread (just before TCB)
st r0, [r1, PTHREAD_PID]
--
2.7.4