diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-06-29 13:09:57 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-07-14 10:05:53 +1000 |
commit | 912402fd71144bcee255141efe12a78abad39240 (patch) | |
tree | 7c5c402091898124290daa0854339351df876bd1 /Xi/getprop.c | |
parent | 2c535b6f13ffbf2c4ac59834dae39bb8e172c003 (diff) |
include: introduce byte counting functions.
This patch adds the following three functions:
bits_to_bytes(bits) - the number of bytes needed to hold 'bits'
bytes_to_int32(bytes) - the number of 4-byte units to hold 'bytes'
pad_to_int32(bytes) - the closest multiple of 4 equal to or larger than
'bytes'.
All three operations are common in protocol processing and currently the
server has ((foo + 7)/8 + 3)/4 operations all over the place. A common set
of functions reduce the error rate of these (albeit simple) calculations and
improve readability of the code.
The functions do not check for overflow.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'Xi/getprop.c')
0 files changed, 0 insertions, 0 deletions