From d69fa4469f834e1c4f6f58e55404c6cd8c962423 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Tue, 16 Jun 2015 13:58:19 -0400 Subject: [PATCH] lib: update the time module to the light FFI MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/standard/time.nit | 7 +++++-- lib/standard/time_nit.c | 19 ------------------- lib/standard/time_nit.h | 20 -------------------- 3 files changed, 5 insertions(+), 41 deletions(-) delete mode 100644 lib/standard/time_nit.c delete mode 100644 lib/standard/time_nit.h diff --git a/lib/standard/time.nit b/lib/standard/time.nit index 260f44c..adac6ff 100644 --- a/lib/standard/time.nit +++ b/lib/standard/time.nit @@ -23,12 +23,15 @@ in "C Header" `{ redef class Object # Unix time: the number of seconds elapsed since January 1, 1970 - protected fun get_time: Int is extern "kernel_Any_Any_get_time_0" + protected fun get_time: Int `{ return time(NULL); `} end redef class Sys # Wait a specific number of second and nanoseconds - fun nanosleep(sec, nanosec: Int) is extern "std_nanosleep" + fun nanosleep(sec, nanosec: Int) `{ + const struct timespec req = {sec, nanosec}; + nanosleep(&req, NULL); + `} end # Time since epoch diff --git a/lib/standard/time_nit.c b/lib/standard/time_nit.c deleted file mode 100644 index ca025fb..0000000 --- a/lib/standard/time_nit.c +++ /dev/null @@ -1,19 +0,0 @@ -/* This file is part of NIT ( http://www.nitlanguage.org ). - * - * Copyright 2008 Floréal Morandat - * - * This file is free software, which comes along with NIT. This software is - * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. You can modify it is you want, provided this header - * is kept unaltered, and a notification of the changes is added. - * You are allowed to redistribute it and sell it, alone or is a part of - * another product. - */ - -#include "time_nit.h" - -void std_nanosleep_(long sec,long nanosec) { - const struct timespec req = {sec, nanosec}; - nanosleep(&req, NULL); -} diff --git a/lib/standard/time_nit.h b/lib/standard/time_nit.h deleted file mode 100644 index ea4a210..0000000 --- a/lib/standard/time_nit.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __TIME_NIT_H -#define __TIME_NIT_H -/* This file is part of NIT ( http://www.nitlanguage.org ). - * - * Copyright 2008 Floréal Morandat - * - * This file is free software, which comes along with NIT. This software is - * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. You can modify it is you want, provided this header - * is kept unaltered, and a notification of the changes is added. - * You are allowed to redistribute it and sell it, alone or is a part of - * another product. - */ - -#include -#define kernel_Any_Any_get_time_0(self) time(NULL) -#define std_nanosleep(self, sec, nanosec) std_nanosleep_(sec, nanosec); -void std_nanosleep_(long sec, long nanosec); -#endif -- 1.7.9.5