Skip to content

Commit d0b04b9

Browse files
authored
Allow avxintrin.h to be used by C compiler (emscripten-core#22850)
An internal union defined to implement 256-bit AVX support added in PR emscripten-core#22430 is missing `union` keywords at declarations so causes errors when used with the C compiler. Add the `union` keyword to the declarations of the `m256_data` union in avxintrin.h. Also adds `__` prefix to make type `__m256_data` to avoid further polluting global namespace.
1 parent dfe3356 commit d0b04b9

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

system/include/compat/avxintrin.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ typedef struct {
4040
__m128i_u v1;
4141
} __m256i_u;
4242

43-
union m256_data {
43+
union __m256_data {
4444
__m256i int_view;
4545
__m256d double_view;
4646
__m256 float_view;
@@ -1771,42 +1771,42 @@ _mm256_setzero_si256(void) {
17711771

17721772
static __inline__ __m256 __attribute__((__always_inline__, __nodebug__))
17731773
_mm256_castpd_ps(__m256d __a) {
1774-
m256_data ret;
1774+
union __m256_data ret;
17751775
ret.double_view = __a;
17761776
return ret.float_view;
17771777
}
17781778

17791779
static __inline__ __m256i __attribute__((__always_inline__, __nodebug__))
17801780
_mm256_castpd_si256(__m256d __a) {
1781-
m256_data ret;
1781+
union __m256_data ret;
17821782
ret.double_view = __a;
17831783
return ret.int_view;
17841784
}
17851785

17861786
static __inline__ __m256d __attribute__((__always_inline__, __nodebug__))
17871787
_mm256_castps_pd(__m256 __a) {
1788-
m256_data ret;
1788+
union __m256_data ret;
17891789
ret.float_view = __a;
17901790
return ret.double_view;
17911791
}
17921792

17931793
static __inline__ __m256i __attribute__((__always_inline__, __nodebug__))
17941794
_mm256_castps_si256(__m256 __a) {
1795-
m256_data ret;
1795+
union __m256_data ret;
17961796
ret.float_view = __a;
17971797
return ret.int_view;
17981798
}
17991799

18001800
static __inline__ __m256 __attribute__((__always_inline__, __nodebug__))
18011801
_mm256_castsi256_ps(__m256i __a) {
1802-
m256_data ret;
1802+
union __m256_data ret;
18031803
ret.int_view = __a;
18041804
return ret.float_view;
18051805
}
18061806

18071807
static __inline__ __m256d __attribute__((__always_inline__, __nodebug__))
18081808
_mm256_castsi256_pd(__m256i __a) {
1809-
m256_data ret;
1809+
union __m256_data ret;
18101810
ret.int_view = __a;
18111811
return ret.double_view;
18121812
}

test/test_other.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9475,7 +9475,7 @@ def test_standalone_system_headers(self):
94759475
'wire.h', 'val.h', 'bind.h',
94769476
'webgpu_cpp.h', 'webgpu_cpp_chained_struct.h', 'webgpu_enum_class_bitmasks.h',
94779477
# Some headers are not yet C compatible
9478-
'arm_neon.h', 'avxintrin.h', 'immintrin.h',
9478+
'arm_neon.h',
94799479
]
94809480
if directory and directory != 'compat':
94819481
header = f'{directory}/{header}'

0 commit comments

Comments
 (0)