33 #ifdef HAVE_TIMINGSAFE_MEMCMP
34 return timingsafe_memcmp(a, b, len);
55 int equal_p = v1 ^ v2;
74 #if ((-60 >> 8) != -1)
75 #error "cpp says right-shift doesn't perform sign-extension."
77 #ifndef RSHIFT_DOES_SIGN_EXTEND
78 #error "configure says right-shift doesn't perform sign-extension."
110 const uint8_t *ba = a, *bb = b;
111 uint32_t any_difference = 0;
115 const uint8_t byte_diff = *ba++ ^ *bb++;
118 any_difference |= byte_diff;
143 return 1 & ((any_difference - 1) >> 8);
165 free_fn(victim->
val);
177 const uint8_t *
key,
void *
val)
182 raw_assert(! old_val);
186 new_ent->
next = *map;
187 memcpy(new_ent->
key,
key, 32);
203 uintptr_t result = (uintptr_t)dflt_val;
211 result |= ((uintptr_t)(map->
val)) & ~r;
216 return (
void *)result;
227 const uint8_t *ptr = mem;
234 return 1 & ((total - 1) >> 8);
239 #if SIZEOF_VOID_P == 8
240 #define gt_i64_timei(a,b) ((a) > (b))
245 int64_t diff = (int64_t) (b - a);
246 int res = diff >> 63;
260 uint64_t total, uint64_t rand_val)
262 int i, i_chosen=-1, n_chosen=0;
263 uint64_t total_so_far = 0;
265 for (i = 0; i < n_entries; ++i) {
266 total_so_far += entries[i];
272 rand_val = INT64_MAX;
275 raw_assert(total_so_far == total);
276 raw_assert(n_chosen == 1);
277 raw_assert(i_chosen >= 0);
278 raw_assert(i_chosen < n_entries);
299 const char mask = (char) -(
signed char)s;
302 const char *srcp = src;
303 for (
size_t i = 0; i < n; ++i) {
304 *destp = (*destp & ~mask) | (*srcp & mask);
void * dimap_search(const di_digest256_map_t *map, const uint8_t *key, void *dflt_val)
void dimap_add_entry(di_digest256_map_t **map, const uint8_t *key, void *val)
void memcpy_if_true_timei(bool s, void *dest, const void *src, size_t n)
int tor_memeq(const void *a, const void *b, size_t sz)
int tor_memcmp(const void *a, const void *b, size_t len)
static int gt_i64_timei(uint64_t a, uint64_t b)
int select_array_member_cumulative_timei(const uint64_t *entries, int n_entries, uint64_t total, uint64_t rand_val)
int safe_mem_is_zero(const void *mem, size_t sz)
void dimap_free_(di_digest256_map_t *map, dimap_free_fn free_fn)
void(* dimap_free_fn)(void *)
Headers for util_malloc.c.
struct di_digest256_map_t * next