115c4125cSchristos /*-
215c4125cSchristos * Copyright (c) 2019 The NetBSD Foundation, Inc.
315c4125cSchristos * All rights reserved.
415c4125cSchristos *
515c4125cSchristos * This code is derived from software contributed to The NetBSD Foundation
615c4125cSchristos * by Christos Zoulas.
715c4125cSchristos *
815c4125cSchristos * Redistribution and use in source and binary forms, with or without
915c4125cSchristos * modification, are permitted provided that the following conditions
1015c4125cSchristos * are met:
1115c4125cSchristos * 1. Redistributions of source code must retain the above copyright
1215c4125cSchristos * notice, this list of conditions and the following disclaimer.
1315c4125cSchristos * 2. Redistributions in binary form must reproduce the above copyright
1415c4125cSchristos * notice, this list of conditions and the following disclaimer in the
1515c4125cSchristos * documentation and/or other materials provided with the distribution.
1615c4125cSchristos *
1715c4125cSchristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1815c4125cSchristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1915c4125cSchristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2015c4125cSchristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2115c4125cSchristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2215c4125cSchristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2315c4125cSchristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2415c4125cSchristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2515c4125cSchristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2615c4125cSchristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2715c4125cSchristos * POSSIBILITY OF SUCH DAMAGE.
2815c4125cSchristos */
29aff4e455Srin
30a2b12303Srin #if HAVE_JEMALLOC > 100
3115c4125cSchristos #include <malloc.h>
3215c4125cSchristos
3315c4125cSchristos void *__je_mallocx(size_t, int);
3415c4125cSchristos void *
mallocx(size_t l,int f)3515c4125cSchristos mallocx(size_t l, int f)
3615c4125cSchristos {
3715c4125cSchristos return __je_mallocx(l, f);
3815c4125cSchristos }
3915c4125cSchristos
4015c4125cSchristos void *__je_rallocx(void *, size_t, int);
4115c4125cSchristos void *
rallocx(void * p,size_t l,int f)4215c4125cSchristos rallocx(void *p, size_t l, int f)
4315c4125cSchristos {
4415c4125cSchristos return __je_rallocx(p, l, f);
4515c4125cSchristos }
4615c4125cSchristos
4715c4125cSchristos size_t __je_xallocx(void *, size_t, size_t, int);
4815c4125cSchristos size_t
xallocx(void * p,size_t l,size_t s,int f)4915c4125cSchristos xallocx(void *p, size_t l, size_t s, int f)
5015c4125cSchristos {
5115c4125cSchristos return __je_xallocx(p, l, s, f);
5215c4125cSchristos }
5315c4125cSchristos
5415c4125cSchristos size_t __je_sallocx(const void *, int);
5515c4125cSchristos size_t
sallocx(const void * p,int f)5615c4125cSchristos sallocx(const void *p, int f)
5715c4125cSchristos {
5815c4125cSchristos return __je_sallocx(p, f);
5915c4125cSchristos }
6015c4125cSchristos
6115c4125cSchristos void __je_dallocx(void *, int);
6215c4125cSchristos void
dallocx(void * p,int f)6315c4125cSchristos dallocx(void *p, int f)
6415c4125cSchristos {
6515c4125cSchristos __je_dallocx(p, f);
6615c4125cSchristos }
6715c4125cSchristos
6815c4125cSchristos void __je_sdallocx(void *, size_t, int);
6915c4125cSchristos void
sdallocx(void * p,size_t l,int f)7015c4125cSchristos sdallocx(void *p, size_t l, int f)
7115c4125cSchristos {
7215c4125cSchristos __je_sdallocx(p, l, f);
7315c4125cSchristos }
7415c4125cSchristos
7515c4125cSchristos size_t __je_nallocx(size_t, int);
7615c4125cSchristos size_t
nallocx(size_t l,int f)7715c4125cSchristos nallocx(size_t l, int f)
7815c4125cSchristos {
7915c4125cSchristos return __je_nallocx(l, f);
8015c4125cSchristos }
8115c4125cSchristos
8215c4125cSchristos int __je_mallctl(const char *, void *, size_t *, void *, size_t);
8315c4125cSchristos int
mallctl(const char * n,void * p,size_t * s,void * v,size_t l)8415c4125cSchristos mallctl(const char *n, void *p, size_t *s, void *v, size_t l)
8515c4125cSchristos {
8615c4125cSchristos return __je_mallctl(n, p, s, v, l);
8715c4125cSchristos }
8815c4125cSchristos
8915c4125cSchristos int __je_mallctlnametomib(const char *, size_t *, size_t *);
9015c4125cSchristos int
mallctlnametomib(const char * n,size_t * l,size_t * s)9115c4125cSchristos mallctlnametomib(const char *n, size_t *l, size_t *s)
9215c4125cSchristos {
9315c4125cSchristos return __je_mallctlnametomib(n, l, s);
9415c4125cSchristos }
9515c4125cSchristos
9615c4125cSchristos int __je_mallctlbymib(const size_t *, size_t, void *, size_t *, void *, size_t);
9715c4125cSchristos int
mallctlbymib(const size_t * sp,size_t s,void * p,size_t * dp,void * r,size_t l)9815c4125cSchristos mallctlbymib(const size_t *sp, size_t s, void *p , size_t *dp, void *r ,
9915c4125cSchristos size_t l)
10015c4125cSchristos {
10115c4125cSchristos return __je_mallctlbymib(sp, s, p , dp, r, l);
10215c4125cSchristos }
10315c4125cSchristos
10415c4125cSchristos void __je_malloc_stats_print(void (*)(void *, const char *), void *,
10515c4125cSchristos const char *);
10615c4125cSchristos void
malloc_stats_print(void (* f)(void *,const char *),void * p,const char * n)10715c4125cSchristos malloc_stats_print(void (*f)(void *, const char *), void *p, const char *n)
10815c4125cSchristos {
10915c4125cSchristos __je_malloc_stats_print(f, p, n);
11015c4125cSchristos }
11115c4125cSchristos
11215c4125cSchristos size_t __je_malloc_usable_size(const void *);
11315c4125cSchristos size_t
malloc_usable_size(const void * p)11415c4125cSchristos malloc_usable_size(const void *p)
11515c4125cSchristos {
11615c4125cSchristos return __je_malloc_usable_size(p);
11715c4125cSchristos }
11815c4125cSchristos void (*__je_malloc_message_get(void))(void *, const char *);
11915c4125cSchristos void (*
malloc_message_get(void)12015c4125cSchristos malloc_message_get(void))(void *, const char *)
12115c4125cSchristos {
12215c4125cSchristos return __je_malloc_message_get();
12315c4125cSchristos }
12415c4125cSchristos
12515c4125cSchristos void __je_malloc_message_set(void (*)(void *, const char *));
12615c4125cSchristos void
malloc_message_set(void (* m)(void *,const char *))12715c4125cSchristos malloc_message_set(void (*m)(void *, const char *))
12815c4125cSchristos {
12915c4125cSchristos __je_malloc_message_set(m);
13015c4125cSchristos }
13115c4125cSchristos
13215c4125cSchristos const char *__je_malloc_conf_get(void);
13315c4125cSchristos const char *
malloc_conf_get(void)13415c4125cSchristos malloc_conf_get(void)
13515c4125cSchristos {
13615c4125cSchristos return __je_malloc_conf_get();
13715c4125cSchristos }
13815c4125cSchristos
13915c4125cSchristos void __je_malloc_conf_set(const char *);
malloc_conf_set(const char * m)14015c4125cSchristos void malloc_conf_set(const char *m)
14115c4125cSchristos {
14215c4125cSchristos __je_malloc_conf_set(m);
14315c4125cSchristos }
144*7cacb676Srin #endif /* HAVE_JEMALLOC > 100 */
145