The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/bsd/sys/malloc.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_LICENSE_HEADER_START@
    5  * 
    6  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
    7  * 
    8  * This file contains Original Code and/or Modifications of Original Code
    9  * as defined in and that are subject to the Apple Public Source License
   10  * Version 2.0 (the 'License'). You may not use this file except in
   11  * compliance with the License. Please obtain a copy of the License at
   12  * http://www.opensource.apple.com/apsl/ and read it before using this
   13  * file.
   14  * 
   15  * The Original Code and all software distributed under the License are
   16  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   17  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   18  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   19  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   20  * Please see the License for the specific language governing rights and
   21  * limitations under the License.
   22  * 
   23  * @APPLE_LICENSE_HEADER_END@
   24  */
   25 /* Copyright (c) 1998, 1999 Apple Computer, Inc. All Rights Reserved */
   26 /* Copyright (c) 1995, 1997 Apple Computer, Inc. All Rights Reserved */
   27 /*
   28  * Copyright (c) 1987, 1993
   29  *      The Regents of the University of California.  All rights reserved.
   30  *
   31  * Redistribution and use in source and binary forms, with or without
   32  * modification, are permitted provided that the following conditions
   33  * are met:
   34  * 1. Redistributions of source code must retain the above copyright
   35  *    notice, this list of conditions and the following disclaimer.
   36  * 2. Redistributions in binary form must reproduce the above copyright
   37  *    notice, this list of conditions and the following disclaimer in the
   38  *    documentation and/or other materials provided with the distribution.
   39  * 3. All advertising materials mentioning features or use of this software
   40  *    must display the following acknowledgement:
   41  *      This product includes software developed by the University of
   42  *      California, Berkeley and its contributors.
   43  * 4. Neither the name of the University nor the names of its contributors
   44  *    may be used to endorse or promote products derived from this software
   45  *    without specific prior written permission.
   46  *
   47  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   48  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   49  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   50  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   51  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   52  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   53  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   54  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   55  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   56  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   57  * SUCH DAMAGE.
   58  *
   59  *      @(#)malloc.h    8.5 (Berkeley) 5/3/95
   60  */
   61 
   62 #ifndef _SYS_MALLOC_H_
   63 #define _SYS_MALLOC_H_
   64 
   65 #include <sys/appleapiopts.h>
   66 
   67 #define KMEMSTATS
   68 
   69 /*
   70  * flags to malloc
   71  */
   72 #define M_WAITOK        0x0000
   73 #define M_NOWAIT        0x0001
   74 #define M_ZERO          0x0004          /* bzero the allocation */
   75 
   76 /*
   77  * Types of memory to be allocated (not all are used by us)
   78  */
   79 #define M_FREE          0       /* should be on free list */
   80 #define M_MBUF          1       /* mbuf */
   81 #define M_DEVBUF        2       /* device driver memory */
   82 #define M_SOCKET        3       /* socket structure */
   83 #define M_PCB           4       /* protocol control block */
   84 #define M_RTABLE        5       /* routing tables */
   85 #define M_HTABLE        6       /* IMP host tables */
   86 #define M_FTABLE        7       /* fragment reassembly header */
   87 #define M_ZOMBIE        8       /* zombie proc status */
   88 #define M_IFADDR        9       /* interface address */
   89 #define M_SOOPTS        10      /* socket options */
   90 #define M_SONAME        11      /* socket name */
   91 #define M_NAMEI         12      /* namei path name buffer */
   92 #define M_GPROF         13      /* kernel profiling buffer */
   93 #define M_IOCTLOPS      14      /* ioctl data buffer */
   94 #define M_MAPMEM        15      /* mapped memory descriptors */
   95 #define M_CRED          16      /* credentials */
   96 #define M_PGRP          17      /* process group header */
   97 #define M_SESSION       18      /* session header */
   98 #define M_IOV           19      /* large iov's */
   99 #define M_MOUNT         20      /* vfs mount struct */
  100 #define M_FHANDLE       21      /* network file handle */
  101 #define M_NFSREQ        22      /* NFS request header */
  102 #define M_NFSMNT        23      /* NFS mount structure */
  103 #define M_NFSNODE       24      /* NFS vnode private part */
  104 #define M_VNODE         25      /* Dynamically allocated vnodes */
  105 #define M_CACHE         26      /* Dynamically allocated cache entries */
  106 #define M_DQUOT         27      /* UFS quota entries */
  107 #define M_UFSMNT        28      /* UFS mount structure */
  108 #define M_SHM           29      /* SVID compatible shared memory segments */
  109 #define M_VMMAP         30      /* VM map structures */
  110 #define M_VMMAPENT      31      /* VM map entry structures */
  111 #define M_VMOBJ         32      /* VM object structure */
  112 #define M_VMOBJHASH     33      /* VM object hash structure */
  113 #define M_VMPMAP        34      /* VM pmap */
  114 #define M_VMPVENT       35      /* VM phys-virt mapping entry */
  115 #define M_VMPAGER       36      /* XXX: VM pager struct */
  116 #define M_VMPGDATA      37      /* XXX: VM pager private data */
  117 #define M_FILE          38      /* Open file structure */
  118 #define M_FILEDESC      39      /* Open file descriptor table */
  119 #define M_LOCKF         40      /* Byte-range locking structures */
  120 #define M_PROC          41      /* Proc structures */
  121 #define M_SUBPROC       42      /* Proc sub-structures */
  122 #define M_SEGMENT       43      /* Segment for LFS */
  123 #define M_LFSNODE       44      /* LFS vnode private part */
  124 #define M_FFSNODE       45      /* FFS vnode private part */
  125 #define M_MFSNODE       46      /* MFS vnode private part */
  126 #define M_NQLEASE       47      /* Nqnfs lease */
  127 #define M_NQMHOST       48      /* Nqnfs host address table */
  128 #define M_NETADDR       49      /* Export host address structure */
  129 #define M_NFSSVC        50      /* Nfs server structure */
  130 #define M_NFSUID        51      /* Nfs uid mapping structure */
  131 #define M_NFSD          52      /* Nfs server daemon structure */
  132 #define M_IPMOPTS       53      /* internet multicast options */
  133 #define M_IPMADDR       54      /* internet multicast address */
  134 #define M_IFMADDR       55      /* link-level multicast address */
  135 #define M_MRTABLE       56      /* multicast routing tables */
  136 #define M_ISOFSMNT      57      /* ISOFS mount structure */
  137 #define M_ISOFSNODE     58      /* ISOFS vnode private part */
  138 #define M_NFSRVDESC     59      /* NFS server socket descriptor */
  139 #define M_NFSDIROFF     60      /* NFS directory offset data */
  140 #define M_NFSBIGFH      61      /* NFS version 3 file handle */
  141 #define M_MSDOSFSMNT    62      /* MSDOS FS mount structure */
  142 #define M_MSDOSFSFAT    63      /* MSDOS FS fat table */
  143 #define M_MSDOSFSNODE   64      /* MSDOS FS vnode private part */
  144 #define M_TTYS          65      /* allocated tty structures */
  145 #define M_EXEC          66      /* argument lists & other mem used by exec */
  146 #define M_MISCFSMNT     67      /* miscfs mount structures */
  147 #define M_MISCFSNODE    68      /* miscfs vnode private part */
  148 #define M_ADOSFSMNT     69      /* adosfs mount structures */
  149 #define M_ADOSFSNODE    70      /* adosfs vnode private part */
  150 #define M_ANODE         71      /* adosfs anode structures and tables. */
  151 #define M_BUFHDR        72      /* File buffer cache headers */
  152 #define M_OFILETABL     73      /* Open file descriptor table */
  153 #define M_MCLUST        74      /* mbuf cluster buffers */
  154 #define M_HFSMNT        75      /* HFS mount structure */
  155 #define M_HFSNODE       76      /* HFS catalog node */
  156 #define M_HFSFORK       77      /* HFS file fork */
  157 #define M_VOLFSMNT      78  /* VOLFS mount structure */
  158 #define M_VOLFSNODE     79      /* VOLFS private node part */
  159 #define M_TEMP          80      /* misc temporary data buffers */
  160 #define M_KTRACE        M_TEMP  /* ktrace buffers */
  161 #define M_SECA          81      /* security associations, key management */
  162 #define M_DEVFS         82
  163 #define M_IPFW          83      /* IP Forwarding/NAT */
  164 #define M_UDFNODE       84      /* UDF inodes */
  165 #define M_UDFMNT        85      /* UDF mount structures */
  166 #define M_IP6NDP        86      /* IPv6 Neighbour Discovery*/
  167 #define M_IP6OPT        87      /* IPv6 options management */
  168 #define M_IP6MISC       88      /* IPv6 misc. memory */
  169 #define M_TSEGQ         89      /* TCP segment queue entry */
  170 #define M_IGMP          90
  171 #define M_JNL_JNL   91  /* Journaling: "struct journal" */
  172 #define M_JNL_TR    92  /* Journaling: "struct transaction" */ 
  173 #define M_SPECINFO      93      /* special file node */
  174 #define M_KQUEUE        94      /* kqueue */
  175 
  176 #define M_LAST          95      /* Must be last type + 1 */
  177 
  178 /* Strings corresponding to types of memory */
  179 /* Must be in synch with the #defines above */
  180 #define INITKMEMNAMES { \
  181         "free",         /* 0 M_FREE */ \
  182         "mbuf",         /* 1 M_MBUF */ \
  183         "devbuf",       /* 2 M_DEVBUF */ \
  184         "socket",       /* 3 M_SOCKET */ \
  185         "pcb",          /* 4 M_PCB */ \
  186         "routetbl",     /* 5 M_RTABLE */ \
  187         "hosttbl",      /* 6 M_HTABLE */ \
  188         "fragtbl",      /* 7 M_FTABLE */ \
  189         "zombie",       /* 8 M_ZOMBIE */ \
  190         "ifaddr",       /* 9 M_IFADDR */ \
  191         "soopts",       /* 10 M_SOOPTS */ \
  192         "soname",       /* 11 M_SONAME */ \
  193         "namei",        /* 12 M_NAMEI */ \
  194         "gprof",        /* 13 M_GPROF */ \
  195         "ioctlops",     /* 14 M_IOCTLOPS */ \
  196         "mapmem",       /* 15 M_MAPMEM */ \
  197         "cred",         /* 16 M_CRED */ \
  198         "pgrp",         /* 17 M_PGRP */ \
  199         "session",      /* 18 M_SESSION */ \
  200         "iov",          /* 19 M_IOV */ \
  201         "mount",        /* 20 M_MOUNT */ \
  202         "fhandle",      /* 21 M_FHANDLE */ \
  203         "NFS req",      /* 22 M_NFSREQ */ \
  204         "NFS mount",    /* 23 M_NFSMNT */ \
  205         "NFS node",     /* 24 M_NFSNODE */ \
  206         "vnodes",       /* 25 M_VNODE */ \
  207         "namecache",    /* 26 M_CACHE */ \
  208         "UFS quota",    /* 27 M_DQUOT */ \
  209         "UFS mount",    /* 28 M_UFSMNT */ \
  210         "shm",          /* 29 M_SHM */ \
  211         "VM map",       /* 30 M_VMMAP */ \
  212         "VM mapent",    /* 31 M_VMMAPENT */ \
  213         "VM object",    /* 32 M_VMOBJ */ \
  214         "VM objhash",   /* 33 M_VMOBJHASH */ \
  215         "VM pmap",      /* 34 M_VMPMAP */ \
  216         "VM pvmap",     /* 35 M_VMPVENT */ \
  217         "VM pager",     /* 36 M_VMPAGER */ \
  218         "VM pgdata",    /* 37 M_VMPGDATA */ \
  219         "file",         /* 38 M_FILE */ \
  220         "file desc",    /* 39 M_FILEDESC */ \
  221         "lockf",        /* 40 M_LOCKF */ \
  222         "proc",         /* 41 M_PROC */ \
  223         "subproc",      /* 42 M_SUBPROC */ \
  224         "LFS segment",  /* 43 M_SEGMENT */ \
  225         "LFS node",     /* 44 M_LFSNODE */ \
  226         "FFS node",     /* 45 M_FFSNODE */ \
  227         "MFS node",     /* 46 M_MFSNODE */ \
  228         "NQNFS Lease",  /* 47 M_NQLEASE */ \
  229         "NQNFS Host",   /* 48 M_NQMHOST */ \
  230         "Export Host",  /* 49 M_NETADDR */ \
  231         "NFS srvsock",  /* 50 M_NFSSVC */ \
  232         "NFS uid",      /* 51 M_NFSUID */ \
  233         "NFS daemon",   /* 52 M_NFSD */ \
  234         "ip_moptions",  /* 53 M_IPMOPTS */ \
  235         "in_multi",     /* 54 M_IPMADDR */ \
  236         "ether_multi",  /* 55 M_IFMADDR */ \
  237         "mrt",          /* 56 M_MRTABLE */ \
  238         "ISOFS mount",  /* 57 M_ISOFSMNT */ \
  239         "ISOFS node",   /* 58 M_ISOFSNODE */ \
  240         "NFSV3 srvdesc",/* 59 M_NFSRVDESC */ \
  241         "NFSV3 diroff", /* 60 M_NFSDIROFF */ \
  242         "NFSV3 bigfh",  /* 61 M_NFSBIGFH */ \
  243         "MSDOSFS mount",/* 62 M_MSDOSFSMNT */ \
  244         "MSDOSFS fat",  /* 63 M_MSDOSFSFAT */ \
  245         "MSDOSFS node", /* 64 M_MSDOSFSNODE */ \
  246         "ttys",         /* 65 M_TTYS */ \
  247         "exec",         /* 66 M_EXEC */ \
  248         "miscfs mount", /* 67 M_MISCFSMNT */ \
  249         "miscfs node",  /* 68 M_MISCFSNODE */ \
  250         "adosfs mount", /* 69 M_ADOSFSMNT */ \
  251         "adosfs node",  /* 70 M_ADOSFSNODE */ \
  252         "adosfs anode", /* 71 M_ANODE */ \
  253         "buf hdrs",     /* 72 M_BUFHDR */ \
  254         "ofile tabl",   /* 73 M_OFILETABL */ \
  255         "mbuf clust",   /* 74 M_MCLUST */ \
  256         "HFS mount",    /* 75 M_HFSMNT */ \
  257         "HFS node",     /* 76 M_HFSNODE */ \
  258         "HFS fork",     /* 77 M_HFSFORK */ \
  259         "VOLFS mount",  /* 78 M_VOLFSMNT */ \
  260         "VOLFS node",   /* 79 M_VOLFSNODE */ \
  261         "temp",         /* 80 M_TEMP */ \
  262         "key mgmt",     /* 81 M_SECA */ \
  263         "DEVFS",        /* 82 M_DEVFS */ \
  264         "IpFw/IpAcct",  /* 83 M_IPFW */ \
  265         "UDF node",     /* 84 M_UDFNODE */ \
  266         "UDF mount",    /* 85 M_UDFMNT */ \
  267         "IPv6 NDP",     /* 86 M_IP6NDP */ \
  268         "IPv6 options", /* 87 M_IP6OPT */ \
  269         "IPv6 Misc",    /* 88 M_IP6MISC */\
  270         "TCP Segment Q",/* 89 M_TSEGQ */\
  271         "IGMP state",   /* 90 M_IGMP */\
  272         "Journal",    /* 91 M_JNL_JNL */\
  273         "Transaction",    /* 92 M_JNL_TR */\
  274         "specinfo",             /* 93 M_SPECINFO */\
  275         "kqueue"                /* 94 M_KQUEUE */\
  276 }
  277 
  278 struct kmemstats {
  279         long    ks_inuse;       /* # of packets of this type currently
  280                                  * in use */
  281         long    ks_calls;       /* total packets of this type ever allocated */
  282         long    ks_memuse;      /* total memory held in bytes */
  283         u_short ks_limblocks;   /* number of times blocked for hitting limit */
  284         u_short ks_mapblocks;   /* number of times blocked for kernel map */
  285         long    ks_maxused;     /* maximum number ever used */
  286         long    ks_limit;       /* most that are allowed to exist */
  287         long    ks_size;        /* sizes of this thing that are allocated */
  288         long    ks_spare;
  289 };
  290 
  291 #ifdef  KERNEL
  292 #ifdef __APPLE_API_PRIVATE
  293 extern struct kmemstats kmemstats[];
  294 #endif /* __APPLE_API_PRIVATE */
  295 
  296 /*
  297  * The malloc/free primatives used
  298  * by the BSD kernel code.
  299  */
  300 #define MALLOC(space, cast, size, type, flags) \
  301         (space) = (cast)_MALLOC(size, type, flags)
  302 
  303 #define FREE(addr, type) \
  304         _FREE((void *)addr, type)
  305 
  306 #define MALLOC_ZONE(space, cast, size, type, flags) \
  307         (space) = (cast)_MALLOC_ZONE(size, type, flags)
  308 
  309 #define FREE_ZONE(addr, size, type) \
  310         _FREE_ZONE((void *)addr, size, type)
  311 
  312 extern void     *_MALLOC __P((
  313                         size_t          size,
  314                         int             type,
  315                         int             flags));
  316 
  317 extern void     _FREE __P((
  318                         void            *addr,
  319                         int             type));
  320 
  321 extern void     *_MALLOC_ZONE __P((
  322                         size_t          size,
  323                         int             type,
  324                         int             flags));
  325 
  326 extern void     _FREE_ZONE __P((
  327                         void            *elem,
  328                         size_t          size,
  329                         int             type));
  330 
  331 #endif  /* KERNEL */
  332 
  333 #endif  /* _SYS_MALLOC_H_ */

Cache object: 157302ae91828b60b1b15b75b0239b0f


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.