libgupc/
[official-gcc.git] / libgo / runtime / go-now.c
blobede4493b8f3afbb9cfd436c8bb828890d30b408f
1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 #include <stddef.h>
6 #include <stdint.h>
7 #include <sys/time.h>
9 // Return current time. This is the implementation of time.now().
11 struct time_now_ret
13 int64_t sec;
14 int32_t nsec;
17 struct time_now_ret now()
18 __asm__ ("time.now")
19 __attribute__ ((no_split_stack));
21 struct time_now_ret
22 now()
24 struct timeval tv;
25 struct time_now_ret ret;
27 gettimeofday (&tv, NULL);
28 ret.sec = tv.tv_sec;
29 ret.nsec = tv.tv_usec * 1000;
30 return ret;