77#ifndef UNIV_NO_ERR_MSGS
79#include "mysqld_error.h"
84#define TEMP_INDEX_PREFIX_STR "\377"
87#if defined(HAVE_PAUSE_INSTRUCTION)
92#define UT_RELAX_CPU() __asm__ __volatile__("pause")
94#elif defined(HAVE_FAKE_PAUSE_INSTRUCTION)
95#define UT_RELAX_CPU() __asm__ __volatile__("rep; nop")
100#define UT_RELAX_CPU() YieldProcessor()
101#elif defined(__aarch64__)
108#define UT_RELAX_CPU() __asm__ __volatile__("isb" ::: "memory")
110#define UT_RELAX_CPU() __asm__ __volatile__("" ::: "memory")
113#if defined(HAVE_HMT_PRIORITY_INSTRUCTION)
114#define UT_LOW_PRIORITY_CPU() __asm__ __volatile__("or 1,1,1")
115#define UT_RESUME_PRIORITY_CPU() __asm__ __volatile__("or 2,2,2")
117#define UT_LOW_PRIORITY_CPU() ((void)0)
118#define UT_RESUME_PRIORITY_CPU() ((void)0)
122#define UT_RELAX_CPU()
125#ifndef UNIV_HOTBACKUP
160#define ut_2pow_remainder(n, m) ((n) & ((m)-1))
166#define ut_2pow_round(n, m) ((n) & ~((m)-1))
171#define ut_calc_align_down(n, m) ut_2pow_round(n, m)
177#define ut_calc_align(n, m) (((n) + ((m)-1)) & ~((m)-1))
197#define UT_BITS_IN_BYTES(b) (((b) + 7UL) / 8UL)
202#define ut_is_2pow(n) UNIV_LIKELY(!((n) & ((n)-1)))
208 return (strcmp(a, b) < 0);
292#define ut_vsnprintf(buf, size, fmt, ap) ((void)vsnprintf(buf, size, fmt, ap))
307 using SC = std::chrono::steady_clock;
317 template <
typename T = std::chrono::milliseconds>
319 return std::chrono::duration_cast<T>(SC::now() -
m_start).count();
326 template <
typename T,
typename Traits>
328 std::basic_ostream<T, Traits> &out,
const Timer &timer)
noexcept {
329 return out << timer.elapsed();
343void meb_sprintf_timestamp_without_extra_chars(
char *
buf);
374 const auto current_time = std::chrono::steady_clock::now();
375 const auto current_time_in_sec =
376 std::chrono::duration_cast<std::chrono::seconds>(
377 current_time.time_since_epoch())
381 static_cast<uint64_t
>(current_time_in_sec)) {
383 current_time_in_sec)) {
407template <
typename T,
typename U>
409 return ((value >
U(0)) == (T(value) > T(0))) &&
U(T(value)) == value;
411template <
typename T,
typename U>
413 return can_type_fit_value<T>(x) ? T(x)
414 : x < 0 ? std::numeric_limits<T>::min()
415 : std::numeric_limits<T>::max();
Allows to monitor an event processing times, allowing to throttle the processing to one per THROTTLE_...
Definition: ut0ut.h:367
static constexpr uint64_t THROTTLE_DELAY_SEC
Throttle all items within that amount seconds from the last non throttled one.
Definition: ut0ut.h:400
std::atomic< uint64_t > m_last_applied_time
Definition: ut0ut.h:396
Throttler()
Definition: ut0ut.h:369
bool apply()
Checks if the item should be processed or ignored to not process them more frequently than one per TH...
Definition: ut0ut.h:373
For measuring time elapsed.
Definition: ut0ut.h:305
std::chrono::steady_clock SC
Definition: ut0ut.h:307
void reset()
Reset the timer to the current time.
Definition: ut0ut.h:314
SC::time_point m_start
High resolution timer instance used for timimg.
Definition: ut0ut.h:334
int64_t elapsed() const noexcept
Definition: ut0ut.h:318
friend std::basic_ostream< T, Traits > & operator<<(std::basic_ostream< T, Traits > &out, const Timer &timer) noexcept
Print time elapsed since last reset (in milliseconds) to the stream.
Definition: ut0ut.h:327
Timer() noexcept
Constructor.
Definition: ut0ut.h:311
#define U
Definition: ctype-tis620.cc:73
Global error codes for the database.
dberr_t
Definition: db0err.h:38
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1085
Definition: buf0block_hint.cc:29
const std::string FILE("FILE")
Definition: ha_prototypes.h:341
This file contains a set of libraries providing overloads for regular dynamic allocation routines whi...
Definition: aligned_alloc.h:47
ulong spin_wait_pause_multiplier
The current value of @innodb_spin_wait_pause_multiplier.
Definition: ut0ut.cc:64
constexpr bool can_type_fit_value(const U value)
Definition: ut0ut.h:408
T clamp(U x)
Definition: ut0ut.h:412
Macros for using atomics.
case opt name
Definition: sslopt-case.h:32
Wait_stats & operator+=(const Wait_stats &rhs)
Definition: ut0ut.h:351
Wait_stats(uint64_t wait_loops=0)
Definition: ut0ut.h:349
uint64_t wait_loops
Definition: ut0ut.h:347
Wait_stats operator+(const Wait_stats &rhs) const
Definition: ut0ut.h:356
bool any_waits() const
Definition: ut0ut.h:360
Definition: trx0trx.h:683
Functor that compares two C strings.
Definition: ut0ut.h:206
bool operator()(const char *a, const char *b) const
Definition: ut0ut.h:207
Include file for Sun RPC to compile out of the box.
unsigned long int ulint
Definition: univ.i:405
Debug utilities for Innobase.
void ut_copy_file(FILE *dest, FILE *src)
Catenate files.
Definition: ut0ut.cc:218
static int ut_pair_cmp(ulint a_h, ulint a_l, ulint b_h, ulint b_l)
Compare two pairs of integers.
const char * ut_strerr(dberr_t num)
Convert an error number to a human readable text message.
Definition: ut0ut.cc:289
ulint ut_2_power_up(ulint n)
Calculates fast the number rounded up to the nearest power of 2.
Definition: ut0ut.cc:122
#define ut_vsnprintf(buf, size, fmt, ap)
A wrapper for vsnprintf(3), formatted output conversion into a limited buffer.
Definition: ut0ut.h:292
static uint32_t ut_2_exp(uint32_t n)
Calculates 2 to power n.
char * ut_format_name(const char *name, char *formatted, ulint formatted_size)
Format a table name, quoted as an SQL identifier.
Definition: ut0ut.cc:188
void ut_format_byte_value(uint64_t data_bytes, std::string &data_str)
Convert byte value to string with unit.
Definition: ut0ut.cc:236
static int ut_ulint_cmp(ulint a, ulint b)
Compares two ulints.
std::string ut_get_name(const trx_t *trx, const char *name)
Get a fixed-length string, quoted as an SQL identifier.
Definition: ut0ut.cc:146
constexpr ulint ut_2_log(ulint n)
Calculates fast the 2-logarithm of a number, rounded upward to an integer.
Definition: ut0ut.ic:97
void ut_print_name(FILE *f, const trx_t *trx, const char *name)
Outputs a fixed-length string, quoted as an SQL identifier.
Definition: ut0ut.cc:162
ulint ut_delay(ulint delay)
Runs an idle loop on CPU.
Definition: ut0ut.cc:98
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.
int n
Definition: xcom_base.cc:508