diff --git a/Tests/Marco.cpp b/Tests/Marco.cpp index 189e9cf..7b3ea81 100644 --- a/Tests/Marco.cpp +++ b/Tests/Marco.cpp @@ -102,6 +102,27 @@ __constructor void TestMacros() pgs++; } } + + { + debug("Testing ROUND_UP and ROUND_DOWN"); + int x = 0x101; + int y = 0x100; + int result; + + result = ROUND_UP(x, y); + if (result != 0x200) + { + error("ERROR: ROUND_UP failed: %d != 0x200\n", result); + inf_loop; + } + + result = ROUND_DOWN(x, y); + if (result != 0x100) + { + error("ERROR: ROUND_DOWN failed: %d != 0x100\n", result); + inf_loop; + } + } } #endif // DEBUG diff --git a/include/types.h b/include/types.h index 2ef2f12..53a27ce 100644 --- a/include/types.h +++ b/include/types.h @@ -81,6 +81,9 @@ typedef __builtin_va_list va_list; #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define ROUND_UP(x, y) (((x) + (y)-1) & ~((y)-1)) +#define ROUND_DOWN(x, y) ((x) & ~((y)-1)) + #define VPOKE(type, address) (*((volatile type *)(address))) #define POKE(type, address) (*((type *)(address))) @@ -342,10 +345,13 @@ typedef uint48_t uint_fast48_t; #define __min_vector_width(x) __attribute__((min_vector_width(x))) // sanitizer +#define __no_sanitize(x) __attribute__((no_sanitize(x))) #define __no_sanitize_address __attribute__((no_sanitize_address)) -#define __no_sanitize_undefined __attribute__((no_sanitize_undefined)) +/** @brief The no_address_safety_analysis is a deprecated alias of the no_sanitize_address attribute, new code should use no_sanitize_address. */ #define __no_address_safety_analysis __attribute__((no_address_safety_analysis)) #define __no_sanitize_thread __attribute__((no_sanitize_thread)) +#define __no_sanitize_undefined __attribute__((no_sanitize_undefined)) +#define __no_sanitize_coverage __attribute__((no_sanitize_coverage)) #define __synchronize __sync_synchronize() #define __sync __synchronize