tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Where's 9.1's malloc?



On Fri, May 15, 2026 at 09:11:35AM -0400, Mouse wrote:
> Where is the source for 9.1's malloc implementation?

See lib/libc/README:

   In the implementation of libc, malloc and free are defined normally
   in src/lib/libc/stdlib/jemalloc.c:

and:

lib/libc/stdlib/Makefile.inc:

.if ${RUMPRUN} != "yes"
.   if (${USE_JEMALLOC} != "no")
.      if ${HAVE_JEMALLOC} > 100
.         include "${NETBSDSRCDIR}/external/bsd/jemalloc/lib/Makefile.inc"
.      else
SRCS+=  jemalloc.c aligned_alloc.c
.      endif
.   else
SRCS+=  malloc.c
.   endif
.endif

Then look at share/mk/bsd.own.mk for the default of HAVE_JEMALLOC:

#
# What version of jemalloc we use (100 is the one
# built-in to libc from 2005 (pre version 3).
#
HAVE_JEMALLOC?=         510

and the final piece is pretty much hidden in distrib/utils/libhack/Makefile.inc
where the smaller (ancient) version from lib/libc/stdlib/jemalloc.c
gets used for environments where binary size needs to be absolutely minimal.

So much for netbsd-9.

We do use the old (small) version on some architectures in newer branches,
e.g. the bsd.own.mk from netbsd-10 and netbsd-11 both have:

#
# What version of jemalloc we use (100 is the one
# built-in to libc from 2005 (pre version 3).
#
.if ${MACHINE_ARCH} == "vax" || ${MACHINE} == "sun2"
HAVE_JEMALLOC?=         100
.else
HAVE_JEMALLOC?=         510
.endif



Martin


Home | Main Index | Thread Index | Old Index