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 runtime.walltime().
12
13 struct walltime_ret
14 {
15 int64_t sec;
16 int32_t nsec;
17 };
18
19 struct walltime_ret now(void) __asm__ (GOSYM_PREFIX "runtime.walltime")
20 __attribute__ ((no_split_stack));
21
22 struct walltime_ret
23 now(void)
24 {
25 struct timespec ts;
26 struct walltime_ret ret;
27
28 clock_gettime (CLOCK_REALTIME, &ts);
29 ret.sec = ts.tv_sec;
30 ret.nsec = ts.tv_nsec;
31 return ret;
32 }