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