mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Add ROUND_UP and ROUND_DOWN
This commit is contained in:
parent
fa8122659a
commit
79c6a5096d
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user