Importing Upstream version 4.8.2
[platform/upstream/gcc48.git] / libgo / runtime / go-now.c
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.
4
5 #include <stddef.h>
6 #include <stdint.h>
7 #include <sys/time.h>
8
9 #include "runtime.h"
10
11 // Return current time.  This is the implementation of time.now().
12
13 struct time_now_ret
14 {
15   int64_t sec;
16   int32_t nsec;
17 };
18
19 struct time_now_ret now()
20   __asm__ (GOSYM_PREFIX "time.now")
21   __attribute__ ((no_split_stack));
22
23 struct time_now_ret
24 now()
25 {
26   struct timeval tv;
27   struct time_now_ret ret;
28
29   gettimeofday (&tv, NULL);
30   ret.sec = tv.tv_sec;
31   ret.nsec = tv.tv_usec * 1000;
32   return ret;
33 }