hz: add __hz to get HZ value
authorAlan Cox <alan@linux.intel.com>
Fri, 2 Jan 2015 19:30:59 +0000 (19:30 +0000)
committerAlan Cox <alan@linux.intel.com>
Fri, 2 Jan 2015 19:30:59 +0000 (19:30 +0000)
We need this to fix the CLOCK_MONOTONIC timer which is in HZ sized ticks not
seconds

Library/libs/Makefile
Library/libs/__hz.c [new file with mode: 0644]

index 28acf62..57762f2 100644 (file)
@@ -12,7 +12,7 @@ SRC_CRT0 = crt0.s
 OBJ_CRT0 = $(SRC_CRT0:.s=.rel)
 SRC_ASM =
 OBJ_ASM = $(SRC_ASM:.s=.rel)
-SRC_C =  abort.c asctime.c assert.c atexit.c
+SRC_C =  __hz.c abort.c asctime.c assert.c atexit.c
 SRC_C += bcmp.c bcopy.c bsearch.c bzero.c calloc.c cfree.c clock.c closedir.c
 SRC_C += clock_gettime.c clock_getres.c clock_settime.c
 SRC_C += creat.c crypt.c ctime.c ctype.c difftime.c errno.c error.c execl.c execv.c
diff --git a/Library/libs/__hz.c b/Library/libs/__hz.c
new file mode 100644 (file)
index 0000000..171f4a2
--- /dev/null
@@ -0,0 +1,16 @@
+#include <unistd.h>
+#include <time.h>
+
+static int hz;
+
+int __hz(void)
+{
+  if (!hz) {
+    struct _uzisysinfoblk info;
+    _uname(&info, sizeof(info));
+    hz = info.ticks;
+  }
+  return hz;
+}
+
+