MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / sigwait

Function sigwait

mysys/my_pthread.c:170–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168
169
170int sigwait(sigset_t *setp, int *sigp)
171{
172 if (memcmp(setp,&sigwait_set,sizeof(sigwait_set)))
173 sigwait_setup(setp); /* Init or change of set */
174
175 for (;;)
176 {
177 /*
178 This is a fast, not 100% portable implementation to find the signal.
179 Because the handler is blocked there should be at most 1 bit set, but
180 the specification on this is somewhat shady so we use a set instead a
181 single variable.
182 */
183
184 ulong *ptr= (ulong*) &px_recd;
185 ulong *end=ptr+sizeof(px_recd)/sizeof(ulong);
186
187 for ( ; ptr != end ; ptr++)
188 {
189 if (*ptr)
190 {
191 ulong set= *ptr;
192 int found= (int) ((char*) ptr - (char*) &px_recd)*8+1;
193 while (!(set & 1))
194 {
195 found++;
196 set>>=1;
197 }
198 *sigp=found;
199 sigdelset(&px_recd,found);
200 return 0;
201 }
202 }
203 sigsuspend(&rev_sigwait_set);
204 }
205 return 0;
206}
207#else /* !DONT_USE_SIGSUSPEND */
208
209/****************************************************************************

Callers 1

my_sigwaitFunction · 0.85

Calls 7

sigwait_setupFunction · 0.85
pthread_cond_initFunction · 0.85
pthread_attr_initFunction · 0.85
pthread_createFunction · 0.85
pthread_attr_destroyFunction · 0.85
pthread_cond_waitFunction · 0.85

Tested by

no test coverage detected