xref: /third_party/musl/porting/linux/user/src/unistd/getpid.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/musl/porting/linux/user/src/unistd/
1570af302Sopenharmony_ci#include <unistd.h>
2570af302Sopenharmony_ci#include "pthread_impl.h"
3570af302Sopenharmony_ci#include "syscall.h"
4570af302Sopenharmony_ci
5570af302Sopenharmony_cistatic pid_t __get_cached_pid()
6570af302Sopenharmony_ci{
7570af302Sopenharmony_ci	return __pthread_self()->pid;
8570af302Sopenharmony_ci}
9570af302Sopenharmony_ci
10570af302Sopenharmony_cipid_t getpid(void)
11570af302Sopenharmony_ci{
12570af302Sopenharmony_ci	pid_t pid = __get_cached_pid();
13570af302Sopenharmony_ci	if (pid != 0) {
14570af302Sopenharmony_ci		return pid;
15570af302Sopenharmony_ci	}
16570af302Sopenharmony_ci	return __syscall(SYS_getpid);
17570af302Sopenharmony_ci}
18

Indexes created Thu Nov 07 10:32:03 CST 2024