MySQL 8.0.30
Source Code Documentation
thr_mutex_bits.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2022, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef COMPONENTS_SERVICES_BITS_THR_MUTEX_BITS_H
24#define COMPONENTS_SERVICES_BITS_THR_MUTEX_BITS_H
25
26#if defined(_WIN32)
27#include <windows.h>
28#else
29#include <pthread.h> // IWYU pragma: export
30#include <sched.h> // IWYU pragma: export
31#endif
32
33/**
34 @file mysql/components/services/bits/thr_mutex_bits.h
35 ABI for thd_mutex
36
37 There are three "layers":
38 1) native_mutex_*()
39 Functions that map directly down to OS primitives.
40 Windows - CriticalSection
41 Other OSes - pthread
42 2) my_mutex_*()
43 Functions that implement SAFE_MUTEX (default for debug),
44 Otherwise native_mutex_*() is used.
45 3) mysql_mutex_*()
46 Functions that include Performance Schema instrumentation.
47 See include/mysql/psi/mysql_thread.h
48*/
49
50#ifdef _WIN32
51typedef CRITICAL_SECTION native_mutex_t;
52typedef int native_mutexattr_t;
53#else
54typedef pthread_mutex_t native_mutex_t;
55typedef pthread_mutexattr_t native_mutexattr_t;
56#endif
57
58struct safe_mutex_t;
59
60struct my_mutex_t {
61 union u {
63 safe_mutex_t *m_safe_ptr;
64 } m_u;
65};
66typedef struct my_mutex_t my_mutex_t;
67
68#endif /* COMPONENTS_SERVICES_BITS_THR_MUTEX_BITS_H */
Definition: thr_mutex_bits.h:60
union my_mutex_t::u m_u
pthread_mutex_t native_mutex_t
Definition: thr_mutex_bits.h:54
pthread_mutexattr_t native_mutexattr_t
Definition: thr_mutex_bits.h:55
Definition: thr_mutex_bits.h:61
native_mutex_t m_native
Definition: thr_mutex_bits.h:62
safe_mutex_t * m_safe_ptr
Definition: thr_mutex_bits.h:63