blob: bf97692d36eca2d8dc714054c601f4beebdb65f8 [file] [log] [blame]
Brian Silvermanf7f267a2017-02-04 16:16:08 -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
14#include <stdint.h>
15
16#include <string>
17
18#include "llvm/StringRef.h"
19
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
37bool wpi_assert_impl(bool conditionValue, llvm::StringRef conditionText,
38 llvm::StringRef message, llvm::StringRef fileName,
39 int lineNumber, llvm::StringRef funcName);
40bool wpi_assertEqual_impl(int valueA, int valueB, llvm::StringRef valueAString,
41 llvm::StringRef valueBString, llvm::StringRef message,
42 llvm::StringRef fileName, int lineNumber,
43 llvm::StringRef funcName);
44bool wpi_assertNotEqual_impl(int valueA, int valueB,
45 llvm::StringRef valueAString,
46 llvm::StringRef valueBString,
47 llvm::StringRef message, llvm::StringRef fileName,
48 int lineNumber, llvm::StringRef funcName);
49
50void wpi_suspendOnAssertEnabled(bool enabled);
51
52namespace frc {
53
54int GetFPGAVersion();
55int64_t GetFPGARevision();
56uint64_t GetFPGATime();
57bool GetUserButton();
58std::string GetStackTrace(int offset);
59
60} // namespace frc