@img/sharp-libvips-dev-wasm32 1.3.0-rc.6 → 1.3.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -23
- package/include/aom/aom_codec.h +1 -1
- package/include/aom/aom_decoder.h +4 -0
- package/include/aom/aom_encoder.h +19 -8
- package/include/aom/aom_ext_ratectrl.h +664 -0
- package/include/aom/aom_image.h +93 -30
- package/include/aom/aom_tpl.h +99 -0
- package/include/aom/aomcx.h +89 -16
- package/include/aom/aomdx.h +12 -0
- package/include/expat.h +14 -2
- package/include/expat_config.h +6 -3
- package/include/expat_external.h +3 -2
- package/include/glib-2.0/gio/gdbusconnection.h +2 -8
- package/include/glib-2.0/gio/gio-visibility.h +34 -0
- package/include/glib-2.0/gio/gioenums.h +5 -4
- package/include/glib-2.0/glib/glib-visibility.h +34 -0
- package/include/glib-2.0/glib/gmacros.h +3 -3
- package/include/glib-2.0/glib/gmarkup.h +10 -0
- package/include/glib-2.0/glib/gmem.h +4 -4
- package/include/glib-2.0/glib/gmessages.h +6 -8
- package/include/glib-2.0/glib/gsequence.h +2 -2
- package/include/glib-2.0/glib/gstrfuncs.h +190 -0
- package/include/glib-2.0/glib/gutils.h +9 -0
- package/include/glib-2.0/glib/gvarianttype.h +16 -16
- package/include/glib-2.0/glib/gversionmacros.h +22 -0
- package/include/glib-2.0/gmodule/gmodule-visibility.h +34 -0
- package/include/glib-2.0/gobject/gobject-visibility.h +34 -0
- package/include/glib-2.0/gobject/gsignal.h +5 -5
- package/include/glib-2.0/gobject/gtype.h +14 -14
- package/include/hwy/aligned_allocator.h +44 -2
- package/include/hwy/auto_tune.h +22 -6
- package/include/hwy/base.h +60 -90
- package/include/hwy/bit_set.h +410 -0
- package/include/hwy/cache_control.h +3 -2
- package/include/hwy/detect_compiler_arch.h +134 -14
- package/include/hwy/detect_targets.h +82 -36
- package/include/hwy/highway.h +15 -0
- package/include/hwy/nanobenchmark.h +12 -3
- package/include/hwy/ops/arm_neon-inl.h +96 -25
- package/include/hwy/ops/arm_sve-inl.h +250 -95
- package/include/hwy/ops/emu128-inl.h +12 -7
- package/include/hwy/ops/generic_ops-inl.h +271 -131
- package/include/hwy/ops/loongarch_lasx-inl.h +31 -9
- package/include/hwy/ops/loongarch_lsx-inl.h +33 -12
- package/include/hwy/ops/ppc_vsx-inl.h +99 -19
- package/include/hwy/ops/rvv-inl.h +239 -130
- package/include/hwy/ops/scalar-inl.h +22 -7
- package/include/hwy/ops/set_macros-inl.h +163 -107
- package/include/hwy/ops/wasm_128-inl.h +13 -22
- package/include/hwy/ops/x86_128-inl.h +223 -120
- package/include/hwy/ops/x86_256-inl.h +70 -134
- package/include/hwy/ops/x86_512-inl.h +130 -134
- package/include/hwy/print-inl.h +2 -0
- package/include/hwy/profiler.h +355 -264
- package/include/hwy/robust_statistics.h +3 -1
- package/include/hwy/timer.h +44 -0
- package/include/lcms2.h +34 -4
- package/include/libexif/exif-utils.h +1 -1
- package/include/libheif/heif.h +2 -0
- package/include/libheif/heif_color.h +127 -11
- package/include/libheif/heif_components.h +264 -0
- package/include/libheif/heif_context.h +2 -1
- package/include/libheif/heif_cxx.h +10 -10
- package/include/libheif/heif_decoding.h +51 -7
- package/include/libheif/heif_encoding.h +15 -9
- package/include/libheif/heif_error.h +9 -2
- package/include/libheif/heif_export.h +48 -0
- package/include/libheif/heif_image.h +81 -66
- package/include/libheif/heif_image_handle.h +2 -2
- package/include/libheif/heif_items.h +1 -1
- package/include/libheif/heif_library.h +8 -16
- package/include/libheif/heif_omaf.h +104 -0
- package/include/libheif/heif_plugin.h +16 -9
- package/include/libheif/heif_properties.h +250 -12
- package/include/libheif/heif_security.h +16 -4
- package/include/libheif/heif_sequences.h +86 -4
- package/include/libheif/heif_tiling.h +2 -2
- package/include/libheif/heif_uncompressed.h +44 -324
- package/include/libheif/heif_version.h +2 -2
- package/include/libpng16/png.h +7 -7
- package/include/libpng16/pngconf.h +1 -1
- package/include/libpng16/pnglibconf.h +1 -1
- package/include/png.h +7 -7
- package/include/pngconf.h +1 -1
- package/include/pnglibconf.h +1 -1
- package/include/tiffconf.h +9 -10
- package/include/tiffio.h +10 -9
- package/include/tiffvers.h +1 -1
- package/include/ultrahdr_api.h +5 -11
- package/include/vips/version.h +4 -4
- package/lib/glib-2.0/include/glibconfig.h +1 -3
- package/lib/libaom.a +0 -0
- package/lib/libcgif.a +0 -0
- package/lib/libexif.a +0 -0
- package/lib/libexif.la +1 -1
- package/lib/libexpat.a +0 -0
- package/lib/libexpat.la +3 -3
- package/lib/libffi.a +0 -0
- package/lib/libgio-2.0.a +0 -0
- package/lib/libglib-2.0.a +0 -0
- package/lib/libgmodule-2.0.a +0 -0
- package/lib/libgobject-2.0.a +0 -0
- package/lib/libgthread-2.0.a +0 -0
- package/lib/libheif.a +0 -0
- package/lib/libhwy.a +0 -0
- package/lib/libimagequant.a +0 -0
- package/lib/libjpeg.a +0 -0
- package/lib/liblcms2.a +0 -0
- package/lib/libpng.a +0 -0
- package/lib/libpng.la +2 -2
- package/lib/libpng16.a +0 -0
- package/lib/libpng16.la +2 -2
- package/lib/libresvg.a +0 -0
- package/lib/libsharpyuv.a +0 -0
- package/lib/libtiff.a +0 -0
- package/lib/libuhdr.a +0 -0
- package/lib/libvips-cpp.a +0 -0
- package/lib/libvips.a +0 -0
- package/lib/libwebp.a +0 -0
- package/lib/libwebpdecoder.a +0 -0
- package/lib/libwebpdemux.a +0 -0
- package/lib/libwebpmux.a +0 -0
- package/lib/libz.a +0 -0
- package/lib/pkgconfig/aom.pc +2 -2
- package/lib/pkgconfig/expat.pc +1 -1
- package/lib/pkgconfig/gio-2.0.pc +1 -1
- package/lib/pkgconfig/glib-2.0.pc +1 -1
- package/lib/pkgconfig/gmodule-2.0.pc +1 -1
- package/lib/pkgconfig/gmodule-export-2.0.pc +1 -1
- package/lib/pkgconfig/gmodule-no-export-2.0.pc +1 -1
- package/lib/pkgconfig/gobject-2.0.pc +1 -1
- package/lib/pkgconfig/gthread-2.0.pc +1 -1
- package/lib/pkgconfig/lcms2.pc +1 -1
- package/lib/pkgconfig/libexif.pc +1 -1
- package/lib/pkgconfig/libheif.pc +2 -2
- package/lib/pkgconfig/libhwy.pc +3 -4
- package/lib/pkgconfig/libpng.pc +1 -1
- package/lib/pkgconfig/libpng16.pc +1 -1
- package/lib/pkgconfig/libsharpyuv.pc +1 -1
- package/lib/pkgconfig/libtiff-4.pc +2 -2
- package/lib/pkgconfig/libwebp.pc +1 -1
- package/lib/pkgconfig/libwebpdecoder.pc +11 -0
- package/lib/pkgconfig/libwebpmux.pc +1 -1
- package/lib/pkgconfig/vips-cpp.pc +1 -1
- package/lib/pkgconfig/vips.pc +1 -1
- package/package.json +1 -1
- package/versions.json +12 -12
- package/include/libheif/heif_uncompressed_types.h +0 -143
- package/lib/libsharpyuv.la +0 -41
- package/lib/libtiff.la +0 -41
- package/lib/libwebp.la +0 -41
- package/lib/libwebpdemux.la +0 -41
- package/lib/libwebpmux.la +0 -41
|
@@ -1574,7 +1574,7 @@ guint g_type_get_type_registration_serial (void);
|
|
|
1574
1574
|
* - the usual `my_app_window_get_type()` function is declared with a return type of #GType
|
|
1575
1575
|
*
|
|
1576
1576
|
* - the `MyAppWindow` type is defined as a `typedef` of `struct _MyAppWindow`. The struct itself is not
|
|
1577
|
-
* defined and should be defined from the
|
|
1577
|
+
* defined and should be defined from the `.c` file before `G_DEFINE_TYPE()` is used.
|
|
1578
1578
|
*
|
|
1579
1579
|
* - the `MY_APP_WINDOW()` cast is emitted as `static inline` function along with the `MY_APP_IS_WINDOW()` type
|
|
1580
1580
|
* checking function
|
|
@@ -1585,9 +1585,9 @@ guint g_type_get_type_registration_serial (void);
|
|
|
1585
1585
|
* and therefore the fact that the size of the class structure is exposed is not a concern and it can be
|
|
1586
1586
|
* freely changed at any point in the future.
|
|
1587
1587
|
*
|
|
1588
|
-
* - g_autoptr() support being added for your type, based on the type of your parent class
|
|
1588
|
+
* - `g_autoptr()` support being added for your type, based on the type of your parent class
|
|
1589
1589
|
*
|
|
1590
|
-
* You can only use this function if your parent type also supports g_autoptr()
|
|
1590
|
+
* You can only use this function if your parent type also supports `g_autoptr()`.
|
|
1591
1591
|
*
|
|
1592
1592
|
* Because the type macro (`MY_APP_TYPE_WINDOW` in the above example) is not a callable, you must continue to
|
|
1593
1593
|
* manually define this as a macro for yourself.
|
|
@@ -1595,11 +1595,11 @@ guint g_type_get_type_registration_serial (void);
|
|
|
1595
1595
|
* The declaration of the `_get_type()` function is the first thing emitted by the macro. This allows this macro
|
|
1596
1596
|
* to be used in the usual way with export control and API versioning macros.
|
|
1597
1597
|
*
|
|
1598
|
-
* If you want to declare your own class structure, use
|
|
1598
|
+
* If you want to declare your own class structure, use [func@GObject.DECLARE_DERIVABLE_TYPE].
|
|
1599
1599
|
*
|
|
1600
1600
|
* If you are writing a library, it is important to note that it is possible to convert a type from using
|
|
1601
|
-
* G_DECLARE_FINAL_TYPE() to G_DECLARE_DERIVABLE_TYPE() without breaking API or ABI. As a precaution, you
|
|
1602
|
-
* should therefore use G_DECLARE_FINAL_TYPE() until you are sure that it makes sense for your class to be
|
|
1601
|
+
* `G_DECLARE_FINAL_TYPE()` to `G_DECLARE_DERIVABLE_TYPE()` without breaking API or ABI. As a precaution, you
|
|
1602
|
+
* should therefore use `G_DECLARE_FINAL_TYPE()` until you are sure that it makes sense for your class to be
|
|
1603
1603
|
* subclassed. Once a class structure has been exposed it is not possible to change its size or remove or
|
|
1604
1604
|
* reorder items without breaking the API and/or ABI.
|
|
1605
1605
|
*
|
|
@@ -1687,7 +1687,7 @@ guint g_type_get_type_registration_serial (void);
|
|
|
1687
1687
|
*
|
|
1688
1688
|
* - g_autoptr() support being added for your type, based on the type of your parent class
|
|
1689
1689
|
*
|
|
1690
|
-
* You can only use this function if your parent type also supports g_autoptr()
|
|
1690
|
+
* You can only use this function if your parent type also supports `g_autoptr()`.
|
|
1691
1691
|
*
|
|
1692
1692
|
* Because the type macro (`GTK_TYPE_FROBBER` in the above example) is not a callable, you must continue to
|
|
1693
1693
|
* manually define this as a macro for yourself.
|
|
@@ -1696,14 +1696,14 @@ guint g_type_get_type_registration_serial (void);
|
|
|
1696
1696
|
* to be used in the usual way with export control and API versioning macros.
|
|
1697
1697
|
*
|
|
1698
1698
|
* If you are writing a library, it is important to note that it is possible to convert a type from using
|
|
1699
|
-
*
|
|
1700
|
-
* should therefore use G_DECLARE_FINAL_TYPE() until you are sure that it makes sense for your class to be
|
|
1699
|
+
* [func@GObject.DECLARE_FINAL_TYPE] to `G_DECLARE_DERIVABLE_TYPE()` without breaking API or ABI. As a precaution, you
|
|
1700
|
+
* should therefore use `G_DECLARE_FINAL_TYPE()` until you are sure that it makes sense for your class to be
|
|
1701
1701
|
* subclassed. Once a class structure has been exposed it is not possible to change its size or remove or
|
|
1702
1702
|
* reorder items without breaking the API and/or ABI. If you want to declare your own class structure, use
|
|
1703
|
-
* G_DECLARE_DERIVABLE_TYPE()
|
|
1704
|
-
* structures, use G_DECLARE_FINAL_TYPE()
|
|
1703
|
+
* `G_DECLARE_DERIVABLE_TYPE()`. If you want to declare a class without exposing the class or instance
|
|
1704
|
+
* structures, use `G_DECLARE_FINAL_TYPE()`.
|
|
1705
1705
|
*
|
|
1706
|
-
* If you must use G_DECLARE_DERIVABLE_TYPE() you should be sure to include some padding at the bottom of your
|
|
1706
|
+
* If you must use `G_DECLARE_DERIVABLE_TYPE()` you should be sure to include some padding at the bottom of your
|
|
1707
1707
|
* class structure to leave space for the addition of future virtual functions.
|
|
1708
1708
|
*
|
|
1709
1709
|
* Since: 2.44
|
|
@@ -1931,9 +1931,9 @@ guint g_type_get_type_registration_serial (void);
|
|
|
1931
1931
|
*
|
|
1932
1932
|
* A convenience macro for type implementations.
|
|
1933
1933
|
*
|
|
1934
|
-
* Similar to
|
|
1934
|
+
* Similar to [func@GObject.DEFINE_TYPE], but defines a final type.
|
|
1935
1935
|
*
|
|
1936
|
-
* See
|
|
1936
|
+
* See [func@GObject.DEFINE_TYPE_EXTENDED] for an example.
|
|
1937
1937
|
*
|
|
1938
1938
|
* Since: 2.70
|
|
1939
1939
|
*/
|
|
@@ -119,8 +119,21 @@ template <typename T, typename... Args>
|
|
|
119
119
|
AlignedUniquePtr<T> MakeUniqueAlignedWithAlloc(AllocPtr alloc, FreePtr free,
|
|
120
120
|
void* opaque, Args&&... args) {
|
|
121
121
|
T* ptr = static_cast<T*>(AllocateAlignedBytes(sizeof(T), alloc, opaque));
|
|
122
|
+
if (HWY_UNLIKELY(ptr == nullptr)) {
|
|
123
|
+
return AlignedUniquePtr<T>(nullptr, AlignedDeleter(free, opaque));
|
|
124
|
+
}
|
|
125
|
+
#ifdef HWY_EXCEPTIONS_ENABLED
|
|
126
|
+
try {
|
|
127
|
+
return AlignedUniquePtr<T>(new (ptr) T(std::forward<Args>(args)...),
|
|
128
|
+
AlignedDeleter(free, opaque));
|
|
129
|
+
} catch (...) {
|
|
130
|
+
FreeAlignedBytes(ptr, free, opaque);
|
|
131
|
+
throw;
|
|
132
|
+
}
|
|
133
|
+
#else
|
|
122
134
|
return AlignedUniquePtr<T>(new (ptr) T(std::forward<Args>(args)...),
|
|
123
135
|
AlignedDeleter(free, opaque));
|
|
136
|
+
#endif
|
|
124
137
|
}
|
|
125
138
|
|
|
126
139
|
// Similar to MakeUniqueAlignedWithAlloc but using the default alloc/free
|
|
@@ -128,8 +141,21 @@ AlignedUniquePtr<T> MakeUniqueAlignedWithAlloc(AllocPtr alloc, FreePtr free,
|
|
|
128
141
|
template <typename T, typename... Args>
|
|
129
142
|
AlignedUniquePtr<T> MakeUniqueAligned(Args&&... args) {
|
|
130
143
|
T* ptr = static_cast<T*>(AllocateAlignedBytes(sizeof(T)));
|
|
144
|
+
if (HWY_UNLIKELY(ptr == nullptr)) {
|
|
145
|
+
return AlignedUniquePtr<T>(nullptr, AlignedDeleter());
|
|
146
|
+
}
|
|
147
|
+
#ifdef HWY_EXCEPTIONS_ENABLED
|
|
148
|
+
try {
|
|
149
|
+
return AlignedUniquePtr<T>(new (ptr) T(std::forward<Args>(args)...),
|
|
150
|
+
AlignedDeleter());
|
|
151
|
+
} catch (...) {
|
|
152
|
+
FreeAlignedBytes(ptr, nullptr, nullptr);
|
|
153
|
+
throw;
|
|
154
|
+
}
|
|
155
|
+
#else
|
|
131
156
|
return AlignedUniquePtr<T>(new (ptr) T(std::forward<Args>(args)...),
|
|
132
157
|
AlignedDeleter());
|
|
158
|
+
#endif
|
|
133
159
|
}
|
|
134
160
|
|
|
135
161
|
template <class T>
|
|
@@ -147,8 +173,13 @@ struct AlignedAllocator {
|
|
|
147
173
|
"AlignedAllocator only supports integer types");
|
|
148
174
|
static_assert(sizeof(V) <= sizeof(std::size_t),
|
|
149
175
|
"V n must be smaller or equal size_t to avoid overflow");
|
|
176
|
+
const size_t count = static_cast<std::size_t>(n);
|
|
177
|
+
if (HWY_LIKELY(count != 0) && sizeof(value_type) > SIZE_MAX / count) {
|
|
178
|
+
HWY_ABORT("AlignedAllocator: allocation size overflow "
|
|
179
|
+
"(%zu * %zu exceeds size_t)", count, sizeof(value_type));
|
|
180
|
+
}
|
|
150
181
|
return static_cast<value_type*>(
|
|
151
|
-
AllocateAlignedBytes(
|
|
182
|
+
AllocateAlignedBytes(count * sizeof(value_type)));
|
|
152
183
|
}
|
|
153
184
|
|
|
154
185
|
template <class V>
|
|
@@ -208,7 +239,7 @@ AlignedUniquePtr<T[]> MakeUniqueAlignedArrayWithAlloc(
|
|
|
208
239
|
T* ptr = detail::AllocateAlignedItems<T>(items, alloc, opaque);
|
|
209
240
|
if (ptr != nullptr) {
|
|
210
241
|
for (size_t i = 0; i < items; i++) {
|
|
211
|
-
new (ptr + i) T(
|
|
242
|
+
new (ptr + i) T(args...);
|
|
212
243
|
}
|
|
213
244
|
}
|
|
214
245
|
return AlignedUniquePtr<T[]>(ptr, AlignedDeleter(free, opaque));
|
|
@@ -399,6 +430,10 @@ class AlignedNDArray {
|
|
|
399
430
|
size_t offset = 0;
|
|
400
431
|
size_t shape_index = 0;
|
|
401
432
|
for (const size_t axis_index : indices) {
|
|
433
|
+
if (HWY_UNLIKELY(axis_index >= shape_[shape_index])) {
|
|
434
|
+
HWY_ABORT("AlignedNDArray index %zu out of bounds (axis %zu, size %zu)",
|
|
435
|
+
axis_index, shape_index, shape_[shape_index]);
|
|
436
|
+
}
|
|
402
437
|
offset += memory_sizes_[shape_index + 1] * axis_index;
|
|
403
438
|
shape_index++;
|
|
404
439
|
}
|
|
@@ -417,6 +452,13 @@ class AlignedNDArray {
|
|
|
417
452
|
sizes[axis] = 1;
|
|
418
453
|
while (axis > 0) {
|
|
419
454
|
--axis;
|
|
455
|
+
// Check for integer overflow in dimension multiplication.
|
|
456
|
+
if (HWY_LIKELY(shape[axis] != 0) &&
|
|
457
|
+
sizes[axis + 1] > SIZE_MAX / shape[axis]) {
|
|
458
|
+
HWY_ABORT("AlignedNDArray: dimension overflow at axis %zu "
|
|
459
|
+
"(%zu * %zu exceeds size_t)",
|
|
460
|
+
axis, sizes[axis + 1], shape[axis]);
|
|
461
|
+
}
|
|
420
462
|
sizes[axis] = sizes[axis + 1] * shape[axis];
|
|
421
463
|
}
|
|
422
464
|
return sizes;
|
package/include/hwy/auto_tune.h
CHANGED
|
@@ -25,7 +25,18 @@
|
|
|
25
25
|
|
|
26
26
|
#include "hwy/aligned_allocator.h" // Span
|
|
27
27
|
#include "hwy/base.h" // HWY_MIN
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
// configuration to allow auto_tune to use std::sort instead of VQSort
|
|
30
|
+
// (also enabled in header only mode).
|
|
31
|
+
#if defined(HWY_HEADER_ONLY)
|
|
32
|
+
#define HWY_AUTOTUNE_STDSORT
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
#ifdef HWY_AUTOTUNE_STDSORT
|
|
36
|
+
#include <algorithm> // std::sort
|
|
37
|
+
#else
|
|
38
|
+
#include "hwy/contrib/sort/vqsort.h" // VQSort
|
|
39
|
+
#endif
|
|
29
40
|
|
|
30
41
|
// Infrastructure for auto-tuning (choosing optimal parameters at runtime).
|
|
31
42
|
|
|
@@ -104,6 +115,10 @@ class CostDistribution {
|
|
|
104
115
|
private:
|
|
105
116
|
static double Median(double* to_sort, size_t n) {
|
|
106
117
|
HWY_DASSERT(n >= 2);
|
|
118
|
+
|
|
119
|
+
#ifdef HWY_AUTOTUNE_STDSORT
|
|
120
|
+
std::sort(to_sort, to_sort + n);
|
|
121
|
+
#else
|
|
107
122
|
// F64 is supported everywhere except Armv7.
|
|
108
123
|
#if !HWY_ARCH_ARM_V7
|
|
109
124
|
VQSort(to_sort, n, SortAscending());
|
|
@@ -112,6 +127,8 @@ class CostDistribution {
|
|
|
112
127
|
// equivalent.
|
|
113
128
|
VQSort(reinterpret_cast<uint64_t*>(to_sort), n, SortAscending());
|
|
114
129
|
#endif
|
|
130
|
+
#endif
|
|
131
|
+
|
|
115
132
|
if (n & 1) return to_sort[n / 2];
|
|
116
133
|
// Even length: average of two middle elements.
|
|
117
134
|
return (to_sort[n / 2] + to_sort[n / 2 - 1]) * 0.5;
|
|
@@ -405,10 +422,9 @@ class AutoTune {
|
|
|
405
422
|
const Config* Best() const { return best_; }
|
|
406
423
|
|
|
407
424
|
// If false, caller must call `SetCandidates` before `NextConfig`.
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
425
|
+
// NOTE: also called after Best() is non-null.
|
|
426
|
+
bool HasCandidates() const { return !candidates_.empty(); }
|
|
427
|
+
|
|
412
428
|
// WARNING: invalidates `Best()`, do not call if that is non-null.
|
|
413
429
|
void SetCandidates(std::vector<Config> candidates) {
|
|
414
430
|
HWY_DASSERT(!Best() && !HasCandidates());
|
|
@@ -429,7 +445,7 @@ class AutoTune {
|
|
|
429
445
|
|
|
430
446
|
// Returns the current `Config` to measure.
|
|
431
447
|
const Config& NextConfig() const {
|
|
432
|
-
HWY_DASSERT(
|
|
448
|
+
HWY_DASSERT(HasCandidates());
|
|
433
449
|
return candidates_[config_idx_];
|
|
434
450
|
}
|
|
435
451
|
|
package/include/hwy/base.h
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
#include <stddef.h>
|
|
23
23
|
#include <stdint.h>
|
|
24
24
|
#if defined(HWY_HEADER_ONLY)
|
|
25
|
-
#include <
|
|
26
|
-
#include <
|
|
25
|
+
#include <stdarg.h>
|
|
26
|
+
#include <stdio.h>
|
|
27
27
|
#endif
|
|
28
28
|
|
|
29
29
|
#if !defined(HWY_NO_LIBCXX)
|
|
@@ -33,9 +33,10 @@
|
|
|
33
33
|
#include "hwy/detect_compiler_arch.h"
|
|
34
34
|
#include "hwy/highway_export.h"
|
|
35
35
|
|
|
36
|
-
// API version (https://semver.org/); keep in sync with CMakeLists.txt
|
|
36
|
+
// API version (https://semver.org/); keep in sync with CMakeLists.txt and
|
|
37
|
+
// meson.build.
|
|
37
38
|
#define HWY_MAJOR 1
|
|
38
|
-
#define HWY_MINOR
|
|
39
|
+
#define HWY_MINOR 4
|
|
39
40
|
#define HWY_PATCH 0
|
|
40
41
|
|
|
41
42
|
// True if the Highway version >= major.minor.0. Added in 1.2.0.
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
|
|
58
59
|
#endif // !HWY_IDE
|
|
59
60
|
|
|
60
|
-
#if
|
|
61
|
+
#if !defined(HWY_NO_LIBCXX) || HWY_COMPILER_MSVC
|
|
61
62
|
#include <atomic>
|
|
62
63
|
#endif
|
|
63
64
|
|
|
@@ -148,6 +149,21 @@
|
|
|
148
149
|
|
|
149
150
|
#endif // !HWY_COMPILER_MSVC
|
|
150
151
|
|
|
152
|
+
#if (HWY_COMPILER_GCC_ACTUAL && HWY_COMPILER_GCC_ACTUAL < 1200) || \
|
|
153
|
+
(HWY_COMPILER_ICC && !HWY_COMPILER_ICX)
|
|
154
|
+
// The use of __attribute__((unused)) in private class member variables triggers
|
|
155
|
+
// a compiler warning with GCC 11 and earlier and ICC
|
|
156
|
+
|
|
157
|
+
// GCC 11 and earlier and ICC also do not emit -Wunused-private-field warnings
|
|
158
|
+
// for unused private class member variables
|
|
159
|
+
#define HWY_MEMBER_VAR_MAYBE_UNUSED
|
|
160
|
+
#else
|
|
161
|
+
// Clang and ICX need __attribute__((unused)) in unused private class member
|
|
162
|
+
// variables to suppress -Wunused-private-field warnings unless this warning is
|
|
163
|
+
// ignored by using HWY_DIAGNOSTICS_OFF
|
|
164
|
+
#define HWY_MEMBER_VAR_MAYBE_UNUSED HWY_MAYBE_UNUSED
|
|
165
|
+
#endif
|
|
166
|
+
|
|
151
167
|
//------------------------------------------------------------------------------
|
|
152
168
|
// Builtin/attributes (no more #include after this point due to namespace!)
|
|
153
169
|
|
|
@@ -202,7 +218,9 @@ namespace hwy {
|
|
|
202
218
|
//------------------------------------------------------------------------------
|
|
203
219
|
// Macros
|
|
204
220
|
|
|
205
|
-
|
|
221
|
+
// Note: it is safe to remove `static` for users who want to use modules, but
|
|
222
|
+
// that might be a breaking change for some users, hence we do not by default.
|
|
223
|
+
#define HWY_API static HWY_INLINE HWY_FLATTEN
|
|
206
224
|
|
|
207
225
|
#define HWY_CONCAT_IMPL(a, b) a##b
|
|
208
226
|
#define HWY_CONCAT(a, b) HWY_CONCAT_IMPL(a, b)
|
|
@@ -349,60 +367,20 @@ HWY_DLLEXPORT HWY_NORETURN void HWY_FORMAT(3, 4)
|
|
|
349
367
|
} while (0)
|
|
350
368
|
#define HWY_ASSERT(condition) HWY_ASSERT_M(condition, "")
|
|
351
369
|
|
|
352
|
-
#if HWY_HAS_FEATURE(memory_sanitizer) || defined(MEMORY_SANITIZER) || \
|
|
353
|
-
defined(__SANITIZE_MEMORY__)
|
|
354
|
-
#define HWY_IS_MSAN 1
|
|
355
|
-
#else
|
|
356
|
-
#define HWY_IS_MSAN 0
|
|
357
|
-
#endif
|
|
358
|
-
|
|
359
|
-
#if HWY_HAS_FEATURE(address_sanitizer) || defined(ADDRESS_SANITIZER) || \
|
|
360
|
-
defined(__SANITIZE_ADDRESS__)
|
|
361
|
-
#define HWY_IS_ASAN 1
|
|
362
|
-
#else
|
|
363
|
-
#define HWY_IS_ASAN 0
|
|
364
|
-
#endif
|
|
365
|
-
|
|
366
|
-
#if HWY_HAS_FEATURE(hwaddress_sanitizer) || defined(HWADDRESS_SANITIZER) || \
|
|
367
|
-
defined(__SANITIZE_HWADDRESS__)
|
|
368
|
-
#define HWY_IS_HWASAN 1
|
|
369
|
-
#else
|
|
370
|
-
#define HWY_IS_HWASAN 0
|
|
371
|
-
#endif
|
|
372
|
-
|
|
373
|
-
#if HWY_HAS_FEATURE(thread_sanitizer) || defined(THREAD_SANITIZER) || \
|
|
374
|
-
defined(__SANITIZE_THREAD__)
|
|
375
|
-
#define HWY_IS_TSAN 1
|
|
376
|
-
#else
|
|
377
|
-
#define HWY_IS_TSAN 0
|
|
378
|
-
#endif
|
|
379
|
-
|
|
380
|
-
#if HWY_HAS_FEATURE(undefined_behavior_sanitizer) || \
|
|
381
|
-
defined(UNDEFINED_BEHAVIOR_SANITIZER)
|
|
382
|
-
#define HWY_IS_UBSAN 1
|
|
383
|
-
#else
|
|
384
|
-
#define HWY_IS_UBSAN 0
|
|
385
|
-
#endif
|
|
386
|
-
|
|
387
|
-
// MSAN may cause lengthy build times or false positives e.g. in AVX3 DemoteTo.
|
|
388
|
-
// You can disable MSAN by adding this attribute to the function that fails.
|
|
389
|
-
#if HWY_IS_MSAN
|
|
390
|
-
#define HWY_ATTR_NO_MSAN __attribute__((no_sanitize_memory))
|
|
391
|
-
#else
|
|
392
|
-
#define HWY_ATTR_NO_MSAN
|
|
393
|
-
#endif
|
|
394
|
-
|
|
395
|
-
#if HWY_IS_ASAN || HWY_IS_HWASAN || HWY_IS_MSAN || HWY_IS_TSAN || HWY_IS_UBSAN
|
|
396
|
-
#define HWY_IS_SANITIZER 1
|
|
397
|
-
#else
|
|
398
|
-
#define HWY_IS_SANITIZER 0
|
|
399
|
-
#endif
|
|
400
|
-
|
|
401
370
|
// For enabling HWY_DASSERT and shortening tests in slower debug builds
|
|
371
|
+
//
|
|
372
|
+
// Note: `HWY_IS_UBSAN` is specifically excluded from engaging debug
|
|
373
|
+
// builds. This is in service of Chromium's `-fsanitize=array-bounds` by
|
|
374
|
+
// default, where we don't want Highway to unconditionally build in
|
|
375
|
+
// debug mode.
|
|
376
|
+
//
|
|
377
|
+
// See also:
|
|
378
|
+
// https://docs.google.com/document/d/1eCtY4AZF-SiFHxhIYWzEytdIx3C24de7ccD6Y5Gn2H8/edit?tab=t.9zkn85hr82ms#heading=h.efcshvfql42c
|
|
402
379
|
#if !defined(HWY_IS_DEBUG_BUILD)
|
|
403
380
|
// Clang does not define NDEBUG, but it and GCC define __OPTIMIZE__, and recent
|
|
404
381
|
// MSVC defines NDEBUG (if not, could instead check _DEBUG).
|
|
405
|
-
#if (!defined(__OPTIMIZE__) && !defined(NDEBUG)) ||
|
|
382
|
+
#if (!defined(__OPTIMIZE__) && !defined(NDEBUG)) || \
|
|
383
|
+
(HWY_IS_ASAN || (HWY_IS_SANITIZER && !HWY_IS_UBSAN)) || \
|
|
406
384
|
defined(__clang_analyzer__)
|
|
407
385
|
#define HWY_IS_DEBUG_BUILD 1
|
|
408
386
|
#else
|
|
@@ -455,21 +433,22 @@ HWY_API void CopySameSize(const From* HWY_RESTRICT from, To* HWY_RESTRICT to) {
|
|
|
455
433
|
CopyBytes<sizeof(From)>(from, to);
|
|
456
434
|
}
|
|
457
435
|
|
|
458
|
-
|
|
459
|
-
HWY_API void
|
|
436
|
+
// Sets each byte to `byte_value`, which must be between 0 and 255.
|
|
437
|
+
HWY_API void FillBytes(void* to, int byte_value, size_t num_bytes) {
|
|
460
438
|
#if HWY_COMPILER_MSVC
|
|
461
|
-
memset(to,
|
|
439
|
+
memset(to, byte_value, num_bytes);
|
|
462
440
|
#else
|
|
463
|
-
__builtin_memset(to,
|
|
441
|
+
__builtin_memset(to, byte_value, num_bytes);
|
|
464
442
|
#endif
|
|
465
443
|
}
|
|
466
444
|
|
|
467
445
|
HWY_API void ZeroBytes(void* to, size_t num_bytes) {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
446
|
+
FillBytes(to, 0, num_bytes);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
template <size_t kBytes, typename To>
|
|
450
|
+
HWY_API void ZeroBytes(To* to) {
|
|
451
|
+
ZeroBytes(to, kBytes);
|
|
473
452
|
}
|
|
474
453
|
|
|
475
454
|
//------------------------------------------------------------------------------
|
|
@@ -1699,28 +1678,14 @@ HWY_F16_CONSTEXPR inline std::partial_ordering operator<=>(
|
|
|
1699
1678
|
//------------------------------------------------------------------------------
|
|
1700
1679
|
// BF16 lane type
|
|
1701
1680
|
|
|
1702
|
-
// Compiler supports ACLE __bf16, not necessarily with operators.
|
|
1703
|
-
|
|
1704
|
-
// Disable the __bf16 type on AArch64 with GCC 13 or earlier as there is a bug
|
|
1705
|
-
// in GCC 13 and earlier that sometimes causes BF16 constant values to be
|
|
1706
|
-
// incorrectly loaded on AArch64, and this GCC bug on AArch64 is
|
|
1707
|
-
// described at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111867.
|
|
1708
|
-
|
|
1709
|
-
#if HWY_ARCH_ARM_A64 && \
|
|
1710
|
-
(HWY_COMPILER_CLANG >= 1700 || HWY_COMPILER_GCC_ACTUAL >= 1400)
|
|
1711
|
-
#define HWY_ARM_HAVE_SCALAR_BF16_TYPE 1
|
|
1712
|
-
#else
|
|
1713
|
-
#define HWY_ARM_HAVE_SCALAR_BF16_TYPE 0
|
|
1714
|
-
#endif
|
|
1715
|
-
|
|
1716
1681
|
// x86 compiler supports __bf16, not necessarily with operators.
|
|
1717
1682
|
// Disable in debug builds due to clang miscompiles as of 2025-07-22: casting
|
|
1718
1683
|
// bf16 <-> f32 in convert_test results in 0x2525 for 1.0 instead of 0x3f80.
|
|
1719
1684
|
// Reported at https://github.com/llvm/llvm-project/issues/151692.
|
|
1720
1685
|
#ifndef HWY_SSE2_HAVE_SCALAR_BF16_TYPE
|
|
1721
|
-
#if HWY_ARCH_X86 && defined(__SSE2__) &&
|
|
1722
|
-
((HWY_COMPILER_CLANG >= 1700 && !HWY_COMPILER_CLANGCL &&
|
|
1723
|
-
!HWY_IS_DEBUG_BUILD) ||
|
|
1686
|
+
#if HWY_ARCH_X86 && defined(__SSE2__) && \
|
|
1687
|
+
((HWY_COMPILER_CLANG >= 1700 && !HWY_COMPILER_CLANGCL && \
|
|
1688
|
+
(!HWY_IS_DEBUG_BUILD || HWY_COMPILER3_CLANG >= 220101)) || \
|
|
1724
1689
|
HWY_COMPILER_GCC_ACTUAL >= 1300)
|
|
1725
1690
|
#define HWY_SSE2_HAVE_SCALAR_BF16_TYPE 1
|
|
1726
1691
|
#else
|
|
@@ -1738,7 +1703,11 @@ HWY_F16_CONSTEXPR inline std::partial_ordering operator<=>(
|
|
|
1738
1703
|
#ifndef HWY_HAVE_SCALAR_BF16_OPERATORS
|
|
1739
1704
|
// Recent enough compiler also has operators. aarch64 clang 18 hits internal
|
|
1740
1705
|
// compiler errors on bf16 ToString, hence only enable on GCC for now.
|
|
1741
|
-
|
|
1706
|
+
// GCC >= 13 will insert a function call to the __extendbfsf2 helper function
|
|
1707
|
+
// for scalar conversions from __bf16 to float. This is prohibitively expensive,
|
|
1708
|
+
// so refrain from using scalar BF16 operators on these compiler versions.
|
|
1709
|
+
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121853
|
|
1710
|
+
#if HWY_HAVE_SCALAR_BF16_TYPE && (HWY_COMPILER_GCC_ACTUAL >= 1700)
|
|
1742
1711
|
#define HWY_HAVE_SCALAR_BF16_OPERATORS 1
|
|
1743
1712
|
#else
|
|
1744
1713
|
#define HWY_HAVE_SCALAR_BF16_OPERATORS 0
|
|
@@ -2734,7 +2703,7 @@ HWY_API constexpr TTo ConvertScalarTo(TFrom in) {
|
|
|
2734
2703
|
template <typename T1, typename T2>
|
|
2735
2704
|
constexpr inline T1 DivCeil(T1 a, T2 b) {
|
|
2736
2705
|
#if HWY_CXX_LANG >= 201703L
|
|
2737
|
-
HWY_DASSERT(b != 0);
|
|
2706
|
+
HWY_DASSERT(b != T2{0});
|
|
2738
2707
|
#endif
|
|
2739
2708
|
return (a + b - 1) / b;
|
|
2740
2709
|
}
|
|
@@ -2957,9 +2926,10 @@ HWY_INLINE constexpr T AddWithWraparound(T t, T2 n) {
|
|
|
2957
2926
|
// 64 x 64 = 128 bit multiplication
|
|
2958
2927
|
HWY_API uint64_t Mul128(uint64_t a, uint64_t b, uint64_t* HWY_RESTRICT upper) {
|
|
2959
2928
|
#if defined(__SIZEOF_INT128__)
|
|
2960
|
-
__uint128_t product =
|
|
2961
|
-
|
|
2962
|
-
|
|
2929
|
+
__uint128_t product =
|
|
2930
|
+
static_cast<__uint128_t>(a) * static_cast<__uint128_t>(b);
|
|
2931
|
+
*upper = static_cast<uint64_t>(product >> 64);
|
|
2932
|
+
return static_cast<uint64_t>(product & 0xFFFFFFFFFFFFFFFFULL);
|
|
2963
2933
|
#elif HWY_COMPILER_MSVC && HWY_ARCH_X86_64
|
|
2964
2934
|
return _umul128(a, b, upper);
|
|
2965
2935
|
#else
|
|
@@ -2976,9 +2946,9 @@ HWY_API uint64_t Mul128(uint64_t a, uint64_t b, uint64_t* HWY_RESTRICT upper) {
|
|
|
2976
2946
|
|
|
2977
2947
|
HWY_API int64_t Mul128(int64_t a, int64_t b, int64_t* HWY_RESTRICT upper) {
|
|
2978
2948
|
#if defined(__SIZEOF_INT128__)
|
|
2979
|
-
__int128_t product = (
|
|
2980
|
-
*upper =
|
|
2981
|
-
return
|
|
2949
|
+
__int128_t product = static_cast<__int128_t>(a) * static_cast<__int128_t>(b);
|
|
2950
|
+
*upper = static_cast<int64_t>(product >> 64);
|
|
2951
|
+
return static_cast<int64_t>(product & 0xFFFFFFFFFFFFFFFFULL);
|
|
2982
2952
|
#elif HWY_COMPILER_MSVC && HWY_ARCH_X86_64
|
|
2983
2953
|
return _mul128(a, b, upper);
|
|
2984
2954
|
#else
|