@img/sharp-libvips-dev-wasm32 1.2.0 → 1.2.2-rc.1

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 (96) hide show
  1. package/include/ffi.h +3 -3
  2. package/include/ffitarget.h +17 -0
  3. package/include/glib-2.0/gio/gdbuserror.h +9 -8
  4. package/include/glib-2.0/gio/ginetaddress.h +12 -0
  5. package/include/glib-2.0/gio/gioenums.h +9 -2
  6. package/include/glib-2.0/glib/gstring.h +2 -2
  7. package/include/glib-2.0/gobject/gvalue.h +78 -35
  8. package/include/hwy/abort.h +2 -19
  9. package/include/hwy/aligned_allocator.h +11 -7
  10. package/include/hwy/auto_tune.h +504 -0
  11. package/include/hwy/base.h +425 -104
  12. package/include/hwy/cache_control.h +16 -0
  13. package/include/hwy/detect_compiler_arch.h +32 -1
  14. package/include/hwy/detect_targets.h +251 -67
  15. package/include/hwy/foreach_target.h +35 -0
  16. package/include/hwy/highway.h +185 -76
  17. package/include/hwy/nanobenchmark.h +1 -19
  18. package/include/hwy/ops/arm_neon-inl.h +969 -458
  19. package/include/hwy/ops/arm_sve-inl.h +1137 -359
  20. package/include/hwy/ops/emu128-inl.h +97 -11
  21. package/include/hwy/ops/generic_ops-inl.h +1222 -34
  22. package/include/hwy/ops/loongarch_lasx-inl.h +4664 -0
  23. package/include/hwy/ops/loongarch_lsx-inl.h +5933 -0
  24. package/include/hwy/ops/ppc_vsx-inl.h +306 -126
  25. package/include/hwy/ops/rvv-inl.h +546 -51
  26. package/include/hwy/ops/scalar-inl.h +77 -22
  27. package/include/hwy/ops/set_macros-inl.h +133 -17
  28. package/include/hwy/ops/shared-inl.h +50 -10
  29. package/include/hwy/ops/wasm_128-inl.h +137 -92
  30. package/include/hwy/ops/x86_128-inl.h +773 -214
  31. package/include/hwy/ops/x86_256-inl.h +712 -255
  32. package/include/hwy/ops/x86_512-inl.h +429 -753
  33. package/include/hwy/ops/x86_avx3-inl.h +501 -0
  34. package/include/hwy/per_target.h +2 -1
  35. package/include/hwy/profiler.h +622 -486
  36. package/include/hwy/targets.h +62 -20
  37. package/include/hwy/timer-inl.h +8 -160
  38. package/include/hwy/timer.h +170 -3
  39. package/include/hwy/x86_cpuid.h +81 -0
  40. package/include/libheif/heif_cxx.h +25 -5
  41. package/include/libheif/heif_regions.h +5 -5
  42. package/include/libheif/heif_version.h +2 -2
  43. package/include/webp/decode.h +11 -2
  44. package/include/webp/demux.h +2 -0
  45. package/include/webp/encode.h +2 -0
  46. package/include/webp/mux_types.h +1 -0
  47. package/include/webp/sharpyuv/sharpyuv.h +1 -1
  48. package/include/webp/types.h +2 -2
  49. package/include/zlib.h +3 -3
  50. package/lib/glib-2.0/include/glibconfig.h +1 -1
  51. package/lib/libaom.a +0 -0
  52. package/lib/libcgif.a +0 -0
  53. package/lib/libexif.a +0 -0
  54. package/lib/libexpat.a +0 -0
  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/libresvg.a +0 -0
  67. package/lib/libsharpyuv.a +0 -0
  68. package/lib/libsharpyuv.la +2 -2
  69. package/lib/libspng.a +0 -0
  70. package/lib/libtiff.a +0 -0
  71. package/lib/libvips-cpp.a +0 -0
  72. package/lib/libvips.a +0 -0
  73. package/lib/libwebp.a +0 -0
  74. package/lib/libwebp.la +4 -4
  75. package/lib/libwebpdemux.a +0 -0
  76. package/lib/libwebpdemux.la +2 -2
  77. package/lib/libwebpmux.a +0 -0
  78. package/lib/libwebpmux.la +2 -2
  79. package/lib/libz.a +0 -0
  80. package/lib/pkgconfig/gio-2.0.pc +1 -1
  81. package/lib/pkgconfig/glib-2.0.pc +1 -1
  82. package/lib/pkgconfig/gmodule-2.0.pc +1 -1
  83. package/lib/pkgconfig/gmodule-export-2.0.pc +1 -1
  84. package/lib/pkgconfig/gmodule-no-export-2.0.pc +1 -1
  85. package/lib/pkgconfig/gobject-2.0.pc +1 -1
  86. package/lib/pkgconfig/gthread-2.0.pc +1 -1
  87. package/lib/pkgconfig/libffi.pc +1 -1
  88. package/lib/pkgconfig/libheif.pc +1 -1
  89. package/lib/pkgconfig/libhwy.pc +1 -1
  90. package/lib/pkgconfig/libsharpyuv.pc +1 -1
  91. package/lib/pkgconfig/libwebp.pc +1 -1
  92. package/lib/pkgconfig/libwebpdemux.pc +1 -1
  93. package/lib/pkgconfig/libwebpmux.pc +1 -1
  94. package/lib/pkgconfig/zlib.pc +1 -0
  95. package/package.json +1 -1
  96. package/versions.json +7 -7
package/include/ffi.h CHANGED
@@ -1,5 +1,5 @@
1
1
  /* -----------------------------------------------------------------*-C-*-
2
- libffi 3.5.1
2
+ libffi 3.5.2
3
3
  - Copyright (c) 2011, 2014, 2019, 2021, 2022, 2024, 2025 Anthony Green
4
4
  - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.
5
5
 
@@ -316,8 +316,8 @@ size_t ffi_java_raw_size (ffi_cif *cif) __attribute__((deprecated));
316
316
 
317
317
  /* ---- Version API ------------------------------------------------------ */
318
318
 
319
- #define FFI_VERSION_STRING "3.5.1"
320
- #define FFI_VERSION_NUMBER 30501
319
+ #define FFI_VERSION_STRING "3.5.2"
320
+ #define FFI_VERSION_NUMBER 30502
321
321
 
322
322
  #ifndef LIBFFI_ASM
323
323
  /* Return a version string. */
@@ -42,14 +42,31 @@ typedef void (*ffi_fp)(void);
42
42
 
43
43
  typedef enum ffi_abi {
44
44
  FFI_FIRST_ABI = 0,
45
+ #if __SIZEOF_POINTER__ == 4
45
46
  FFI_WASM32, // "raw", no structures, varargs, or closures (not implemented!)
46
47
  FFI_WASM32_EMSCRIPTEN, // structures, varargs, and split 64-bit params
48
+ #elif __SIZEOF_POINTER__ == 8
49
+ FFI_WASM64,
50
+ FFI_WASM64_EMSCRIPTEN,
51
+ #else
52
+ #error "Unknown pointer size"
53
+ #endif
47
54
  FFI_LAST_ABI,
55
+ #if __SIZEOF_POINTER__ == 4
48
56
  #ifdef __EMSCRIPTEN__
49
57
  FFI_DEFAULT_ABI = FFI_WASM32_EMSCRIPTEN
50
58
  #else
51
59
  FFI_DEFAULT_ABI = FFI_WASM32
52
60
  #endif
61
+ #elif __SIZEOF_POINTER__ == 8
62
+ #ifdef __EMSCRIPTEN__
63
+ FFI_DEFAULT_ABI = FFI_WASM64_EMSCRIPTEN
64
+ #else
65
+ FFI_DEFAULT_ABI = FFI_WASM64
66
+ #endif
67
+ #else
68
+ #error "Unknown pointer size"
69
+ #endif
53
70
  } ffi_abi;
54
71
 
55
72
  #define FFI_CLOSURES 1
@@ -34,14 +34,15 @@ G_BEGIN_DECLS
34
34
  /**
35
35
  * G_DBUS_ERROR:
36
36
  *
37
- * Error domain for errors generated by a remote message bus. Errors
38
- * in this domain will be from the #GDBusError enumeration. See
39
- * #GError for more information on error domains.
37
+ * Error domain for errors generated by a remote message bus.
38
+ *
39
+ * Errors in this domain will be from the [error@Gio.DBusError] enumeration.
40
+ * See [type@GLib.Error] for more information on error domains.
40
41
  *
41
42
  * Note that this error domain is intended only for
42
43
  * returning errors from a remote message bus process. Errors
43
- * generated locally in-process by e.g. #GDBusConnection should use the
44
- * %G_IO_ERROR domain.
44
+ * generated locally in-process (for example, by [class@Gio.DBusConnection])
45
+ * should use the [error@Gio.IOErrorEnum] domain.
45
46
  *
46
47
  * Since: 2.26
47
48
  */
@@ -60,10 +61,10 @@ gboolean g_dbus_error_strip_remote_error (GError *error);
60
61
 
61
62
  /**
62
63
  * GDBusErrorEntry:
63
- * @error_code: An error code.
64
- * @dbus_error_name: The D-Bus error name to associate with @error_code.
64
+ * @error_code: an error code
65
+ * @dbus_error_name: the D-Bus error name to associate with @error_code
65
66
  *
66
- * Struct used in g_dbus_error_register_error_domain().
67
+ * Struct used in [func@Gio.DBusError.register_error_domain].
67
68
  *
68
69
  * Since: 2.26
69
70
  */
@@ -71,6 +71,12 @@ GInetAddress * g_inet_address_new_from_bytes (const guint8
71
71
  GIO_AVAILABLE_IN_ALL
72
72
  GInetAddress * g_inet_address_new_loopback (GSocketFamily family);
73
73
 
74
+ GIO_AVAILABLE_IN_2_86
75
+ GInetAddress * g_inet_address_new_from_bytes_with_ipv6_info (const guint8 *bytes,
76
+ GSocketFamily family,
77
+ guint32 flowinfo,
78
+ guint32 scope_id);
79
+
74
80
  GIO_AVAILABLE_IN_ALL
75
81
  GInetAddress * g_inet_address_new_any (GSocketFamily family);
76
82
 
@@ -120,6 +126,12 @@ gboolean g_inet_address_get_is_mc_org_local (GInetAddress
120
126
  GIO_AVAILABLE_IN_ALL
121
127
  gboolean g_inet_address_get_is_mc_site_local (GInetAddress *address);
122
128
 
129
+ GIO_AVAILABLE_IN_2_86
130
+ guint32 g_inet_address_get_scope_id (GInetAddress *address);
131
+
132
+ GIO_AVAILABLE_IN_2_86
133
+ guint32 g_inet_address_get_flowinfo (GInetAddress *address);
134
+
123
135
  G_END_DECLS
124
136
 
125
137
  #endif /* __G_INET_ADDRESS_H__ */
@@ -987,13 +987,20 @@ typedef enum
987
987
  * @G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT: Allow another message bus connection to claim the name.
988
988
  * @G_BUS_NAME_OWNER_FLAGS_REPLACE: If another message bus connection owns the name and have
989
989
  * specified %G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT, then take the name from the other connection.
990
- * @G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE: If another message bus connection owns the name, immediately
991
- * return an error from g_bus_own_name() rather than entering the waiting queue for that name. (Since 2.54)
992
990
  *
993
991
  * Flags used in g_bus_own_name().
994
992
  *
995
993
  * Since: 2.26
996
994
  */
995
+ /**
996
+ * G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE:
997
+ *
998
+ * If another message bus connection owns the name, immediately return an error
999
+ * from [func@Gio.bus_own_name] rather than entering the waiting queue for that
1000
+ * name.
1001
+ *
1002
+ * Since: 2.54
1003
+ **/
997
1004
  typedef enum
998
1005
  {
999
1006
  G_BUS_NAME_OWNER_FLAGS_NONE = 0, /*< nick=none >*/
@@ -234,10 +234,10 @@ g_string_append_len_inline (GString *gstring,
234
234
  else
235
235
  len_unsigned = (gsize) len;
236
236
 
237
- if (G_LIKELY (gstring->len + len_unsigned < gstring->allocated_len))
237
+ if (G_LIKELY (len_unsigned < gstring->allocated_len - gstring->len))
238
238
  {
239
239
  char *end = gstring->str + gstring->len;
240
- if (G_LIKELY (val + len_unsigned <= end || val > end + len_unsigned))
240
+ if (G_LIKELY (val + len_unsigned <= end || val >= end + len_unsigned))
241
241
  memcpy (end, val, len_unsigned);
242
242
  else
243
243
  memmove (end, val, len_unsigned);
@@ -32,53 +32,61 @@ G_BEGIN_DECLS
32
32
  /* --- type macros --- */
33
33
  /**
34
34
  * G_TYPE_IS_VALUE:
35
- * @type: A #GType value.
35
+ * @type: a type
36
36
  *
37
- * Checks whether the passed in type ID can be used for g_value_init().
37
+ * Checks whether the passed in type ID can be used for
38
+ * [method@GObject.Value.init].
38
39
  *
39
40
  * That is, this macro checks whether this type provides an implementation
40
- * of the #GTypeValueTable functions required for a type to create a #GValue of.
41
+ * of the [struct@GObject.TypeValueTable] functions required to be able to
42
+ * create a [struct@GObject.Value] instance.
41
43
  *
42
- * Returns: Whether @type is suitable as a #GValue type.
44
+ * Returns: Whether @type is suitable as a [struct@GObject.Value] type.
43
45
  */
44
46
  #define G_TYPE_IS_VALUE(type) (g_type_check_is_value_type (type))
47
+
45
48
  /**
46
49
  * G_IS_VALUE:
47
- * @value: A #GValue structure.
50
+ * @value: a [struct@GObject.Value] structure
48
51
  *
49
- * Checks if @value is a valid and initialized #GValue structure.
52
+ * Checks if @value is a valid and initialized [struct@GObject.Value] structure.
50
53
  *
51
- * Returns: %TRUE on success.
54
+ * Returns: true on success; false otherwise
52
55
  */
53
56
  #define G_IS_VALUE(value) (G_TYPE_CHECK_VALUE (value))
57
+
54
58
  /**
55
59
  * G_VALUE_TYPE:
56
- * @value: A #GValue structure.
60
+ * @value: a [struct@GObject.Value] structure
57
61
  *
58
62
  * Get the type identifier of @value.
59
63
  *
60
- * Returns: the #GType.
64
+ * Returns: the type ID
61
65
  */
62
66
  #define G_VALUE_TYPE(value) (((GValue*) (value))->g_type)
67
+
63
68
  /**
64
69
  * G_VALUE_TYPE_NAME:
65
- * @value: A #GValue structure.
70
+ * @value: a [struct@GObject.Value] structure
66
71
  *
67
- * Gets the type name of @value.
72
+ * Gets the name of the type of @value.
68
73
  *
69
- * Returns: the type name.
74
+ * Returns: the type name
70
75
  */
71
76
  #define G_VALUE_TYPE_NAME(value) (g_type_name (G_VALUE_TYPE (value)))
77
+
72
78
  /**
73
79
  * G_VALUE_HOLDS:
74
- * @value: A #GValue structure.
75
- * @type: A #GType value.
80
+ * @value: (not nullable): a [struct@GObject.Value] structure
81
+ * @type: a [type@GObject.Type]
76
82
  *
77
- * Checks if @value holds (or contains) a value of @type.
78
- * This macro will also check for @value != %NULL and issue a
83
+ * Checks if @value holds a value of @type.
84
+ *
85
+ * This macro will also check for `value != NULL` and issue a
79
86
  * warning if the check fails.
80
87
  *
81
- * Returns: %TRUE if @value holds the @type.
88
+ * Returns: true if @value is non-`NULL` and holds a value of the given @type;
89
+ * false otherwise
82
90
  */
83
91
  #define G_VALUE_HOLDS(value,type) (G_TYPE_CHECK_VALUE_TYPE ((value), (type)))
84
92
 
@@ -86,29 +94,39 @@ G_BEGIN_DECLS
86
94
  /* --- typedefs & structures --- */
87
95
  /**
88
96
  * GValueTransform:
89
- * @src_value: Source value.
90
- * @dest_value: Target value.
97
+ * @src_value: source value
98
+ * @dest_value: target value
91
99
  *
92
100
  * The type of value transformation functions which can be registered with
93
- * g_value_register_transform_func().
101
+ * [func@GObject.Value.register_transform_func].
94
102
  *
95
103
  * @dest_value will be initialized to the correct destination type.
96
104
  */
97
105
  typedef void (*GValueTransform) (const GValue *src_value,
98
106
  GValue *dest_value);
107
+
99
108
  /**
100
109
  * GValue:
101
110
  *
102
111
  * An opaque structure used to hold different types of values.
103
112
  *
113
+ * Before it can be used, a `GValue` has to be initialized to a specific type by
114
+ * calling [method@GObject.Value.init] on it.
115
+ *
116
+ * Many types which are stored within a `GValue` need to allocate data on the
117
+ * heap, so [method@GObject.Value.unset] must always be called on a `GValue` to
118
+ * free any such data once you’re finished with the `GValue`, even if the
119
+ * `GValue` itself is stored on the stack.
120
+ *
104
121
  * The data within the structure has protected scope: it is accessible only
105
- * to functions within a #GTypeValueTable structure, or implementations of
106
- * the g_value_*() API. That is, code portions which implement new fundamental
107
- * types.
122
+ * to functions within a [struct@GObject.TypeValueTable] structure, or
123
+ * implementations of the `g_value_*()` API. That is, code which implements new
124
+ * fundamental types.
108
125
  *
109
- * #GValue users cannot make any assumptions about how data is stored
126
+ * `GValue` users cannot make any assumptions about how data is stored
110
127
  * within the 2 element @data union, and the @g_type member should
111
- * only be accessed through the G_VALUE_TYPE() macro.
128
+ * only be accessed through the [func@GObject.VALUE_TYPE] macro and related
129
+ * macros.
112
130
  */
113
131
  struct _GValue
114
132
  {
@@ -174,18 +192,32 @@ void g_value_register_transform_func (GType src_type,
174
192
  /**
175
193
  * G_VALUE_NOCOPY_CONTENTS:
176
194
  *
177
- * If passed to G_VALUE_COLLECT(), allocated data won't be copied
178
- * but used verbatim. This does not affect ref-counted types like
179
- * objects. This does not affect usage of g_value_copy(), the data will
195
+ * Flag to indicate that allocated data in a [struct@GObject.Value] shouldn’t be
196
+ * copied.
197
+ *
198
+ * If passed to [func@GObject.VALUE_COLLECT], allocated data won’t be copied
199
+ * but used verbatim. This does not affect ref-counted types like objects.
200
+ *
201
+ * This does not affect usage of [method@GObject.Value.copy]: the data will
180
202
  * be copied if it is not ref-counted.
203
+ *
204
+ * This flag should be checked by implementations of
205
+ * [callback@GObject.TypeValueFreeFunc], [callback@GObject.TypeValueCollectFunc]
206
+ * and [callback@GObject.TypeValueLCopyFunc].
181
207
  */
182
208
  #define G_VALUE_NOCOPY_CONTENTS (1 << 27)
183
209
 
184
210
  /**
185
211
  * G_VALUE_INTERNED_STRING:
186
212
  *
187
- * For string values, indicates that the string contained is canonical and will
188
- * exist for the duration of the process. See g_value_set_interned_string().
213
+ * Flag to indicate that a string in a [struct@GObject.Value] is canonical and
214
+ * will exist for the duration of the process.
215
+ *
216
+ * See [method@GObject.Value.set_interned_string].
217
+ *
218
+ * This flag should be checked by implementations of
219
+ * [callback@GObject.TypeValueFreeFunc], [callback@GObject.TypeValueCollectFunc]
220
+ * and [callback@GObject.TypeValueLCopyFunc].
189
221
  *
190
222
  * Since: 2.66
191
223
  */
@@ -194,13 +226,24 @@ void g_value_register_transform_func (GType src_type,
194
226
  /**
195
227
  * G_VALUE_INIT:
196
228
  *
197
- * A #GValue must be initialized before it can be used. This macro can
198
- * be used as initializer instead of an explicit `{ 0 }` when declaring
199
- * a variable, but it cannot be assigned to a variable.
229
+ * Clears a [struct@GObject.Value] to zero at declaration time.
230
+ *
231
+ * A [struct@GObject.Value] must be cleared and then initialized before it can
232
+ * be used. This macro can be assigned to a variable instead of an explicit
233
+ * `{ 0 }` when declaring it, but it cannot be assigned to a variable after
234
+ * declaration time.
200
235
  *
201
- * |[<!-- language="C" -->
236
+ * After the [struct@GObject.Value] is cleared, it must be initialized by
237
+ * calling [method@GObject.Value.init] on it before any other methods can be
238
+ * called on it.
239
+ *
240
+ * ```c
202
241
  * GValue value = G_VALUE_INIT;
203
- * ]|
242
+ *
243
+ * g_value_init (&value, SOME_G_TYPE);
244
+ * …
245
+ * g_value_unset (&value);
246
+ * ```
204
247
  *
205
248
  * Since: 2.30
206
249
  */
@@ -5,24 +5,7 @@
5
5
  #ifndef HIGHWAY_HWY_ABORT_H_
6
6
  #define HIGHWAY_HWY_ABORT_H_
7
7
 
8
- #include "hwy/highway_export.h"
9
-
10
- namespace hwy {
11
-
12
- // Interface for custom abort handler
13
- typedef void (*AbortFunc)(const char* file, int line,
14
- const char* formatted_err);
15
-
16
- // Retrieve current abort handler
17
- // Returns null if no abort handler registered, indicating Highway should print and abort
18
- HWY_DLLEXPORT AbortFunc& GetAbortFunc();
19
-
20
- // Sets a new abort handler and returns the previous abort handler
21
- // If this handler does not do the aborting itself Highway will use its own abort mechanism
22
- // which allows this to be used to customize the handling of the error itself.
23
- // Returns null if no previous abort handler registered
24
- HWY_DLLEXPORT AbortFunc SetAbortFunc(AbortFunc func);
25
-
26
- } // namespace hwy
8
+ // Empty header for compatibility.
9
+ // All Abort/Warn functionalities are in base.h.
27
10
 
28
11
  #endif // HIGHWAY_HWY_ABORT_H_
@@ -40,6 +40,7 @@ namespace hwy {
40
40
  // access pairs of lines, and M1 L2 and POWER8 lines are also 128 bytes.
41
41
  #define HWY_ALIGNMENT 128
42
42
 
43
+ // `align` is in bytes.
43
44
  template <typename T>
44
45
  HWY_API constexpr bool IsAligned(T* ptr, size_t align = HWY_ALIGNMENT) {
45
46
  return reinterpret_cast<uintptr_t>(ptr) % align == 0;
@@ -181,14 +182,14 @@ static inline constexpr size_t ShiftCount(size_t n) {
181
182
 
182
183
  template <typename T>
183
184
  T* AllocateAlignedItems(size_t items, AllocPtr alloc_ptr, void* opaque_ptr) {
184
- constexpr size_t size = sizeof(T);
185
+ constexpr size_t kSize = sizeof(T);
185
186
 
186
- constexpr bool is_pow2 = (size & (size - 1)) == 0;
187
- constexpr size_t bits = ShiftCount(size);
188
- static_assert(!is_pow2 || (1ull << bits) == size, "ShiftCount is incorrect");
187
+ constexpr bool kIsPow2 = (kSize & (kSize - 1)) == 0;
188
+ constexpr size_t kBits = ShiftCount(kSize);
189
+ static_assert(!kIsPow2 || (1ull << kBits) == kSize, "ShiftCount has a bug");
189
190
 
190
- const size_t bytes = is_pow2 ? items << bits : items * size;
191
- const size_t check = is_pow2 ? bytes >> bits : bytes / size;
191
+ const size_t bytes = kIsPow2 ? items << kBits : items * kSize;
192
+ const size_t check = kIsPow2 ? bytes >> kBits : bytes / kSize;
192
193
  if (check != items) {
193
194
  return nullptr; // overflowed
194
195
  }
@@ -232,7 +233,6 @@ class AlignedFreer {
232
233
 
233
234
  template <typename T>
234
235
  void operator()(T* aligned_pointer) const {
235
- // TODO(deymo): assert that we are using a POD type T.
236
236
  FreeAlignedBytes(aligned_pointer, free_, opaque_ptr_);
237
237
  }
238
238
 
@@ -251,6 +251,10 @@ using AlignedFreeUniquePtr = std::unique_ptr<T, AlignedFreer>;
251
251
  template <typename T>
252
252
  AlignedFreeUniquePtr<T[]> AllocateAligned(const size_t items, AllocPtr alloc,
253
253
  FreePtr free, void* opaque) {
254
+ static_assert(std::is_trivially_copyable<T>::value,
255
+ "AllocateAligned: requires trivially copyable T");
256
+ static_assert(std::is_trivially_destructible<T>::value,
257
+ "AllocateAligned: requires trivially destructible T");
254
258
  return AlignedFreeUniquePtr<T[]>(
255
259
  detail::AllocateAlignedItems<T>(items, alloc, opaque),
256
260
  AlignedFreer(free, opaque));