diff --git a/userspace/libraries/LibC/include/sys/types.h b/userspace/libraries/LibC/include/sys/types.h index bae8324562..3b661a31cc 100644 --- a/userspace/libraries/LibC/include/sys/types.h +++ b/userspace/libraries/LibC/include/sys/types.h @@ -185,6 +185,12 @@ __BEGIN_DECLS #endif #undef __need_uid_t +#if !defined(__useconds_t_defined) && (defined(__need_all_types) || defined(__need_useconds_t)) + #define __useconds_t_defined 1 + typedef unsigned long useconds_t; +#endif +#undef __need_useconds_t + #ifdef __need_all_types #include #endif diff --git a/userspace/libraries/LibC/include/unistd.h b/userspace/libraries/LibC/include/unistd.h index 21748a03dd..ea45e984c8 100644 --- a/userspace/libraries/LibC/include/unistd.h +++ b/userspace/libraries/LibC/include/unistd.h @@ -101,6 +101,7 @@ __BEGIN_DECLS #define __need_gid_t #define __need_off_t #define __need_pid_t +#define __need_useconds_t #include // FIXME: _CS prefixed definitions @@ -206,6 +207,7 @@ char* ttyname(int fildes); int ttyname_r(int fildes, char* name, size_t namesize); int unlink(const char* path); int unlinkat(int fd, const char* path, int flag); +int usleep(useconds_t usec); ssize_t write(int fildes, const void* buf, size_t nbyte); extern char* optarg; diff --git a/userspace/libraries/LibC/unistd.cpp b/userspace/libraries/LibC/unistd.cpp index 82dd95d146..d3afcfbf60 100644 --- a/userspace/libraries/LibC/unistd.cpp +++ b/userspace/libraries/LibC/unistd.cpp @@ -280,6 +280,14 @@ unsigned int sleep(unsigned int seconds) return ret; } +int usleep(useconds_t usec) +{ + timespec ts; + ts.tv_sec = usec / 1'000'000; + ts.tv_nsec = (usec % 1'000'000) * 1000; + return nanosleep(&ts, nullptr); +} + char* getcwd(char* buf, size_t size) { if (size == 0)