xref: /aosp_15_r20/external/musl/compat/time32/thrd_sleep_time32.c (revision c9945492fdd68bbe62686c5b452b4dc1be3f8453)
1*c9945492SAndroid Build Coastguard Worker #include "time32.h"
2*c9945492SAndroid Build Coastguard Worker #include <time.h>
3*c9945492SAndroid Build Coastguard Worker #include <threads.h>
4*c9945492SAndroid Build Coastguard Worker #include <errno.h>
5*c9945492SAndroid Build Coastguard Worker 
__thrd_sleep_time32(const struct timespec32 * req32,struct timespec32 * rem32)6*c9945492SAndroid Build Coastguard Worker int __thrd_sleep_time32(const struct timespec32 *req32, struct timespec32 *rem32)
7*c9945492SAndroid Build Coastguard Worker {
8*c9945492SAndroid Build Coastguard Worker 	struct timespec rem;
9*c9945492SAndroid Build Coastguard Worker 	int ret = thrd_sleep((&(struct timespec){
10*c9945492SAndroid Build Coastguard Worker 		.tv_sec = req32->tv_sec, .tv_nsec = req32->tv_nsec}), &rem);
11*c9945492SAndroid Build Coastguard Worker 	if (ret<0 && errno==EINTR && rem32) {
12*c9945492SAndroid Build Coastguard Worker 		rem32->tv_sec = rem.tv_sec;
13*c9945492SAndroid Build Coastguard Worker 		rem32->tv_nsec = rem.tv_nsec;
14*c9945492SAndroid Build Coastguard Worker 	}
15*c9945492SAndroid Build Coastguard Worker 	return ret;
16*c9945492SAndroid Build Coastguard Worker }
17