MySQL 8.0.31
Source Code Documentation
ut0byte.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1994, 2022, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is also distributed with certain software (including but not
10limited to OpenSSL) that is licensed under separate terms, as designated in a
11particular file or component or in included license documentation. The authors
12of MySQL hereby grant you an additional permission to link the program and
13your derivative works with the separately licensed software that they have
14included with MySQL.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19for more details.
20
21You should have received a copy of the GNU General Public License along with
22this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
25*****************************************************************************/
26
27/** @file include/ut0byte.h
28 Utilities for byte operations
29
30 Created 1/20/1994 Heikki Tuuri
31 ***********************************************************************/
32
33#ifndef ut0byte_h
34#define ut0byte_h
35
36#include "univ.i"
37#include "ut0ut.h"
38
39/** Creates a 64-bit integer out of two 32-bit integers.
40@param[in] high high-order 32 bits
41@param[in] low low-order 32 bits
42@return created integer */
43constexpr uint64_t ut_ull_create(uint32_t high, uint32_t low);
44
45/** Rounds a 64-bit integer downward to a multiple of a power of 2.
46@param[in] n number to be rounded
47@param[in] align_no align by this number
48@return rounded value */
49static inline uint64_t ut_uint64_align_down(uint64_t n, ulint align_no);
50
51/** Rounds uint64_t upward to a multiple of a power of 2.
52@param[in] n number to be rounded
53@param[in] align_no align by this number
54@return rounded value */
55static inline uint64_t ut_uint64_align_up(uint64_t n, ulint align_no);
56
57/** The following function rounds up a pointer to the nearest aligned address.
58@param[in] ptr pointer
59@param[in] align_no align by this number
60@return aligned pointer */
61static inline void *ut_align(const void *ptr, ulint align_no);
62
63/** The following function rounds down a pointer to the nearest aligned address.
64@param[in] ptr pointer
65@param[in] align_no align by this number
66@return aligned pointer */
67static inline void *ut_align_down(const void *ptr, ulint align_no);
68
69/** The following function computes the offset of a pointer from the nearest
70aligned address.
71@param[in] ptr pointer
72@param[in] align_no align by this number
73@return distance from aligned pointer */
74static inline ulint ut_align_offset(const void *ptr, ulint align_no);
75
76/** Gets the nth bit of a ulint.
77@param[in] a ulint
78@param[in] n nth bit requested
79@return true if nth bit is 1; 0th bit is defined to be the least significant */
80static inline bool ut_bit_get_nth(ulint a, ulint n);
81
82/** Sets the nth bit of a ulint.
83@param[in] a ulint
84@param[in] n nth bit requested
85@param[in] val value for the bit to set
86@return the ulint with the bit set as requested */
87static inline ulint ut_bit_set_nth(ulint a, ulint n, bool val);
88
89#include "ut0byte.ic"
90
91#endif
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:407
static ulint ut_align_offset(const void *ptr, ulint align_no)
The following function computes the offset of a pointer from the nearest aligned address.
constexpr uint64_t ut_ull_create(uint32_t high, uint32_t low)
Creates a 64-bit integer out of two 32-bit integers.
Definition: ut0byte.ic:33
static uint64_t ut_uint64_align_down(uint64_t n, ulint align_no)
Rounds a 64-bit integer downward to a multiple of a power of 2.
static uint64_t ut_uint64_align_up(uint64_t n, ulint align_no)
Rounds uint64_t upward to a multiple of a power of 2.
static bool ut_bit_get_nth(ulint a, ulint n)
Gets the nth bit of a ulint.
static void * ut_align(const void *ptr, ulint align_no)
The following function rounds up a pointer to the nearest aligned address.
static ulint ut_bit_set_nth(ulint a, ulint n, bool val)
Sets the nth bit of a ulint.
static void * ut_align_down(const void *ptr, ulint align_no)
The following function rounds down a pointer to the nearest aligned address.
Utilities for byte operations.
Various utilities.
int n
Definition: xcom_base.cc:505