MySQL
8.0.39
Source Code Documentation
my_pointer_arithmetic.h
Go to the documentation of this file.
1
#ifndef MY_POINTER_ARITHMETIC_INCLUDED
2
#define MY_POINTER_ARITHMETIC_INCLUDED
3
/*
4
Copyright (c) 2016, 2024, Oracle and/or its affiliates.
5
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License, version 2.0,
8
as published by the Free Software Foundation.
9
10
This program is designed to work with certain software (including
11
but not limited to OpenSSL) that is licensed under separate terms,
12
as designated in a particular file or component or in included license
13
documentation. The authors of MySQL hereby grant you an additional
14
permission to link the program and your derivative works with the
15
separately licensed software that they have either included with
16
the program or referenced in the documentation.
17
18
This program is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
GNU General Public License, version 2.0, for more details.
22
23
You should have received a copy of the GNU General Public License
24
along with this program; if not, write to the Free Software
25
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26
27
#include <stdint.h>
28
29
/**
30
@file include/my_pointer_arithmetic.h
31
Some macros for dealing with pointer arithmetic, e.g., aligning
32
of buffers to a given size.
33
*/
34
35
#define MY_ALIGN(A, L) (((A) + (L)-1) & ~((L)-1))
36
#define ALIGN_SIZE(A) MY_ALIGN((A), sizeof(double))
37
38
#ifdef __cplusplus
39
40
template
<
typename
T>
41
bool
is_aligned_to
(T *t,
int
increment) {
42
return
reinterpret_cast<
uintptr_t
>
(t) % increment == 0;
43
}
44
45
template
<
typename
T>
46
bool
is_aligned
(T *t) {
47
return
is_aligned_to
(t,
alignof
(T));
48
}
49
50
#endif
// __cplusplus
51
52
#endif
// MY_POINTER_ARITHMETIC_INCLUDED
is_aligned
bool is_aligned(T *t)
Definition:
my_pointer_arithmetic.h:46
is_aligned_to
bool is_aligned_to(T *t, int increment)
Definition:
my_pointer_arithmetic.h:41
include
my_pointer_arithmetic.h
Generated by
1.9.2