Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame^] | 1 | /*---------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2008. All Rights Reserved. |
| 3 | */ |
| 4 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
| 5 | /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ |
| 6 | /*---------------------------------------------------------------------------*/ |
| 7 | #pragma once |
| 8 | |
| 9 | /** @file |
| 10 | * Contains global utility functions |
| 11 | */ |
| 12 | |
| 13 | #include <stdint.h> |
| 14 | #include <string> |
| 15 | |
| 16 | #define wpi_assert(condition) \ |
| 17 | wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__) |
| 18 | #define wpi_assertWithMessage(condition, message) \ |
| 19 | wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, \ |
| 20 | __FUNCTION__) |
| 21 | |
| 22 | #define wpi_assertEqual(a, b) \ |
| 23 | wpi_assertEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__) |
| 24 | #define wpi_assertEqualWithMessage(a, b, message) \ |
| 25 | wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__) |
| 26 | |
| 27 | #define wpi_assertNotEqual(a, b) \ |
| 28 | wpi_assertNotEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__) |
| 29 | #define wpi_assertNotEqualWithMessage(a, b, message) \ |
| 30 | wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \ |
| 31 | __FUNCTION__) |
| 32 | |
| 33 | bool wpi_assert_impl(bool conditionValue, const char *conditionText, |
| 34 | const char *message, const char *fileName, |
| 35 | uint32_t lineNumber, const char *funcName); |
| 36 | bool wpi_assertEqual_impl(int valueA, int valueB, const char *valueAString, |
| 37 | const char *valueBString, const char *message, |
| 38 | const char *fileName, uint32_t lineNumber, |
| 39 | const char *funcName); |
| 40 | bool wpi_assertNotEqual_impl(int valueA, int valueB, const char *valueAString, |
| 41 | const char *valueBString, const char *message, |
| 42 | const char *fileName, uint32_t lineNumber, |
| 43 | const char *funcName); |
| 44 | |
| 45 | void wpi_suspendOnAssertEnabled(bool enabled); |
| 46 | |
| 47 | uint16_t GetFPGAVersion(); |
| 48 | uint32_t GetFPGARevision(); |
| 49 | uint32_t GetFPGATime(); |
| 50 | bool GetUserButton(); |
| 51 | std::string GetStackTrace(uint32_t offset); |