Path: blob/main/cddl/compat/opensolaris/lib/libumem/umem.h
39488 views
/*1* CDDL HEADER START2*3* The contents of this file are subject to the terms of the4* Common Development and Distribution License, Version 1.0 only5* (the "License"). You may not use this file except in compliance6* with the License.7*8* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE9* or http://www.opensolaris.org/os/licensing.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*/21/*22* Copyright 2004 Sun Microsystems, Inc. All rights reserved.23* Use is subject to license terms.24*/2526#ifndef _UMEM_H27#define _UMEM_H28293031#include <sys/types.h>32#include <stdlib.h>3334#ifdef __cplusplus35extern "C" {36#endif3738#define UMEM_DEFAULT 0x0000 /* normal -- may fail */39#define UMEM_NOFAIL 0x0100 /* Never fails -- may call exit(2) */4041#define UMEM_FLAGS 0xffff /* all settable umem flags */4243extern void *umem_alloc(size_t, int);44extern void *umem_alloc_align(size_t, size_t, int);45extern void *umem_zalloc(size_t, int);46extern void umem_free(void *, size_t);47extern void umem_free_align(void *, size_t);4849/*50* Flags for umem_cache_create()51*/52#define UMC_NOTOUCH 0x0001000053#define UMC_NODEBUG 0x0002000054#define UMC_NOMAGAZINE 0x0004000055#define UMC_NOHASH 0x000800005657struct umem_cache; /* cache structure is opaque to umem clients */5859typedef struct umem_cache umem_cache_t;60typedef int umem_constructor_t(void *, void *, int);61typedef void umem_destructor_t(void *, void *);62typedef void umem_reclaim_t(void *);6364typedef int umem_nofail_callback_t(void);65#define UMEM_CALLBACK_RETRY 066#define UMEM_CALLBACK_EXIT(status) (0x100 | ((status) & 0xFF))6768extern void umem_nofail_callback(umem_nofail_callback_t *);6970extern umem_cache_t *umem_cache_create(char *, size_t,71size_t, umem_constructor_t *, umem_destructor_t *, umem_reclaim_t *,72void *, void *, int);73extern void umem_cache_destroy(umem_cache_t *);7475extern void *umem_cache_alloc(umem_cache_t *, int);76extern void umem_cache_free(umem_cache_t *, void *);7778extern void umem_reap(void);7980#ifdef __cplusplus81}82#endif8384#endif /* _UMEM_H */858687