2017-11-20 François Dumont <fdumont@gcc.gnu.org>
[official-gcc.git] / libgo / runtime / go-now.c
blob13e8f517722da937075682757dcf1348f14a8115
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 #include "runtime.h"
11 // Return current time. This is the implementation of time.walltime().
13 struct walltime_ret
15 int64_t sec;
16 int32_t nsec;
19 struct walltime_ret now() __asm__ (GOSYM_PREFIX "runtime.walltime")
20 __attribute__ ((no_split_stack));
22 struct walltime_ret
23 now()
25 struct timespec ts;
26 struct walltime_ret ret;
28 clock_gettime (CLOCK_REALTIME, &ts);
29 ret.sec = ts.tv_sec;
30 ret.nsec = ts.tv_nsec;
31 return ret;