From 5c2599e24e3aeef9c5ea4966ebef4cc2f9383703 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sat, 24 Nov 2018 14:53:52 +0100 Subject: [PATCH] Remove 'clock()' implementation, print warning FreeBSD implements 'clock' with an accuracy of 128 ticks-per-second for compatibility reasons, Linux uses 1000000 per-second. Remove 'clock' and print an error because it is unlikely that this is the resolution expected by the application. Fix #3057 --- repos/libports/lib/mk/libc-gen.inc | 3 +++ repos/libports/src/lib/libc/time.cc | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/repos/libports/lib/mk/libc-gen.inc b/repos/libports/lib/mk/libc-gen.inc index 85fcd6df9..449653f30 100644 --- a/repos/libports/lib/mk/libc-gen.inc +++ b/repos/libports/lib/mk/libc-gen.inc @@ -8,6 +8,9 @@ FILTER_OUT_C += \ devname.c feature_present.c getpagesizes.c getvfsbyname.c \ setproctitle.c sysconf.c sysctlbyname.c +# the following is a wrapper over rusage, which we cannot provide +FILTER_OUT_C += clock.c + SRC_C = $(filter-out $(FILTER_OUT_C),$(notdir $(wildcard $(LIBC_GEN_DIR)/*.c))) # 'sysconf.c' includes the local 'stdtime/tzfile.h' diff --git a/repos/libports/src/lib/libc/time.cc b/repos/libports/src/lib/libc/time.cc index c9945ac57..0ac13d4a5 100644 --- a/repos/libports/src/lib/libc/time.cc +++ b/repos/libports/src/lib/libc/time.cc @@ -6,7 +6,7 @@ */ /* - * Copyright (C) 2010-2017 Genode Labs GmbH + * Copyright (C) 2010-2018 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU Affero General Public License version 3. @@ -18,6 +18,9 @@ #include "task.h" #include "libc_errno.h" +/* Genode includes */ +#include + namespace Libc { time_t read_rtc(); } @@ -91,3 +94,11 @@ int gettimeofday(struct timeval *tv, struct timezone *) tv->tv_usec = ts.tv_nsec / 1000; return 0; } + + +extern "C" +clock_t clock() +{ + Genode::error(__func__, " not implemented, use 'clock_gettime' instead"); + return -1; +}