1178479Sjb/* 2178479Sjb * CDDL HEADER START 3178479Sjb * 4178479Sjb * The contents of this file are subject to the terms of the 5178479Sjb * Common Development and Distribution License, Version 1.0 only 6178479Sjb * (the "License"). You may not use this file except in compliance 7178479Sjb * with the License. 8178479Sjb * 9178479Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10178479Sjb * or http://www.opensolaris.org/os/licensing. 11178479Sjb * See the License for the specific language governing permissions 12178479Sjb * and limitations under the License. 13178479Sjb * 14178479Sjb * When distributing Covered Code, include this CDDL HEADER in each 15178479Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16178479Sjb * If applicable, add the following below this CDDL HEADER, with the 17178479Sjb * fields enclosed by brackets "[]" replaced with your own identifying 18178479Sjb * information: Portions Copyright [yyyy] [name of copyright owner] 19178479Sjb * 20178479Sjb * CDDL HEADER END 21178479Sjb */ 22178479Sjb/* 23178479Sjb * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24178479Sjb * Use is subject to license terms. 25178479Sjb */ 26178479Sjb 27178479Sjb#pragma ident "%Z%%M% %I% %E% SMI" 28178479Sjb 29178479Sjb#include <ctf_impl.h> 30178479Sjb#include <sys/mman.h> 31178479Sjb#include <stdarg.h> 32178479Sjb 33178479Sjbvoid * 34178479Sjbctf_data_alloc(size_t size) 35178479Sjb{ 36178479Sjb return (mmap(NULL, size, PROT_READ | PROT_WRITE, 37178479Sjb MAP_PRIVATE | MAP_ANON, -1, 0)); 38178479Sjb} 39178479Sjb 40178479Sjbvoid 41178479Sjbctf_data_free(void *buf, size_t size) 42178479Sjb{ 43178479Sjb (void) munmap(buf, size); 44178479Sjb} 45178479Sjb 46178479Sjbvoid 47178479Sjbctf_data_protect(void *buf, size_t size) 48178479Sjb{ 49178479Sjb (void) mprotect(buf, size, PROT_READ); 50178479Sjb} 51178479Sjb 52178479Sjbvoid * 53178479Sjbctf_alloc(size_t size) 54178479Sjb{ 55178479Sjb return (malloc(size)); 56178479Sjb} 57178479Sjb 58178479Sjb/*ARGSUSED*/ 59178479Sjbvoid 60178554Sjbctf_free(void *buf, __unused size_t size) 61178479Sjb{ 62178479Sjb free(buf); 63178479Sjb} 64178479Sjb 65178479Sjbconst char * 66178479Sjbctf_strerror(int err) 67178479Sjb{ 68178554Sjb return ((const char *) strerror(err)); 69178479Sjb} 70178479Sjb 71178479Sjb/*PRINTFLIKE1*/ 72178479Sjbvoid 73178479Sjbctf_dprintf(const char *format, ...) 74178479Sjb{ 75178479Sjb if (_libctf_debug) { 76178479Sjb va_list alist; 77178479Sjb 78178479Sjb va_start(alist, format); 79178479Sjb (void) fputs("libctf DEBUG: ", stderr); 80178479Sjb (void) vfprintf(stderr, format, alist); 81178479Sjb va_end(alist); 82178479Sjb } 83178479Sjb} 84