OSDN Git Service

runtime: support NumCPU() on more platforms
[pf3gnuchains/gcc-fork.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 // Return current time.  This is the implementation of time.now().
10
11 struct time_now_ret
12 {
13   int64_t sec;
14   int32_t nsec;
15 };
16
17 struct time_now_ret now()
18   __asm__ ("time.now")
19   __attribute__ ((no_split_stack));
20
21 struct time_now_ret
22 now()
23 {
24   struct timeval tv;
25   struct time_now_ret ret;
26
27   gettimeofday (&tv, NULL);
28   ret.sec = tv.tv_sec;
29   ret.nsec = tv.tv_usec * 1000;
30   return ret;
31 }