Annotation of kernel/bsd/sys/malloc.h, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.