MySQL
8.1.0
Source Code Documentation
os0atomic.h
Go to the documentation of this file.
1
/*****************************************************************************
2
Copyright (c) 1995, 2023, Oracle and/or its affiliates.
3
Copyright (c) 2008, Google Inc.
4
5
Portions of this file contain modifications contributed and copyrighted by
6
Google, Inc. Those modifications are gratefully acknowledged and are described
7
briefly in the InnoDB documentation. The contributions by Google are
8
incorporated with their permission, and subject to the conditions contained in
9
the file COPYING.Google.
10
11
This program is free software; you can redistribute it and/or modify it under
12
the terms of the GNU General Public License, version 2.0, as published by the
13
Free Software Foundation.
14
15
This program is also distributed with certain software (including but not
16
limited to OpenSSL) that is licensed under separate terms, as designated in a
17
particular file or component or in included license documentation. The authors
18
of MySQL hereby grant you an additional permission to link the program and
19
your derivative works with the separately licensed software that they have
20
included with MySQL.
21
22
This program is distributed in the hope that it will be useful, but WITHOUT
23
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
24
FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
25
for more details.
26
27
You should have received a copy of the GNU General Public License along with
28
this program; if not, write to the Free Software Foundation, Inc.,
29
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
31
*****************************************************************************/
32
33
/** @file include/os0atomic.h
34
Macros for using atomics
35
36
Created 2012-09-23 Sunny Bains (Split from os0sync.h)
37
*******************************************************/
38
39
#ifndef os0atomic_h
40
#define os0atomic_h
41
42
#include "
univ.i
"
43
44
/** barrier definitions for memory ordering */
45
#ifdef HAVE_IB_GCC_ATOMIC_THREAD_FENCE
46
#define HAVE_MEMORY_BARRIER
47
#define os_rmb __atomic_thread_fence(__ATOMIC_ACQUIRE)
48
#define os_wmb __atomic_thread_fence(__ATOMIC_RELEASE)
49
#define IB_MEMORY_BARRIER_STARTUP_MSG \
50
"GCC builtin __atomic_thread_fence() is used for memory barrier"
51
52
#elif defined(HAVE_IB_GCC_SYNC_SYNCHRONISE)
53
#define HAVE_MEMORY_BARRIER
54
#define os_rmb __sync_synchronize()
55
#define os_wmb __sync_synchronize()
56
#define IB_MEMORY_BARRIER_STARTUP_MSG \
57
"GCC builtin __sync_synchronize() is used for memory barrier"
58
59
#elif defined(HAVE_IB_MACHINE_BARRIER_SOLARIS)
60
#define HAVE_MEMORY_BARRIER
61
#include <mbarrier.h>
62
#define os_rmb __machine_r_barrier()
63
#define os_wmb __machine_w_barrier()
64
#define IB_MEMORY_BARRIER_STARTUP_MSG \
65
"Solaris memory ordering functions are used for memory barrier"
66
67
#elif defined(HAVE_WINDOWS_MM_FENCE) && defined(_WIN64)
68
#define HAVE_MEMORY_BARRIER
69
#include <mmintrin.h>
70
#define os_rmb _mm_lfence()
71
#define os_wmb _mm_sfence()
72
#define IB_MEMORY_BARRIER_STARTUP_MSG \
73
"_mm_lfence() and _mm_sfence() are used for memory barrier"
74
75
#else
76
#define os_rmb
77
#define os_wmb
78
#define IB_MEMORY_BARRIER_STARTUP_MSG "Memory barrier is not used"
79
#endif
80
81
#endif
/* !os0atomic_h */
univ.i
Version control for database, common definitions, and include files.
storage
innobase
include
os0atomic.h
Generated by
1.9.2