diff options
author | 2008-12-17 22:01:16 +0300 | |
---|---|---|
committer | 2008-12-17 22:01:16 +0300 | |
commit | eb800bdc37916dc96dfbd5b424dea3e6cde2409b (patch) | |
tree | 5a3d8d4cb7680c3890541c74c41747da3e32fe40 /target.h | |
parent | Evaluate iterator symbols (diff) | |
download | sparse-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.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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 |