summaryrefslogtreecommitdiff
path: root/lib/type-props.h
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-04-01 10:20:17 -0700
committerBen Pfaff <blp@nicira.com>2011-04-04 10:58:54 -0700
commit67a51a1d851df25eebc676cf24bbb0f821d1c736 (patch)
tree418339101ae358aa77014b492d29c67d6a0f060d /lib/type-props.h
parentfe1e967e3bc6c04f773b150fbb358b2350d0ad8c (diff)
downloadopenvswitch-67a51a1d851df25eebc676cf24bbb0f821d1c736.tar.gz
type-props: New macro for estimating length of a decimal integer.
Diffstat (limited to 'lib/type-props.h')
-rw-r--r--lib/type-props.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/type-props.h b/lib/type-props.h
index efaf4a5de..922504174 100644
--- a/lib/type-props.h
+++ b/lib/type-props.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008 Nicira Networks.
+ * Copyright (c) 2008, 2011 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,4 +29,11 @@
? ~(~(TYPE)0 << TYPE_VALUE_BITS(TYPE)) \
: (TYPE)-1)
+/* Number of decimal digits required to format an integer of the given TYPE.
+ * Includes space for a sign, if TYPE is signed, but not for a null
+ * terminator.
+ *
+ * The value is an overestimate. */
+#define INT_STRLEN(TYPE) (TYPE_IS_SIGNED(TYPE) + TYPE_VALUE_BITS(TYPE) / 3 + 1)
+
#endif /* type-props.h */