diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-13 19:16:27 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-13 19:16:27 +0000 |
commit | 7b1c3dd9e670da2041ff1af415999310f88888ad (patch) | |
tree | c5132538d5da85ed816c7e1f9d93c4a503b838ab /libgo/runtime | |
parent | 36cfbee133027429a681ce585643d38228ab1213 (diff) | |
download | gcc-7b1c3dd9e670da2041ff1af415999310f88888ad.zip gcc-7b1c3dd9e670da2041ff1af415999310f88888ad.tar.gz gcc-7b1c3dd9e670da2041ff1af415999310f88888ad.tar.bz2 |
libgo: Update to weekly.2011-12-02.
From-SVN: r182295
Diffstat (limited to 'libgo/runtime')
-rw-r--r-- | libgo/runtime/go-nanotime.c | 9 | ||||
-rw-r--r-- | libgo/runtime/go-now.c | 31 | ||||
-rw-r--r-- | libgo/runtime/time.goc | 5 |
3 files changed, 36 insertions, 9 deletions
diff --git a/libgo/runtime/go-nanotime.c b/libgo/runtime/go-nanotime.c index 197fb15..7e5e3e0 100644 --- a/libgo/runtime/go-nanotime.c +++ b/libgo/runtime/go-nanotime.c @@ -6,17 +6,16 @@ #include <sys/time.h> -#include "go-assert.h" #include "runtime.h" +int64 runtime_nanotime (void) + __attribute__ ((no_split_stack)); + int64 runtime_nanotime (void) { - int i; struct timeval tv; - i = gettimeofday (&tv, NULL); - __go_assert (i == 0); - + gettimeofday (&tv, NULL); return (int64) tv.tv_sec * 1000000000 + (int64) tv.tv_usec * 1000; } diff --git a/libgo/runtime/go-now.c b/libgo/runtime/go-now.c new file mode 100644 index 0000000..5df8085 --- /dev/null +++ b/libgo/runtime/go-now.c @@ -0,0 +1,31 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include <stddef.h> +#include <stdint.h> +#include <sys/time.h> + +// Return current time. This is the implementation of time.now(). + +struct time_now_ret +{ + int64_t sec; + int32_t nsec; +}; + +struct time_now_ret now() + __asm__ ("libgo_time.time.now") + __attribute__ ((no_split_stack)); + +struct time_now_ret +now() +{ + struct timeval tv; + struct time_now_ret ret; + + gettimeofday (&tv, NULL); + ret.sec = tv.tv_sec; + ret.nsec = tv.tv_usec * 1000; + return ret; +} diff --git a/libgo/runtime/time.goc b/libgo/runtime/time.goc index 93b896e..cae15e5 100644 --- a/libgo/runtime/time.goc +++ b/libgo/runtime/time.goc @@ -18,10 +18,7 @@ static bool deltimer(Timer*); // Package time APIs. // Godoc uses the comments in package time, not these. -// Nanoseconds returns the current time in nanoseconds. -func Nanoseconds() (ret int64) { - ret = runtime_nanotime(); -} +// time.now is implemented in assembly. // Sleep puts the current goroutine to sleep for at least ns nanoseconds. func Sleep(ns int64) { |