aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Given <dg@cowlark.com>2008-12-17 22:01:16 +0300
committerAlexey Zaytsev <alexey.zaytsev@gmail.com>2008-12-17 22:01:16 +0300
commiteb800bdc37916dc96dfbd5b424dea3e6cde2409b (patch)
tree5a3d8d4cb7680c3890541c74c41747da3e32fe40 /target.h
parentEvaluate iterator symbols (diff)
downloadsparse-eb800bdc37916dc96dfbd5b424dea3e6cde2409b.tar.gz
sparse-eb800bdc37916dc96dfbd5b424dea3e6cde2409b.tar.bz2
sparse-eb800bdc37916dc96dfbd5b424dea3e6cde2409b.zip
Unhardcode byte size being 8 bits.
Signed-off-by: David Given <dg@cowlark.com> [negative value division fixed by alexey.zaytsev@gmal.com] Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
Diffstat (limited to 'target.h')
-rw-r--r--target.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/target.h b/target.h
index 25f7948..7f0fd27 100644
--- a/target.h
+++ b/target.h
@@ -42,4 +42,18 @@ extern int pointer_alignment;
extern int bits_in_enum;
extern int enum_alignment;
+/*
+ * Helper functions for converting bits to bytes and vice versa.
+ */
+
+static inline int bits_to_bytes(int bits)
+{
+ return bits >= 0 ? bits / bits_in_char : -1;
+}
+
+static inline int bytes_to_bits(int bytes)
+{
+ return bytes * bits_in_char;
+}
+
#endif