[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [RFC/PATCH v3 2/8] libbb: add DECIMAL_STR_MAX macro
From: Bartosz Golaszewski <bartekgola () gmail ! com>
Date: 2015-08-25 11:09:57
Message-ID: 1440501003-17364-3-git-send-email-bartekgola () gmail ! com
[Download RAW message or body]
Add a macro returning the maximum required buffer size for given
integer type.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
---
include/libbb.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/libbb.h b/include/libbb.h
index 6d7b128..abbd2c7 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -225,6 +225,13 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
: ((T)1 << (sizeof(T)*8-1)) \
)
+/* Found in systemd, src/basic/macro.h */
+#define DECIMAL_STR_MAX(type) \
+ (2+(sizeof(type) <= 1 ? 3 : \
+ sizeof(type) <= 2 ? 5 : \
+ sizeof(type) <= 4 ? 10 : \
+ sizeof(type) <= 8 ? 20 : sizeof(int[-2*(sizeof(type) > 8)])))
+
/* Large file support */
/* Note that CONFIG_LFS=y forces bbox to be built with all common ops
* (stat, lseek etc) mapped to "largefile" variants by libc.
--
2.1.4
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic