@@ -36,6 +36,8 @@ void __nolibc_timespec_kernel_to_user(const struct __kernel_timespec *kts, struc
36
36
* int clock_getres(clockid_t clockid, struct timespec *res);
37
37
* int clock_gettime(clockid_t clockid, struct timespec *tp);
38
38
* int clock_settime(clockid_t clockid, const struct timespec *tp);
39
+ * int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp,
40
+ * struct timespec *rmtp)
39
41
*/
40
42
41
43
static __attribute__((unused ))
@@ -107,13 +109,45 @@ int clock_settime(clockid_t clockid, struct timespec *tp)
107
109
return __sysret (sys_clock_settime (clockid , tp ));
108
110
}
109
111
112
+ static __attribute__((unused ))
113
+ int sys_clock_nanosleep (clockid_t clockid , int flags , const struct timespec * rqtp ,
114
+ struct timespec * rmtp )
115
+ {
116
+ #if defined(__NR_clock_nanosleep )
117
+ return my_syscall4 (__NR_clock_nanosleep , clockid , flags , rqtp , rmtp );
118
+ #elif defined(__NR_clock_nanosleep_time64 )
119
+ struct __kernel_timespec krqtp , krmtp ;
120
+ int ret ;
121
+
122
+ __nolibc_timespec_user_to_kernel (rqtp , & krqtp );
123
+ ret = my_syscall4 (__NR_clock_nanosleep_time64 , clockid , flags , & krqtp , & krmtp );
124
+ if (rmtp )
125
+ __nolibc_timespec_kernel_to_user (& krmtp , rmtp );
126
+ return ret ;
127
+ #else
128
+ return __nolibc_enosys (__func__ , clockid , flags , rqtp , rmtp );
129
+ #endif
130
+ }
131
+
132
+ static __attribute__((unused ))
133
+ int clock_nanosleep (clockid_t clockid , int flags , const struct timespec * rqtp ,
134
+ struct timespec * rmtp )
135
+ {
136
+ return __sysret (sys_clock_nanosleep (clockid , flags , rqtp , rmtp ));
137
+ }
110
138
111
139
static __inline__
112
140
double difftime (time_t time1 , time_t time2 )
113
141
{
114
142
return time1 - time2 ;
115
143
}
116
144
145
+ static __inline__
146
+ int nanosleep (const struct timespec * rqtp , struct timespec * rmtp )
147
+ {
148
+ return clock_nanosleep (CLOCK_REALTIME , 0 , rqtp , rmtp );
149
+ }
150
+
117
151
118
152
static __attribute__((unused ))
119
153
time_t time (time_t * tptr )
0 commit comments