head	1.7;
access;
symbols
	netbsd-11-0-RC5:1.7
	netbsd-11-0-RC4:1.7
	netbsd-11-0-RC3:1.7
	netbsd-11-0-RC2:1.7
	netbsd-11-0-RC1:1.7
	perseant-exfatfs-base-20250801:1.7
	netbsd-11:1.7.0.4
	netbsd-11-base:1.7
	netbsd-10-1-RELEASE:1.4
	perseant-exfatfs-base-20240630:1.7
	perseant-exfatfs:1.7.0.2
	perseant-exfatfs-base:1.7
	netbsd-8-3-RELEASE:1.4
	netbsd-9-4-RELEASE:1.4
	netbsd-10-0-RELEASE:1.4
	netbsd-10-0-RC6:1.4
	netbsd-10-0-RC5:1.4
	netbsd-10-0-RC4:1.4
	netbsd-10-0-RC3:1.4
	netbsd-10-0-RC2:1.4
	netbsd-10-0-RC1:1.4
	netbsd-10:1.4.0.42
	netbsd-10-base:1.4
	netbsd-9-3-RELEASE:1.4
	cjep_sun2x-base1:1.4
	cjep_sun2x:1.4.0.40
	cjep_sun2x-base:1.4
	cjep_staticlib_x-base1:1.4
	netbsd-9-2-RELEASE:1.4
	cjep_staticlib_x:1.4.0.38
	cjep_staticlib_x-base:1.4
	netbsd-9-1-RELEASE:1.4
	phil-wifi-20200421:1.4
	phil-wifi-20200411:1.4
	is-mlppp:1.4.0.36
	is-mlppp-base:1.4
	phil-wifi-20200406:1.4
	netbsd-8-2-RELEASE:1.4
	netbsd-9-0-RELEASE:1.4
	netbsd-9-0-RC2:1.4
	netbsd-9-0-RC1:1.4
	phil-wifi-20191119:1.4
	netbsd-9:1.4.0.34
	netbsd-9-base:1.4
	phil-wifi-20190609:1.4
	netbsd-8-1-RELEASE:1.4
	netbsd-8-1-RC1:1.4
	pgoyette-compat-merge-20190127:1.4
	pgoyette-compat-20190127:1.4
	pgoyette-compat-20190118:1.4
	pgoyette-compat-1226:1.4
	pgoyette-compat-1126:1.4
	pgoyette-compat-1020:1.4
	pgoyette-compat-0930:1.4
	pgoyette-compat-0906:1.4
	netbsd-7-2-RELEASE:1.4
	pgoyette-compat-0728:1.4
	netbsd-8-0-RELEASE:1.4
	phil-wifi:1.4.0.32
	phil-wifi-base:1.4
	pgoyette-compat-0625:1.4
	netbsd-8-0-RC2:1.4
	pgoyette-compat-0521:1.4
	pgoyette-compat-0502:1.4
	pgoyette-compat-0422:1.4
	netbsd-8-0-RC1:1.4
	pgoyette-compat-0415:1.4
	pgoyette-compat-0407:1.4
	pgoyette-compat-0330:1.4
	pgoyette-compat-0322:1.4
	pgoyette-compat-0315:1.4
	netbsd-7-1-2-RELEASE:1.4
	pgoyette-compat:1.4.0.30
	pgoyette-compat-base:1.4
	netbsd-7-1-1-RELEASE:1.4
	matt-nb8-mediatek:1.4.0.28
	matt-nb8-mediatek-base:1.4
	perseant-stdc-iso10646:1.4.0.26
	perseant-stdc-iso10646-base:1.4
	netbsd-8:1.4.0.24
	netbsd-8-base:1.4
	prg-localcount2-base3:1.4
	prg-localcount2-base2:1.4
	prg-localcount2-base1:1.4
	prg-localcount2:1.4.0.22
	prg-localcount2-base:1.4
	pgoyette-localcount-20170426:1.4
	bouyer-socketcan-base1:1.4
	pgoyette-localcount-20170320:1.4
	netbsd-7-1:1.4.0.20
	netbsd-7-1-RELEASE:1.4
	netbsd-7-1-RC2:1.4
	netbsd-7-nhusb-base-20170116:1.4
	bouyer-socketcan:1.4.0.18
	bouyer-socketcan-base:1.4
	pgoyette-localcount-20170107:1.4
	netbsd-7-1-RC1:1.4
	pgoyette-localcount-20161104:1.4
	netbsd-7-0-2-RELEASE:1.4
	localcount-20160914:1.4
	netbsd-7-nhusb:1.4.0.16
	netbsd-7-nhusb-base:1.4
	pgoyette-localcount-20160806:1.4
	pgoyette-localcount-20160726:1.4
	pgoyette-localcount:1.4.0.14
	pgoyette-localcount-base:1.4
	netbsd-7-0-1-RELEASE:1.4
	netbsd-7-0:1.4.0.12
	netbsd-7-0-RELEASE:1.4
	netbsd-7-0-RC3:1.4
	netbsd-7-0-RC2:1.4
	netbsd-7-0-RC1:1.4
	netbsd-5-2-3-RELEASE:1.2
	netbsd-5-1-5-RELEASE:1.2
	netbsd-6-0-6-RELEASE:1.3
	netbsd-6-1-5-RELEASE:1.3
	netbsd-7:1.4.0.10
	netbsd-7-base:1.4
	yamt-pagecache-base9:1.4
	yamt-pagecache-tag8:1.3.4.1
	netbsd-6-1-4-RELEASE:1.3
	netbsd-6-0-5-RELEASE:1.3
	tls-earlyentropy:1.4.0.8
	tls-earlyentropy-base:1.4
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.4
	riastradh-drm2-base3:1.4
	netbsd-6-1-3-RELEASE:1.3
	netbsd-6-0-4-RELEASE:1.3
	netbsd-5-2-2-RELEASE:1.2
	netbsd-5-1-4-RELEASE:1.2
	netbsd-6-1-2-RELEASE:1.3
	netbsd-6-0-3-RELEASE:1.3
	netbsd-5-2-1-RELEASE:1.2
	netbsd-5-1-3-RELEASE:1.2
	netbsd-6-1-1-RELEASE:1.3
	riastradh-drm2-base2:1.4
	riastradh-drm2-base1:1.4
	riastradh-drm2:1.4.0.4
	riastradh-drm2-base:1.4
	netbsd-6-1:1.3.0.12
	netbsd-6-0-2-RELEASE:1.3
	netbsd-6-1-RELEASE:1.3
	netbsd-6-1-RC4:1.3
	netbsd-6-1-RC3:1.3
	agc-symver:1.4.0.6
	agc-symver-base:1.4
	netbsd-6-1-RC2:1.3
	netbsd-6-1-RC1:1.3
	yamt-pagecache-base8:1.4
	netbsd-5-2:1.2.0.52
	netbsd-6-0-1-RELEASE:1.3
	yamt-pagecache-base7:1.4
	netbsd-5-2-RELEASE:1.2
	netbsd-5-2-RC1:1.2
	matt-nb6-plus-nbase:1.3
	yamt-pagecache-base6:1.4
	netbsd-6-0:1.3.0.10
	netbsd-6-0-RELEASE:1.3
	netbsd-6-0-RC2:1.3
	tls-maxphys:1.4.0.2
	tls-maxphys-base:1.4
	matt-nb6-plus:1.3.0.8
	matt-nb6-plus-base:1.3
	netbsd-6-0-RC1:1.3
	yamt-pagecache-base5:1.4
	yamt-pagecache-base4:1.4
	netbsd-6:1.3.0.6
	netbsd-6-base:1.3
	netbsd-5-1-2-RELEASE:1.2
	netbsd-5-1-1-RELEASE:1.2
	yamt-pagecache-base3:1.3
	yamt-pagecache-base2:1.3
	yamt-pagecache:1.3.0.4
	yamt-pagecache-base:1.3
	cherry-xenmp:1.3.0.2
	cherry-xenmp-base:1.3
	bouyer-quota2-nbase:1.2
	bouyer-quota2:1.2.0.50
	bouyer-quota2-base:1.2
	matt-mips64-premerge-20101231:1.2
	matt-nb5-mips64-premerge-20101231:1.2
	matt-nb5-pq3:1.2.0.48
	matt-nb5-pq3-base:1.2
	netbsd-5-1:1.2.0.46
	netbsd-5-1-RELEASE:1.2
	netbsd-5-1-RC4:1.2
	matt-nb5-mips64-k15:1.2
	netbsd-5-1-RC3:1.2
	netbsd-5-1-RC2:1.2
	netbsd-5-1-RC1:1.2
	netbsd-5-0-2-RELEASE:1.2
	matt-nb5-mips64-premerge-20091211:1.2
	matt-premerge-20091211:1.2
	matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.2
	matt-nb4-mips64-k7-u2a-k9b:1.2
	matt-nb5-mips64-u1-k1-k5:1.2
	matt-nb5-mips64:1.2.0.44
	netbsd-5-0-1-RELEASE:1.2
	jym-xensuspend-nbase:1.2
	netbsd-5-0:1.2.0.42
	netbsd-5-0-RELEASE:1.2
	netbsd-5-0-RC4:1.2
	netbsd-5-0-RC3:1.2
	netbsd-5-0-RC2:1.2
	jym-xensuspend:1.2.0.40
	jym-xensuspend-base:1.2
	netbsd-5-0-RC1:1.2
	netbsd-5:1.2.0.38
	netbsd-5-base:1.2
	matt-mips64-base2:1.2
	matt-mips64:1.2.0.36
	mjf-devfs2:1.2.0.34
	mjf-devfs2-base:1.2
	netbsd-4-0-1-RELEASE:1.2
	wrstuden-revivesa-base-3:1.2
	wrstuden-revivesa-base-2:1.2
	wrstuden-fixsa-newbase:1.2
	wrstuden-revivesa-base-1:1.2
	yamt-pf42-base4:1.2
	yamt-pf42-base3:1.2
	hpcarm-cleanup-nbase:1.2
	yamt-pf42-baseX:1.2
	yamt-pf42-base2:1.2
	wrstuden-revivesa:1.2.0.32
	wrstuden-revivesa-base:1.2
	yamt-pf42:1.2.0.30
	yamt-pf42-base:1.2
	keiichi-mipv6:1.2.0.28
	keiichi-mipv6-base:1.2
	matt-armv6-nbase:1.2
	matt-armv6-prevmlocking:1.2
	wrstuden-fixsa-base-1:1.2
	netbsd-4-0:1.2.0.26
	netbsd-4-0-RELEASE:1.2
	cube-autoconf:1.2.0.24
	cube-autoconf-base:1.2
	netbsd-4-0-RC5:1.2
	netbsd-4-0-RC4:1.2
	netbsd-4-0-RC3:1.2
	netbsd-4-0-RC2:1.2
	netbsd-4-0-RC1:1.2
	matt-armv6:1.2.0.22
	matt-armv6-base:1.2
	matt-mips64-base:1.2
	hpcarm-cleanup:1.2.0.20
	hpcarm-cleanup-base:1.2
	netbsd-3-1-1-RELEASE:1.2
	netbsd-3-0-3-RELEASE:1.2
	wrstuden-fixsa:1.2.0.18
	wrstuden-fixsa-base:1.2
	abandoned-netbsd-4-base:1.2
	abandoned-netbsd-4:1.2.0.12
	netbsd-3-1:1.2.0.14
	netbsd-3-1-RELEASE:1.2
	netbsd-3-0-2-RELEASE:1.2
	netbsd-3-1-RC4:1.2
	netbsd-3-1-RC3:1.2
	netbsd-3-1-RC2:1.2
	netbsd-3-1-RC1:1.2
	netbsd-4:1.2.0.16
	netbsd-4-base:1.2
	netbsd-3-0-1-RELEASE:1.2
	netbsd-3-0:1.2.0.10
	netbsd-3-0-RELEASE:1.2
	netbsd-3-0-RC6:1.2
	netbsd-3-0-RC5:1.2
	netbsd-3-0-RC4:1.2
	netbsd-3-0-RC3:1.2
	netbsd-3-0-RC2:1.2
	netbsd-3-0-RC1:1.2
	netbsd-2-0-3-RELEASE:1.2
	netbsd-2-1:1.2.0.8
	netbsd-2-1-RELEASE:1.2
	netbsd-2-1-RC6:1.2
	netbsd-2-1-RC5:1.2
	netbsd-2-1-RC4:1.2
	netbsd-2-1-RC3:1.2
	netbsd-2-1-RC2:1.2
	netbsd-2-1-RC1:1.2
	netbsd-2-0-2-RELEASE:1.2
	netbsd-3:1.2.0.6
	netbsd-3-base:1.2
	netbsd-2-0-1-RELEASE:1.2
	netbsd-2:1.2.0.4
	netbsd-2-base:1.2
	netbsd-2-0-RELEASE:1.2
	netbsd-2-0-RC5:1.2
	netbsd-2-0-RC4:1.2
	netbsd-2-0-RC3:1.2
	netbsd-2-0-RC2:1.2
	netbsd-2-0-RC1:1.2
	netbsd-2-0:1.2.0.2
	netbsd-2-0-base:1.2;
locks; strict;
comment	@# @;


1.7
date	2023.07.04.18.40.14;	author riastradh;	state Exp;
branches;
next	1.6;
commitid	TVuXJ6Y341q33wvE;

1.6
date	2023.07.04.16.23.15;	author riastradh;	state Exp;
branches;
next	1.5;
commitid	Mj4cTTgCmLa0ivvE;

1.5
date	2023.07.04.15.08.55;	author riastradh;	state Exp;
branches;
next	1.4;
commitid	lmROmdE4PftySuvE;

1.4
date	2012.03.21.10.08.30;	author matt;	state Exp;
branches
	1.4.42.1;
next	1.3;

1.3
date	2011.04.10.16.47.39;	author joerg;	state Exp;
branches
	1.3.4.1;
next	1.2;

1.2
date	2003.07.10.11.27.45;	author lukem;	state Exp;
branches;
next	1.1;

1.1
date	2003.04.21.22.21.06;	author elric;	state Exp;
branches;
next	;

1.4.42.1
date	2026.06.27.19.13.11;	author martin;	state Exp;
branches;
next	;
commitid	lW5u4UMslbp4etLG;

1.3.4.1
date	2012.04.17.00.05.12;	author yamt;	state Exp;
branches;
next	;


desc
@@


1.7
log
@libbsdmalloc: Nix K&R definitions.  Bump WARNS to 3.
@
text
@# $NetBSD: Makefile,v 1.6 2023/07/04 16:23:15 riastradh Exp $

WARNS=	3

.include <bsd.own.mk>

LIB=	bsdmalloc
SRCS=	malloc.c
MAN=	bsdmalloc.3

CFLAGS+=	-fno-builtin-aligned_alloc
CFLAGS+=	-fno-builtin-calloc
CFLAGS+=	-fno-builtin-free
CFLAGS+=	-fno-builtin-malloc
CFLAGS+=	-fno-builtin-posix_memalign
CFLAGS+=	-fno-builtin-realloc

CPPFLAGS+= -D_REENT -D_REENTRANT -I${.CURDIR}/../libc/include/

.include <bsd.lib.mk>
@


1.6
log
@libbsdmalloc: New man page.

XXX pullup-10
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.5 2023/07/04 15:08:55 riastradh Exp $
d3 1
a3 1
WARNS=	2
@


1.5
log
@libbsdmalloc: Provide all allocator front ends and fork hooks.

Front ends:

- aligned_alloc
- calloc
- posix_memalign

Fork hooks:

- _malloc_prefork
- _malloc_postfork
- _malloc_postfork_child

Otherwise these will pull in the jemalloc definitions from libc,
which (a) defeats the purpose, and (b) won't work correctly with
fork and threads.

Thanks to kre@@ and the thread on tech-userlevel for pointing me in
the right direction to making this actually work to override
jemalloc:

https://mail-index.netbsd.org/tech-userlevel/2023/06/30/msg013957.html

Note: libbsdmalloc doesn't set errno=ENOMEM on malloc failure, but
these front ends do (even aligned_alloc, which is from C11, which
doesn't define ENOMEM at all, but this pacifies our aligned_alloc
tests in t_posix_memalign.c).  Might want to fix that.

XXX pullup-10
@
text
@d1 1
a1 3
# $NetBSD: Makefile,v 1.4 2012/03/21 10:08:30 matt Exp $

NOMAN=1
d9 1
@


1.4
log
@These directories don't handle WARNS=5
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.3 2011/04/10 16:47:39 joerg Exp $
d12 7
@


1.4.42.1
log
@Pull up following revision(s) (requested by riastradh in ticket #1286):

	lib/libbsdmalloc/bsdmalloc.3: revision 1.1
	lib/libbsdmalloc/bsdmalloc.3: revision 1.2
	lib/libbsdmalloc/bsdmalloc.3: revision 1.3
	distrib/sets/lists/base/shl.mi: revision 1.952
	tests/lib/libc/stdlib/t_posix_memalign.c: revision 1.8
	lib/libbsdmalloc/malloc.c: revision 1.3
	lib/libbsdmalloc/malloc.c: revision 1.4
	lib/libbsdmalloc/malloc.c: revision 1.5
	lib/libbsdmalloc/malloc.c: revision 1.10
	lib/libbsdmalloc/malloc.c: revision 1.6
	lib/libbsdmalloc/malloc.c: revision 1.11
	lib/libbsdmalloc/malloc.c: revision 1.7
	lib/libbsdmalloc/malloc.c: revision 1.8
	lib/libbsdmalloc/malloc.c: revision 1.9
	lib/libbsdmalloc/shlib_version: revision 1.2
	distrib/sets/lists/debug/shl.mi: revision 1.313
	distrib/sets/lists/comp/mi: revision 1.2434
	lib/libbsdmalloc/Makefile: revision 1.5
	lib/libbsdmalloc/Makefile: revision 1.6
	lib/libbsdmalloc/Makefile: revision 1.7
	(all via patch)


libbsdmalloc: Provide all allocator front ends and fork hooks.

Front ends:
- aligned_alloc
- calloc
- posix_memalign

Fork hooks:
- _malloc_prefork
- _malloc_postfork
- _malloc_postfork_child

Otherwise these will pull in the jemalloc definitions from libc,
which (a) defeats the purpose, and (b) won't work correctly with
fork and threads.

Thanks to kre@@ and the thread on tech-userlevel for pointing me in
the right direction to making this actually work to override
jemalloc:
https://mail-index.netbsd.org/tech-userlevel/2023/06/30/msg013957.html

Note: libbsdmalloc doesn't set errno=ENOMEM on malloc failure, but
these front ends do (even aligned_alloc, which is from C11, which
doesn't define ENOMEM at all, but this pacifies our aligned_alloc
tests in t_posix_memalign.c).  Might want to fix that.

libbsdmalloc: Nix trailing whitespace.
No functional change intended.

libbsdmalloc: Bump shlib minor.
New symbols, new minor.

libbsdmalloc: New man page.

libbsdmalloc: Nix K&R definitions.  Bump WARNS to 3.

libbsdmalloc: Fix build with DEBUG.
Nix __P while here.

bsdmalloc.3: fix typos in function parameters
libbsdmalloc: Lift C11 divisibility restriction on aligned_alloc.
Restriction was lifted in C17.

libbsdmalloc: Make aligned_alloc(A, S) actually align when A > S.

t_posix_memalign: Simplify.
No functional change intended.

libbsdmalloc: Use a multiply-overflow that clang supports too.

bsdmalloc(3): fix malloc() signature

Make mstats() decl match prototype so this compiles with -DMSTATS.

libbsdmalloc: Fix sense of assertion in aligned_alloc.
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.7 2023/07/04 18:40:14 riastradh Exp $
d3 3
a5 1
WARNS=	3
a10 8
MAN=	bsdmalloc.3

CFLAGS+=	-fno-builtin-aligned_alloc
CFLAGS+=	-fno-builtin-calloc
CFLAGS+=	-fno-builtin-free
CFLAGS+=	-fno-builtin-malloc
CFLAGS+=	-fno-builtin-posix_memalign
CFLAGS+=	-fno-builtin-realloc
@


1.3
log
@Define _REENT. Extend CPPFLAGS.
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.2 2003/07/10 11:27:45 lukem Exp $
d5 2
@


1.3.4.1
log
@sync with head
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.3 2011/04/10 16:47:39 joerg Exp $
a4 2
WARNS=	2

@


1.2
log
@NOxxx= variables must appear before <bsd.own.mk>
@
text
@d1 1
a1 1
# $NetBSD: Makefile,v 1.1 2003/04/21 22:21:06 elric Exp $
d10 1
a10 2
CPPFLAGS= -D_REENTRANT
CPPFLAGS= -I${.CURDIR}/../libc/include/
@


1.1
log
@Adding libbsdmalloc which is Chris Kingsley's `power of two bucket' malloc.

Suggested by christos.
@
text
@d1 3
a3 1
# $NetBSD: Makefile,v 1.10 2002/08/29 01:31:27 itojun Exp $
a11 2

NOMAN=1
@

