mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 08:38:14 +01:00
base: restrict x86_avx2 to 64-bit (not 32-bit) x86
32-bit C/C++ compilers don't always compile the AVX intrinsics. Per the 60773 bug below, > clang++ -m32 etc etc fuzz/c/std/jpeg_fuzzer.c > undefined reference to `_mm_cvtsi128_si64' > undefined reference to `_mm256_extract_epi64' See also the "#ifdef __x86_64__" guards in https://github.com/gcc-mirror/gcc/blob/4a3895903c29ed85da6fcb886f31ff23d4c6e935/gcc/config/i386/emmintrin.h#L228-L231 https://github.com/llvm/llvm-project/blob/08fab9ebecf72a682279d75489dc2460121cbeed/clang/lib/Headers/emmintrin.h#L3502-L3515 Note that -m32 is not the same as -mx32 > $ touch empty.c > $ gcc -dM -E empty.c | grep -E '__i386__|__x86_64__' > #define __x86_64__ 1 > $ gcc -m32 -dM -E empty.c | grep -E '__i386__|__x86_64__' > #define __i386__ 1 > $ gcc -mx32 -dM -E empty.c | grep -E '__i386__|__x86_64__' > #define __x86_64__ 1 Updates https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60773
This commit is contained in:
1 parent
605b10a492
commit
e2b9566fc5
7 files changed
+44
-32
No files matched your search
@@ -82,6 +82,9 @@
|
||||
#include <x86intrin.h>
|
||||
// X86_FAMILY means X86 (32-bit) or X86_64 (64-bit, obviously).
|
||||
#define WUFFS_BASE__CPU_ARCH__X86_FAMILY
|
||||
#if defined(__x86_64__)
|
||||
#define WUFFS_BASE__CPU_ARCH__X86_64
|
||||
#endif // defined(__x86_64__)
|
||||
#endif // !defined(__native_client__)
|
||||
#endif // defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
@@ -103,6 +106,9 @@
|
||||
#include <wmmintrin.h> // AES, PCLMUL
|
||||
// X86_FAMILY means X86 (32-bit) or X86_64 (64-bit, obviously).
|
||||
#define WUFFS_BASE__CPU_ARCH__X86_FAMILY
|
||||
#if defined(_M_X64)
|
||||
#define WUFFS_BASE__CPU_ARCH__X86_64
|
||||
#endif // defined(_M_X64)
|
||||
|
||||
#else // defined(__AVX__) || defined(__clang__)
|
||||
|
||||
@@ -157,7 +163,7 @@ wuffs_base__cpu_arch__have_arm_neon() {
|
||||
|
||||
static inline bool //
|
||||
wuffs_base__cpu_arch__have_x86_avx2() {
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
// GCC defines these macros but MSVC does not.
|
||||
// - bit_AVX2 = (1 << 5)
|
||||
const unsigned int avx2_ebx7 = 0x00000020;
|
||||
@@ -197,7 +203,7 @@ wuffs_base__cpu_arch__have_x86_avx2() {
|
||||
#else
|
||||
#error "WUFFS_BASE__CPU_ARCH__ETC combined with an unsupported compiler"
|
||||
#endif // defined(__GNUC__); defined(_MSC_VER)
|
||||
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
|
||||
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ wuffs_base__pixel_swizzler__xxxx__y__x86_sse42(uint8_t* dst_ptr,
|
||||
size_t dst_palette_len,
|
||||
const uint8_t* src_ptr,
|
||||
size_t src_len);
|
||||
#endif
|
||||
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
|
||||
|
||||
// --------
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// --------
|
||||
|
||||
// ‼ WUFFS MULTI-FILE SECTION +x86_avx2
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET("pclmul,popcnt,sse4.2,avx2")
|
||||
static void //
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__convert_bgrx_x86_avx2(
|
||||
@@ -632,5 +632,5 @@ wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2v2_triangle_x86_avx2(
|
||||
|
||||
return dst_ptr;
|
||||
}
|
||||
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
|
||||
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
// ‼ WUFFS MULTI-FILE SECTION -x86_avx2
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
// --------
|
||||
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET("pclmul,popcnt,sse4.2,avx2")
|
||||
static void //
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__convert_bgrx_x86_avx2(
|
||||
@@ -47,7 +47,7 @@ wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2v2_triangle_x86_avx2(
|
||||
uint32_t h1v2_bias_ignored,
|
||||
bool first_column,
|
||||
bool last_column);
|
||||
#endif
|
||||
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
|
||||
// --------
|
||||
|
||||
@@ -990,7 +990,7 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:
|
||||
case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:
|
||||
case WUFFS_BASE__PIXEL_FORMAT__BGRX:
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
if (wuffs_base__cpu_arch__have_x86_avx2()) {
|
||||
convfunc =
|
||||
&wuffs_base__pixel_swizzler__swizzle_ycc__convert_bgrx_x86_avx2;
|
||||
@@ -1002,7 +1002,7 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:
|
||||
case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:
|
||||
case WUFFS_BASE__PIXEL_FORMAT__RGBX:
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
if (wuffs_base__cpu_arch__have_x86_avx2()) {
|
||||
convfunc =
|
||||
&wuffs_base__pixel_swizzler__swizzle_ycc__convert_rgbx_x86_avx2;
|
||||
@@ -1048,7 +1048,7 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h1, inv_v1) ||
|
||||
wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h2, inv_v2))) {
|
||||
func = &wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter;
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
if (wuffs_base__cpu_arch__have_x86_avx2()) {
|
||||
upfuncs[1][1] =
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2v2_triangle_x86_avx2;
|
||||
|
||||
@@ -281,7 +281,7 @@ func cpuArchCNames(asserts []*a.Node) (caMacro string, caName string, caAttribut
|
||||
"WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET(\"pclmul,popcnt,sse4.2\")"
|
||||
case t.IDX86AVX2:
|
||||
caMacro, caName, caAttribute =
|
||||
"X86_FAMILY", "x86_avx2",
|
||||
"X86_64", "x86_avx2",
|
||||
"WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET(\"pclmul,popcnt,sse4.2,avx2\")"
|
||||
case t.IDX86BMI2:
|
||||
caMacro, caName, caAttribute =
|
||||
|
||||
Reference in new issue
Block a user