@img/sharp-libvips-dev 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.
- package/include/ffi.h +3 -3
- package/include/harfbuzz/hb-deprecated.h +4 -4
- package/include/harfbuzz/hb-font.h +120 -9
- package/include/harfbuzz/hb-version.h +3 -3
- package/include/hwy/abort.h +2 -19
- package/include/hwy/aligned_allocator.h +11 -7
- package/include/hwy/auto_tune.h +504 -0
- package/include/hwy/base.h +425 -104
- package/include/hwy/cache_control.h +16 -0
- package/include/hwy/detect_compiler_arch.h +32 -1
- package/include/hwy/detect_targets.h +251 -67
- package/include/hwy/foreach_target.h +35 -0
- package/include/hwy/highway.h +185 -76
- package/include/hwy/nanobenchmark.h +1 -19
- package/include/hwy/ops/arm_neon-inl.h +969 -458
- package/include/hwy/ops/arm_sve-inl.h +1137 -359
- package/include/hwy/ops/emu128-inl.h +97 -11
- package/include/hwy/ops/generic_ops-inl.h +1222 -34
- package/include/hwy/ops/loongarch_lasx-inl.h +4664 -0
- package/include/hwy/ops/loongarch_lsx-inl.h +5933 -0
- package/include/hwy/ops/ppc_vsx-inl.h +306 -126
- package/include/hwy/ops/rvv-inl.h +546 -51
- package/include/hwy/ops/scalar-inl.h +77 -22
- package/include/hwy/ops/set_macros-inl.h +138 -17
- package/include/hwy/ops/shared-inl.h +50 -10
- package/include/hwy/ops/wasm_128-inl.h +137 -92
- package/include/hwy/ops/x86_128-inl.h +773 -214
- package/include/hwy/ops/x86_256-inl.h +712 -255
- package/include/hwy/ops/x86_512-inl.h +429 -753
- package/include/hwy/ops/x86_avx3-inl.h +501 -0
- package/include/hwy/per_target.h +2 -1
- package/include/hwy/profiler.h +622 -486
- package/include/hwy/targets.h +62 -20
- package/include/hwy/timer-inl.h +8 -160
- package/include/hwy/timer.h +170 -3
- package/include/hwy/x86_cpuid.h +81 -0
- package/include/libheif/heif_cxx.h +25 -5
- package/include/libheif/heif_regions.h +5 -5
- package/include/libheif/heif_version.h +2 -2
- package/include/librsvg-2.0/librsvg/rsvg-version.h +2 -2
- package/include/libxml2/libxml/xmlversion.h +4 -4
- package/include/pango-1.0/pango/pango-enum-types.h +3 -0
- package/include/pango-1.0/pango/pango-features.h +3 -3
- package/include/pango-1.0/pango/pango-font.h +30 -0
- package/include/pango-1.0/pango/pango-version-macros.h +26 -0
- package/include/pixman-1/pixman-version.h +2 -2
- package/include/webp/decode.h +11 -2
- package/include/webp/demux.h +2 -0
- package/include/webp/encode.h +2 -0
- package/include/webp/mux_types.h +1 -0
- package/include/webp/sharpyuv/sharpyuv.h +1 -1
- package/include/webp/types.h +2 -2
- package/include/zlib.h +3 -3
- package/package.json +1 -1
- package/versions.json +11 -11
package/include/ffi.h
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* -----------------------------------------------------------------*-C-*-
|
|
2
|
-
libffi 3.5.
|
|
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.
|
|
320
|
-
#define FFI_VERSION_NUMBER
|
|
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. */
|
|
@@ -287,7 +287,7 @@ typedef void (*hb_font_get_glyph_shape_func_t) (hb_font_t *font, void *font_data
|
|
|
287
287
|
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
|
288
288
|
*
|
|
289
289
|
* Since: 7.0.0
|
|
290
|
-
*
|
|
290
|
+
* Deprecated: 11.2.0: Use hb_font_draw_glyph_func_or_fail_t instead.
|
|
291
291
|
**/
|
|
292
292
|
typedef void (*hb_font_draw_glyph_func_t) (hb_font_t *font, void *font_data,
|
|
293
293
|
hb_codepoint_t glyph,
|
|
@@ -308,7 +308,7 @@ typedef void (*hb_font_draw_glyph_func_t) (hb_font_t *font, void *font_data,
|
|
|
308
308
|
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
|
309
309
|
*
|
|
310
310
|
* Since: 7.0.0
|
|
311
|
-
*
|
|
311
|
+
* Deprecated: 11.2.0: Use hb_font_paint_glyph_or_fail_func_t instead.
|
|
312
312
|
*/
|
|
313
313
|
typedef hb_bool_t (*hb_font_paint_glyph_func_t) (hb_font_t *font, void *font_data,
|
|
314
314
|
hb_codepoint_t glyph,
|
|
@@ -346,7 +346,7 @@ hb_font_funcs_set_glyph_shape_func (hb_font_funcs_t *ffuncs,
|
|
|
346
346
|
* Sets the implementation function for #hb_font_draw_glyph_func_t.
|
|
347
347
|
*
|
|
348
348
|
* Since: 7.0.0
|
|
349
|
-
*
|
|
349
|
+
* Deprecated: 11.2.0: Use hb_font_funcs_set_draw_glyph_or_fail_func instead.
|
|
350
350
|
**/
|
|
351
351
|
HB_DEPRECATED_FOR (hb_font_funcs_set_draw_glyph_or_fail_func)
|
|
352
352
|
HB_EXTERN void
|
|
@@ -364,7 +364,7 @@ hb_font_funcs_set_draw_glyph_func (hb_font_funcs_t *ffuncs,
|
|
|
364
364
|
* Sets the implementation function for #hb_font_paint_glyph_func_t.
|
|
365
365
|
*
|
|
366
366
|
* Since: 7.0.0
|
|
367
|
-
*
|
|
367
|
+
* Deprecated: 11.2.0: Use hb_font_funcs_set_paint_glyph_or_fail_func() instead.
|
|
368
368
|
*/
|
|
369
369
|
HB_DEPRECATED_FOR (hb_font_funcs_set_paint_glyph_or_fail_func)
|
|
370
370
|
HB_EXTERN void
|
|
@@ -97,7 +97,7 @@ hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
|
|
|
97
97
|
* @descender: The depth of typographic descenders.
|
|
98
98
|
* @line_gap: The suggested line-spacing gap.
|
|
99
99
|
*
|
|
100
|
-
* Font-wide extent values, measured in
|
|
100
|
+
* Font-wide extent values, measured in scaled units.
|
|
101
101
|
*
|
|
102
102
|
* Note that typically @ascender is positive and @descender
|
|
103
103
|
* negative, in coordinate systems that grow up.
|
|
@@ -332,7 +332,7 @@ typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_v_advances_func_t;
|
|
|
332
332
|
*
|
|
333
333
|
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
|
334
334
|
*
|
|
335
|
-
* This method should retrieve the (X,Y) coordinates (in
|
|
335
|
+
* This method should retrieve the (X,Y) coordinates (in scaled units) of the
|
|
336
336
|
* origin for a glyph. Each coordinate must be returned in an #hb_position_t
|
|
337
337
|
* output parameter.
|
|
338
338
|
*
|
|
@@ -349,7 +349,7 @@ typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *fon
|
|
|
349
349
|
*
|
|
350
350
|
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
|
351
351
|
*
|
|
352
|
-
* This method should retrieve the (X,Y) coordinates (in
|
|
352
|
+
* This method should retrieve the (X,Y) coordinates (in scaled units) of the
|
|
353
353
|
* origin for a glyph, for horizontal-direction text segments. Each
|
|
354
354
|
* coordinate must be returned in an #hb_position_t output parameter.
|
|
355
355
|
*
|
|
@@ -361,13 +361,72 @@ typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t;
|
|
|
361
361
|
*
|
|
362
362
|
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
|
363
363
|
*
|
|
364
|
-
* This method should retrieve the (X,Y) coordinates (in
|
|
364
|
+
* This method should retrieve the (X,Y) coordinates (in scaled units) of the
|
|
365
365
|
* origin for a glyph, for vertical-direction text segments. Each coordinate
|
|
366
366
|
* must be returned in an #hb_position_t output parameter.
|
|
367
367
|
*
|
|
368
368
|
**/
|
|
369
369
|
typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t;
|
|
370
370
|
|
|
371
|
+
/**
|
|
372
|
+
* hb_font_get_glyph_origins_func_t:
|
|
373
|
+
* @font: #hb_font_t to work upon
|
|
374
|
+
* @font_data: @font user data pointer
|
|
375
|
+
* @first_glyph: The first glyph ID to query
|
|
376
|
+
* @count: number of glyphs to query
|
|
377
|
+
* @glyph_stride: The stride between successive glyph IDs
|
|
378
|
+
* @first_x: (out): The first origin X coordinate retrieved
|
|
379
|
+
* @x_stride: The stride between successive origin X coordinates
|
|
380
|
+
* @first_y: (out): The first origin Y coordinate retrieved
|
|
381
|
+
* @y_stride: The stride between successive origin Y coordinates
|
|
382
|
+
* @user_data: User data pointer passed by the caller
|
|
383
|
+
*
|
|
384
|
+
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
|
385
|
+
*
|
|
386
|
+
* This method should retrieve the (X,Y) coordinates (in scaled units) of the
|
|
387
|
+
* origin for each requested glyph. Each coordinate value must be returned in
|
|
388
|
+
* an #hb_position_t in the two output parameters.
|
|
389
|
+
*
|
|
390
|
+
* Return value: `true` if data found, `false` otherwise
|
|
391
|
+
*
|
|
392
|
+
* Since: 11.3.0
|
|
393
|
+
**/
|
|
394
|
+
typedef hb_bool_t (*hb_font_get_glyph_origins_func_t) (hb_font_t *font, void *font_data,
|
|
395
|
+
unsigned int count,
|
|
396
|
+
const hb_codepoint_t *first_glyph,
|
|
397
|
+
unsigned glyph_stride,
|
|
398
|
+
hb_position_t *first_x,
|
|
399
|
+
unsigned x_stride,
|
|
400
|
+
hb_position_t *first_y,
|
|
401
|
+
unsigned y_stride,
|
|
402
|
+
void *user_data);
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* hb_font_get_glyph_h_origins_func_t:
|
|
406
|
+
*
|
|
407
|
+
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
|
408
|
+
*
|
|
409
|
+
* This method should retrieve the (X,Y) coordinates (in scaled units) of the
|
|
410
|
+
* origin for requested glyph, for horizontal-direction text segments. Each
|
|
411
|
+
* coordinate must be returned in a the x/y #hb_position_t output parameters.
|
|
412
|
+
*
|
|
413
|
+
* Since: 11.3.0
|
|
414
|
+
**/
|
|
415
|
+
typedef hb_font_get_glyph_origins_func_t hb_font_get_glyph_h_origins_func_t;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* hb_font_get_glyph_v_origins_func_t:
|
|
419
|
+
*
|
|
420
|
+
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
|
421
|
+
*
|
|
422
|
+
* This method should retrieve the (X,Y) coordinates (in scaled units) of the
|
|
423
|
+
* origin for requested glyph, for vertical-direction text segments. Each
|
|
424
|
+
* coordinate must be returned in a the x/y #hb_position_t output parameters.
|
|
425
|
+
*
|
|
426
|
+
* Since: 11.3.0
|
|
427
|
+
**/
|
|
428
|
+
typedef hb_font_get_glyph_origins_func_t hb_font_get_glyph_v_origins_func_t;
|
|
429
|
+
|
|
371
430
|
/**
|
|
372
431
|
* hb_font_get_glyph_kerning_func_t:
|
|
373
432
|
* @font: #hb_font_t to work upon
|
|
@@ -428,7 +487,7 @@ typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *fo
|
|
|
428
487
|
*
|
|
429
488
|
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
|
|
430
489
|
*
|
|
431
|
-
* This method should retrieve the (X,Y) coordinates (in
|
|
490
|
+
* This method should retrieve the (X,Y) coordinates (in scaled units) for a
|
|
432
491
|
* specified contour point in a glyph. Each coordinate must be returned as
|
|
433
492
|
* an #hb_position_t output parameter.
|
|
434
493
|
*
|
|
@@ -498,7 +557,7 @@ typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *
|
|
|
498
557
|
*
|
|
499
558
|
* Return value: `true` if glyph was drawn, `false` otherwise
|
|
500
559
|
*
|
|
501
|
-
*
|
|
560
|
+
* Since: 11.2.0
|
|
502
561
|
**/
|
|
503
562
|
typedef hb_bool_t (*hb_font_draw_glyph_or_fail_func_t) (hb_font_t *font, void *font_data,
|
|
504
563
|
hb_codepoint_t glyph,
|
|
@@ -520,7 +579,7 @@ typedef hb_bool_t (*hb_font_draw_glyph_or_fail_func_t) (hb_font_t *font, void *f
|
|
|
520
579
|
*
|
|
521
580
|
* Return value: `true` if glyph was painted, `false` otherwise
|
|
522
581
|
*
|
|
523
|
-
*
|
|
582
|
+
* Since: 11.2.0
|
|
524
583
|
*/
|
|
525
584
|
typedef hb_bool_t (*hb_font_paint_glyph_or_fail_func_t) (hb_font_t *font, void *font_data,
|
|
526
585
|
hb_codepoint_t glyph,
|
|
@@ -707,6 +766,38 @@ hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs,
|
|
|
707
766
|
hb_font_get_glyph_v_origin_func_t func,
|
|
708
767
|
void *user_data, hb_destroy_func_t destroy);
|
|
709
768
|
|
|
769
|
+
/**
|
|
770
|
+
* hb_font_funcs_set_glyph_h_origins_func:
|
|
771
|
+
* @ffuncs: A font-function structure
|
|
772
|
+
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
|
773
|
+
* @user_data: Data to pass to @func
|
|
774
|
+
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
|
775
|
+
*
|
|
776
|
+
* Sets the implementation function for #hb_font_get_glyph_h_origins_func_t.
|
|
777
|
+
*
|
|
778
|
+
* Since: 11.3.0
|
|
779
|
+
**/
|
|
780
|
+
HB_EXTERN void
|
|
781
|
+
hb_font_funcs_set_glyph_h_origins_func (hb_font_funcs_t *ffuncs,
|
|
782
|
+
hb_font_get_glyph_h_origins_func_t func,
|
|
783
|
+
void *user_data, hb_destroy_func_t destroy);
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* hb_font_funcs_set_glyph_v_origins_func:
|
|
787
|
+
* @ffuncs: A font-function structure
|
|
788
|
+
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
|
|
789
|
+
* @user_data: Data to pass to @func
|
|
790
|
+
* @destroy: (nullable): The function to call when @user_data is not needed anymore
|
|
791
|
+
*
|
|
792
|
+
* Sets the implementation function for #hb_font_get_glyph_v_origins_func_t.
|
|
793
|
+
*
|
|
794
|
+
* Since: 11.3.0
|
|
795
|
+
**/
|
|
796
|
+
HB_EXTERN void
|
|
797
|
+
hb_font_funcs_set_glyph_v_origins_func (hb_font_funcs_t *ffuncs,
|
|
798
|
+
hb_font_get_glyph_v_origins_func_t func,
|
|
799
|
+
void *user_data, hb_destroy_func_t destroy);
|
|
800
|
+
|
|
710
801
|
/**
|
|
711
802
|
* hb_font_funcs_set_glyph_h_kerning_func:
|
|
712
803
|
* @ffuncs: A font-function structure
|
|
@@ -796,7 +887,7 @@ hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs,
|
|
|
796
887
|
*
|
|
797
888
|
* Sets the implementation function for #hb_font_draw_glyph_or_fail_func_t.
|
|
798
889
|
*
|
|
799
|
-
*
|
|
890
|
+
* Since: 11.2.0
|
|
800
891
|
**/
|
|
801
892
|
HB_EXTERN void
|
|
802
893
|
hb_font_funcs_set_draw_glyph_or_fail_func (hb_font_funcs_t *ffuncs,
|
|
@@ -812,7 +903,7 @@ hb_font_funcs_set_draw_glyph_or_fail_func (hb_font_funcs_t *ffuncs,
|
|
|
812
903
|
*
|
|
813
904
|
* Sets the implementation function for #hb_font_paint_glyph_or_fail_func_t.
|
|
814
905
|
*
|
|
815
|
-
*
|
|
906
|
+
* Since: 11.2.0
|
|
816
907
|
*/
|
|
817
908
|
HB_EXTERN void
|
|
818
909
|
hb_font_funcs_set_paint_glyph_or_fail_func (hb_font_funcs_t *ffuncs,
|
|
@@ -876,6 +967,26 @@ hb_font_get_glyph_v_origin (hb_font_t *font,
|
|
|
876
967
|
hb_codepoint_t glyph,
|
|
877
968
|
hb_position_t *x, hb_position_t *y);
|
|
878
969
|
|
|
970
|
+
HB_EXTERN hb_bool_t
|
|
971
|
+
hb_font_get_glyph_h_origins (hb_font_t *font,
|
|
972
|
+
unsigned int count,
|
|
973
|
+
const hb_codepoint_t *first_glyph,
|
|
974
|
+
unsigned glyph_stride,
|
|
975
|
+
hb_position_t *first_x,
|
|
976
|
+
unsigned x_stride,
|
|
977
|
+
hb_position_t *first_y,
|
|
978
|
+
unsigned y_stride);
|
|
979
|
+
|
|
980
|
+
HB_EXTERN hb_bool_t
|
|
981
|
+
hb_font_get_glyph_v_origins (hb_font_t *font,
|
|
982
|
+
unsigned int count,
|
|
983
|
+
const hb_codepoint_t *first_glyph,
|
|
984
|
+
unsigned glyph_stride,
|
|
985
|
+
hb_position_t *first_x,
|
|
986
|
+
unsigned x_stride,
|
|
987
|
+
hb_position_t *first_y,
|
|
988
|
+
unsigned y_stride);
|
|
989
|
+
|
|
879
990
|
HB_EXTERN hb_position_t
|
|
880
991
|
hb_font_get_glyph_h_kerning (hb_font_t *font,
|
|
881
992
|
hb_codepoint_t left_glyph, hb_codepoint_t right_glyph);
|
|
@@ -47,20 +47,20 @@ HB_BEGIN_DECLS
|
|
|
47
47
|
*
|
|
48
48
|
* The minor component of the library version available at compile-time.
|
|
49
49
|
*/
|
|
50
|
-
#define HB_VERSION_MINOR
|
|
50
|
+
#define HB_VERSION_MINOR 4
|
|
51
51
|
/**
|
|
52
52
|
* HB_VERSION_MICRO:
|
|
53
53
|
*
|
|
54
54
|
* The micro component of the library version available at compile-time.
|
|
55
55
|
*/
|
|
56
|
-
#define HB_VERSION_MICRO
|
|
56
|
+
#define HB_VERSION_MICRO 5
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* HB_VERSION_STRING:
|
|
60
60
|
*
|
|
61
61
|
* A string literal containing the library version available at compile-time.
|
|
62
62
|
*/
|
|
63
|
-
#define HB_VERSION_STRING "11.
|
|
63
|
+
#define HB_VERSION_STRING "11.4.5"
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* HB_VERSION_ATLEAST:
|
package/include/hwy/abort.h
CHANGED
|
@@ -5,24 +5,7 @@
|
|
|
5
5
|
#ifndef HIGHWAY_HWY_ABORT_H_
|
|
6
6
|
#define HIGHWAY_HWY_ABORT_H_
|
|
7
7
|
|
|
8
|
-
|
|
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
|
|
185
|
+
constexpr size_t kSize = sizeof(T);
|
|
185
186
|
|
|
186
|
-
constexpr bool
|
|
187
|
-
constexpr size_t
|
|
188
|
-
static_assert(!
|
|
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 =
|
|
191
|
-
const size_t check =
|
|
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));
|