1 /*
2  * Copyright (c) 2018, Pinecone Inc. and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 /*
8  * @file	nuttx/time.c
9  * @brief	NuttX libmetal time handling.
10  */
11 
12 #include <metal/time.h>
13 #include <nuttx/clock.h>
14 
metal_get_timestamp(void)15 unsigned long long metal_get_timestamp(void)
16 {
17 	unsigned long long t = 0;
18 	struct timespec tp;
19 	int r;
20 
21 	r = clock_systime_timespec(&tp);
22 	if (!r) {
23 		t = (unsigned long long)tp.tv_sec * NSEC_PER_SEC;
24 		t += tp.tv_nsec;
25 	}
26 	return t;
27 }
28