Update macros header Updates the macros header to ensure redefinition of macros doesn't happen and adds a helper macro for determining if a bit is set in a provided value. Bug: 171916502 Test: N/A Merged-In: I27ff6226058b15316b0a8739acd27e2a74b5e43a Merged-In: I6b486106bcd9bf48c5ee0f4ca69bc38b49b72d96 Change-Id: I6b486106bcd9bf48c5ee0f4ca69bc38b49b72d96
diff --git a/util/include/chre/util/macros.h b/util/include/chre/util/macros.h index 92160b8..2fe7d7e 100644 --- a/util/include/chre/util/macros.h +++ b/util/include/chre/util/macros.h
@@ -24,14 +24,26 @@ /** * Obtains the number of elements in a C-style array. */ +#ifndef ARRAY_SIZE #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) +#endif + +#ifndef ARRAY_END #define ARRAY_END(array) (array + ARRAY_SIZE(array)) +#endif + +/** Determines if the provided bit is set in the provided value. */ +#ifndef IS_BIT_SET +#define IS_BIT_SET(value, bit) (((value) & (bit)) == (bit)) +#endif /** * Performs macro expansion then converts the value into a string literal */ +#ifndef STRINGIFY #define STRINGIFY(x) STRINGIFY2(x) #define STRINGIFY2(x) #x +#endif // Compiler-specific functionality #if defined(__clang__) || defined(__GNUC__)