summaryrefslogtreecommitdiff
path: root/src/basic/macro.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-27 01:03:38 +0100
committerLennart Poettering <lennart@poettering.net>2015-10-27 13:25:57 +0100
commit0d1dbeb3a4c5c86eba5125d43488da7bec16ea0e (patch)
treebdbc26ea11361ea2334d25e39eb04bcc991f5cc5 /src/basic/macro.h
parent8f328d36c9c66efdb40fd19a970523d715078826 (diff)
macro: move DECIMAL_STR_WIDTH() into macro.h
So that it sets next to DECIMAL_STR_MAX(), where it belongs.
Diffstat (limited to 'src/basic/macro.h')
-rw-r--r--src/basic/macro.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/basic/macro.h b/src/basic/macro.h
index 02f34cedad..01916bd788 100644
--- a/src/basic/macro.h
+++ b/src/basic/macro.h
@@ -362,6 +362,15 @@ do { \
sizeof(type) <= 4 ? 10 : \
sizeof(type) <= 8 ? 20 : sizeof(int[-2*(sizeof(type) > 8)])))
+#define DECIMAL_STR_WIDTH(x) \
+ ({ \
+ typeof(x) _x_ = (x); \
+ unsigned ans = 1; \
+ while (_x_ /= 10) \
+ ans++; \
+ ans; \
+ })
+
#define SET_FLAG(v, flag, b) \
(v) = (b) ? ((v) | (flag)) : ((v) & ~(flag))