diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-09-14 22:32:36 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-09-14 22:32:36 -0400 |
commit | 6d8fc4eb3866122ef42f209cc51a875a3e438607 (patch) | |
tree | 89190e195c05359882d3ce2fbc282419eaa6d928 /src/common/util.h | |
parent | 60e3def3ed7428b139cfd6e36517f930a84bd085 (diff) | |
download | tor-6d8fc4eb3866122ef42f209cc51a875a3e438607.tar.gz tor-6d8fc4eb3866122ef42f209cc51a875a3e438607.zip |
Add a simple integer-ceiling-division macro before we get it wrong
Diffstat (limited to 'src/common/util.h')
-rw-r--r-- | src/common/util.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/common/util.h b/src/common/util.h index 3a3a87378a..4a31c277e3 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -160,6 +160,11 @@ unsigned round_to_next_multiple_of(unsigned number, unsigned divisor); uint32_t round_uint32_to_next_multiple_of(uint32_t number, uint32_t divisor); uint64_t round_uint64_to_next_multiple_of(uint64_t number, uint64_t divisor); +/* Compute the CEIL of <b>a</b> divided by <b>b</b>, for nonnegative <b>a</b> + * and positive <b>b</b>. Works on integer types only. Not defined if a+b can + * overflow. */ +#define CEIL_DIV(a,b) (((a)+(b)-1)/(b)) + /* String manipulation */ /** Allowable characters in a hexadecimal string. */ |