SDL 3.0
SDL_intrin.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/**
23 * \file SDL_intrin.h
24 *
25 * Header file for CPU intrinsics for SDL
26 */
27
28#ifndef SDL_intrin_h_
29#define SDL_intrin_h_
30
31#include <SDL3/SDL_stdinc.h>
32
33/* Need to do this here because intrin.h has C++ code in it */
34/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
35#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
36#ifdef __clang__
37/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
38 so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
39
40#ifndef __PRFCHWINTRIN_H
41#define __PRFCHWINTRIN_H
42
43static __inline__ void __attribute__((__always_inline__, __nodebug__))
44_m_prefetch(void *__P)
45{
46 __builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */);
47}
48
49#endif /* __PRFCHWINTRIN_H */
50#endif /* __clang__ */
51#include <intrin.h>
52#ifndef _WIN64
53#ifndef __MMX__
54#define __MMX__
55#endif
56#endif
57#ifndef __SSE__
58#define __SSE__
59#endif
60#ifndef __SSE2__
61#define __SSE2__
62#endif
63#ifndef __SSE3__
64#define __SSE3__
65#endif
66#elif defined(__MINGW64_VERSION_MAJOR)
67#include <intrin.h>
68#if !defined(SDL_DISABLE_ARM_NEON_H) && defined(__ARM_NEON)
69# include <arm_neon.h>
70#endif
71#else
72/* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */
73#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H)
74#include <altivec.h>
75#endif
76#if !defined(SDL_DISABLE_ARM_NEON_H)
77# if defined(__ARM_NEON)
78# include <arm_neon.h>
79# elif defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)
80/* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */
81# if defined(_M_ARM)
82# include <armintr.h>
83# include <arm_neon.h>
84# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
85# endif
86# if defined (_M_ARM64)
87# include <arm64intr.h>
88# include <arm64_neon.h>
89# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
90# define __ARM_ARCH 8
91# endif
92# endif
93#endif
94#endif /* compiler version */
95
96#if defined(__loongarch_sx) && !defined(SDL_DISABLE_LSX_H)
97#include <lsxintrin.h>
98#define __LSX__
99#endif
100#if defined(__loongarch_asx) && !defined(SDL_DISABLE_LASX_H)
101#include <lasxintrin.h>
102#define __LASX__
103#endif
104#if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H)
105#include <immintrin.h>
106#else
107#if defined(__MMX__) && !defined(SDL_DISABLE_MMINTRIN_H)
108#include <mmintrin.h>
109#endif
110#if defined(__SSE__) && !defined(SDL_DISABLE_XMMINTRIN_H)
111#include <xmmintrin.h>
112#endif
113#if defined(__SSE2__) && !defined(SDL_DISABLE_EMMINTRIN_H)
114#include <emmintrin.h>
115#endif
116#if defined(__SSE3__) && !defined(SDL_DISABLE_PMMINTRIN_H)
117#include <pmmintrin.h>
118#endif
119#endif /* HAVE_IMMINTRIN_H */
120
121#endif /* SDL_intrin_h_ */
#define __inline__