Remove everything to do with 'struct malloc_type' and the malloc link_set.
To make code in 'external' (etc) still compile, MALLOC_DECLARE() still has to generate something of type 'struct malloc_type *', with normal optimisation gcc generates a compile-time 0. MALLOC_DEFINE() and friends have no effect. Fix one or two places where the code would no longer compile.
This commit is contained in:
parent
346d105dac
commit
e05eb71de5
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: firmload.c,v 1.16 2010/11/24 16:31:12 dholland Exp $ */
|
||||
/* $NetBSD: firmload.c,v 1.17 2012/04/29 20:27:31 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: firmload.c,v 1.16 2010/11/24 16:31:12 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: firmload.c,v 1.17 2012/04/29 20:27:31 dsl Exp $");
|
||||
|
||||
/*
|
||||
* The firmload API provides an interface for device drivers to access
|
||||
|
@ -50,7 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: firmload.c,v 1.16 2010/11/24 16:31:12 dholland Exp $
|
|||
|
||||
#include <dev/firmload.h>
|
||||
|
||||
static MALLOC_DEFINE(M_DEVFIRM, "devfirm", "device firmware buffers");
|
||||
MALLOC_DEFINE(M_DEVFIRM, "devfirm", "device firmware buffers");
|
||||
|
||||
struct firmware_handle {
|
||||
struct vnode *fh_vp;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sbp.c,v 1.33 2010/08/14 10:39:33 cegger Exp $ */
|
||||
/* $NetBSD: sbp.c,v 1.34 2012/04/29 20:27:31 dsl Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2003 Hidetoshi Shimokawa
|
||||
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sbp.c,v 1.33 2010/08/14 10:39:33 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sbp.c,v 1.34 2012/04/29 20:27:31 dsl Exp $");
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -344,6 +344,7 @@ struct sbp_softc {
|
|||
};
|
||||
|
||||
MALLOC_DEFINE(M_SBP, "sbp", "SBP-II/IEEE1394");
|
||||
MALLOC_DECLARE(M_SBP);
|
||||
|
||||
|
||||
static int sbpmatch(device_t, cfdata_t, void *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: efs_ihash.c,v 1.8 2012/01/27 19:48:40 para Exp $ */
|
||||
/* $NetBSD: efs_ihash.c,v 1.9 2012/04/29 20:27:31 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
||||
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: efs_ihash.c,v 1.8 2012/01/27 19:48:40 para Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: efs_ihash.c,v 1.9 2012/04/29 20:27:31 dsl Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -70,8 +70,6 @@ static u_long ihash; /* size of hash table - 1 */
|
|||
static kmutex_t efs_ihash_lock;
|
||||
static kmutex_t efs_hashlock;
|
||||
|
||||
MALLOC_DECLARE(M_EFSINO);
|
||||
|
||||
/*
|
||||
* Initialize inode hash table.
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_malloc.c,v 1.140 2012/04/29 16:36:53 dsl Exp $ */
|
||||
/* $NetBSD: kern_malloc.c,v 1.141 2012/04/29 20:27:31 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1991, 1993
|
||||
|
@ -70,7 +70,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.140 2012/04/29 16:36:53 dsl Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.141 2012/04/29 20:27:31 dsl Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/malloc.h>
|
||||
|
@ -205,28 +205,10 @@ kern_realloc(void *curaddr, unsigned long newsize, int flags)
|
|||
return newaddr;
|
||||
}
|
||||
|
||||
void
|
||||
malloc_type_attach(struct malloc_type *type)
|
||||
{
|
||||
KASSERT(type->ks_magic == M_MAGIC);
|
||||
}
|
||||
|
||||
void
|
||||
malloc_type_detach(struct malloc_type *type)
|
||||
{
|
||||
KASSERT(type->ks_magic == M_MAGIC);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the kernel memory allocator
|
||||
*/
|
||||
void
|
||||
kmeminit(void)
|
||||
{
|
||||
__link_set_decl(malloc_types, struct malloc_type);
|
||||
struct malloc_type * const *ksp;
|
||||
|
||||
/* Attach all of the statically-linked malloc types. */
|
||||
__link_set_foreach(ksp, malloc_types)
|
||||
malloc_type_attach(*ksp);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: smb_conn.c,v 1.28 2012/03/13 18:41:01 elad Exp $ */
|
||||
/* $NetBSD: smb_conn.c,v 1.29 2012/04/29 20:27:31 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -61,7 +61,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: smb_conn.c,v 1.28 2012/03/13 18:41:01 elad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: smb_conn.c,v 1.29 2012/04/29 20:27:31 dsl Exp $");
|
||||
|
||||
/*
|
||||
* Connection engine.
|
||||
|
@ -90,6 +90,7 @@ static int smb_vcnext = 1; /* next unique id for VC */
|
|||
static kauth_listener_t smb_listener;
|
||||
|
||||
MALLOC_DEFINE(M_SMBCONN, "SMB conn", "SMB connection");
|
||||
MALLOC_DECLARE(M_SMBCONN);
|
||||
|
||||
static void smb_co_init(struct smb_connobj *cp, int level, const char *objname);
|
||||
static void smb_co_done(struct smb_connobj *cp);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: smb_dev.c,v 1.39 2010/12/17 14:27:34 pooka Exp $ */
|
||||
/* $NetBSD: smb_dev.c,v 1.40 2012/04/29 20:27:31 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000-2001 Boris Popov
|
||||
|
@ -35,7 +35,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: smb_dev.c,v 1.39 2010/12/17 14:27:34 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: smb_dev.c,v 1.40 2012/04/29 20:27:31 dsl Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
|
@ -73,7 +73,7 @@ static struct smb_dev **smb_devtbl; /* indexed by minor */
|
|||
#define NSMB_DEFNUM 4
|
||||
|
||||
|
||||
static MALLOC_DEFINE(M_NSMBDEV, "NETSMBDEV", "NET/SMB device");
|
||||
MALLOC_DEFINE(M_NSMBDEV, "NETSMBDEV", "NET/SMB device");
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: smb_iod.c,v 1.39 2010/12/17 13:05:29 pooka Exp $ */
|
||||
/* $NetBSD: smb_iod.c,v 1.40 2012/04/29 20:27:31 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000-2001 Boris Popov
|
||||
|
@ -35,7 +35,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: smb_iod.c,v 1.39 2010/12/17 13:05:29 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: smb_iod.c,v 1.40 2012/04/29 20:27:31 dsl Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -62,7 +62,8 @@ __KERNEL_RCSID(0, "$NetBSD: smb_iod.c,v 1.39 2010/12/17 13:05:29 pooka Exp $");
|
|||
|
||||
#define smb_iod_wakeup(iod) wakeup(&(iod)->iod_flags)
|
||||
|
||||
static MALLOC_DEFINE(M_SMBIOD, "SMBIOD", "SMB network io daemon");
|
||||
MALLOC_DEFINE(M_SMBIOD, "SMBIOD", "SMB network io daemon");
|
||||
MALLOC_DECLARE(M_SMBIOD);
|
||||
|
||||
static int smb_iod_next;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: memalloc.c,v 1.14 2012/04/29 16:36:53 dsl Exp $ */
|
||||
/* $NetBSD: memalloc.c,v 1.15 2012/04/29 20:27:32 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
|
||||
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: memalloc.c,v 1.14 2012/04/29 16:36:53 dsl Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: memalloc.c,v 1.15 2012/04/29 20:27:32 dsl Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kmem.h>
|
||||
|
@ -54,20 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: memalloc.c,v 1.14 2012/04/29 16:36:53 dsl Exp $");
|
|||
* malloc
|
||||
*/
|
||||
|
||||
void
|
||||
malloc_type_attach(struct malloc_type *type)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
malloc_type_detach(struct malloc_type *type)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void *
|
||||
kern_malloc(unsigned long size, int flags)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: malloc.h,v 1.112 2012/04/29 16:36:54 dsl Exp $ */
|
||||
/* $NetBSD: malloc.h,v 1.113 2012/04/29 20:27:32 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
|
@ -45,9 +45,13 @@
|
|||
#define M_CANFAIL 0x0004 /* can fail if requested memory can't ever
|
||||
* be allocated */
|
||||
#include <sys/mallocvar.h>
|
||||
#if 0
|
||||
/*
|
||||
* The following are standard, built-in malloc types that are
|
||||
* not specific to any one subsystem.
|
||||
*
|
||||
* They are currently not defined, but are still passed to malloc()
|
||||
* and free(). They may be re-instated as diagnostics at some point.
|
||||
*/
|
||||
MALLOC_DECLARE(M_DEVBUF);
|
||||
MALLOC_DECLARE(M_DMAMAP);
|
||||
|
@ -62,6 +66,7 @@ MALLOC_DECLARE(M_IPMOPTS);
|
|||
MALLOC_DECLARE(M_IPMADDR);
|
||||
MALLOC_DECLARE(M_MRTABLE);
|
||||
MALLOC_DECLARE(M_BWMETER);
|
||||
#endif
|
||||
|
||||
void *kern_malloc(unsigned long, int);
|
||||
void *kern_realloc(void *, unsigned long, int);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mallocvar.h,v 1.11 2012/04/28 23:03:40 rmind Exp $ */
|
||||
/* $NetBSD: mallocvar.h,v 1.12 2012/04/29 20:27:32 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
|
@ -36,56 +36,29 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define M_MAGIC 877983977
|
||||
|
||||
#define MAXBUCKET 15
|
||||
/*
|
||||
* This structure describes a type of malloc'd memory and carries
|
||||
* allocation statistics for that memory.
|
||||
*/
|
||||
struct malloc_type {
|
||||
struct malloc_type *ks_next; /* next in list */
|
||||
u_long ks_magic; /* indicates valid structure */
|
||||
const char *ks_shortdesc;/* short description */
|
||||
|
||||
/* Statistics */
|
||||
u_long ks_inuse; /* # of packets of this type currently in use */
|
||||
u_long ks_calls; /* total packets of this type ever allocated */
|
||||
u_long ks_memuse; /* total memory held in bytes */
|
||||
u_short ks_limblocks; /* number of times blocked for hitting limit */
|
||||
u_short ks_mapblocks; /* number of times blocked for kernel map */
|
||||
u_long ks_maxused; /* maximum number ever used */
|
||||
u_long ks_limit; /* most that are allowed to exist */
|
||||
u_long ks_size; /* sizes of this thing that are allocated */
|
||||
u_int ks_active[MAXBUCKET+1]; /* number of active allocations per size */
|
||||
};
|
||||
struct malloc_type;
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define MALLOC_JUSTDEFINE_LIMIT(type, shortdesc, longdesc, limit) \
|
||||
struct malloc_type type[1] = { \
|
||||
[0] = { \
|
||||
.ks_magic = M_MAGIC, \
|
||||
.ks_shortdesc = shortdesc, \
|
||||
.ks_limit = limit, \
|
||||
}, \
|
||||
};
|
||||
#define MALLOC_JUSTDEFINE_LIMIT(type, shortdesc, longdesc, limit)
|
||||
|
||||
#define MALLOC_JUSTDEFINE(type, shortdesc, longdesc) \
|
||||
MALLOC_JUSTDEFINE_LIMIT(type, shortdesc, longdesc, 0)
|
||||
|
||||
#define MALLOC_DEFINE_LIMIT(type, shortdesc, longdesc, limit) \
|
||||
MALLOC_JUSTDEFINE_LIMIT(type, shortdesc, longdesc, limit) \
|
||||
__link_set_add_data(malloc_types, type)
|
||||
MALLOC_JUSTDEFINE_LIMIT(type, shortdesc, longdesc, limit)
|
||||
|
||||
#define MALLOC_DEFINE(type, shortdesc, longdesc) \
|
||||
MALLOC_DEFINE_LIMIT(type, shortdesc, longdesc, 0)
|
||||
|
||||
#define MALLOC_DECLARE(type) \
|
||||
extern struct malloc_type type[1]
|
||||
|
||||
void malloc_type_attach(struct malloc_type *);
|
||||
void malloc_type_detach(struct malloc_type *);
|
||||
static struct malloc_type *const __unused type = 0
|
||||
|
||||
#define malloc_type_attach(malloc_type)
|
||||
#define malloc_type_detach(malloc_type)
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _SYS_MALLOCVAR_H_ */
|
||||
|
|
Loading…
Reference in New Issue