MySQL 8.0.40
Source Code Documentation
ut0ut.ic File Reference

Various utilities. More...

#include <algorithm>
#include "os0thread.h"
#include "ut0dbg.h"

Namespaces

namespace  ut
 This file contains a set of libraries providing overloads for regular dynamic allocation routines which allow for opt-in memory instrumentation through performance schema memory engine (PFS).
 

Functions

static void ut_pair_min (ulint *min_hi, ulint *min_lo, ulint a_hi, ulint a_lo, ulint b_hi, ulint b_lo)
 Calculate the minimum of two pairs. More...
 
static int ut_ulint_cmp (ulint a, ulint b)
 Compares two ulints. More...
 
static int ut_pair_cmp (ulint a_h, ulint a_l, ulint b_h, ulint b_l)
 Compare two pairs of integers. More...
 
constexpr ulint ut_2_log (ulint n)
 Calculates fast the 2-logarithm of a number, rounded upward to an integer. More...
 
static uint32_t ut_2_exp (uint32_t n)
 Calculates 2 to power n. More...
 
template<typename TCondition >
bool ut::wait_for (TCondition cond, std::chrono::steady_clock::duration max_wait)
 Delays execution for at most max_wait or returns earlier if cond becomes true. More...
 
template<typename Condition >
static Wait_stats ut::wait_for (uint64_t spins_limit, std::chrono::microseconds sleep, Condition condition={})
 Waits in loop until given condition is satisfied. More...
 

Detailed Description

Various utilities.

Created 5/30/1994 Heikki Tuuri

Function Documentation

◆ ut_2_exp()

static uint32_t ut_2_exp ( uint32_t  n)
inlinestatic

Calculates 2 to power n.

Parameters
[in]npower of 2
Returns
2 to power n

◆ ut_2_log()

constexpr ulint ut_2_log ( ulint  n)
constexpr

Calculates fast the 2-logarithm of a number, rounded upward to an integer.

Returns
logarithm in the base 2, rounded upward
Parameters
nin: number != 0

◆ ut_pair_cmp()

static int ut_pair_cmp ( ulint  a_h,
ulint  a_l,
ulint  b_h,
ulint  b_l 
)
inlinestatic

Compare two pairs of integers.

Parameters
[in]a_hmore significant part of first pair
[in]a_lless significant part of first pair
[in]b_hmore significant part of second pair
[in]b_lless significant part of second pair
Returns
comparison result of (a_h,a_l) and (b_h,b_l)
Return values
-1if (a_h,a_l) is less than (b_h,b_l)
0if (a_h,a_l) is equal to (b_h,b_l)
1if (a_h,a_l) is greater than (b_h,b_l)

◆ ut_pair_min()

static void ut_pair_min ( ulint min_hi,
ulint min_lo,
ulint  a_hi,
ulint  a_lo,
ulint  b_hi,
ulint  b_lo 
)
inlinestatic

Calculate the minimum of two pairs.

Parameters
[out]min_hiMSB of the minimum pair
[out]min_loLSB of the minimum pair
[in]a_hiMSB of the first pair
[in]a_loLSB of the first pair
[in]b_hiMSB of the second pair
[in]b_loLSB of the second pair

◆ ut_ulint_cmp()

static int ut_ulint_cmp ( ulint  a,
ulint  b 
)
inlinestatic

Compares two ulints.

Returns
1 if a > b, 0 if a == b, -1 if a < b
Parameters
ain: ulint
bin: ulint