tor  0.4.2.1-alpha-dev
muldiv.h
Go to the documentation of this file.
1 /* Copyright (c) 2003-2004, Roger Dingledine
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
12 #ifndef TOR_INTMATH_MULDIV_H
13 #define TOR_INTMATH_MULDIV_H
14 
15 #include "lib/cc/torint.h"
16 
17 unsigned round_to_next_multiple_of(unsigned number, unsigned divisor);
18 uint32_t round_uint32_to_next_multiple_of(uint32_t number, uint32_t divisor);
19 uint64_t round_uint64_to_next_multiple_of(uint64_t number, uint64_t divisor);
20 
21 void simplify_fraction64(uint64_t *numer, uint64_t *denom);
22 
23 /* Compute the CEIL of <b>a</b> divided by <b>b</b>, for nonnegative <b>a</b>
24  * and positive <b>b</b>. Works on integer types only. Not defined if a+(b-1)
25  * can overflow. */
26 #define CEIL_DIV(a,b) (((a)+((b)-1))/(b))
27 
28 #endif /* !defined(TOR_INTMATH_MULDIV_H) */
unsigned round_to_next_multiple_of(unsigned number, unsigned divisor)
Definition: muldiv.c:21
Integer definitions used throughout Tor.
uint32_t round_uint32_to_next_multiple_of(uint32_t number, uint32_t divisor)
Definition: muldiv.c:35
uint64_t round_uint64_to_next_multiple_of(uint64_t number, uint64_t divisor)
Definition: muldiv.c:50