WPILibC++ 2023.4.3
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
11extern "C" {
12#endif
13
14/**
15 * The default implementation used for Now().
16 * In general this is the time returned by the operating system.
17 * @return Time in microseconds.
18 */
20
21/**
22 * Set the implementation used by WPI_Now().
23 * The implementation must return monotonic time in microseconds to maintain
24 * the contract of WPI_Now().
25 * @param func Function called by WPI_Now() to return the time.
26 */
27void WPI_SetNowImpl(uint64_t (*func)(void));
28
29/**
30 * Return a value representing the current time in microseconds.
31 * The epoch is not defined.
32 * @return Time in microseconds.
33 */
35
36/**
37 * Return the current system time in microseconds since the Unix epoch
38 * (January 1st, 1970 00:00 UTC).
39 *
40 * @return Time in microseconds.
41 */
43
44#ifdef __cplusplus
45} // extern "C"
46#endif
47
48#ifdef __cplusplus
49namespace wpi {
50
51/**
52 * The default implementation used for Now().
53 * In general this is the time returned by the operating system.
54 * @return Time in microseconds.
55 */
56uint64_t NowDefault(void);
57
58/**
59 * Set the implementation used by Now().
60 * The implementation must return monotonic time in microseconds to maintain
61 * the contract of Now().
62 * @param func Function called by Now() to return the time.
63 */
64void SetNowImpl(uint64_t (*func)());
65
66/**
67 * Return a value representing the current time in microseconds.
68 * This is a monotonic clock with an undefined epoch.
69 * @return Time in microseconds.
70 */
71uint64_t Now(void);
72
73/**
74 * Return the current system time in microseconds since the Unix epoch
75 * (January 1st, 1970 00:00 UTC).
76 *
77 * @return Time in microseconds.
78 */
79uint64_t GetSystemTime();
80
81} // namespace wpi
82#endif
83
84#endif // WPIUTIL_WPI_TIMESTAMP_H_
int64_t Now()
Returns monotonic current time in 1 us increments.
::uint64_t uint64_t
Definition: Meta.h:58
/file This file defines the SmallVector class.
Definition: AprilTagFieldLayout.h:18
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).