Add a macro returning the maximum required buffer size for given integer type.
Signed-off-by: Bartosz Golaszewski <bartekg...@gmail.com> --- include/libbb.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/libbb.h b/include/libbb.h index 478c030..a56b684 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