diff --git a/include/bits/timespec.h b/include/bits/timespec.h new file mode 100644 index 0000000000000000000000000000000000000000..52d696fc3129c3a14a9f2dce1c351e0c5aea567f --- /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 0813cddfe4974a14426f1475a8693c66cb23498d..7312acfd4bb99cdca80da29228c06e194231d747 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 afc1ec2138df1300916890965e3c73d1ebad42fa..ef3a5240e6d6dd30ae2b1b7421ecc5f4783a7f8f 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 7b70bccffc40d658e29d3a82098cafef75130ba3..98ef35573f083045c76debb30a5b9895a2352d02 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 6c2a838d878c6e7498fa8909e987439c5cb6615e..c60411f66cdceb1f391548852b304c3a7ab1a326 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 0000000000000000000000000000000000000000..ab66a4e75e540ce88a0fcb6ae49b33d7ccb8af79 --- /dev/null +++ b/tests/sleep.c @@ -0,0 +1,13 @@ +#include <time.h> +#include <unistd.h> +#include <stdio.h> + +int main(int argc, char** argv) { + sleep(2); + perror("sleep"); + usleep(1000); + perror("usleep"); + timespec tm = {0, 10000}; + nanosleep(&tm, NULL); + perror("nanosleep"); +}