Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
bb24fa31
Commit
bb24fa31
authored
Mar 20, 2020
by
Eugene Kosov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move my_assume_aligned() to a separate header
parent
95da2113
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
47 deletions
+74
-47
include/assume_aligned.h
include/assume_aligned.h
+70
-0
include/m_string.h
include/m_string.h
+0
-47
storage/innobase/buf/buf0buf.cc
storage/innobase/buf/buf0buf.cc
+1
-0
storage/innobase/include/buf0flu.ic
storage/innobase/include/buf0flu.ic
+1
-0
storage/innobase/include/fsp0fsp.h
storage/innobase/include/fsp0fsp.h
+1
-0
storage/innobase/log/log0crypt.cc
storage/innobase/log/log0crypt.cc
+1
-0
No files found.
include/assume_aligned.h
0 → 100644
View file @
bb24fa31
/*
Copyright (c) 2000, 2012, Oracle and/or its affiliates.
Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
#pragma once
#include <cassert>
#include <cstring>
#ifdef _MSC_VER
template
<
std
::
size_t
Alignment
,
class
T
>
static
inline
T
my_assume_aligned
(
T
ptr
)
{
assert
(
reinterpret_cast
<
size_t
>
(
ptr
)
%
Alignment
==
0
);
__assume
(
reinterpret_cast
<
size_t
>
(
ptr
)
%
Alignment
==
0
);
return
ptr
;
}
#else
template
<
std
::
size_t
Alignment
,
class
T
>
static
inline
T
my_assume_aligned
(
T
ptr
)
{
assert
(
reinterpret_cast
<
size_t
>
(
ptr
)
%
Alignment
==
0
);
return
static_cast
<
T
>
(
__builtin_assume_aligned
(
ptr
,
Alignment
));
}
#endif
template
<
std
::
size_t
Alignment
>
inline
void
*
memcpy_aligned
(
void
*
dest
,
const
void
*
src
,
size_t
n
)
{
static_assert
(
Alignment
&&
!
(
Alignment
&
(
Alignment
-
1
)),
"power of 2"
);
return
std
::
memcpy
(
my_assume_aligned
<
Alignment
>
(
dest
),
my_assume_aligned
<
Alignment
>
(
src
),
n
);
}
template
<
std
::
size_t
Alignment
>
inline
void
*
memmove_aligned
(
void
*
dest
,
const
void
*
src
,
size_t
n
)
{
static_assert
(
Alignment
&&
!
(
Alignment
&
(
Alignment
-
1
)),
"power of 2"
);
return
std
::
memmove
(
my_assume_aligned
<
Alignment
>
(
dest
),
my_assume_aligned
<
Alignment
>
(
src
),
n
);
}
template
<
std
::
size_t
Alignment
>
inline
int
memcmp_aligned
(
const
void
*
s1
,
const
void
*
s2
,
size_t
n
)
{
static_assert
(
Alignment
&&
!
(
Alignment
&
(
Alignment
-
1
)),
"power of 2"
);
return
std
::
memcmp
(
my_assume_aligned
<
Alignment
>
(
s1
),
my_assume_aligned
<
Alignment
>
(
s2
),
n
);
}
template
<
std
::
size_t
Alignment
>
inline
void
*
memset_aligned
(
void
*
s
,
int
c
,
size_t
n
)
{
static_assert
(
Alignment
&&
!
(
Alignment
&
(
Alignment
-
1
)),
"power of 2"
);
return
std
::
memset
(
my_assume_aligned
<
Alignment
>
(
s
),
c
,
n
);
}
include/m_string.h
View file @
bb24fa31
...
...
@@ -195,53 +195,6 @@ extern ulonglong strtoull(const char *str, char **ptr, int base);
#if defined(__cplusplus)
}
# ifdef _MSC_VER
template
<
size_t
Alignment
,
class
T
>
static
inline
T
my_assume_aligned
(
T
ptr
)
{
DBUG_ASSERT
(
reinterpret_cast
<
size_t
>
(
ptr
)
%
Alignment
==
0
);
__assume
(
reinterpret_cast
<
size_t
>
(
ptr
)
%
Alignment
==
0
);
return
ptr
;
}
# else
template
<
size_t
Alignment
,
class
T
>
static
inline
T
my_assume_aligned
(
T
ptr
)
{
DBUG_ASSERT
(
reinterpret_cast
<
size_t
>
(
ptr
)
%
Alignment
==
0
);
return
static_cast
<
T
>
(
__builtin_assume_aligned
(
ptr
,
Alignment
));
}
# endif
template
<
size_t
Alignment
>
inline
void
*
memcpy_aligned
(
void
*
dest
,
const
void
*
src
,
size_t
n
)
{
static_assert
(
Alignment
&&
!
(
Alignment
&
(
Alignment
-
1
)),
"power of 2"
);
return
memcpy
(
my_assume_aligned
<
Alignment
>
(
dest
),
my_assume_aligned
<
Alignment
>
(
src
),
n
);
}
template
<
size_t
Alignment
>
inline
void
*
memmove_aligned
(
void
*
dest
,
const
void
*
src
,
size_t
n
)
{
static_assert
(
Alignment
&&
!
(
Alignment
&
(
Alignment
-
1
)),
"power of 2"
);
return
memmove
(
my_assume_aligned
<
Alignment
>
(
dest
),
my_assume_aligned
<
Alignment
>
(
src
),
n
);
}
template
<
size_t
Alignment
>
inline
int
memcmp_aligned
(
const
void
*
s1
,
const
void
*
s2
,
size_t
n
)
{
static_assert
(
Alignment
&&
!
(
Alignment
&
(
Alignment
-
1
)),
"power of 2"
);
return
memcmp
(
my_assume_aligned
<
Alignment
>
(
s1
),
my_assume_aligned
<
Alignment
>
(
s2
),
n
);
}
template
<
size_t
Alignment
>
inline
void
*
memset_aligned
(
void
*
s
,
int
c
,
size_t
n
)
{
static_assert
(
Alignment
&&
!
(
Alignment
&
(
Alignment
-
1
)),
"power of 2"
);
return
memset
(
my_assume_aligned
<
Alignment
>
(
s
),
c
,
n
);
}
#endif
#include <mysql/plugin.h>
...
...
storage/innobase/buf/buf0buf.cc
View file @
bb24fa31
...
...
@@ -31,6 +31,7 @@ The database buffer buf_pool
Created 11/5/1995 Heikki Tuuri
*******************************************************/
#include "assume_aligned.h"
#include "mtr0types.h"
#include "mach0data.h"
#include "buf0buf.h"
...
...
storage/innobase/include/buf0flu.ic
View file @
bb24fa31
...
...
@@ -24,6 +24,7 @@ The database buffer pool flush algorithm
Created 11/5/1995 Heikki Tuuri
*******************************************************/
#include "assume_aligned.h"
#include "buf0buf.h"
#include "mtr0mtr.h"
#include "srv0srv.h"
...
...
storage/innobase/include/fsp0fsp.h
View file @
bb24fa31
...
...
@@ -27,6 +27,7 @@ Created 12/18/1995 Heikki Tuuri
#ifndef fsp0fsp_h
#define fsp0fsp_h
#include "assume_aligned.h"
#include "fsp0types.h"
#include "fut0lst.h"
#include "ut0byte.h"
...
...
storage/innobase/log/log0crypt.cc
View file @
bb24fa31
...
...
@@ -27,6 +27,7 @@ MDEV-11782: Rewritten for MariaDB 10.2 by Marko Mäkelä, MariaDB Corporation.
#include <my_global.h>
#include "log0crypt.h"
#include <mysql/service_my_crypt.h>
#include "assume_aligned.h"
#include "log0crypt.h"
#include "log0recv.h" // for recv_sys
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment