1 /* $NetBSD: umem.h,v 1.1 2009/03/26 22:11:43 ad Exp $ */
6 * The contents of this file are subject to the terms of the
7 * Common Development and Distribution License, Version 1.0 only
8 * (the "License"). You may not use this file except in compliance
11 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
12 * or http://www.opensolaris.org/os/licensing.
13 * See the License for the specific language governing permissions
14 * and limitations under the License.
16 * When distributing Covered Code, include this CDDL HEADER in each
17 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
18 * If applicable, add the following below this CDDL HEADER, with the
19 * fields enclosed by brackets "[]" replaced with your own identifying
20 * information: Portions Copyright [yyyy] [name of copyright owner]
25 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
34 #include <sys/types.h>
41 #define UMEM_DEFAULT 0x0000 /* normal -- may fail */
42 #define UMEM_NOFAIL 0x0100 /* Never fails -- may call exit(2) */
44 #define UMEM_FLAGS 0xffff /* all settable umem flags */
46 extern void *umem_alloc(size_t, int);
47 extern void *umem_alloc_align(size_t, size_t, int);
48 extern void *umem_zalloc(size_t, int);
49 extern void umem_free(void *, size_t);
50 extern void umem_free_align(void *, size_t);
53 * Flags for umem_cache_create()
55 #define UMC_NOTOUCH 0x00010000
56 #define UMC_NODEBUG 0x00020000
57 #define UMC_NOMAGAZINE 0x00040000
58 #define UMC_NOHASH 0x00080000
60 struct umem_cache
; /* cache structure is opaque to umem clients */
62 typedef struct umem_cache umem_cache_t
;
63 typedef int umem_constructor_t(void *, void *, int);
64 typedef void umem_destructor_t(void *, void *);
65 typedef void umem_reclaim_t(void *);
67 typedef int umem_nofail_callback_t(void);
68 #define UMEM_CALLBACK_RETRY 0
69 #define UMEM_CALLBACK_EXIT(status) (0x100 | ((status) & 0xFF))
71 extern void umem_nofail_callback(umem_nofail_callback_t
*);
73 extern umem_cache_t
*umem_cache_create(char *, size_t,
74 size_t, umem_constructor_t
*, umem_destructor_t
*, umem_reclaim_t
*,
76 extern void umem_cache_destroy(umem_cache_t
*);
78 extern void *umem_cache_alloc(umem_cache_t
*, int);
79 extern void umem_cache_free(umem_cache_t
*, void *);
81 extern void umem_reap(void);