MySQL 8.0.31
Source Code Documentation
os0atomic.h
Go to the documentation of this file.
1/*****************************************************************************
2Copyright (c) 1995, 2022, Oracle and/or its affiliates.
3Copyright (c) 2008, Google Inc.
4
5Portions of this file contain modifications contributed and copyrighted by
6Google, Inc. Those modifications are gratefully acknowledged and are described
7briefly in the InnoDB documentation. The contributions by Google are
8incorporated with their permission, and subject to the conditions contained in
9the file COPYING.Google.
10
11This program is free software; you can redistribute it and/or modify it under
12the terms of the GNU General Public License, version 2.0, as published by the
13Free Software Foundation.
14
15This program is also distributed with certain software (including but not
16limited to OpenSSL) that is licensed under separate terms, as designated in a
17particular file or component or in included license documentation. The authors
18of MySQL hereby grant you an additional permission to link the program and
19your derivative works with the separately licensed software that they have
20included with MySQL.
21
22This program is distributed in the hope that it will be useful, but WITHOUT
23ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
24FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
25for more details.
26
27You should have received a copy of the GNU General Public License along with
28this program; if not, write to the Free Software Foundation, Inc.,
2951 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 */
Version control for database, common definitions, and include files.