annotate libgo/runtime/go-now.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // Copyright 2011 The Go Authors. All rights reserved.
kono
parents:
diff changeset
2 // Use of this source code is governed by a BSD-style
kono
parents:
diff changeset
3 // license that can be found in the LICENSE file.
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 #include <stddef.h>
kono
parents:
diff changeset
6 #include <stdint.h>
kono
parents:
diff changeset
7 #include <sys/time.h>
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 #include "runtime.h"
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 // Return current time. This is the implementation of time.walltime().
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 struct walltime_ret
kono
parents:
diff changeset
14 {
kono
parents:
diff changeset
15 int64_t sec;
kono
parents:
diff changeset
16 int32_t nsec;
kono
parents:
diff changeset
17 };
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 struct walltime_ret now() __asm__ (GOSYM_PREFIX "runtime.walltime")
kono
parents:
diff changeset
20 __attribute__ ((no_split_stack));
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 struct walltime_ret
kono
parents:
diff changeset
23 now()
kono
parents:
diff changeset
24 {
kono
parents:
diff changeset
25 struct timespec ts;
kono
parents:
diff changeset
26 struct walltime_ret ret;
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 clock_gettime (CLOCK_REALTIME, &ts);
kono
parents:
diff changeset
29 ret.sec = ts.tv_sec;
kono
parents:
diff changeset
30 ret.nsec = ts.tv_nsec;
kono
parents:
diff changeset
31 return ret;
kono
parents:
diff changeset
32 }