summary refs log tree commit diff
path: root/src/shell.h
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-10-11 22:36:28 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2007-10-11 22:36:28 +0800
commitf6e3b2f8a59922405f42c8bc283e0f5546c25d0e (patch)
tree6f8a59c3b8f836292fda23c77b1c95eefeae9cc4 /src/shell.h
parent[PARSER] Report substition errors at expansion time (diff)
downloaddash-f6e3b2f8a59922405f42c8bc283e0f5546c25d0e.tar.gz
dash-f6e3b2f8a59922405f42c8bc283e0f5546c25d0e.zip
[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.
Diffstat (limited to '')
-rw-r--r--src/shell.h10
1 files changed, 10 insertions, 0 deletions
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;
+}