PAPI 7.1.0.0
Loading...
Searching...
No Matches
standard_ao_double_t.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2004-2011 Hewlett-Packard Development Company, L.P.
3 * Copyright (c) 2012-2021 Ivan Maidanski
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24/* For 64-bit systems, we expect the double type to hold two int64's. */
25
26#if ((defined(__x86_64__) && defined(AO_GCC_ATOMIC_TEST_AND_SET)) \
27 || defined(__aarch64__)) && !defined(__ILP32__)
28 /* x86-64: __m128 is not applicable to atomic intrinsics. */
29# if AO_GNUC_PREREQ(4, 7) || AO_CLANG_PREREQ(3, 6)
30# pragma GCC diagnostic push
31 /* Suppress warning about __int128 type. */
32# if defined(__clang__) || AO_GNUC_PREREQ(6, 4)
33# pragma GCC diagnostic ignored "-Wpedantic"
34# else
35 /* GCC before ~4.8 does not accept "-Wpedantic" quietly. */
36# pragma GCC diagnostic ignored "-pedantic"
37# endif
38 typedef unsigned __int128 double_ptr_storage;
39# pragma GCC diagnostic pop
40# else /* pragma diagnostic is not supported */
41 typedef unsigned __int128 double_ptr_storage;
42# endif
43#elif defined(_M_ARM64) && defined(_MSC_VER)
44 /* __int128 does not seem to be available. */
45 typedef __declspec(align(16)) unsigned __int64 double_ptr_storage[2];
46#elif ((defined(__x86_64__) && AO_GNUC_PREREQ(4, 0)) || defined(_WIN64)) \
47 && !defined(__ILP32__)
48 /* x86-64 (except for x32): __m128 serves as a placeholder which also */
49 /* requires the compiler to align it on 16-byte boundary (as required */
50 /* by cmpxchg16b). */
51 /* Similar things could be done for PPC 64-bit using a VMX data type. */
52# include <xmmintrin.h>
53 typedef __m128 double_ptr_storage;
54#elif defined(_WIN32) && !defined(__GNUC__)
55 typedef unsigned __int64 double_ptr_storage;
56#elif defined(__i386__) && defined(__GNUC__)
57 typedef unsigned long long double_ptr_storage
58 __attribute__((__aligned__(8)));
59#else
60 typedef unsigned long long double_ptr_storage;
61#endif
62# define AO_HAVE_DOUBLE_PTR_STORAGE
63
64typedef union {
65 struct { AO_t AO_v1; AO_t AO_v2; } AO_parts;
66 /* Note that AO_v1 corresponds to the low or the high part of */
67 /* AO_whole depending on the machine endianness. */
69 /* AO_whole is now (starting from v7.3alpha3) the 2nd element */
70 /* of this union to make AO_DOUBLE_T_INITIALIZER portable */
71 /* (because __m128 definition could vary from a primitive type */
72 /* to a structure or array/vector). */
74#define AO_HAVE_double_t
75
76/* Note: AO_double_t volatile variables are not intended to be local */
77/* ones (at least those which are passed to AO double-wide primitives */
78/* as the first argument), otherwise it is the client responsibility to */
79/* ensure they have double-word alignment. */
80
81/* Dummy declaration as a compile-time assertion for AO_double_t size. */
83 char dummy[sizeof(AO_double_t) == 2 * sizeof(AO_t) ? 1 : -1];
84};
85
86#define AO_DOUBLE_T_INITIALIZER { { (AO_t)0, (AO_t)0 } }
87
88#define AO_val1 AO_parts.AO_v1
89#define AO_val2 AO_parts.AO_v2
#define AO_t
Definition: atomic_ops.h:156
unsigned long AO_t __attribute__((__aligned__(4)))
Definition: m68k.h:21
unsigned long long double_ptr_storage
char dummy[sizeof(AO_double_t)==2 *sizeof(AO_t) ? 1 :-1]
double_ptr_storage AO_whole