@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.
Files changed (153) hide show
  1. package/README.md +23 -23
  2. package/include/aom/aom_codec.h +1 -1
  3. package/include/aom/aom_decoder.h +4 -0
  4. package/include/aom/aom_encoder.h +19 -8
  5. package/include/aom/aom_ext_ratectrl.h +664 -0
  6. package/include/aom/aom_image.h +93 -30
  7. package/include/aom/aom_tpl.h +99 -0
  8. package/include/aom/aomcx.h +89 -16
  9. package/include/aom/aomdx.h +12 -0
  10. package/include/expat.h +14 -2
  11. package/include/expat_config.h +6 -3
  12. package/include/expat_external.h +3 -2
  13. package/include/glib-2.0/gio/gdbusconnection.h +2 -8
  14. package/include/glib-2.0/gio/gio-visibility.h +34 -0
  15. package/include/glib-2.0/gio/gioenums.h +5 -4
  16. package/include/glib-2.0/glib/glib-visibility.h +34 -0
  17. package/include/glib-2.0/glib/gmacros.h +3 -3
  18. package/include/glib-2.0/glib/gmarkup.h +10 -0
  19. package/include/glib-2.0/glib/gmem.h +4 -4
  20. package/include/glib-2.0/glib/gmessages.h +6 -8
  21. package/include/glib-2.0/glib/gsequence.h +2 -2
  22. package/include/glib-2.0/glib/gstrfuncs.h +190 -0
  23. package/include/glib-2.0/glib/gutils.h +9 -0
  24. package/include/glib-2.0/glib/gvarianttype.h +16 -16
  25. package/include/glib-2.0/glib/gversionmacros.h +22 -0
  26. package/include/glib-2.0/gmodule/gmodule-visibility.h +34 -0
  27. package/include/glib-2.0/gobject/gobject-visibility.h +34 -0
  28. package/include/glib-2.0/gobject/gsignal.h +5 -5
  29. package/include/glib-2.0/gobject/gtype.h +14 -14
  30. package/include/hwy/aligned_allocator.h +44 -2
  31. package/include/hwy/auto_tune.h +22 -6
  32. package/include/hwy/base.h +60 -90
  33. package/include/hwy/bit_set.h +410 -0
  34. package/include/hwy/cache_control.h +3 -2
  35. package/include/hwy/detect_compiler_arch.h +134 -14
  36. package/include/hwy/detect_targets.h +82 -36
  37. package/include/hwy/highway.h +15 -0
  38. package/include/hwy/nanobenchmark.h +12 -3
  39. package/include/hwy/ops/arm_neon-inl.h +96 -25
  40. package/include/hwy/ops/arm_sve-inl.h +250 -95
  41. package/include/hwy/ops/emu128-inl.h +12 -7
  42. package/include/hwy/ops/generic_ops-inl.h +271 -131
  43. package/include/hwy/ops/loongarch_lasx-inl.h +31 -9
  44. package/include/hwy/ops/loongarch_lsx-inl.h +33 -12
  45. package/include/hwy/ops/ppc_vsx-inl.h +99 -19
  46. package/include/hwy/ops/rvv-inl.h +239 -130
  47. package/include/hwy/ops/scalar-inl.h +22 -7
  48. package/include/hwy/ops/set_macros-inl.h +163 -107
  49. package/include/hwy/ops/wasm_128-inl.h +13 -22
  50. package/include/hwy/ops/x86_128-inl.h +223 -120
  51. package/include/hwy/ops/x86_256-inl.h +70 -134
  52. package/include/hwy/ops/x86_512-inl.h +130 -134
  53. package/include/hwy/print-inl.h +2 -0
  54. package/include/hwy/profiler.h +355 -264
  55. package/include/hwy/robust_statistics.h +3 -1
  56. package/include/hwy/timer.h +44 -0
  57. package/include/lcms2.h +34 -4
  58. package/include/libexif/exif-utils.h +1 -1
  59. package/include/libheif/heif.h +2 -0
  60. package/include/libheif/heif_color.h +127 -11
  61. package/include/libheif/heif_components.h +264 -0
  62. package/include/libheif/heif_context.h +2 -1
  63. package/include/libheif/heif_cxx.h +10 -10
  64. package/include/libheif/heif_decoding.h +51 -7
  65. package/include/libheif/heif_encoding.h +15 -9
  66. package/include/libheif/heif_error.h +9 -2
  67. package/include/libheif/heif_export.h +48 -0
  68. package/include/libheif/heif_image.h +81 -66
  69. package/include/libheif/heif_image_handle.h +2 -2
  70. package/include/libheif/heif_items.h +1 -1
  71. package/include/libheif/heif_library.h +8 -16
  72. package/include/libheif/heif_omaf.h +104 -0
  73. package/include/libheif/heif_plugin.h +16 -9
  74. package/include/libheif/heif_properties.h +250 -12
  75. package/include/libheif/heif_security.h +16 -4
  76. package/include/libheif/heif_sequences.h +86 -4
  77. package/include/libheif/heif_tiling.h +2 -2
  78. package/include/libheif/heif_uncompressed.h +44 -324
  79. package/include/libheif/heif_version.h +2 -2
  80. package/include/libpng16/png.h +7 -7
  81. package/include/libpng16/pngconf.h +1 -1
  82. package/include/libpng16/pnglibconf.h +1 -1
  83. package/include/png.h +7 -7
  84. package/include/pngconf.h +1 -1
  85. package/include/pnglibconf.h +1 -1
  86. package/include/tiffconf.h +9 -10
  87. package/include/tiffio.h +10 -9
  88. package/include/tiffvers.h +1 -1
  89. package/include/ultrahdr_api.h +5 -11
  90. package/include/vips/version.h +4 -4
  91. package/lib/glib-2.0/include/glibconfig.h +1 -3
  92. package/lib/libaom.a +0 -0
  93. package/lib/libcgif.a +0 -0
  94. package/lib/libexif.a +0 -0
  95. package/lib/libexif.la +1 -1
  96. package/lib/libexpat.a +0 -0
  97. package/lib/libexpat.la +3 -3
  98. package/lib/libffi.a +0 -0
  99. package/lib/libgio-2.0.a +0 -0
  100. package/lib/libglib-2.0.a +0 -0
  101. package/lib/libgmodule-2.0.a +0 -0
  102. package/lib/libgobject-2.0.a +0 -0
  103. package/lib/libgthread-2.0.a +0 -0
  104. package/lib/libheif.a +0 -0
  105. package/lib/libhwy.a +0 -0
  106. package/lib/libimagequant.a +0 -0
  107. package/lib/libjpeg.a +0 -0
  108. package/lib/liblcms2.a +0 -0
  109. package/lib/libpng.a +0 -0
  110. package/lib/libpng.la +2 -2
  111. package/lib/libpng16.a +0 -0
  112. package/lib/libpng16.la +2 -2
  113. package/lib/libresvg.a +0 -0
  114. package/lib/libsharpyuv.a +0 -0
  115. package/lib/libtiff.a +0 -0
  116. package/lib/libuhdr.a +0 -0
  117. package/lib/libvips-cpp.a +0 -0
  118. package/lib/libvips.a +0 -0
  119. package/lib/libwebp.a +0 -0
  120. package/lib/libwebpdecoder.a +0 -0
  121. package/lib/libwebpdemux.a +0 -0
  122. package/lib/libwebpmux.a +0 -0
  123. package/lib/libz.a +0 -0
  124. package/lib/pkgconfig/aom.pc +2 -2
  125. package/lib/pkgconfig/expat.pc +1 -1
  126. package/lib/pkgconfig/gio-2.0.pc +1 -1
  127. package/lib/pkgconfig/glib-2.0.pc +1 -1
  128. package/lib/pkgconfig/gmodule-2.0.pc +1 -1
  129. package/lib/pkgconfig/gmodule-export-2.0.pc +1 -1
  130. package/lib/pkgconfig/gmodule-no-export-2.0.pc +1 -1
  131. package/lib/pkgconfig/gobject-2.0.pc +1 -1
  132. package/lib/pkgconfig/gthread-2.0.pc +1 -1
  133. package/lib/pkgconfig/lcms2.pc +1 -1
  134. package/lib/pkgconfig/libexif.pc +1 -1
  135. package/lib/pkgconfig/libheif.pc +2 -2
  136. package/lib/pkgconfig/libhwy.pc +3 -4
  137. package/lib/pkgconfig/libpng.pc +1 -1
  138. package/lib/pkgconfig/libpng16.pc +1 -1
  139. package/lib/pkgconfig/libsharpyuv.pc +1 -1
  140. package/lib/pkgconfig/libtiff-4.pc +2 -2
  141. package/lib/pkgconfig/libwebp.pc +1 -1
  142. package/lib/pkgconfig/libwebpdecoder.pc +11 -0
  143. package/lib/pkgconfig/libwebpmux.pc +1 -1
  144. package/lib/pkgconfig/vips-cpp.pc +1 -1
  145. package/lib/pkgconfig/vips.pc +1 -1
  146. package/package.json +1 -1
  147. package/versions.json +12 -12
  148. package/include/libheif/heif_uncompressed_types.h +0 -143
  149. package/lib/libsharpyuv.la +0 -41
  150. package/lib/libtiff.la +0 -41
  151. package/lib/libwebp.la +0 -41
  152. package/lib/libwebpdemux.la +0 -41
  153. 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 .c file before G_DEFINE_TYPE() is used.
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 G_DECLARE_DERIVABLE_TYPE().
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
- * G_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
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(). If you want to declare a class without exposing the class or instance
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 G_DEFINE_TYPE(), but defines a final type.
1934
+ * Similar to [func@GObject.DEFINE_TYPE], but defines a final type.
1935
1935
  *
1936
- * See G_DEFINE_TYPE_EXTENDED() for an example.
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(static_cast<std::size_t>(n) * sizeof(value_type)));
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(std::forward<Args>(args)...);
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;
@@ -25,7 +25,18 @@
25
25
 
26
26
  #include "hwy/aligned_allocator.h" // Span
27
27
  #include "hwy/base.h" // HWY_MIN
28
- #include "hwy/contrib/sort/vqsort.h"
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
- bool HasCandidates() const {
409
- HWY_DASSERT(!Best());
410
- return !candidates_.empty();
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(!Best() && HasCandidates());
448
+ HWY_DASSERT(HasCandidates());
433
449
  return candidates_[config_idx_];
434
450
  }
435
451
 
@@ -22,8 +22,8 @@
22
22
  #include <stddef.h>
23
23
  #include <stdint.h>
24
24
  #if defined(HWY_HEADER_ONLY)
25
- #include <cstdarg>
26
- #include <cstdio>
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 3
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 (HWY_ARCH_X86 && !defined(HWY_NO_LIBCXX)) || HWY_COMPILER_MSVC
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
- #define HWY_API static HWY_INLINE HWY_FLATTEN HWY_MAYBE_UNUSED
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)) || HWY_IS_SANITIZER || \
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
- template <size_t kBytes, typename To>
459
- HWY_API void ZeroBytes(To* to) {
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, 0, kBytes);
439
+ memset(to, byte_value, num_bytes);
462
440
  #else
463
- __builtin_memset(to, 0, kBytes);
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
- #if HWY_COMPILER_MSVC
469
- memset(to, 0, num_bytes);
470
- #else
471
- __builtin_memset(to, 0, num_bytes);
472
- #endif
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
- #if HWY_HAVE_SCALAR_BF16_TYPE && (HWY_COMPILER_GCC_ACTUAL >= 1300)
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 = (__uint128_t)a * (__uint128_t)b;
2961
- *upper = (uint64_t)(product >> 64);
2962
- return (uint64_t)(product & 0xFFFFFFFFFFFFFFFFULL);
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 = (__int128_t)a * (__int128_t)b;
2980
- *upper = (int64_t)(product >> 64);
2981
- return (int64_t)(product & 0xFFFFFFFFFFFFFFFFULL);
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