From 69b5a6a96a1fcb3f741a098a0703e62ea03a1e00 Mon Sep 17 00:00:00 2001
From: Per Hedbor <ph@opera.com>
Date: Tue, 10 Feb 1998 16:45:52 +0100
Subject: [PATCH] Added gethrtime() even when gethrtime(2) does not exist

Rev: src/builtin_functions.c:1.68
---
 src/builtin_functions.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/builtin_functions.c b/src/builtin_functions.c
index 15deb1f7ce..23e14ba69c 100644
--- a/src/builtin_functions.c
+++ b/src/builtin_functions.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: builtin_functions.c,v 1.67 1998/02/01 07:07:37 hubbe Exp $");
+RCSID("$Id: builtin_functions.c,v 1.68 1998/02/10 15:45:52 per Exp $");
 #include "interpret.h"
 #include "svalue.h"
 #include "pike_macros.h"
@@ -1749,6 +1749,14 @@ void f_gethrtime(INT32 args)
   pop_n_elems(args);
   push_int((INT32)(gethrtime()/1000)); 
 }
+#else
+void f_gethrtime(INT32 args)
+{
+  struct timeval tv;
+  pop_n_elems(args);
+  GETTIMEOFDAY(&tv);
+  push_int((INT32)((tv.tv_sec *1000000) + tv.tv_usec));
+}
 #endif /* HAVE_GETHRVTIME */
 
 #ifdef PROFILING
@@ -1815,9 +1823,10 @@ void init_builtin_efuns(void)
 {
   init_operators();
 
+  add_efun("gethrtime", f_gethrtime,"function(void:int)", OPT_EXTERNAL_DEPEND);
+
 #ifdef HAVE_GETHRVTIME
   add_efun("gethrvtime",f_gethrvtime,"function(void:int)",OPT_EXTERNAL_DEPEND);
-  add_efun("gethrtime", f_gethrtime,"function(void:int)", OPT_EXTERNAL_DEPEND);
 #endif
   
 #ifdef PROFILING
-- 
GitLab