]> git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/OSMalloc.h
c54b90070f0d882099c60690709393f59b85155c
[apple/xnu.git] / libkern / libkern / OSMalloc.h
1 /*
2 * Copyright (c) 2003-2004 Apple Computer, 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 #ifndef LIBKERN_OSMALLOC_h
30 #define LIBKERN_OSMALLOC_h
31
32 #include <sys/cdefs.h>
33
34 __BEGIN_DECLS
35
36 #include <stdint.h>
37 #ifdef MACH_KERNEL_PRIVATE
38 #include <kern/queue.h>
39 #endif
40
41 #ifdef MACH_KERNEL_PRIVATE
42
43 #define OSMT_MAX_NAME 64
44
45 typedef struct _OSMallocTag_ {
46 queue_chain_t OSMT_link;
47 uint32_t OSMT_refcnt;
48 uint32_t OSMT_state;
49 uint32_t OSMT_attr;
50 char OSMT_name[OSMT_MAX_NAME];
51 } *OSMallocTag;
52
53 #define OSMT_VALID_MASK 0xFFFF0000
54 #define OSMT_VALID 0xDEAB0000
55 #define OSMT_RELEASED 0x00000001
56
57 #define OSMT_ATTR_PAGEABLE 0x01
58 #else
59 typedef struct __OSMallocTag__ *OSMallocTag, *OSMallocTag_t;
60 #endif
61
62 #define OSMT_DEFAULT 0x00
63 #define OSMT_PAGEABLE 0x01
64
65 extern OSMallocTag OSMalloc_Tagalloc(const char * str, uint32_t flags);
66
67 extern void OSMalloc_Tagfree(OSMallocTag tag);
68
69 extern void * OSMalloc(uint32_t size, OSMallocTag tag);
70
71 extern void * OSMalloc_nowait(uint32_t size, OSMallocTag tag);
72
73 extern void * OSMalloc_noblock(uint32_t size, OSMallocTag tag);
74
75 extern void OSFree(void * addr, uint32_t size, OSMallocTag tag);
76
77 __END_DECLS
78
79 #endif /* LIBKERN_OSMALLOC_h */