xref: /netbsd-src/external/bsd/jemalloc/lib/jemalloc_stub.c (revision 7cacb6761ae7c2a6bdbec10bc05ee47b73788115)
1 /*-
2  * Copyright (c) 2019 The NetBSD Foundation, Inc.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to The NetBSD Foundation
6  * by Christos Zoulas.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #if HAVE_JEMALLOC > 100
31 #include <malloc.h>
32 
33 void *__je_mallocx(size_t, int);
34 void *
mallocx(size_t l,int f)35 mallocx(size_t l, int f)
36 {
37 	return __je_mallocx(l, f);
38 }
39 
40 void *__je_rallocx(void *, size_t, int);
41 void *
rallocx(void * p,size_t l,int f)42 rallocx(void *p, size_t l, int f)
43 {
44 	return __je_rallocx(p, l, f);
45 }
46 
47 size_t __je_xallocx(void *, size_t, size_t, int);
48 size_t
xallocx(void * p,size_t l,size_t s,int f)49 xallocx(void *p, size_t l, size_t s, int f)
50 {
51 	return __je_xallocx(p, l, s, f);
52 }
53 
54 size_t __je_sallocx(const void *, int);
55 size_t
sallocx(const void * p,int f)56 sallocx(const void *p, int f)
57 {
58 	return __je_sallocx(p, f);
59 }
60 
61 void __je_dallocx(void *, int);
62 void
dallocx(void * p,int f)63 dallocx(void *p, int f)
64 {
65 	__je_dallocx(p, f);
66 }
67 
68 void __je_sdallocx(void *, size_t, int);
69 void
sdallocx(void * p,size_t l,int f)70 sdallocx(void *p, size_t l, int f)
71 {
72 	__je_sdallocx(p, l, f);
73 }
74 
75 size_t __je_nallocx(size_t, int);
76 size_t
nallocx(size_t l,int f)77 nallocx(size_t l, int f)
78 {
79 	return __je_nallocx(l, f);
80 }
81 
82 int __je_mallctl(const char *, void *, size_t *, void *, size_t);
83 int
mallctl(const char * n,void * p,size_t * s,void * v,size_t l)84 mallctl(const char *n, void *p, size_t *s, void *v, size_t l)
85 {
86 	return __je_mallctl(n, p, s, v, l);
87 }
88 
89 int __je_mallctlnametomib(const char *, size_t *, size_t *);
90 int
mallctlnametomib(const char * n,size_t * l,size_t * s)91 mallctlnametomib(const char *n, size_t *l, size_t *s)
92 {
93 	return __je_mallctlnametomib(n, l, s);
94 }
95 
96 int __je_mallctlbymib(const size_t *, size_t, void *, size_t *, void *, size_t);
97 int
mallctlbymib(const size_t * sp,size_t s,void * p,size_t * dp,void * r,size_t l)98 mallctlbymib(const size_t *sp, size_t s, void *p , size_t *dp, void *r ,
99     size_t l)
100 {
101 	return __je_mallctlbymib(sp, s, p , dp, r, l);
102 }
103 
104 void __je_malloc_stats_print(void (*)(void *, const char *), void *,
105     const char *);
106 void
malloc_stats_print(void (* f)(void *,const char *),void * p,const char * n)107 malloc_stats_print(void (*f)(void *, const char *), void *p, const char *n)
108 {
109 	__je_malloc_stats_print(f, p, n);
110 }
111 
112 size_t __je_malloc_usable_size(const void *);
113 size_t
malloc_usable_size(const void * p)114 malloc_usable_size(const void *p)
115 {
116     return __je_malloc_usable_size(p);
117 }
118 void (*__je_malloc_message_get(void))(void *, const char *);
119 void (*
malloc_message_get(void)120 malloc_message_get(void))(void *, const char *)
121 {
122 	return __je_malloc_message_get();
123 }
124 
125 void __je_malloc_message_set(void (*)(void *, const char *));
126 void
malloc_message_set(void (* m)(void *,const char *))127 malloc_message_set(void (*m)(void *, const char *))
128 {
129 	__je_malloc_message_set(m);
130 }
131 
132 const char *__je_malloc_conf_get(void);
133 const char *
malloc_conf_get(void)134 malloc_conf_get(void)
135 {
136 	return __je_malloc_conf_get();
137 }
138 
139 void __je_malloc_conf_set(const char *);
malloc_conf_set(const char * m)140 void malloc_conf_set(const char *m)
141 {
142 	__je_malloc_conf_set(m);
143 }
144 #endif /* HAVE_JEMALLOC > 100 */
145