xref: /third_party/musl/src/unistd/getpid.c (revision 570af302)
1#include <unistd.h>
2#include "pthread_impl.h"
3#include "syscall.h"
4
5static pid_t __get_cached_pid()
6{
7	return __pthread_self()->pid;
8}
9
10pid_t getpid(void)
11{
12	pid_t pid = __get_cached_pid();
13	if (pid != 0) {
14		return pid;
15	}
16	return __syscall(SYS_getpid);
17}
18