78#ifndef UNIV_NO_ERR_MSGS
80#include "mysqld_error.h"
85#define TEMP_INDEX_PREFIX_STR "\377"
88#if defined(HAVE_PAUSE_INSTRUCTION)
93#define UT_RELAX_CPU() __asm__ __volatile__("pause")
95#elif defined(HAVE_FAKE_PAUSE_INSTRUCTION)
96#define UT_RELAX_CPU() __asm__ __volatile__("rep; nop")
101#define UT_RELAX_CPU() YieldProcessor()
102#elif defined(__aarch64__)
109#define UT_RELAX_CPU() __asm__ __volatile__("isb" ::: "memory")
111#define UT_RELAX_CPU() __asm__ __volatile__("" ::: "memory")
114#if defined(HAVE_HMT_PRIORITY_INSTRUCTION)
115#define UT_LOW_PRIORITY_CPU() __asm__ __volatile__("or 1,1,1")
116#define UT_RESUME_PRIORITY_CPU() __asm__ __volatile__("or 2,2,2")
118#define UT_LOW_PRIORITY_CPU() ((void)0)
119#define UT_RESUME_PRIORITY_CPU() ((void)0)
123#define UT_RELAX_CPU()
126#ifndef UNIV_HOTBACKUP
161#define ut_2pow_remainder(n, m) ((n) & ((m)-1))
167#define ut_2pow_round(n, m) ((n) & ~((m)-1))
172#define ut_calc_align_down(n, m) ut_2pow_round(n, m)
178#define ut_calc_align(n, m) (((n) + ((m)-1)) & ~((m)-1))
198#define UT_BITS_IN_BYTES(b) (((b) + 7UL) / 8UL)
203#define ut_is_2pow(n) UNIV_LIKELY(!((n) & ((n)-1)))
209 return (strcmp(a, b) < 0);
293#define ut_vsnprintf(buf, size, fmt, ap) ((void)vsnprintf(buf, size, fmt, ap))
308 using SC = std::chrono::steady_clock;
318 template <
typename T = std::chrono::milliseconds>
320 return std::chrono::duration_cast<T>(SC::now() -
m_start).count();
327 template <
typename T,
typename Traits>
329 std::basic_ostream<T, Traits> &out,
const Timer &timer)
noexcept {
330 return out << timer.elapsed();
344void meb_sprintf_timestamp_without_extra_chars(
char *
buf);
369 using seconds = std::chrono::duration<uint64_t>;
370 using clock = std::chrono::steady_clock;
381 std::chrono::time_point_cast<seconds>(clock::now());
385 current_time_in_sec)) {
410template <
typename T,
typename U>
412 return ((value >
U(0)) == (T(value) > T(0))) &&
U(T(value)) == value;
414template <
typename T,
typename U>
416 return can_type_fit_value<T>(x) ? T(x)
417 : x < 0 ? std::numeric_limits<T>::min()
418 : std::numeric_limits<T>::max();
Allows to monitor an event processing times, allowing to throttle the processing to one per throttle_...
Definition: ut0ut.h:368
std::atomic< time_point > m_last_applied_time
Definition: ut0ut.h:398
Throttler(seconds delay=seconds{10})
Definition: ut0ut.h:374
std::chrono::steady_clock clock
Definition: ut0ut.h:370
std::chrono::duration< uint64_t > seconds
Definition: ut0ut.h:369
const seconds m_throttle_delay
Throttle all items within that amount seconds from the last non throttled one.
Definition: ut0ut.h:399
std::chrono::time_point< clock, seconds > time_point
Definition: ut0ut.h:371
bool apply()
Checks if the item should be processed or ignored to not process them more frequently than one per th...
Definition: ut0ut.h:379
For measuring time elapsed.
Definition: ut0ut.h:306
std::chrono::steady_clock SC
Definition: ut0ut.h:308
void reset()
Reset the timer to the current time.
Definition: ut0ut.h:315
SC::time_point m_start
High resolution timer instance used for timimg.
Definition: ut0ut.h:335
int64_t elapsed() const noexcept
Definition: ut0ut.h:319
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:328
Timer() noexcept
Constructor.
Definition: ut0ut.h:312
#define U
Definition: ctype-tis620.cc:74
Global error codes for the database.
dberr_t
Definition: db0err.h:39
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1105
Definition: buf0block_hint.cc:30
const std::string FILE("FILE")
Definition: ha_prototypes.h:342
size_t size(const char *const c)
Definition: base64.h:46
This file contains a set of libraries providing overloads for regular dynamic allocation routines whi...
Definition: aligned_alloc.h:48
ulong spin_wait_pause_multiplier
The current value of @innodb_spin_wait_pause_multiplier.
Definition: ut0ut.cc:65
constexpr bool can_type_fit_value(const U value)
Definition: ut0ut.h:411
T clamp(U x)
Definition: ut0ut.h:415
Macros for using atomics.
case opt name
Definition: sslopt-case.h:29
Wait_stats & operator+=(const Wait_stats &rhs)
Definition: ut0ut.h:352
Wait_stats(uint64_t wait_loops=0)
Definition: ut0ut.h:350
uint64_t wait_loops
Definition: ut0ut.h:348
Wait_stats operator+(const Wait_stats &rhs) const
Definition: ut0ut.h:357
bool any_waits() const
Definition: ut0ut.h:361
Definition: trx0trx.h:675
Functor that compares two C strings.
Definition: ut0ut.h:207
bool operator()(const char *a, const char *b) const
Definition: ut0ut.h:208
Include file for Sun RPC to compile out of the box.
unsigned long int ulint
Definition: univ.i:406
Debug utilities for Innobase.
void ut_copy_file(FILE *dest, FILE *src)
Catenate files.
Definition: ut0ut.cc:219
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:290
ulint ut_2_power_up(ulint n)
Calculates fast the number rounded up to the nearest power of 2.
Definition: ut0ut.cc:123
#define ut_vsnprintf(buf, size, fmt, ap)
A wrapper for vsnprintf(3), formatted output conversion into a limited buffer.
Definition: ut0ut.h:293
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:189
void ut_format_byte_value(uint64_t data_bytes, std::string &data_str)
Convert byte value to string with unit.
Definition: ut0ut.cc:237
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:147
constexpr ulint ut_2_log(ulint n)
Calculates fast the 2-logarithm of a number, rounded upward to an integer.
Definition: ut0ut.ic:98
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:163
ulint ut_delay(ulint delay)
Runs an idle loop on CPU.
Definition: ut0ut.cc:99
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:509