summaryrefslogtreecommitdiffstats
path: root/libc/arch-x86_64
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-06-19 16:39:01 -0700
committerElliott Hughes <enh@google.com>2014-06-20 09:06:57 -0700
commit7086ad6919feb2415c6027163f5c63323bcca27c (patch)
treef32c06d513e90ba1fcb8fe56f9cd055cccc7d01b /libc/arch-x86_64
parentd1bf37780d0bcaca3e6046171f958ebfea34bde1 (diff)
downloadbionic-7086ad6919feb2415c6027163f5c63323bcca27c.zip
bionic-7086ad6919feb2415c6027163f5c63323bcca27c.tar.gz
bionic-7086ad6919feb2415c6027163f5c63323bcca27c.tar.bz2
Cache getpid.
In practice, with this implementation we never need to make a system call. We get the main thread's tid (which is the same as our pid) back from the set_tid_address system call we have to make during initialization. A new pthread will have the same pid as its parent, and a fork child's main (and only) thread will have a pid equal to its tid, which we get for free from the kernel before clone returns. The only time we'd actually have to make a getpid system call now is if we take a signal during fork and the signal handler calls getpid. (That, or we call getpid in the dynamic linker while it's still dealing with its own relocations and hasn't even set up the main thread yet.) Bug: 15387103 Change-Id: I6d4718ed0a5c912fc75b5f738c49a023dbed5189
Diffstat (limited to 'libc/arch-x86_64')
-rw-r--r--libc/arch-x86_64/syscalls/__getpid.S (renamed from libc/arch-x86_64/syscalls/getpid.S)5
1 files changed, 3 insertions, 2 deletions
diff --git a/libc/arch-x86_64/syscalls/getpid.S b/libc/arch-x86_64/syscalls/__getpid.S
index a2d732c..bd1bf1e 100644
--- a/libc/arch-x86_64/syscalls/getpid.S
+++ b/libc/arch-x86_64/syscalls/__getpid.S
@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
-ENTRY(getpid)
+ENTRY(__getpid)
movl $__NR_getpid, %eax
syscall
cmpq $-MAX_ERRNO, %rax
@@ -12,4 +12,5 @@ ENTRY(getpid)
call __set_errno
1:
ret
-END(getpid)
+END(__getpid)
+.hidden __getpid