annotate libgo/runtime/go-now.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
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
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
11 // Return current time. This is the implementation of time.walltime1().
111
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
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
19 struct walltime_ret now(void) __asm__ (GOSYM_PREFIX "runtime.walltime1")
111
kono
parents:
diff changeset
20 __attribute__ ((no_split_stack));
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 struct walltime_ret
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
23 now(void)
111
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 }