]>
git.proxmox.com Git - rustc.git/blob - src/jemalloc/src/extent.c
1 #define JEMALLOC_EXTENT_C_
2 #include "jemalloc/internal/jemalloc_internal.h"
4 /******************************************************************************/
6 JEMALLOC_INLINE_C
size_t
7 extent_quantize(size_t size
)
11 * Round down to the nearest chunk size that can actually be requested
12 * during normal huge allocation.
14 return (index2size(size2index(size
+ 1) - 1));
18 extent_szad_comp(const extent_node_t
*a
, const extent_node_t
*b
)
21 size_t a_qsize
= extent_quantize(extent_node_size_get(a
));
22 size_t b_qsize
= extent_quantize(extent_node_size_get(b
));
25 * Compare based on quantized size rather than size, in order to sort
26 * equally useful extents only by address.
28 ret
= (a_qsize
> b_qsize
) - (a_qsize
< b_qsize
);
30 uintptr_t a_addr
= (uintptr_t)extent_node_addr_get(a
);
31 uintptr_t b_addr
= (uintptr_t)extent_node_addr_get(b
);
33 ret
= (a_addr
> b_addr
) - (a_addr
< b_addr
);
39 /* Generate red-black tree functions. */
40 rb_gen(, extent_tree_szad_
, extent_tree_t
, extent_node_t
, szad_link
,
44 extent_ad_comp(const extent_node_t
*a
, const extent_node_t
*b
)
46 uintptr_t a_addr
= (uintptr_t)extent_node_addr_get(a
);
47 uintptr_t b_addr
= (uintptr_t)extent_node_addr_get(b
);
49 return ((a_addr
> b_addr
) - (a_addr
< b_addr
));
52 /* Generate red-black tree functions. */
53 rb_gen(, extent_tree_ad_
, extent_tree_t
, extent_node_t
, ad_link
, extent_ad_comp
)