1168404Spjd/* 2168404Spjd * CDDL HEADER START 3168404Spjd * 4168404Spjd * The contents of this file are subject to the terms of the 5168404Spjd * Common Development and Distribution License (the "License"). 6168404Spjd * You may not use this file except in compliance with the License. 7168404Spjd * 8168404Spjd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9168404Spjd * or http://www.opensolaris.org/os/licensing. 10168404Spjd * See the License for the specific language governing permissions 11168404Spjd * and limitations under the License. 12168404Spjd * 13168404Spjd * When distributing Covered Code, include this CDDL HEADER in each 14168404Spjd * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15168404Spjd * If applicable, add the following below this CDDL HEADER, with the 16168404Spjd * fields enclosed by brackets "[]" replaced with your own identifying 17168404Spjd * information: Portions Copyright [yyyy] [name of copyright owner] 18168404Spjd * 19168404Spjd * CDDL HEADER END 20168404Spjd */ 21168404Spjd 22168404Spjd/* 23168404Spjd * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24168404Spjd * Use is subject to license terms. 25168404Spjd */ 26168404Spjd 27168404Spjd#pragma ident "%Z%%M% %I% %E% SMI" 28168404Spjd 29168404Spjd#include <sys/systm.h> 30168404Spjd#include <sys/cmn_err.h> 31168404Spjd#include <sys/kobj.h> 32168404Spjd 33168404Spjdstruct zchdr { 34168404Spjd uint_t zch_magic; 35168404Spjd uint_t zch_size; 36168404Spjd}; 37168404Spjd 38168404Spjd#define ZCH_MAGIC 0x3cc13cc1 39168404Spjd 40168404Spjd/*ARGSUSED*/ 41168404Spjdvoid * 42168404Spjdzcalloc(void *opaque, uint_t items, uint_t size) 43168404Spjd{ 44168404Spjd size_t nbytes = sizeof (struct zchdr) + items * size; 45168404Spjd struct zchdr *z = kobj_zalloc(nbytes, KM_NOWAIT|KM_TMP); 46168404Spjd 47168404Spjd if (z == NULL) 48168404Spjd return (NULL); 49168404Spjd 50168404Spjd z->zch_magic = ZCH_MAGIC; 51168404Spjd z->zch_size = nbytes; 52168404Spjd 53168404Spjd return (z + 1); 54168404Spjd} 55168404Spjd 56168404Spjd/*ARGSUSED*/ 57168404Spjdvoid 58168404Spjdzcfree(void *opaque, void *ptr) 59168404Spjd{ 60168404Spjd struct zchdr *z = ((struct zchdr *)ptr) - 1; 61168404Spjd 62168404Spjd if (z->zch_magic != ZCH_MAGIC) 63168404Spjd panic("zcfree region corrupt: hdr=%p ptr=%p", (void *)z, ptr); 64168404Spjd 65168404Spjd kobj_free(z, z->zch_size); 66168404Spjd} 67168404Spjd 68168404Spjdvoid 69168404Spjdzmemcpy(void *dest, const void *source, uint_t len) 70168404Spjd{ 71168404Spjd bcopy(source, dest, len); 72168404Spjd} 73168404Spjd 74168404Spjdint 75168404Spjdzmemcmp(const void *s1, const void *s2, uint_t len) 76168404Spjd{ 77168404Spjd return (bcmp(s1, s2, len)); 78168404Spjd} 79168404Spjd 80168404Spjdvoid 81168404Spjdzmemzero(void *dest, uint_t len) 82168404Spjd{ 83168404Spjd bzero(dest, len); 84168404Spjd} 85