Skip to content
Myr

Merge branch 'fix_stbimage_gcc_sse2' of https://github.com/rygorous/stb into working

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parents 24fa816, 3e17544 · Browse files · 1 file+11 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−13 removed

  • other:+11 added−13 removed

1 file+11 added−13 removed

modified:stb_image.h+11 added-13 removed
582 unmodified lines
583#elif defined(__i386) || defined(_M_IX86)584#define STBI__X86_TARGET585#endif586587#if defined(__GNUC__) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) && !defined(__SSE2__) && !defined(STBI_NO_SIMD)588// NOTE: not clear do we actually need this for the 64-bit path?587#if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD)588// gcc doesn't support sse2 intrinsics unless you compile with -msse2,590// (but compiling with -msse2 allows the compiler to use SSE2 everywhere;591// this is just broken and gcc are jerks for not fixing it properly592// http://www.virtualdub.org/blog/pivot/entry.php?id=363 )589// which in turn means it gets to use SSE2 everywhere. This is unfortunate,590// but previous attempts to provide the SSE2 functions with runtime591// detection caused numerous issues. The way architecture extensions are592// exposed in GCC/Clang is, sadly, not really suited for one-file libs.593// New behavior: if compiled with -msse2, we use SSE2 without any594// detection; if not, we don't use it at all.595#define STBI_NO_SIMD596#endif597598#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD)
49 unmodified lines
648#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))649650static int stbi__sse2_available()651{650#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 // GCC 4.8 or later651 // GCC 4.8+ has a nice way to do this652 return __builtin_cpu_supports("sse2");653#else654 // portable way to do this, preferably without using GCC inline ASM?655 // just bail for now.656 return 0;657#endif652 // If we're even attempting to compile this on GCC/Clang, that means653 // -msse2 is on, which means the compiler is allowed to use SSE2654 // instructions at will, and so are we.655 return 1;656}657#endif658#endif659
6480 unmodified lines