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