From f6e3b2f8a59922405f42c8bc283e0f5546c25d0e Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Thu, 11 Oct 2007 22:36:28 +0800 Subject: [ARITH] Add assignment and intmax_t support This patch adds assignment operator support in arithmetic expansions. It also changes the type used to intmax_t. --- src/shell.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/shell.h') diff --git a/src/shell.h b/src/shell.h index 9b67696..98edc8b 100644 --- a/src/shell.h +++ b/src/shell.h @@ -92,3 +92,13 @@ extern char nullstr[1]; /* null string */ #define likely(x) __builtin_expect(!!(x),1) #define unlikely(x) __builtin_expect(!!(x),0) + +/* + * Hack to calculate maximum length. + * (length * 8 - 1) * log10(2) + 1 + 1 + 12 + * The second 1 is for the minus sign and the 12 is a safety margin. + */ +static inline int max_int_length(int bytes) +{ + return (bytes * 8 - 1) * 0.30102999566398119521 + 14; +} -- cgit 1.4.1