xref: /freebsd/contrib/jemalloc/src/extent.c (revision fcb560670601b2a4d87bb31d7531c8dcc37ee71b)
1 #define	JEMALLOC_EXTENT_C_
2 #include "jemalloc/internal/jemalloc_internal.h"
3 
4 /******************************************************************************/
5 
6 static inline int
7 extent_szad_comp(extent_node_t *a, extent_node_t *b)
8 {
9 	int ret;
10 	size_t a_size = a->size;
11 	size_t b_size = b->size;
12 
13 	ret = (a_size > b_size) - (a_size < b_size);
14 	if (ret == 0) {
15 		uintptr_t a_addr = (uintptr_t)a->addr;
16 		uintptr_t b_addr = (uintptr_t)b->addr;
17 
18 		ret = (a_addr > b_addr) - (a_addr < b_addr);
19 	}
20 
21 	return (ret);
22 }
23 
24 /* Generate red-black tree functions. */
25 rb_gen(, extent_tree_szad_, extent_tree_t, extent_node_t, link_szad,
26     extent_szad_comp)
27 
28 static inline int
29 extent_ad_comp(extent_node_t *a, extent_node_t *b)
30 {
31 	uintptr_t a_addr = (uintptr_t)a->addr;
32 	uintptr_t b_addr = (uintptr_t)b->addr;
33 
34 	return ((a_addr > b_addr) - (a_addr < b_addr));
35 }
36 
37 /* Generate red-black tree functions. */
38 rb_gen(, extent_tree_ad_, extent_tree_t, extent_node_t, link_ad,
39     extent_ad_comp)
40