WPILibC++ 2027.0.0-alpha-2
Loading...
Searching...
No Matches
timestamp.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#ifndef WPIUTIL_WPI_TIMESTAMP_H_
6#define WPIUTIL_WPI_TIMESTAMP_H_
7
8#include <stdint.h>
9
10#ifdef __cplusplus
11#include <memory> // NOLINT
12
13#endif
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/**
20 * The default implementation used for Now().
21 * In general this is the time returned by the operating system.
22 * @return Time in microseconds.
23 */
24uint64_t WPI_NowDefault(void);
25
26/**
27 * Set the implementation used by WPI_Now().
28 * The implementation must return monotonic time in microseconds to maintain
29 * the contract of WPI_Now().
30 * @param func Function called by WPI_Now() to return the time.
31 */
32void WPI_SetNowImpl(uint64_t (*func)(void));
33
34/**
35 * Return a value representing the current time in microseconds.
36 * The epoch is not defined.
37 * @return Time in microseconds.
38 */
39uint64_t WPI_Now(void);
40
41/**
42 * Return the current system time in microseconds since the Unix epoch
43 * (January 1st, 1970 00:00 UTC).
44 *
45 * @return Time in microseconds.
46 */
47uint64_t WPI_GetSystemTime(void);
48
49#ifdef __cplusplus
50} // extern "C"
51#endif
52
53#ifdef __cplusplus
54namespace wpi {
55
56/**
57 * The default implementation used for Now().
58 * In general this is the time returned by the operating system.
59 * @return Time in microseconds.
60 */
61uint64_t NowDefault();
62
63/**
64 * Set the implementation used by Now().
65 * The implementation must return monotonic time in microseconds to maintain
66 * the contract of Now().
67 * @param func Function called by Now() to return the time.
68 */
69void SetNowImpl(uint64_t (*func)());
70
71/**
72 * Return a value representing the current time in microseconds.
73 * This is a monotonic clock with an undefined epoch.
74 * @return Time in microseconds.
75 */
76uint64_t Now();
77
78/**
79 * Return the current system time in microseconds since the Unix epoch
80 * (January 1st, 1970 00:00 UTC).
81 *
82 * @return Time in microseconds.
83 */
84uint64_t GetSystemTime();
85
86} // namespace wpi
87#endif
88
89#endif // WPIUTIL_WPI_TIMESTAMP_H_
Definition ntcore_cpp.h:26
uint64_t GetSystemTime()
Return the current system time in microseconds since the Unix epoch (January 1st, 1970 00:00 UTC).
uint64_t Now()
Return a value representing the current time in microseconds.
void SetNowImpl(uint64_t(*func)())
Set the implementation used by Now().
uint64_t NowDefault()
The default implementation used for Now().
void WPI_SetNowImpl(uint64_t(*func)(void))
Set the implementation used by WPI_Now().
uint64_t WPI_NowDefault(void)
The default implementation used for Now().
uint64_t WPI_Now(void)
Return a value representing the current time in microseconds.
uint64_t WPI_GetSystemTime(void)
Return the current system time in microseconds since the Unix epoch (January 1st, 1970 00:00 UTC).