| 1 | /* |
| 2 | * Copyright (c) 2007 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
| 5 | * |
| 6 | * This file contains Original Code and/or Modifications of Original Code |
| 7 | * as defined in and that are subject to the Apple Public Source License |
| 8 | * Version 2.0 (the 'License'). You may not use this file except in |
| 9 | * compliance with the License. The rights granted to you under the License |
| 10 | * may not be used to create, or enable the creation or redistribution of, |
| 11 | * unlawful or unlicensed copies of an Apple operating system, or to |
| 12 | * circumvent, violate, or enable the circumvention or violation of, any |
| 13 | * terms of an Apple operating system software license agreement. |
| 14 | * |
| 15 | * Please obtain a copy of the License at |
| 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. |
| 17 | * |
| 18 | * The Original Code and all software distributed under the License are |
| 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
| 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
| 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, |
| 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
| 23 | * Please see the License for the specific language governing rights and |
| 24 | * limitations under the License. |
| 25 | * |
| 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
| 27 | */ |
| 28 | /* |
| 29 | * Memory allocation wrappers. |
| 30 | */ |
| 31 | |
| 32 | #ifndef _SECURITY_MAC_ALLOC_H_ |
| 33 | #define _SECURITY_MAC_ALLOC_H_ |
| 34 | |
| 35 | #include <mach/machine/vm_types.h> |
| 36 | #include <kern/kern_types.h> |
| 37 | #include <sys/appleapiopts.h> |
| 38 | |
| 39 | /* JMM - should use OSMlloc.h interfaces */ |
| 40 | |
| 41 | #ifdef __APPLE_API_EVOLVING |
| 42 | /* |
| 43 | * Kernel Memory allocator |
| 44 | */ |
| 45 | void * mac_kalloc (vm_size_t size, int how); |
| 46 | void mac_kfree (void *data, vm_size_t size); |
| 47 | |
| 48 | /* |
| 49 | * Mbuf allocator for mbuf labels. |
| 50 | */ |
| 51 | void * mac_mbuf_alloc (int len, int wait); |
| 52 | void mac_mbuf_free (void *data); |
| 53 | |
| 54 | /* |
| 55 | * |
| 56 | */ |
| 57 | int mac_wire (void *start, void *end); |
| 58 | int mac_unwire (void *start, void *end); |
| 59 | |
| 60 | /* |
| 61 | * Zone allocator |
| 62 | */ |
| 63 | zone_t mac_zinit (vm_size_t size, vm_size_t maxmem, |
| 64 | vm_size_t alloc, const char *name); |
| 65 | void mac_zone_change (zone_t zone, unsigned int item, boolean_t value); |
| 66 | void * mac_zalloc (zone_t zone, int how); |
| 67 | void mac_zfree (zone_t zone, void *elem); |
| 68 | |
| 69 | /* Item definitions */ |
| 70 | #define Z_EXHAUST 1 /* Make zone exhaustible */ |
| 71 | #define Z_COLLECT 2 /* Make zone collectable */ |
| 72 | #define Z_EXPAND 3 /* Make zone expandable */ |
| 73 | #define Z_FOREIGN 4 /* Allow collectable zone to contain foreign elements */ |
| 74 | #define Z_CALLERACCT 5 /* Account alloc/free against the caller */ |
| 75 | |
| 76 | #endif /* __APPLE_API_EVOLVING */ |
| 77 | #endif /* _SECURITY_MAC_ALLOC_H_ */ |
| 78 | |