@img/sharp-libvips-dev 1.0.1 → 1.0.3

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 (169) hide show
  1. package/README.md +1 -2
  2. package/include/aom/aom_decoder.h +1 -1
  3. package/include/aom/aom_encoder.h +7 -1
  4. package/include/aom/aom_image.h +24 -12
  5. package/include/aom/aom_integer.h +3 -3
  6. package/include/aom/aomcx.h +15 -0
  7. package/include/aom/aomdx.h +5 -2
  8. package/include/archive.h +7 -5
  9. package/include/archive_entry.h +5 -3
  10. package/include/cgif.h +3 -0
  11. package/include/expat.h +21 -10
  12. package/include/expat_config.h +11 -5
  13. package/include/ffi.h +12 -25
  14. package/include/freetype2/freetype/config/ftoption.h +2 -2
  15. package/include/fribidi/fribidi-config.h +2 -2
  16. package/include/fribidi/fribidi-unicode-version.h +3 -3
  17. package/include/gio-unix-2.0/gio/gfiledescriptorbased.h +3 -2
  18. package/include/glib-2.0/gio/gappinfo.h +40 -25
  19. package/include/glib-2.0/gio/gapplication.h +6 -0
  20. package/include/glib-2.0/gio/gasyncresult.h +1 -1
  21. package/include/glib-2.0/gio/gconverter.h +5 -0
  22. package/include/glib-2.0/gio/gdbusintrospection.h +1 -1
  23. package/include/glib-2.0/gio/gfile.h +16 -0
  24. package/include/glib-2.0/gio/gio-visibility.h +34 -0
  25. package/include/glib-2.0/gio/giotypes.h +0 -1
  26. package/include/glib-2.0/gio/gsettings.h +8 -0
  27. package/include/glib-2.0/gio/gvfs.h +2 -2
  28. package/include/glib-2.0/girepository/gi-visibility.h +34 -0
  29. package/include/glib-2.0/girepository/giarginfo.h +23 -6
  30. package/include/glib-2.0/girepository/gibaseinfo.h +44 -18
  31. package/include/glib-2.0/girepository/gicallableinfo.h +26 -16
  32. package/include/glib-2.0/girepository/gicallbackinfo.h +17 -2
  33. package/include/glib-2.0/girepository/giconstantinfo.h +19 -4
  34. package/include/glib-2.0/girepository/gienuminfo.h +20 -21
  35. package/include/glib-2.0/girepository/gifieldinfo.h +22 -7
  36. package/include/glib-2.0/girepository/giflagsinfo.h +60 -0
  37. package/include/glib-2.0/girepository/gifunctioninfo.h +22 -7
  38. package/include/glib-2.0/girepository/giinterfaceinfo.h +33 -18
  39. package/include/glib-2.0/girepository/giobjectinfo.h +41 -26
  40. package/include/glib-2.0/girepository/gipropertyinfo.h +18 -3
  41. package/include/glib-2.0/girepository/giregisteredtypeinfo.h +22 -11
  42. package/include/glib-2.0/girepository/girepository-autocleanups.h +56 -0
  43. package/include/glib-2.0/girepository/girepository.h +53 -62
  44. package/include/glib-2.0/girepository/girffi.h +8 -7
  45. package/include/glib-2.0/girepository/gisignalinfo.h +18 -3
  46. package/include/glib-2.0/girepository/gistructinfo.h +26 -11
  47. package/include/glib-2.0/girepository/gitypeinfo.h +29 -16
  48. package/include/glib-2.0/girepository/gitypelib.h +9 -13
  49. package/include/glib-2.0/girepository/gitypes.h +52 -104
  50. package/include/glib-2.0/girepository/giunioninfo.h +28 -12
  51. package/include/glib-2.0/girepository/giunresolvedinfo.h +17 -2
  52. package/include/glib-2.0/girepository/givalueinfo.h +65 -0
  53. package/include/glib-2.0/girepository/givfuncinfo.h +23 -8
  54. package/include/glib-2.0/glib/deprecated/gthread.h +9 -5
  55. package/include/glib-2.0/glib/gbitlock.h +31 -0
  56. package/include/glib-2.0/glib/gbookmarkfile.h +1 -1
  57. package/include/glib-2.0/glib/giochannel.h +2 -2
  58. package/include/glib-2.0/glib/glib-visibility.h +34 -0
  59. package/include/glib-2.0/glib/gmacros.h +12 -5
  60. package/include/glib-2.0/glib/gmain.h +93 -7
  61. package/include/glib-2.0/glib/gmessages.h +8 -0
  62. package/include/glib-2.0/glib/gqsort.h +8 -1
  63. package/include/glib-2.0/glib/gslice.h +2 -0
  64. package/include/glib-2.0/glib/gstrfuncs.h +24 -30
  65. package/include/glib-2.0/glib/gstrvbuilder.h +3 -0
  66. package/include/glib-2.0/glib/gthread.h +191 -3
  67. package/include/glib-2.0/glib/gunicode.h +1 -1
  68. package/include/glib-2.0/glib/gversionmacros.h +9 -0
  69. package/include/glib-2.0/glib-unix.h +7 -1
  70. package/include/glib-2.0/gmodule/gmodule-visibility.h +34 -0
  71. package/include/glib-2.0/gobject/genums.h +6 -6
  72. package/include/glib-2.0/gobject/glib-types.h +11 -0
  73. package/include/glib-2.0/gobject/gobject-visibility.h +34 -0
  74. package/include/glib-2.0/gobject/gsignal.h +16 -6
  75. package/include/glib-2.0/gobject/gtype.h +6 -6
  76. package/include/harfbuzz/hb-buffer.h +6 -0
  77. package/include/harfbuzz/hb-common.h +6 -9
  78. package/include/harfbuzz/hb-cplusplus.hh +8 -11
  79. package/include/harfbuzz/hb-subset.h +17 -4
  80. package/include/harfbuzz/hb-version.h +3 -3
  81. package/include/hwy/abort.h +28 -0
  82. package/include/hwy/aligned_allocator.h +218 -6
  83. package/include/hwy/base.h +1935 -512
  84. package/include/hwy/cache_control.h +24 -6
  85. package/include/hwy/detect_compiler_arch.h +105 -10
  86. package/include/hwy/detect_targets.h +146 -37
  87. package/include/hwy/foreach_target.h +36 -1
  88. package/include/hwy/highway.h +222 -50
  89. package/include/hwy/ops/arm_neon-inl.h +2055 -894
  90. package/include/hwy/ops/arm_sve-inl.h +1476 -348
  91. package/include/hwy/ops/emu128-inl.h +711 -623
  92. package/include/hwy/ops/generic_ops-inl.h +4431 -2157
  93. package/include/hwy/ops/inside-inl.h +691 -0
  94. package/include/hwy/ops/ppc_vsx-inl.h +2186 -673
  95. package/include/hwy/ops/rvv-inl.h +1556 -536
  96. package/include/hwy/ops/scalar-inl.h +353 -233
  97. package/include/hwy/ops/set_macros-inl.h +171 -23
  98. package/include/hwy/ops/shared-inl.h +198 -56
  99. package/include/hwy/ops/wasm_128-inl.h +283 -244
  100. package/include/hwy/ops/x86_128-inl.h +3673 -1357
  101. package/include/hwy/ops/x86_256-inl.h +1737 -663
  102. package/include/hwy/ops/x86_512-inl.h +1697 -500
  103. package/include/hwy/per_target.h +4 -0
  104. package/include/hwy/profiler.h +648 -0
  105. package/include/hwy/robust_statistics.h +2 -2
  106. package/include/hwy/targets.h +40 -32
  107. package/include/hwy/timer-inl.h +3 -3
  108. package/include/hwy/timer.h +16 -1
  109. package/include/libheif/heif.h +170 -15
  110. package/include/libheif/heif_items.h +237 -0
  111. package/include/libheif/heif_properties.h +38 -2
  112. package/include/libheif/heif_regions.h +1 -1
  113. package/include/libheif/heif_version.h +2 -2
  114. package/include/libpng16/png.h +32 -29
  115. package/include/libpng16/pngconf.h +2 -2
  116. package/include/libpng16/pnglibconf.h +8 -3
  117. package/include/librsvg-2.0/librsvg/rsvg-cairo.h +1 -1
  118. package/include/librsvg-2.0/librsvg/rsvg-features.h +3 -4
  119. package/include/librsvg-2.0/librsvg/rsvg-pixbuf.h +235 -0
  120. package/include/librsvg-2.0/librsvg/rsvg-version.h +3 -3
  121. package/include/librsvg-2.0/librsvg/rsvg.h +55 -176
  122. package/include/libxml2/libxml/HTMLparser.h +12 -19
  123. package/include/libxml2/libxml/c14n.h +1 -12
  124. package/include/libxml2/libxml/debugXML.h +1 -1
  125. package/include/libxml2/libxml/encoding.h +9 -0
  126. package/include/libxml2/libxml/entities.h +12 -1
  127. package/include/libxml2/libxml/hash.h +19 -0
  128. package/include/libxml2/libxml/list.h +2 -2
  129. package/include/libxml2/libxml/nanohttp.h +17 -0
  130. package/include/libxml2/libxml/parser.h +73 -58
  131. package/include/libxml2/libxml/parserInternals.h +9 -1
  132. package/include/libxml2/libxml/pattern.h +6 -0
  133. package/include/libxml2/libxml/tree.h +32 -12
  134. package/include/libxml2/libxml/uri.h +11 -0
  135. package/include/libxml2/libxml/valid.h +29 -2
  136. package/include/libxml2/libxml/xinclude.h +7 -0
  137. package/include/libxml2/libxml/xmlIO.h +21 -5
  138. package/include/libxml2/libxml/xmlerror.h +14 -0
  139. package/include/libxml2/libxml/xmlexports.h +111 -15
  140. package/include/libxml2/libxml/xmlmemory.h +8 -45
  141. package/include/libxml2/libxml/xmlreader.h +2 -0
  142. package/include/libxml2/libxml/xmlsave.h +5 -0
  143. package/include/libxml2/libxml/xmlunicode.h +165 -1
  144. package/include/libxml2/libxml/xmlversion.h +15 -179
  145. package/include/libxml2/libxml/xmlwriter.h +1 -0
  146. package/include/libxml2/libxml/xpath.h +4 -0
  147. package/include/pango-1.0/pango/pango-features.h +2 -2
  148. package/include/pango-1.0/pango/pango-fontmap.h +7 -0
  149. package/include/pango-1.0/pango/pango-item.h +4 -2
  150. package/include/pango-1.0/pango/pango-version-macros.h +25 -0
  151. package/include/pango-1.0/pango/pangofc-font.h +2 -1
  152. package/include/pixman-1/pixman-version.h +2 -2
  153. package/include/png.h +32 -29
  154. package/include/pngconf.h +2 -2
  155. package/include/pnglibconf.h +8 -3
  156. package/include/vips/connection.h +9 -3
  157. package/include/vips/util.h +1 -11
  158. package/include/vips/version.h +4 -4
  159. package/include/webp/decode.h +58 -56
  160. package/include/webp/demux.h +25 -21
  161. package/include/webp/encode.h +44 -39
  162. package/include/webp/mux.h +76 -15
  163. package/include/webp/mux_types.h +2 -1
  164. package/include/webp/sharpyuv/sharpyuv.h +77 -8
  165. package/include/webp/types.h +29 -8
  166. package/include/zconf.h +1 -1
  167. package/include/zlib.h +12 -12
  168. package/package.json +1 -1
  169. package/versions.json +18 -19
@@ -18,10 +18,17 @@
18
18
  // IWYU pragma: begin_exports
19
19
  #include "hwy/base.h"
20
20
  #include "hwy/detect_compiler_arch.h"
21
+ #include "hwy/detect_targets.h"
21
22
  #include "hwy/highway_export.h"
22
23
  #include "hwy/targets.h"
23
24
  // IWYU pragma: end_exports
24
25
 
26
+ #if HWY_CXX_LANG < 201703L
27
+ #define HWY_DISPATCH_MAP 1
28
+ #else
29
+ #define HWY_DISPATCH_MAP 0
30
+ #endif
31
+
25
32
  // This include guard is checked by foreach_target, so avoid the usual _H_
26
33
  // suffix to prevent copybara from renaming it. NOTE: ops/*-inl.h are included
27
34
  // after/outside this include guard.
@@ -30,11 +37,6 @@
30
37
 
31
38
  namespace hwy {
32
39
 
33
- // API version (https://semver.org/); keep in sync with CMakeLists.txt.
34
- #define HWY_MAJOR 1
35
- #define HWY_MINOR 0
36
- #define HWY_PATCH 7
37
-
38
40
  //------------------------------------------------------------------------------
39
41
  // Shorthand for tags (defined in shared-inl.h) used to select overloads.
40
42
  // Note that ScalableTag<T> is preferred over HWY_FULL, and CappedTag<T, N> over
@@ -84,6 +86,8 @@ namespace hwy {
84
86
  #define HWY_STATIC_DISPATCH(FUNC_NAME) N_NEON_WITHOUT_AES::FUNC_NAME
85
87
  #elif HWY_STATIC_TARGET == HWY_NEON
86
88
  #define HWY_STATIC_DISPATCH(FUNC_NAME) N_NEON::FUNC_NAME
89
+ #elif HWY_STATIC_TARGET == HWY_NEON_BF16
90
+ #define HWY_STATIC_DISPATCH(FUNC_NAME) N_NEON_BF16::FUNC_NAME
87
91
  #elif HWY_STATIC_TARGET == HWY_SVE
88
92
  #define HWY_STATIC_DISPATCH(FUNC_NAME) N_SVE::FUNC_NAME
89
93
  #elif HWY_STATIC_TARGET == HWY_SVE2
@@ -98,6 +102,10 @@ namespace hwy {
98
102
  #define HWY_STATIC_DISPATCH(FUNC_NAME) N_PPC9::FUNC_NAME
99
103
  #elif HWY_STATIC_TARGET == HWY_PPC10
100
104
  #define HWY_STATIC_DISPATCH(FUNC_NAME) N_PPC10::FUNC_NAME
105
+ #elif HWY_STATIC_TARGET == HWY_Z14
106
+ #define HWY_STATIC_DISPATCH(FUNC_NAME) N_Z14::FUNC_NAME
107
+ #elif HWY_STATIC_TARGET == HWY_Z15
108
+ #define HWY_STATIC_DISPATCH(FUNC_NAME) N_Z15::FUNC_NAME
101
109
  #elif HWY_STATIC_TARGET == HWY_SSE2
102
110
  #define HWY_STATIC_DISPATCH(FUNC_NAME) N_SSE2::FUNC_NAME
103
111
  #elif HWY_STATIC_TARGET == HWY_SSSE3
@@ -158,6 +166,12 @@ namespace hwy {
158
166
  #define HWY_CHOOSE_NEON(FUNC_NAME) nullptr
159
167
  #endif
160
168
 
169
+ #if HWY_TARGETS & HWY_NEON_BF16
170
+ #define HWY_CHOOSE_NEON_BF16(FUNC_NAME) &N_NEON_BF16::FUNC_NAME
171
+ #else
172
+ #define HWY_CHOOSE_NEON_BF16(FUNC_NAME) nullptr
173
+ #endif
174
+
161
175
  #if HWY_TARGETS & HWY_SVE
162
176
  #define HWY_CHOOSE_SVE(FUNC_NAME) &N_SVE::FUNC_NAME
163
177
  #else
@@ -200,6 +214,18 @@ namespace hwy {
200
214
  #define HWY_CHOOSE_PPC10(FUNC_NAME) nullptr
201
215
  #endif
202
216
 
217
+ #if HWY_TARGETS & HWY_Z14
218
+ #define HWY_CHOOSE_Z14(FUNC_NAME) &N_Z14::FUNC_NAME
219
+ #else
220
+ #define HWY_CHOOSE_Z14(FUNC_NAME) nullptr
221
+ #endif
222
+
223
+ #if HWY_TARGETS & HWY_Z15
224
+ #define HWY_CHOOSE_Z15(FUNC_NAME) &N_Z15::FUNC_NAME
225
+ #else
226
+ #define HWY_CHOOSE_Z15(FUNC_NAME) nullptr
227
+ #endif
228
+
203
229
  #if HWY_TARGETS & HWY_SSE2
204
230
  #define HWY_CHOOSE_SSE2(FUNC_NAME) &N_SSE2::FUNC_NAME
205
231
  #else
@@ -252,41 +278,68 @@ namespace hwy {
252
278
  // apparently cannot be an array. Use a function pointer instead, which has the
253
279
  // disadvantage that we call the static (not best) target on the first call to
254
280
  // any HWY_DYNAMIC_DISPATCH.
255
- #if HWY_COMPILER_MSVC && HWY_COMPILER_MSVC < 1915
281
+ #if (HWY_COMPILER_MSVC && HWY_COMPILER_MSVC < 1915) || \
282
+ (HWY_COMPILER_GCC_ACTUAL && HWY_COMPILER_GCC_ACTUAL < 700)
256
283
  #define HWY_DISPATCH_WORKAROUND 1
257
284
  #else
258
285
  #define HWY_DISPATCH_WORKAROUND 0
259
286
  #endif
260
287
 
288
+ #if HWY_DISPATCH_MAP
289
+ struct AllExports {
290
+ template <class FuncPtr, class ExportsKey, uint64_t kHash>
291
+ static const FuncPtr*& GetRefToExportsPtr() {
292
+ static const FuncPtr* s_exports = nullptr;
293
+ return s_exports;
294
+ }
295
+ };
296
+ #endif
297
+
261
298
  // Provides a static member function which is what is called during the first
262
299
  // HWY_DYNAMIC_DISPATCH, where GetIndex is still zero, and instantiations of
263
- // this function are the first entry in the tables created by HWY_EXPORT.
300
+ // this function are the first entry in the tables created by HWY_EXPORT[_T].
264
301
  template <typename RetType, typename... Args>
265
302
  struct FunctionCache {
266
303
  public:
267
- typedef RetType(FunctionType)(Args...);
304
+ typedef RetType(FuncType)(Args...);
305
+ using FuncPtr = FuncType*;
268
306
 
269
- #if HWY_DISPATCH_WORKAROUND
270
- template <FunctionType* const func>
271
- static RetType ChooseAndCall(Args... args) {
272
- ChosenTarget& chosen_target = GetChosenTarget();
273
- chosen_target.Update(SupportedTargets());
274
- return (*func)(args...);
275
- }
276
- #else
277
307
  // A template function that when instantiated has the same signature as the
278
308
  // function being called. This function initializes the bit array of targets
279
309
  // supported by the current CPU and then calls the appropriate entry within
280
310
  // the HWY_EXPORT table. Subsequent calls via HWY_DYNAMIC_DISPATCH to any
281
311
  // exported functions, even those defined by different translation units,
282
312
  // will dispatch directly to the best available target.
283
- template <FunctionType* const table[]>
313
+ #if HWY_DISPATCH_MAP
314
+ template <class ExportsKey, uint64_t kHash>
284
315
  static RetType ChooseAndCall(Args... args) {
285
316
  ChosenTarget& chosen_target = GetChosenTarget();
286
317
  chosen_target.Update(SupportedTargets());
318
+
319
+ const FuncPtr* table = AllExports::template GetRefToExportsPtr<
320
+ FuncPtr, RemoveCvRef<ExportsKey>, kHash>();
321
+ HWY_ASSERT(table);
322
+
323
+ return (table[chosen_target.GetIndex()])(args...);
324
+ }
325
+
326
+ #if !HWY_DISPATCH_WORKAROUND
327
+ template <const FuncPtr* table>
328
+ static RetType TableChooseAndCall(Args... args) {
329
+ ChosenTarget& chosen_target = GetChosenTarget();
330
+ chosen_target.Update(SupportedTargets());
287
331
  return (table[chosen_target.GetIndex()])(args...);
288
332
  }
289
- #endif // HWY_DISPATCH_WORKAROUND
333
+ #endif // !HWY_DISPATCH_WORKAROUND
334
+
335
+ #else // !HWY_DISPATCH_MAP: zero-overhead, but requires C++17
336
+ template <const FuncPtr* table>
337
+ static RetType ChooseAndCall(Args... args) {
338
+ ChosenTarget& chosen_target = GetChosenTarget();
339
+ chosen_target.Update(SupportedTargets());
340
+ return (table[chosen_target.GetIndex()])(args...);
341
+ }
342
+ #endif // HWY_DISPATCH_MAP
290
343
  };
291
344
 
292
345
  // Used to deduce the template parameters RetType and Args from a function.
@@ -299,9 +352,7 @@ FunctionCache<RetType, Args...> DeduceFunctionCache(RetType (*)(Args...)) {
299
352
  HWY_CONCAT(FUNC_NAME, HighwayDispatchTable)
300
353
 
301
354
  // HWY_EXPORT(FUNC_NAME); expands to a static array that is used by
302
- // HWY_DYNAMIC_DISPATCH() to call the appropriate function at runtime. This
303
- // static array must be defined at the same namespace level as the function
304
- // it is exporting.
355
+ // HWY_DYNAMIC_DISPATCH() to call the appropriate function at runtime.
305
356
  // After being exported, it can be called from other parts of the same source
306
357
  // file using HWY_DYNAMIC_DISPATCH(), in particular from a function wrapper
307
358
  // like in the following example:
@@ -326,59 +377,181 @@ FunctionCache<RetType, Args...> DeduceFunctionCache(RetType (*)(Args...)) {
326
377
  // }
327
378
  // } // namespace skeleton
328
379
  //
380
+ // For templated code with a single type parameter, instead use HWY_EXPORT_T and
381
+ // its HWY_DYNAMIC_DISPATCH_T counterpart:
382
+ //
383
+ // template <typename T>
384
+ // void MyFunctionCaller(T ...) {
385
+ // // First argument to both HWY_EXPORT_T and HWY_DYNAMIC_DISPATCH_T is an
386
+ // // arbitrary table name; you must provide the same name for each call.
387
+ // // It is fine to have multiple HWY_EXPORT_T in a function, but a 64-bit
388
+ // // FNV hash collision among *any* table names will trigger HWY_ABORT.
389
+ // HWY_EXPORT_T(Table1, MyFunction<T>)
390
+ // HWY_DYNAMIC_DISPATCH_T(Table1)(a, b, c);
391
+ // }
392
+ //
393
+ // Note that HWY_EXPORT_T must be invoked inside a template (in the above
394
+ // example: `MyFunctionCaller`), so that a separate table will be created for
395
+ // each template instantiation. For convenience, we also provide a macro that
396
+ // combines both steps and avoids the need to pick a table name:
397
+ //
398
+ // template <typename T>
399
+ // void MyFunctionCaller(T ...) {
400
+ // // Table name is automatically chosen. Note that this variant must be
401
+ // // called in statement context; it is not a valid expression.
402
+ // HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(MyFunction<T>)(a, b, c);
403
+ // }
329
404
 
405
+ // Simplified version for IDE or the dynamic dispatch case with only one target.
330
406
  #if HWY_IDE || ((HWY_TARGETS & (HWY_TARGETS - 1)) == 0)
331
407
 
332
- // Simplified version for IDE or the dynamic dispatch case with only one target.
333
- // This case still uses a table, although of a single element, to provide the
334
- // same compile error conditions as with the dynamic dispatch case when multiple
335
- // targets are being compiled.
336
- #define HWY_EXPORT(FUNC_NAME) \
408
+ // We use a table to provide the same compile error conditions as with the
409
+ // non-simplified case, but the table only has a single entry.
410
+ #define HWY_EXPORT_T(TABLE_NAME, FUNC_NAME) \
337
411
  HWY_MAYBE_UNUSED static decltype(&HWY_STATIC_DISPATCH(FUNC_NAME)) const \
338
- HWY_DISPATCH_TABLE(FUNC_NAME)[1] = {&HWY_STATIC_DISPATCH(FUNC_NAME)}
339
- #define HWY_DYNAMIC_DISPATCH(FUNC_NAME) HWY_STATIC_DISPATCH(FUNC_NAME)
412
+ HWY_DISPATCH_TABLE(TABLE_NAME)[1] = {&HWY_STATIC_DISPATCH(FUNC_NAME)}
413
+
414
+ // Use the table, not just STATIC_DISPATCH as in DYNAMIC_DISPATCH, because
415
+ // TABLE_NAME might not match the function name.
416
+ #define HWY_DYNAMIC_POINTER_T(TABLE_NAME) (HWY_DISPATCH_TABLE(TABLE_NAME)[0])
417
+ #define HWY_DYNAMIC_DISPATCH_T(TABLE_NAME) \
418
+ (*(HWY_DYNAMIC_POINTER_T(TABLE_NAME)))
419
+
420
+ #define HWY_EXPORT(FUNC_NAME) HWY_EXPORT_T(FUNC_NAME, FUNC_NAME)
340
421
  #define HWY_DYNAMIC_POINTER(FUNC_NAME) &HWY_STATIC_DISPATCH(FUNC_NAME)
422
+ #define HWY_DYNAMIC_DISPATCH(FUNC_NAME) HWY_STATIC_DISPATCH(FUNC_NAME)
341
423
 
342
- #else
424
+ #else // not simplified: full table
425
+
426
+ // Pre-C++17 workaround: non-type template arguments must have linkage, which
427
+ // means we cannot pass &table as a template argument to ChooseAndCall.
428
+ // ChooseAndCall must find a way to access the table in order to dispatch to the
429
+ // chosen target:
430
+ // 0) Skipping this by dispatching to the static target would be surprising to
431
+ // users and may have serious performance implications.
432
+ // 1) An extra function parameter would be unacceptable because it changes the
433
+ // user-visible function signature.
434
+ // 2) Declaring a table, then defining a pointer to it would work, but requires
435
+ // an additional DECLARE step outside the function so that the pointer has
436
+ // linkage, which breaks existing code.
437
+ // 3) We instead associate the function with the table using an instance of an
438
+ // unnamed struct and the hash of the table name as the key. Because
439
+ // ChooseAndCall has the type information, it can then cast to the function
440
+ // pointer type. However, we cannot simply pass the name as a template
441
+ // argument to ChooseAndCall because this requires char*, which hits the same
442
+ // linkage problem. We instead hash the table name, which assumes the
443
+ // function names do not have collisions.
444
+ #if HWY_DISPATCH_MAP
445
+
446
+ static constexpr uint64_t FNV(const char* name) {
447
+ return *name ? static_cast<uint64_t>(static_cast<uint8_t>(*name)) ^
448
+ (0x100000001b3ULL * FNV(name + 1))
449
+ : 0xcbf29ce484222325ULL;
450
+ }
343
451
 
344
- // Simplified version for MSVC 2017: function pointer instead of table.
345
- #if HWY_DISPATCH_WORKAROUND
452
+ template <uint64_t kHash>
453
+ struct AddExport {
454
+ template <class ExportsKey, class FuncPtr>
455
+ AddExport(ExportsKey /*exports_key*/, const char* table_name,
456
+ const FuncPtr* table) {
457
+ using FuncCache = decltype(DeduceFunctionCache(hwy::DeclVal<FuncPtr>()));
458
+ static_assert(
459
+ hwy::IsSame<RemoveCvRef<FuncPtr>, typename FuncCache::FuncPtr>(),
460
+ "FuncPtr should be same type as FuncCache::FuncPtr");
461
+
462
+ const FuncPtr*& exports_ptr = AllExports::template GetRefToExportsPtr<
463
+ RemoveCvRef<FuncPtr>, RemoveCvRef<ExportsKey>, kHash>();
464
+ if (exports_ptr && exports_ptr != table) {
465
+ HWY_ABORT("Hash collision for %s, rename the function\n", table_name);
466
+ } else {
467
+ exports_ptr = table;
468
+ }
469
+ }
470
+ };
346
471
 
472
+ // Dynamic dispatch: defines table of function pointers. This must be invoked
473
+ // from inside the function template that calls the template we are exporting.
474
+ // TABLE_NAME must match the one passed to HWY_DYNAMIC_DISPATCH_T. This
475
+ // argument allows multiple exports within one function.
476
+ #define HWY_EXPORT_T(TABLE_NAME, FUNC_NAME) \
477
+ static const struct { \
478
+ } HWY_CONCAT(TABLE_NAME, HighwayDispatchExportsKey) = {}; \
479
+ static decltype(&HWY_STATIC_DISPATCH(FUNC_NAME)) const HWY_DISPATCH_TABLE( \
480
+ TABLE_NAME)[static_cast<size_t>(HWY_MAX_DYNAMIC_TARGETS + 2)] = { \
481
+ /* The first entry in the table initializes the global cache and \
482
+ * calls the appropriate function. */ \
483
+ &decltype(hwy::DeduceFunctionCache(&HWY_STATIC_DISPATCH(FUNC_NAME))):: \
484
+ template ChooseAndCall<decltype(HWY_CONCAT( \
485
+ TABLE_NAME, HighwayDispatchExportsKey)), \
486
+ hwy::FNV(#TABLE_NAME)>, \
487
+ HWY_CHOOSE_TARGET_LIST(FUNC_NAME), \
488
+ HWY_CHOOSE_FALLBACK(FUNC_NAME), \
489
+ }; \
490
+ HWY_MAYBE_UNUSED static hwy::AddExport<hwy::FNV(#TABLE_NAME)> HWY_CONCAT( \
491
+ HighwayAddTable, __LINE__)( \
492
+ HWY_CONCAT(TABLE_NAME, HighwayDispatchExportsKey), #TABLE_NAME, \
493
+ HWY_DISPATCH_TABLE(TABLE_NAME))
494
+
495
+ // For non-template functions. Not necessarily invoked within a function, hence
496
+ // we derive the string and variable names from FUNC_NAME, not HWY_FUNCTION.
497
+ #if HWY_DISPATCH_WORKAROUND
498
+ #define HWY_EXPORT(FUNC_NAME) HWY_EXPORT_T(FUNC_NAME, FUNC_NAME)
499
+ #else
347
500
  #define HWY_EXPORT(FUNC_NAME) \
348
501
  static decltype(&HWY_STATIC_DISPATCH(FUNC_NAME)) const HWY_DISPATCH_TABLE( \
349
- FUNC_NAME)[HWY_MAX_DYNAMIC_TARGETS + 2] = { \
502
+ FUNC_NAME)[static_cast<size_t>(HWY_MAX_DYNAMIC_TARGETS + 2)] = { \
350
503
  /* The first entry in the table initializes the global cache and \
351
- * calls the function from HWY_STATIC_TARGET. */ \
352
- &decltype(hwy::DeduceFunctionCache(&HWY_STATIC_DISPATCH( \
353
- FUNC_NAME)))::ChooseAndCall<&HWY_STATIC_DISPATCH(FUNC_NAME)>, \
504
+ * calls the appropriate function. */ \
505
+ &decltype(hwy::DeduceFunctionCache(&HWY_STATIC_DISPATCH(FUNC_NAME))):: \
506
+ template TableChooseAndCall<HWY_DISPATCH_TABLE(FUNC_NAME)>, \
354
507
  HWY_CHOOSE_TARGET_LIST(FUNC_NAME), \
355
508
  HWY_CHOOSE_FALLBACK(FUNC_NAME), \
356
509
  }
510
+ #endif // HWY_DISPATCH_WORKAROUND
357
511
 
358
- #else
512
+ #else // !HWY_DISPATCH_MAP
359
513
 
360
- // Dynamic dispatch case with one entry per dynamic target plus the fallback
361
- // target and the initialization wrapper.
362
- #define HWY_EXPORT(FUNC_NAME) \
514
+ // Zero-overhead, but requires C++17 for non-type template arguments without
515
+ // linkage, because HWY_EXPORT_T tables are local static variables.
516
+ #define HWY_EXPORT_T(TABLE_NAME, FUNC_NAME) \
363
517
  static decltype(&HWY_STATIC_DISPATCH(FUNC_NAME)) const HWY_DISPATCH_TABLE( \
364
- FUNC_NAME)[HWY_MAX_DYNAMIC_TARGETS + 2] = { \
518
+ TABLE_NAME)[static_cast<size_t>(HWY_MAX_DYNAMIC_TARGETS + 2)] = { \
365
519
  /* The first entry in the table initializes the global cache and \
366
520
  * calls the appropriate function. */ \
367
- &decltype(hwy::DeduceFunctionCache(&HWY_STATIC_DISPATCH( \
368
- FUNC_NAME)))::ChooseAndCall<HWY_DISPATCH_TABLE(FUNC_NAME)>, \
521
+ &decltype(hwy::DeduceFunctionCache(&HWY_STATIC_DISPATCH(FUNC_NAME))):: \
522
+ template ChooseAndCall<HWY_DISPATCH_TABLE(TABLE_NAME)>, \
369
523
  HWY_CHOOSE_TARGET_LIST(FUNC_NAME), \
370
524
  HWY_CHOOSE_FALLBACK(FUNC_NAME), \
371
525
  }
372
526
 
373
- #endif // HWY_DISPATCH_WORKAROUND
527
+ #define HWY_EXPORT(FUNC_NAME) HWY_EXPORT_T(FUNC_NAME, FUNC_NAME)
528
+
529
+ #endif // HWY_DISPATCH_MAP
530
+
531
+ // HWY_DISPATCH_MAP only affects how tables are created, not their usage.
374
532
 
375
- #define HWY_DYNAMIC_DISPATCH(FUNC_NAME) \
376
- (*(HWY_DISPATCH_TABLE(FUNC_NAME)[hwy::GetChosenTarget().GetIndex()]))
533
+ // Evaluates to the function pointer for the chosen target.
377
534
  #define HWY_DYNAMIC_POINTER(FUNC_NAME) \
378
535
  (HWY_DISPATCH_TABLE(FUNC_NAME)[hwy::GetChosenTarget().GetIndex()])
379
536
 
537
+ // Calls the function pointer for the chosen target.
538
+ #define HWY_DYNAMIC_DISPATCH(FUNC_NAME) (*(HWY_DYNAMIC_POINTER(FUNC_NAME)))
539
+
540
+ // Same as DISPATCH, but provide a different arg name to clarify usage.
541
+ #define HWY_DYNAMIC_DISPATCH_T(TABLE_NAME) HWY_DYNAMIC_DISPATCH(TABLE_NAME)
542
+ #define HWY_DYNAMIC_POINTER_T(TABLE_NAME) HWY_DYNAMIC_POINTER(TABLE_NAME)
543
+
380
544
  #endif // HWY_IDE || ((HWY_TARGETS & (HWY_TARGETS - 1)) == 0)
381
545
 
546
+ // Returns the name of an anonymous dispatch table that is only shared with
547
+ // macro invocations coming from the same source line.
548
+ #define HWY_DISPATCH_TABLE_T() HWY_CONCAT(HighwayDispatchTableT, __LINE__)
549
+
550
+ // For templated code, combines export and dispatch using an anonymous table.
551
+ #define HWY_EXPORT_AND_DYNAMIC_DISPATCH_T(FUNC_NAME) \
552
+ HWY_EXPORT_T(HWY_DISPATCH_TABLE_T(), FUNC_NAME); \
553
+ HWY_DYNAMIC_DISPATCH_T(HWY_DISPATCH_TABLE_T())
554
+
382
555
  // DEPRECATED names; please use HWY_HAVE_* instead.
383
556
  #define HWY_CAP_INTEGER64 HWY_HAVE_INTEGER64
384
557
  #define HWY_CAP_FLOAT16 HWY_HAVE_FLOAT16
@@ -408,13 +581,12 @@ FunctionCache<RetType, Args...> DeduceFunctionCache(RetType (*)(Args...)) {
408
581
  #elif HWY_TARGET == HWY_AVX3 || HWY_TARGET == HWY_AVX3_DL || \
409
582
  HWY_TARGET == HWY_AVX3_ZEN4 || HWY_TARGET == HWY_AVX3_SPR
410
583
  #include "hwy/ops/x86_512-inl.h"
411
- #elif HWY_TARGET == HWY_PPC8 || HWY_TARGET == HWY_PPC9 || \
412
- HWY_TARGET == HWY_PPC10
584
+ #elif HWY_TARGET == HWY_Z14 || HWY_TARGET == HWY_Z15 || \
585
+ (HWY_TARGET & HWY_ALL_PPC)
413
586
  #include "hwy/ops/ppc_vsx-inl.h"
414
- #elif HWY_TARGET == HWY_NEON || HWY_TARGET == HWY_NEON_WITHOUT_AES
587
+ #elif HWY_TARGET & HWY_ALL_NEON
415
588
  #include "hwy/ops/arm_neon-inl.h"
416
- #elif HWY_TARGET == HWY_SVE || HWY_TARGET == HWY_SVE2 || \
417
- HWY_TARGET == HWY_SVE_256 || HWY_TARGET == HWY_SVE2_128
589
+ #elif HWY_TARGET & HWY_ALL_SVE
418
590
  #include "hwy/ops/arm_sve-inl.h"
419
591
  #elif HWY_TARGET == HWY_WASM_EMU256
420
592
  #include "hwy/ops/wasm_256-inl.h"