Tor  0.4.7.0-alpha-dev
Functions
bits.h File Reference

Header for bits.c. More...

#include "lib/cc/torint.h"
#include "lib/cc/compat_compiler.h"

Go to the source code of this file.

Functions

int tor_log2 (uint64_t u64) ATTR_CONST
 
uint64_t round_to_power_of_2 (uint64_t u64)
 
int n_bits_set_u8 (uint8_t v)
 

Detailed Description

Header for bits.c.

Definition in file bits.h.

Function Documentation

◆ n_bits_set_u8()

int n_bits_set_u8 ( uint8_t  v)

Return the number of bits set in v.

Definition at line 72 of file bits.c.

◆ round_to_power_of_2()

uint64_t round_to_power_of_2 ( uint64_t  u64)

Return the power of 2 in range [1,UINT64_MAX] closest to u64. If there are two powers of 2 equally close, round down.

Definition at line 49 of file bits.c.

◆ tor_log2()

int tor_log2 ( uint64_t  u64)

Returns floor(log2(u64)). If u64 is 0, (incorrectly) returns 0.

Definition at line 16 of file bits.c.

Referenced by domain_to_string(), and round_to_power_of_2().