From 67a577ae6403183fddc9f4e6aa06f0a3263e8210 Mon Sep 17 00:00:00 2001
From: Per Hedbor <ph@opera.com>
Date: Thu, 12 Mar 1998 22:43:40 +0100
Subject: [PATCH] Added option to gethrtime() to get nano-second time
 resolution

Rev: src/builtin_functions.c:1.80
---
 src/builtin_functions.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/builtin_functions.c b/src/builtin_functions.c
index 48cbd6f646..f8e8a62bfa 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.79 1998/03/09 23:23:53 grubba Exp $");
+RCSID("$Id: builtin_functions.c,v 1.80 1998/03/12 21:43:40 per Exp $");
 #include "interpret.h"
 #include "svalue.h"
 #include "pike_macros.h"
@@ -2292,7 +2292,10 @@ void f_gethrvtime(INT32 args)
 void f_gethrtime(INT32 args)
 {
   pop_n_elems(args);
-  push_int((INT32)(gethrtime()/1000)); 
+  if(args)
+    push_int((INT32)(gethrtime())); 
+  else
+    push_int((INT32)(gethrtime()/1000)); 
 }
 #else
 void f_gethrtime(INT32 args)
@@ -2300,7 +2303,10 @@ void f_gethrtime(INT32 args)
   struct timeval tv;
   pop_n_elems(args);
   GETTIMEOFDAY(&tv);
-  push_int((INT32)((tv.tv_sec *1000000) + tv.tv_usec));
+  if(args)
+    push_int((INT32)((tv.tv_sec *1000000) + tv.tv_usec)*1000);
+  else
+    push_int((INT32)((tv.tv_sec *1000000) + tv.tv_usec));
 }
 #endif /* HAVE_GETHRVTIME */
 
@@ -2368,7 +2374,7 @@ void init_builtin_efuns(void)
 {
   init_operators();
 
-  add_efun("gethrtime", f_gethrtime,"function(void:int)", OPT_EXTERNAL_DEPEND);
+  add_efun("gethrtime", f_gethrtime,"function(int|void:int)", OPT_EXTERNAL_DEPEND);
 
 #ifdef HAVE_GETHRVTIME
   add_efun("gethrvtime",f_gethrvtime,"function(void:int)",OPT_EXTERNAL_DEPEND);
-- 
GitLab