MCPcopy Create free account
hub / github.com/Tencent/libco / GetPid

Function GetPid

co_routine.cpp:117–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117static pid_t GetPid()
118{
119 static __thread pid_t pid = 0;
120 static __thread pid_t tid = 0;
121 if( !pid || !tid || pid != getpid() )
122 {
123 pid = getpid();
124#if defined( __APPLE__ )
125 tid = syscall( SYS_gettid );
126 if( -1 == (long)tid )
127 {
128 tid = pid;
129 }
130#elif defined( __FreeBSD__ )
131 syscall(SYS_thr_self, &tid);
132 if( tid < 0 )
133 {
134 tid = pid;
135 }
136#else
137 tid = syscall( __NR_gettid );
138#endif
139
140 }
141 return tid;
142
143}
144/*
145static pid_t GetPid()
146{

Callers 2

co_init_curr_thread_envFunction · 0.70
co_get_curr_thread_envFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected