xref: /haiku/src/system/libroot/posix/time/timespec_get.cpp (revision b8fdef84a6d514e63a6d77319ad0111852d755bd)
1a7115745SJérôme Duval /*
2a7115745SJérôme Duval  * Copyright 2022, Jérôme Duval, jerome.duval@gmail.com.
3a7115745SJérôme Duval  * Distributed under the terms of the MIT License.
4a7115745SJérôme Duval  */
5a7115745SJérôme Duval 
6a7115745SJérôme Duval 
7a7115745SJérôme Duval #include <time.h>
8a7115745SJérôme Duval 
9a7115745SJérôme Duval #include <OS.h>
10a7115745SJérôme Duval #include <SupportDefs.h>
11a7115745SJérôme Duval 
12*b8fdef84SAugustin Cavalier #include <time_private.h>
13*b8fdef84SAugustin Cavalier 
14a7115745SJérôme Duval 
15a7115745SJérôme Duval int
timespec_get(struct timespec * time,int base)16a7115745SJérôme Duval timespec_get(struct timespec* time, int base)
17a7115745SJérôme Duval {
18a7115745SJérôme Duval 	if (base != TIME_UTC)
19a7115745SJérôme Duval 		return 0;
20a7115745SJérôme Duval 
21*b8fdef84SAugustin Cavalier 	bigtime_t microSeconds = real_time_clock_usecs();
22*b8fdef84SAugustin Cavalier 	bigtime_to_timespec(microSeconds, *time);
23a7115745SJérôme Duval 	return base;
24a7115745SJérôme Duval }
25