diff --git a/include/bits/timespec.h b/include/bits/timespec.h new file mode 100644 index 0000000000..52d696fc31 --- /dev/null +++ b/include/bits/timespec.h @@ -0,0 +1,4 @@ +typedef struct { + time_t tv_sec; + long tv_nsec; +} timespec; diff --git a/include/sys/types.h b/include/sys/types.h index 0813cddfe4..7312acfd4b 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -24,4 +24,12 @@ typedef long time_t; typedef int useconds_t; +typedef long suseconds_t; + +typedef long clock_t; + +typedef int clockid_t; + +typedef void* timer_t; + #endif /* _SYS_TYPES_H */ diff --git a/src/time/cbindgen.toml b/src/time/cbindgen.toml index afc1ec2138..ef3a5240e6 100644 --- a/src/time/cbindgen.toml +++ b/src/time/cbindgen.toml @@ -1,4 +1,4 @@ -sys_includes = ["sys/types.h"] +sys_includes = ["sys/types.h", "bits/timespec.h", "stdint.h"] include_guard = "_TIME_H" language = "C" diff --git a/tests/.gitignore b/tests/.gitignore index 7b70bccffc..98ef35573f 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -20,7 +20,10 @@ /link /link.out /math +/setid +/sleep /pipe /printf /rmdir +/unlink /write diff --git a/tests/Makefile b/tests/Makefile index 6c2a838d87..c60411f66c 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -19,6 +19,7 @@ BINS=\ rmdir \ pipe \ printf \ + sleep \ write all: $(BINS) @@ -28,7 +29,7 @@ clean: run: $(BINS) for bin in $(BINS); \ - do + do \ echo "# $${bin} #"; \ "./$${bin}" test args; \ done diff --git a/tests/sleep.c b/tests/sleep.c new file mode 100644 index 0000000000..ab66a4e75e --- /dev/null +++ b/tests/sleep.c @@ -0,0 +1,13 @@ +#include +#include +#include + +int main(int argc, char** argv) { + sleep(2); + perror("sleep"); + usleep(1000); + perror("usleep"); + timespec tm = {0, 10000}; + nanosleep(&tm, NULL); + perror("nanosleep"); +}