@img/sharp-libvips-dev-wasm32 1.3.0-rc.5 → 1.3.0-rc.7

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 (105) hide show
  1. package/README.md +23 -23
  2. package/include/expat.h +14 -2
  3. package/include/expat_config.h +6 -3
  4. package/include/expat_external.h +3 -2
  5. package/include/glib-2.0/glib/gvarianttype.h +16 -16
  6. package/include/glib-2.0/glib/gversionmacros.h +13 -0
  7. package/include/hwy/aligned_allocator.h +44 -2
  8. package/include/hwy/auto_tune.h +22 -6
  9. package/include/hwy/base.h +60 -90
  10. package/include/hwy/bit_set.h +410 -0
  11. package/include/hwy/cache_control.h +3 -2
  12. package/include/hwy/detect_compiler_arch.h +134 -14
  13. package/include/hwy/detect_targets.h +82 -36
  14. package/include/hwy/highway.h +15 -0
  15. package/include/hwy/nanobenchmark.h +12 -3
  16. package/include/hwy/ops/arm_neon-inl.h +96 -25
  17. package/include/hwy/ops/arm_sve-inl.h +250 -95
  18. package/include/hwy/ops/emu128-inl.h +12 -7
  19. package/include/hwy/ops/generic_ops-inl.h +271 -131
  20. package/include/hwy/ops/loongarch_lasx-inl.h +31 -9
  21. package/include/hwy/ops/loongarch_lsx-inl.h +33 -12
  22. package/include/hwy/ops/ppc_vsx-inl.h +99 -19
  23. package/include/hwy/ops/rvv-inl.h +239 -130
  24. package/include/hwy/ops/scalar-inl.h +22 -7
  25. package/include/hwy/ops/set_macros-inl.h +163 -107
  26. package/include/hwy/ops/wasm_128-inl.h +13 -22
  27. package/include/hwy/ops/x86_128-inl.h +223 -120
  28. package/include/hwy/ops/x86_256-inl.h +70 -134
  29. package/include/hwy/ops/x86_512-inl.h +130 -134
  30. package/include/hwy/print-inl.h +2 -0
  31. package/include/hwy/profiler.h +355 -264
  32. package/include/hwy/robust_statistics.h +3 -1
  33. package/include/hwy/timer.h +44 -0
  34. package/include/lcms2.h +34 -4
  35. package/include/libexif/exif-utils.h +1 -1
  36. package/include/libheif/heif_sequences.h +12 -2
  37. package/include/libheif/heif_uncompressed.h +8 -0
  38. package/include/libpng16/png.h +7 -7
  39. package/include/libpng16/pngconf.h +1 -1
  40. package/include/libpng16/pnglibconf.h +1 -1
  41. package/include/png.h +7 -7
  42. package/include/pngconf.h +1 -1
  43. package/include/pnglibconf.h +1 -1
  44. package/include/tiffconf.h +9 -10
  45. package/include/tiffio.h +10 -9
  46. package/include/tiffvers.h +1 -1
  47. package/include/ultrahdr_api.h +5 -11
  48. package/lib/glib-2.0/include/glibconfig.h +1 -1
  49. package/lib/libaom.a +0 -0
  50. package/lib/libcgif.a +0 -0
  51. package/lib/libexif.a +0 -0
  52. package/lib/libexif.la +1 -1
  53. package/lib/libexpat.a +0 -0
  54. package/lib/libexpat.la +3 -3
  55. package/lib/libffi.a +0 -0
  56. package/lib/libgio-2.0.a +0 -0
  57. package/lib/libglib-2.0.a +0 -0
  58. package/lib/libgmodule-2.0.a +0 -0
  59. package/lib/libgobject-2.0.a +0 -0
  60. package/lib/libgthread-2.0.a +0 -0
  61. package/lib/libheif.a +0 -0
  62. package/lib/libhwy.a +0 -0
  63. package/lib/libimagequant.a +0 -0
  64. package/lib/libjpeg.a +0 -0
  65. package/lib/liblcms2.a +0 -0
  66. package/lib/libpng.a +0 -0
  67. package/lib/libpng.la +2 -2
  68. package/lib/libpng16.a +0 -0
  69. package/lib/libpng16.la +2 -2
  70. package/lib/libresvg.a +0 -0
  71. package/lib/libsharpyuv.a +0 -0
  72. package/lib/libtiff.a +0 -0
  73. package/lib/libuhdr.a +0 -0
  74. package/lib/libvips-cpp.a +0 -0
  75. package/lib/libvips.a +0 -0
  76. package/lib/libwebp.a +0 -0
  77. package/lib/libwebpdecoder.a +0 -0
  78. package/lib/libwebpdemux.a +0 -0
  79. package/lib/libwebpmux.a +0 -0
  80. package/lib/libz.a +0 -0
  81. package/lib/pkgconfig/expat.pc +1 -1
  82. package/lib/pkgconfig/gio-2.0.pc +1 -1
  83. package/lib/pkgconfig/glib-2.0.pc +1 -1
  84. package/lib/pkgconfig/gmodule-2.0.pc +1 -1
  85. package/lib/pkgconfig/gmodule-export-2.0.pc +1 -1
  86. package/lib/pkgconfig/gmodule-no-export-2.0.pc +1 -1
  87. package/lib/pkgconfig/gobject-2.0.pc +1 -1
  88. package/lib/pkgconfig/gthread-2.0.pc +1 -1
  89. package/lib/pkgconfig/lcms2.pc +1 -1
  90. package/lib/pkgconfig/libexif.pc +1 -1
  91. package/lib/pkgconfig/libhwy.pc +3 -4
  92. package/lib/pkgconfig/libpng.pc +1 -1
  93. package/lib/pkgconfig/libpng16.pc +1 -1
  94. package/lib/pkgconfig/libsharpyuv.pc +1 -1
  95. package/lib/pkgconfig/libtiff-4.pc +2 -2
  96. package/lib/pkgconfig/libwebp.pc +1 -1
  97. package/lib/pkgconfig/libwebpdecoder.pc +11 -0
  98. package/lib/pkgconfig/libwebpmux.pc +1 -1
  99. package/package.json +1 -1
  100. package/versions.json +10 -10
  101. package/lib/libsharpyuv.la +0 -41
  102. package/lib/libtiff.la +0 -41
  103. package/lib/libwebp.la +0 -41
  104. package/lib/libwebpdemux.la +0 -41
  105. package/lib/libwebpmux.la +0 -41
package/README.md CHANGED
@@ -5,30 +5,30 @@ Header files and static wasm32 libraries for libvips and dependencies to build s
5
5
  ## Licensing
6
6
 
7
7
  This software contains third-party libraries
8
- used under the terms of the following licences:
8
+ used under the terms of the following licenses:
9
9
 
10
- | Library | Used under the terms of |
11
- |---------------|-----------------------------------------------------------------------------------------------------------|
12
- | aom | BSD 2-Clause + [Alliance for Open Media Patent License 1.0](https://aomedia.org/license/patent-license/) |
13
- | cgif | MIT Licence |
14
- | emscripten | [MIT Licence](https://github.com/emscripten-core/emscripten/blob/main/LICENSE) |
15
- | expat | MIT Licence |
16
- | glib | LGPLv3 |
17
- | highway | Apache-2.0 License, BSD 3-Clause |
18
- | lcms | MIT Licence |
19
- | libexif | LGPLv3 |
20
- | libffi | MIT Licence |
21
- | libheif | LGPLv3 |
22
- | libimagequant | [BSD 2-Clause](https://github.com/lovell/libimagequant/blob/main/COPYRIGHT) |
23
- | libnsgif | MIT Licence |
24
- | libpng | [libpng License](https://github.com/pnggroup/libpng/blob/master/LICENSE) |
25
- | libtiff | [libtiff License](https://gitlab.com/libtiff/libtiff/blob/master/LICENSE.md) (BSD-like) |
26
- | libultrahdr | Apache-2.0 License |
27
- | libvips | LGPLv3 |
28
- | libwebp | New BSD License |
29
- | mozjpeg | [zlib License, IJG License, BSD-3-Clause](https://github.com/mozilla/mozjpeg/blob/master/LICENSE.md) |
30
- | resvg | MIT Licence |
31
- | zlib-ng | [zlib Licence](https://github.com/zlib-ng/zlib-ng/blob/develop/LICENSE.md) |
10
+ | Library | Used under the terms of |
11
+ |---------------|----------------------------------------------------------------------------------------------------------|
12
+ | aom | BSD 2-Clause + [Alliance for Open Media Patent License 1.0](https://aomedia.org/license/patent-license/) |
13
+ | cgif | MIT License |
14
+ | emscripten | [MIT License](https://github.com/emscripten-core/emscripten/blob/main/LICENSE) |
15
+ | expat | MIT License |
16
+ | glib | LGPLv3 |
17
+ | highway | BSD 3-Clause |
18
+ | lcms | MIT License |
19
+ | libexif | LGPLv3 |
20
+ | libffi | MIT License |
21
+ | libheif | LGPLv3 |
22
+ | libimagequant | [BSD 2-Clause](https://github.com/lovell/libimagequant/blob/main/COPYRIGHT) |
23
+ | libnsgif | MIT License |
24
+ | libpng | [libpng License](https://github.com/pnggroup/libpng/blob/master/LICENSE) |
25
+ | libtiff | [libtiff License](https://gitlab.com/libtiff/libtiff/blob/master/LICENSE.md) (BSD-like) |
26
+ | libultrahdr | MIT License |
27
+ | libvips | LGPLv3 |
28
+ | libwebp | New BSD License |
29
+ | mozjpeg | [zlib License, IJG License, BSD 3-Clause](https://github.com/mozilla/mozjpeg/blob/master/LICENSE.md) |
30
+ | resvg | MIT License |
31
+ | zlib-ng | [zlib License](https://github.com/zlib-ng/zlib-ng/blob/develop/LICENSE.md) |
32
32
 
33
33
  Use of libraries under the terms of the LGPLv3 is via the
34
34
  "any later version" clause of the LGPLv2 or LGPLv2.1.
package/include/expat.h CHANGED
@@ -45,6 +45,7 @@
45
45
  #ifndef Expat_INCLUDED
46
46
  # define Expat_INCLUDED 1
47
47
 
48
+ # include <stdint.h> // for uint8_t
48
49
  # include <stdlib.h>
49
50
  # include "expat_external.h"
50
51
 
@@ -917,10 +918,21 @@ XML_SetParamEntityParsing(XML_Parser parser,
917
918
  function behavior. This must be called before parsing is started.
918
919
  Returns 1 if successful, 0 when called after parsing has started.
919
920
  Note: If parser == NULL, the function will do nothing and return 0.
921
+ DEPRECATED since Expat 2.8.0.
920
922
  */
921
923
  XMLPARSEAPI(int)
922
924
  XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt);
923
925
 
926
+ /* Sets the hash salt to use for internal hash calculations.
927
+ Helps in preventing DoS attacks based on predicting hash function behavior.
928
+ This must be called before parsing is started.
929
+ Returns XML_TRUE if successful, XML_FALSE when called after parsing has
930
+ started or when parser is NULL.
931
+ Added in Expat 2.8.0.
932
+ */
933
+ XMLPARSEAPI(XML_Bool)
934
+ XML_SetHashSalt16Bytes(XML_Parser parser, const uint8_t entropy[16]);
935
+
924
936
  /* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
925
937
  XML_GetErrorCode returns information about the error.
926
938
  */
@@ -1081,8 +1093,8 @@ XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled);
1081
1093
  See https://semver.org
1082
1094
  */
1083
1095
  # define XML_MAJOR_VERSION 2
1084
- # define XML_MINOR_VERSION 7
1085
- # define XML_MICRO_VERSION 5
1096
+ # define XML_MINOR_VERSION 8
1097
+ # define XML_MICRO_VERSION 0
1086
1098
 
1087
1099
  # ifdef __cplusplus
1088
1100
  }
@@ -25,6 +25,9 @@
25
25
  /* Define to 1 if you have the <fcntl.h> header file. */
26
26
  #define HAVE_FCNTL_H 1
27
27
 
28
+ /* Define to 1 if you have the `getentropy' function. */
29
+ #define HAVE_GETENTROPY 1
30
+
28
31
  /* Define to 1 if you have the 'getpagesize' function. */
29
32
  #define HAVE_GETPAGESIZE 1
30
33
 
@@ -80,7 +83,7 @@
80
83
  #define PACKAGE_NAME "expat"
81
84
 
82
85
  /* Define to the full name and version of this package. */
83
- #define PACKAGE_STRING "expat 2.7.5"
86
+ #define PACKAGE_STRING "expat 2.8.0"
84
87
 
85
88
  /* Define to the one symbol short name of this package. */
86
89
  #define PACKAGE_TARNAME "expat"
@@ -89,7 +92,7 @@
89
92
  #define PACKAGE_URL ""
90
93
 
91
94
  /* Define to the version of this package. */
92
- #define PACKAGE_VERSION "2.7.5"
95
+ #define PACKAGE_VERSION "2.8.0"
93
96
 
94
97
  /* Define to 1 if all of the C89 standard headers exist (not just the ones
95
98
  required in a freestanding environment). This macro is provided for
@@ -97,7 +100,7 @@
97
100
  #define STDC_HEADERS 1
98
101
 
99
102
  /* Version number of package */
100
- #define VERSION "2.7.5"
103
+ #define VERSION "2.8.0"
101
104
 
102
105
  /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
103
106
  significant byte first (like Motorola and SPARC, unlike Intel). */
@@ -12,9 +12,10 @@
12
12
  Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net>
13
13
  Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
14
14
  Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org>
15
- Copyright (c) 2016-2026 Sebastian Pipping <sebastian@pipping.org>
15
+ Copyright (c) 2016-2025 Sebastian Pipping <sebastian@pipping.org>
16
16
  Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
17
17
  Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com>
18
+ Copyright (c) 2026 Matthew Fernandez <matthew.fernandez@gmail.com>
18
19
  Licensed under the MIT license:
19
20
 
20
21
  Permission is hereby granted, free of charge, to any person obtaining
@@ -45,7 +46,7 @@
45
46
  /* Expat tries very hard to make the API boundary very specifically
46
47
  defined. There are two macros defined to control this boundary;
47
48
  each of these can be defined before including this header to
48
- achieve some different behavior, but doing so it not recommended or
49
+ achieve some different behavior, but doing so is not recommended or
49
50
  tested frequently.
50
51
 
51
52
  XMLCALL - The calling convention to use for all calls across the
@@ -302,7 +302,7 @@ typedef struct _GVariantType GVariantType;
302
302
 
303
303
  /* type string checking */
304
304
  GLIB_AVAILABLE_IN_ALL
305
- gboolean g_variant_type_string_is_valid (const gchar *type_string) G_GNUC_CONST;
305
+ gboolean g_variant_type_string_is_valid (const gchar *type_string) G_GNUC_PURE;
306
306
  GLIB_AVAILABLE_IN_ALL
307
307
  gboolean g_variant_type_string_scan (const gchar *string,
308
308
  const gchar *limit,
@@ -326,21 +326,21 @@ gchar * g_variant_type_dup_string (const G
326
326
 
327
327
  /* classification */
328
328
  GLIB_AVAILABLE_IN_ALL
329
- gboolean g_variant_type_is_definite (const GVariantType *type) G_GNUC_CONST;
329
+ gboolean g_variant_type_is_definite (const GVariantType *type) G_GNUC_PURE;
330
330
  GLIB_AVAILABLE_IN_ALL
331
- gboolean g_variant_type_is_container (const GVariantType *type) G_GNUC_CONST;
331
+ gboolean g_variant_type_is_container (const GVariantType *type) G_GNUC_PURE;
332
332
  GLIB_AVAILABLE_IN_ALL
333
- gboolean g_variant_type_is_basic (const GVariantType *type) G_GNUC_CONST;
333
+ gboolean g_variant_type_is_basic (const GVariantType *type) G_GNUC_PURE;
334
334
  GLIB_AVAILABLE_IN_ALL
335
- gboolean g_variant_type_is_maybe (const GVariantType *type) G_GNUC_CONST;
335
+ gboolean g_variant_type_is_maybe (const GVariantType *type) G_GNUC_PURE;
336
336
  GLIB_AVAILABLE_IN_ALL
337
- gboolean g_variant_type_is_array (const GVariantType *type) G_GNUC_CONST;
337
+ gboolean g_variant_type_is_array (const GVariantType *type) G_GNUC_PURE;
338
338
  GLIB_AVAILABLE_IN_ALL
339
- gboolean g_variant_type_is_tuple (const GVariantType *type) G_GNUC_CONST;
339
+ gboolean g_variant_type_is_tuple (const GVariantType *type) G_GNUC_PURE;
340
340
  GLIB_AVAILABLE_IN_ALL
341
- gboolean g_variant_type_is_dict_entry (const GVariantType *type) G_GNUC_CONST;
341
+ gboolean g_variant_type_is_dict_entry (const GVariantType *type) G_GNUC_PURE;
342
342
  GLIB_AVAILABLE_IN_ALL
343
- gboolean g_variant_type_is_variant (const GVariantType *type) G_GNUC_CONST;
343
+ gboolean g_variant_type_is_variant (const GVariantType *type) G_GNUC_PURE;
344
344
 
345
345
  /* for hash tables */
346
346
  GLIB_AVAILABLE_IN_ALL
@@ -352,21 +352,21 @@ gboolean g_variant_type_equal (gconstp
352
352
  /* subtypes */
353
353
  GLIB_AVAILABLE_IN_ALL
354
354
  gboolean g_variant_type_is_subtype_of (const GVariantType *type,
355
- const GVariantType *supertype) G_GNUC_CONST;
355
+ const GVariantType *supertype) G_GNUC_PURE;
356
356
 
357
357
  /* type iterator interface */
358
358
  GLIB_AVAILABLE_IN_ALL
359
- const GVariantType * g_variant_type_element (const GVariantType *type) G_GNUC_CONST;
359
+ const GVariantType * g_variant_type_element (const GVariantType *type) G_GNUC_PURE;
360
360
  GLIB_AVAILABLE_IN_ALL
361
- const GVariantType * g_variant_type_first (const GVariantType *type) G_GNUC_CONST;
361
+ const GVariantType * g_variant_type_first (const GVariantType *type) G_GNUC_PURE;
362
362
  GLIB_AVAILABLE_IN_ALL
363
- const GVariantType * g_variant_type_next (const GVariantType *type) G_GNUC_CONST;
363
+ const GVariantType * g_variant_type_next (const GVariantType *type) G_GNUC_PURE;
364
364
  GLIB_AVAILABLE_IN_ALL
365
- gsize g_variant_type_n_items (const GVariantType *type) G_GNUC_CONST;
365
+ gsize g_variant_type_n_items (const GVariantType *type) G_GNUC_PURE;
366
366
  GLIB_AVAILABLE_IN_ALL
367
- const GVariantType * g_variant_type_key (const GVariantType *type) G_GNUC_CONST;
367
+ const GVariantType * g_variant_type_key (const GVariantType *type) G_GNUC_PURE;
368
368
  GLIB_AVAILABLE_IN_ALL
369
- const GVariantType * g_variant_type_value (const GVariantType *type) G_GNUC_CONST;
369
+ const GVariantType * g_variant_type_value (const GVariantType *type) G_GNUC_PURE;
370
370
 
371
371
  /* constructors */
372
372
  GLIB_AVAILABLE_IN_ALL
@@ -33,6 +33,19 @@
33
33
 
34
34
  /* Version boundaries checks */
35
35
 
36
+ /**
37
+ * G_ENCODE_VERSION:
38
+ * @major: major version number
39
+ * @minor: minor version number
40
+ *
41
+ * Encode a major.minor version as a single integer.
42
+ *
43
+ * This is the encoding used by macros such as `GLIB_VERSION_2_84` and
44
+ * `GLIB_VERSION_CUR_STABLE`, and is intended to be used when (for example)
45
+ * setting the value of `GLIB_VERSION_MAX_ALLOWED`.
46
+ *
47
+ * Since: 2.32
48
+ */
36
49
  #define G_ENCODE_VERSION(major, minor) ((major) << 16 | (minor) << 8)
37
50
 
38
51
  /**
@@ -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