From b937db08589494ec5e36212c907d33f186ca0bcb Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 2 Jan 2015 19:30:59 +0000 Subject: [PATCH] hz: add __hz to get HZ value We need this to fix the CLOCK_MONOTONIC timer which is in HZ sized ticks not seconds --- Library/libs/Makefile | 2 +- Library/libs/__hz.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 Library/libs/__hz.c diff --git a/Library/libs/Makefile b/Library/libs/Makefile index 28acf62b..57762f2d 100644 --- a/Library/libs/Makefile +++ b/Library/libs/Makefile @@ -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 index 00000000..171f4a2a --- /dev/null +++ b/Library/libs/__hz.c @@ -0,0 +1,16 @@ +#include +#include + +static int hz; + +int __hz(void) +{ + if (!hz) { + struct _uzisysinfoblk info; + _uname(&info, sizeof(info)); + hz = info.ticks; + } + return hz; +} + + -- 2.34.1