libfilezilla
Namespaces | Functions
util.hpp File Reference

Various utility functions. More...

#include "libfilezilla.hpp"
#include "time.hpp"
#include <cstdint>
Include dependency graph for util.hpp:

Go to the source code of this file.

Namespaces

 fz
 The namespace used by libfilezilla.
 

Functions

void sleep (duration const &d)
 Sleep current thread for the specified duration. More...
 
void yield ()
 Relinquish control for a brief amount of time. More...
 
int64_t random_number (int64_t min, int64_t max)
 Get a secure random integer uniformly distributed in the closed interval [min, max]. More...
 
std::vector< uint8_t > random_bytes (size_t size)
 Get random uniformly distributed bytes. More...
 
void random_bytes (size_t size, uint8_t *destination)
 
uint64_t bitscan (uint64_t v)
 Returns index of the least-significant set bit. More...
 
uint64_t bitscan_reverse (uint64_t v)
 Returns index of the most-significant set bit. More...
 
bool equal_consttime (std::basic_string_view< uint8_t > const &lhs, std::basic_string_view< uint8_t > const &rhs)
 Secure equality test in constant time. More...
 
template<typename First , typename Second , std::enable_if_t< sizeof(typename First::value_type)==sizeof(uint8_t) &&sizeof(typename Second::value_type)==sizeof(uint8_t)> * = nullptr>
bool equal_consttime (First const &lhs, Second const &rhs)
 
template<typename T , typename std::enable_if_t< std::is_final_v< T >> * = nullptr>
T & move_assign_through_move_constructor (T *p, T &&op) noexcept
 

Detailed Description

Various utility functions.