xref: /netbsd-src/external/bsd/jemalloc/lib/jemalloc_stub.c (revision 53b02e147d4ed531c0d2a5ca9b3e8026ba3e99b5)
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 #include <malloc.h>
30 
31 void *__je_mallocx(size_t, int);
32 void *
33 mallocx(size_t l, int f)
34 {
35 	return __je_mallocx(l, f);
36 }
37 
38 void *__je_rallocx(void *, size_t, int);
39 void *
40 rallocx(void *p, size_t l, int f)
41 {
42 	return __je_rallocx(p, l, f);
43 }
44 
45 size_t __je_xallocx(void *, size_t, size_t, int);
46 size_t
47 xallocx(void *p, size_t l, size_t s, int f)
48 {
49 	return __je_xallocx(p, l, s, f);
50 }
51 
52 size_t __je_sallocx(const void *, int);
53 size_t
54 sallocx(const void *p, int f)
55 {
56 	return __je_sallocx(p, f);
57 }
58 
59 void __je_dallocx(void *, int);
60 void
61 dallocx(void *p, int f)
62 {
63 	__je_dallocx(p, f);
64 }
65 
66 void __je_sdallocx(void *, size_t, int);
67 void
68 sdallocx(void *p, size_t l, int f)
69 {
70 	__je_sdallocx(p, l, f);
71 }
72 
73 size_t __je_nallocx(size_t, int);
74 size_t
75 nallocx(size_t l, int f)
76 {
77 	return __je_nallocx(l, f);
78 }
79 
80 int __je_mallctl(const char *, void *, size_t *, void *, size_t);
81 int
82 mallctl(const char *n, void *p, size_t *s, void *v, size_t l)
83 {
84 	return __je_mallctl(n, p, s, v, l);
85 }
86 
87 int __je_mallctlnametomib(const char *, size_t *, size_t *);
88 int
89 mallctlnametomib(const char *n, size_t *l, size_t *s)
90 {
91 	return __je_mallctlnametomib(n, l, s);
92 }
93 
94 int __je_mallctlbymib(const size_t *, size_t, void *, size_t *, void *, size_t);
95 int
96 mallctlbymib(const size_t *sp, size_t s, void *p , size_t *dp, void *r ,
97     size_t l)
98 {
99 	return __je_mallctlbymib(sp, s, p , dp, r, l);
100 }
101 
102 void __je_malloc_stats_print(void (*)(void *, const char *), void *,
103     const char *);
104 void
105 malloc_stats_print(void (*f)(void *, const char *), void *p, const char *n)
106 {
107 	__je_malloc_stats_print(f, p, n);
108 }
109 
110 size_t __je_malloc_usable_size(const void *);
111 size_t
112 malloc_usable_size(const void *p)
113 {
114     return __je_malloc_usable_size(p);
115 }
116 void (*__je_malloc_message_get(void))(void *, const char *);
117 void (*
118 malloc_message_get(void))(void *, const char *)
119 {
120 	return __je_malloc_message_get();
121 }
122 
123 void __je_malloc_message_set(void (*)(void *, const char *));
124 void
125 malloc_message_set(void (*m)(void *, const char *))
126 {
127 	__je_malloc_message_set(m);
128 }
129 
130 const char *__je_malloc_conf_get(void);
131 const char *
132 malloc_conf_get(void)
133 {
134 	return __je_malloc_conf_get();
135 }
136 
137 void __je_malloc_conf_set(const char *);
138 void malloc_conf_set(const char *m)
139 {
140 	__je_malloc_conf_set(m);
141 }
142