Path: blob/main/sys/contrib/openzfs/lib/libnvpair/nvpair_alloc_system.c
48378 views
// SPDX-License-Identifier: CDDL-1.01/*2* CDDL HEADER START3*4* The contents of this file are subject to the terms of the5* Common Development and Distribution License, Version 1.0 only6* (the "License"). You may not use this file except in compliance7* with the License.8*9* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE10* or https://opensource.org/licenses/CDDL-1.0.11* See the License for the specific language governing permissions12* and limitations under the License.13*14* When distributing Covered Code, include this CDDL HEADER in each15* file and include the License file at usr/src/OPENSOLARIS.LICENSE.16* If applicable, add the following below this CDDL HEADER, with the17* fields enclosed by brackets "[]" replaced with your own identifying18* information: Portions Copyright [yyyy] [name of copyright owner]19*20* CDDL HEADER END21*/22/*23* Copyright 2004 Sun Microsystems, Inc. All rights reserved.24* Use is subject to license terms.25*/26272829#include <rpc/types.h>30#include <sys/kmem.h>31#include <sys/nvpair.h>3233static void *34nv_alloc_sys(nv_alloc_t *nva, size_t size)35{36return (kmem_alloc(size, (int)(uintptr_t)nva->nva_arg));37}3839static void40nv_free_sys(nv_alloc_t *nva, void *buf, size_t size)41{42(void) nva;43kmem_free(buf, size);44}4546static const nv_alloc_ops_t system_ops = {47NULL, /* nv_ao_init() */48NULL, /* nv_ao_fini() */49nv_alloc_sys, /* nv_ao_alloc() */50nv_free_sys, /* nv_ao_free() */51NULL /* nv_ao_reset() */52};5354static nv_alloc_t nv_alloc_sleep_def = {55&system_ops,56(void *)KM_SLEEP57};5859static nv_alloc_t nv_alloc_nosleep_def = {60&system_ops,61(void *)KM_NOSLEEP62};6364nv_alloc_t *const nv_alloc_sleep = &nv_alloc_sleep_def;65nv_alloc_t *const nv_alloc_nosleep = &nv_alloc_nosleep_def;666768