Paul Sajna 7 vuotta sitten
vanhempi
commit
4d4ab1a75f
6 muutettua tiedostoa jossa 31 lisäystä ja 2 poistoa
  1. 4 0
      include/bits/timespec.h
  2. 8 0
      include/sys/types.h
  3. 1 1
      src/time/cbindgen.toml
  4. 3 0
      tests/.gitignore
  5. 2 1
      tests/Makefile
  6. 13 0
      tests/sleep.c

+ 4 - 0
include/bits/timespec.h

@@ -0,0 +1,4 @@
+typedef struct {
+    time_t tv_sec;
+    long tv_nsec;
+} timespec;

+ 8 - 0
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 */

+ 1 - 1
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"
 

+ 3 - 0
tests/.gitignore

@@ -20,7 +20,10 @@
 /link
 /link.out
 /math
+/setid
+/sleep
 /pipe
 /printf
 /rmdir
+/unlink
 /write

+ 2 - 1
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

+ 13 - 0
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");
+}