]> git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/OSMalloc.h
8f87701753a8eefc67475066c9cc2b6e17c39889
[apple/xnu.git] / libkern / libkern / OSMalloc.h
1 /*
2 * Copyright (c) 2003-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef LIBKERN_OSMALLOC_h
25 #define LIBKERN_OSMALLOC_h
26
27 #include <sys/cdefs.h>
28
29 __BEGIN_DECLS
30
31 #include <stdint.h>
32 #ifdef MACH_KERNEL_PRIVATE
33 #include <kern/queue.h>
34 #endif
35
36 #ifdef MACH_KERNEL_PRIVATE
37
38 #define OSMT_MAX_NAME 64
39
40 typedef struct _OSMallocTag_ {
41 queue_chain_t OSMT_link;
42 uint32_t OSMT_refcnt;
43 uint32_t OSMT_state;
44 uint32_t OSMT_attr;
45 char OSMT_name[OSMT_MAX_NAME];
46 } *OSMallocTag;
47
48 #define OSMT_VALID_MASK 0xFFFF0000
49 #define OSMT_VALID 0xDEAB0000
50 #define OSMT_RELEASED 0x00000001
51
52 #define OSMT_ATTR_PAGEABLE 0x01
53 #else
54 typedef struct __OSMallocTag__ *OSMallocTag, *OSMallocTag_t;
55 #endif
56
57 #define OSMT_DEFAULT 0x00
58 #define OSMT_PAGEABLE 0x01
59
60 extern OSMallocTag OSMalloc_Tagalloc(const char * str, uint32_t flags);
61
62 extern void OSMalloc_Tagfree(OSMallocTag tag);
63
64 extern void * OSMalloc(uint32_t size, OSMallocTag tag);
65
66 extern void * OSMalloc_nowait(uint32_t size, OSMallocTag tag);
67
68 extern void * OSMalloc_noblock(uint32_t size, OSMallocTag tag);
69
70 extern void OSFree(void * addr, uint32_t size, OSMallocTag tag);
71
72 __END_DECLS
73
74 #endif /* LIBKERN_OSMALLOC_h */