blob: 89b97296a8bb677227dcedfde94a88b35efb641b [file] [log] [blame]
Brian Silverman1a675112016-02-20 20:42:49 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008-2016. 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
Brian Silverman26e4e522015-12-17 01:56:40 -05008#pragma once
9
10/** @file
11 * Contains global utility functions
12 */
13
14#include <stdint.h>
15#include <string>
16
17#define wpi_assert(condition) \
18 wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__)
19#define wpi_assertWithMessage(condition, message) \
20 wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, \
21 __FUNCTION__)
22
23#define wpi_assertEqual(a, b) \
24 wpi_assertEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
25#define wpi_assertEqualWithMessage(a, b, message) \
26 wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__)
27
28#define wpi_assertNotEqual(a, b) \
29 wpi_assertNotEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
30#define wpi_assertNotEqualWithMessage(a, b, message) \
31 wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
32 __FUNCTION__)
33
34bool wpi_assert_impl(bool conditionValue, const char *conditionText,
35 const char *message, const char *fileName,
36 uint32_t lineNumber, const char *funcName);
37bool wpi_assertEqual_impl(int valueA, int valueB, const char *valueAString,
38 const char *valueBString, const char *message,
39 const char *fileName, uint32_t lineNumber,
40 const char *funcName);
41bool wpi_assertNotEqual_impl(int valueA, int valueB, const char *valueAString,
42 const char *valueBString, const char *message,
43 const char *fileName, uint32_t lineNumber,
44 const char *funcName);
45
46void wpi_suspendOnAssertEnabled(bool enabled);
47
48uint16_t GetFPGAVersion();
49uint32_t GetFPGARevision();
Brian Silverman1a675112016-02-20 20:42:49 -050050uint64_t GetFPGATime();
Brian Silverman26e4e522015-12-17 01:56:40 -050051bool GetUserButton();
52std::string GetStackTrace(uint32_t offset);