MySQL 9.1.0
Source Code Documentation
thr_mutex_bits.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef COMPONENTS_SERVICES_BITS_THR_MUTEX_BITS_H
25#define COMPONENTS_SERVICES_BITS_THR_MUTEX_BITS_H
26
27#if defined(_WIN32)
28#include <windows.h>
29#else
30#include <pthread.h> // IWYU pragma: export
31#include <sched.h> // IWYU pragma: export
32#endif
33
34/**
35 @file mysql/components/services/bits/thr_mutex_bits.h
36 ABI for thd_mutex
37
38 There are three "layers":
39 1) native_mutex_*()
40 Functions that map directly down to OS primitives.
41 Windows - CriticalSection
42 Other OSes - pthread
43 2) my_mutex_*()
44 Functions that implement SAFE_MUTEX (default for debug),
45 Otherwise native_mutex_*() is used.
46 3) mysql_mutex_*()
47 Functions that include Performance Schema instrumentation.
48 See include/mysql/psi/mysql_thread.h
49*/
50
51#ifdef _WIN32
52typedef CRITICAL_SECTION native_mutex_t;
53typedef int native_mutexattr_t;
54#else
55typedef pthread_mutex_t native_mutex_t;
56typedef pthread_mutexattr_t native_mutexattr_t;
57#endif
58
59struct safe_mutex_t;
60
61struct my_mutex_t {
62 union u {
64 safe_mutex_t *m_safe_ptr;
65 } m_u;
66};
67typedef struct my_mutex_t my_mutex_t;
68
69#endif /* COMPONENTS_SERVICES_BITS_THR_MUTEX_BITS_H */
Definition: thr_mutex_bits.h:61
union my_mutex_t::u m_u
pthread_mutex_t native_mutex_t
Definition: thr_mutex_bits.h:55
pthread_mutexattr_t native_mutexattr_t
Definition: thr_mutex_bits.h:56
Definition: thr_mutex_bits.h:62
native_mutex_t m_native
Definition: thr_mutex_bits.h:63
safe_mutex_t * m_safe_ptr
Definition: thr_mutex_bits.h:64