MobilityDB 1.3
Loading...
Searching...
No Matches
meos_tls.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * This MobilityDB code is provided under The PostgreSQL License.
4 * Copyright (c) 2016-2026, Université libre de Bruxelles and MobilityDB
5 * contributors
6 *
7 * MobilityDB includes portions of PostGIS version 3 source code released
8 * under the GNU General Public License (GPLv2 or later).
9 * Copyright (c) 2001-2026, PostGIS contributors
10 *
11 * Permission to use, copy, modify, and distribute this software and its
12 * documentation for any purpose, without fee, and without a written
13 * agreement is hereby granted, provided that the above copyright notice and
14 * this paragraph and the following two paragraphs appear in all copies.
15 *
16 * IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
17 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
18 * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
19 * EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
20 * OF SUCH DAMAGE.
21 *
22 * UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
25 * AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
26 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
27 *
28 *****************************************************************************/
29
38#ifndef __MEOS_TLS_H__
39#define __MEOS_TLS_H__
40
41/*
42 * Thread-local storage qualifier. C11 _Thread_local is supported by GCC,
43 * Clang, and MSVC 2019 16.10+; older compilers fall back to vendor
44 * extensions. If none of these is available the macro expands to
45 * nothing and MEOS state remains process-global (legacy behaviour).
46 */
47#if defined(__cplusplus) && __cplusplus >= 201103L
48#define MEOS_TLS thread_local
49#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && \
50 !defined(__STDC_NO_THREADS__)
51#define MEOS_TLS _Thread_local
52#elif defined(_MSC_VER)
53#define MEOS_TLS __declspec(thread)
54#elif defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)
55#define MEOS_TLS __thread
56#else
57#define MEOS_TLS /* not supported; falls back to non-thread-safe globals */
58#endif
59
60#endif /* __MEOS_TLS_H__ */