]>
Commit | Line | Data |
---|---|---|
43eb1b72 | 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 | ||
9c03884a | 9 | #include "runtime.h" |
10 | ||
e104cab8 | 11 | // Return current time. This is the implementation of time.walltime(). |
43eb1b72 | 12 | |
e104cab8 | 13 | struct walltime_ret |
14 | { | |
15 | int64_t sec; | |
16 | int32_t nsec; | |
17 | }; | |
18 | ||
86b4a2e6 | 19 | struct walltime_ret now(void) __asm__ (GOSYM_PREFIX "runtime.walltime") |
e104cab8 | 20 | __attribute__ ((no_split_stack)); |
21 | ||
22 | struct walltime_ret | |
86b4a2e6 | 23 | now(void) |
43eb1b72 | 24 | { |
2b19d687 | 25 | struct timespec ts; |
e104cab8 | 26 | struct walltime_ret ret; |
43eb1b72 | 27 | |
2b19d687 | 28 | clock_gettime (CLOCK_REALTIME, &ts); |
29 | ret.sec = ts.tv_sec; | |
30 | ret.nsec = ts.tv_nsec; | |
43eb1b72 | 31 | return ret; |
32 | } |