blob: 196dfce2d102b2641ec3244f4783dc77cc4d25aa [file] [log] [blame]
Parker Schuhd3b7a8872018-02-19 16:42:27 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008-2017. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
6/*----------------------------------------------------------------------------*/
7
8#pragma once
9
10/** @file
11 * Contains global utility functions
12 */
13
Tyler Chatowbf0609c2021-07-31 16:13:27 -070014#include <cstdint>
Parker Schuhd3b7a8872018-02-19 16:42:27 -080015#include <string>
16
Austin Schuhf6b94632019-02-02 22:11:27 -080017#include "wpi/StringRef.h"
18#include "wpi/Twine.h"
Parker Schuhd3b7a8872018-02-19 16:42:27 -080019
20#define wpi_assert(condition) \
21 wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__)
22#define wpi_assertWithMessage(condition, message) \
23 wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, \
24 __FUNCTION__)
25
26#define wpi_assertEqual(a, b) \
27 wpi_assertEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
28#define wpi_assertEqualWithMessage(a, b, message) \
29 wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__)
30
31#define wpi_assertNotEqual(a, b) \
32 wpi_assertNotEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
33#define wpi_assertNotEqualWithMessage(a, b, message) \
34 wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
35 __FUNCTION__)
36
Austin Schuhf6b94632019-02-02 22:11:27 -080037bool wpi_assert_impl(bool conditionValue, const wpi::Twine &conditionText,
38 const wpi::Twine &message, wpi::StringRef fileName,
39 int lineNumber, wpi::StringRef funcName);
40bool wpi_assertEqual_impl(int valueA, int valueB,
41 const wpi::Twine &valueAString,
42 const wpi::Twine &valueBString,
43 const wpi::Twine &message, wpi::StringRef fileName,
44 int lineNumber, wpi::StringRef funcName);
Parker Schuhd3b7a8872018-02-19 16:42:27 -080045bool wpi_assertNotEqual_impl(int valueA, int valueB,
Austin Schuhf6b94632019-02-02 22:11:27 -080046 const wpi::Twine &valueAString,
47 const wpi::Twine &valueBString,
48 const wpi::Twine &message, wpi::StringRef fileName,
49 int lineNumber, wpi::StringRef funcName);
Parker Schuhd3b7a8872018-02-19 16:42:27 -080050
51void wpi_suspendOnAssertEnabled(bool enabled);
52
53namespace frc {
54
55int GetFPGAVersion();
56int64_t GetFPGARevision();
57uint64_t GetFPGATime();
58bool GetUserButton();
59std::string GetStackTrace(int offset);
60
61} // namespace frc