aboutsummaryrefslogtreecommitdiff
path: root/include/apos/utils.h
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-05-29 11:23:29 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2022-05-29 11:23:29 +0300
commite148f38dc937c34b222ba8df8612b3fa2b6bc349 (patch)
treec51f045c6632b2073cb0e3183bd9d3b559ccd228 /include/apos/utils.h
parent360c18fcbe228220e5c9799fb30b2032982c06cf (diff)
downloadkmi-e148f38dc937c34b222ba8df8612b3fa2b6bc349.tar.gz
kmi-e148f38dc937c34b222ba8df8612b3fa2b6bc349.zip
modify formatting rules
Diffstat (limited to 'include/apos/utils.h')
-rw-r--r--include/apos/utils.h144
1 files changed, 72 insertions, 72 deletions
diff --git a/include/apos/utils.h b/include/apos/utils.h
index c4a83be..d2b81c0 100644
--- a/include/apos/utils.h
+++ b/include/apos/utils.h
@@ -10,13 +10,13 @@
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MAX3(a, b, c) (MAX(a, b) >= MAX(b, c) ? MAX(a, b) : MAX(b, c))
-#define MAX4(a, b, c, d) \
+#define MAX4(a, b, c, d) \
(MAX3(a, b, c) >= MAX3(b, c, d) ? MAX3(a, b, c) : MAX3(b, c, d))
/* etc... */
#define MIN(a, b) ((a) <= (b) ? (a) : (b))
#define MIN3(a, b, c) (MIN(a, b) <= MIN(b, c) ? MIN(a, b) : MIN(b, c))
-#define MIN4(a, b, c, d) \
+#define MIN4(a, b, c, d) \
(MIN3(a, b, c) <= MIN3(b, c, d) ? MIN3(a, b, c) : MIN3(b, c, d))
/* etc... */
@@ -45,7 +45,7 @@
#define unlikely(x) (x)
#endif
-#define container_of(ptr, type, member) \
+#define container_of(ptr, type, member) \
((type *)((char *)(ptr)-offsetof(type, member)))
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
@@ -56,35 +56,35 @@
#include <apos/types.h>
/* clang-format doesn't like _Generic, but I guess that's fine. */
-#define align_up(x, y) \
- _Generic((x), signed char \
- : align_up_c, signed short \
- : align_up_s, signed int \
- : align_up_i, signed long \
- : align_up_l, signed long long \
- : align_up_ll, \
- \
- unsigned char \
- : align_up_uc, unsigned short \
- : align_up_us, unsigned int \
- : align_up_ui, unsigned long \
- : align_up_ul, unsigned long long \
+#define align_up(x, y) \
+ _Generic((x), signed char \
+ : align_up_c, signed short \
+ : align_up_s, signed int \
+ : align_up_i, signed long \
+ : align_up_l, signed long long \
+ : align_up_ll, \
+ \
+ unsigned char \
+ : align_up_uc, unsigned short \
+ : align_up_us, unsigned int \
+ : align_up_ui, unsigned long \
+ : align_up_ul, unsigned long long \
: align_up_ull)((x), (y))
-#define DEFINE_ALIGN_UP(name, type) \
- static inline type align_up_##name(type val, type a) \
- { \
- if (!a) { \
- return val; \
- } \
- \
- type rem = val % a; \
- \
- if (rem == 0) { \
- return val; \
- } \
- \
- return val + a - rem; \
+#define DEFINE_ALIGN_UP(name, type) \
+ static inline type align_up_##name(type val, type a) \
+ { \
+ if (!a) { \
+ return val; \
+ } \
+ \
+ type rem = val % a; \
+ \
+ if (rem == 0) { \
+ return val; \
+ } \
+ \
+ return val + a - rem; \
}
DEFINE_ALIGN_UP(c, signed char);
@@ -99,29 +99,29 @@ DEFINE_ALIGN_UP(ui, unsigned int);
DEFINE_ALIGN_UP(ul, unsigned long);
DEFINE_ALIGN_UP(ull, unsigned long long);
-#define align_down(x, y) \
- _Generic((x), signed char \
- : align_down_c, signed short \
- : align_down_s, signed int \
- : align_down_i, signed long \
- : align_down_l, signed long long \
- : align_down_ll, \
- \
- unsigned char \
- : align_down_uc, unsigned short \
- : align_down_us, unsigned int \
- : align_down_ui, unsigned long \
- : align_down_ul, unsigned long long \
+#define align_down(x, y) \
+ _Generic((x), signed char \
+ : align_down_c, signed short \
+ : align_down_s, signed int \
+ : align_down_i, signed long \
+ : align_down_l, signed long long \
+ : align_down_ll, \
+ \
+ unsigned char \
+ : align_down_uc, unsigned short \
+ : align_down_us, unsigned int \
+ : align_down_ui, unsigned long \
+ : align_down_ul, unsigned long long \
: align_down_ull)((x), (y))
-#define DEFINE_ALIGN_DOWN(name, type) \
- static inline type align_down_##name(type val, type a) \
- { \
- if (!a) { \
- return val; \
- } \
- \
- return val - (val % a); \
+#define DEFINE_ALIGN_DOWN(name, type) \
+ static inline type align_down_##name(type val, type a) \
+ { \
+ if (!a) { \
+ return val; \
+ } \
+ \
+ return val - (val % a); \
}
DEFINE_ALIGN_DOWN(c, signed char);
@@ -136,29 +136,29 @@ DEFINE_ALIGN_DOWN(ui, unsigned int);
DEFINE_ALIGN_DOWN(ul, unsigned long);
DEFINE_ALIGN_DOWN(ull, unsigned long long);
-#define is_aligned(x, y) \
- _Generic((x), signed char \
- : is_aligned_c, signed short \
- : is_aligned_s, signed int \
- : is_aligned_i, signed long \
- : is_aligned_l, signed long long \
- : is_aligned_ll, \
- \
- unsigned char \
- : is_aligned_uc, unsigned short \
- : is_aligned_us, unsigned int \
- : is_aligned_ui, unsigned long \
- : is_aligned_ul, unsigned long long \
+#define is_aligned(x, y) \
+ _Generic((x), signed char \
+ : is_aligned_c, signed short \
+ : is_aligned_s, signed int \
+ : is_aligned_i, signed long \
+ : is_aligned_l, signed long long \
+ : is_aligned_ll, \
+ \
+ unsigned char \
+ : is_aligned_uc, unsigned short \
+ : is_aligned_us, unsigned int \
+ : is_aligned_ui, unsigned long \
+ : is_aligned_ul, unsigned long long \
: is_aligned_ll)((x), (y))
-#define DEFINE_ALIGNED(name, type) \
- static inline bool is_aligned_##name(type val, type a) \
- { \
- if (!a) { \
- return true; \
- } \
- \
- return val % a == 0; \
+#define DEFINE_ALIGNED(name, type) \
+ static inline bool is_aligned_##name(type val, type a) \
+ { \
+ if (!a) { \
+ return true; \
+ } \
+ \
+ return val % a == 0; \
}
DEFINE_ALIGNED(c, signed char);