00001 /* 00002 * Copyright (C) 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 00003 * 00004 * Permission to use, copy, modify, and/or distribute this software for any 00005 * purpose with or without fee is hereby granted, provided that the above 00006 * copyright notice and this permission notice appear in all copies. 00007 * 00008 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 00009 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 00010 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 00011 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 00012 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 00013 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00014 * PERFORMANCE OF THIS SOFTWARE. 00015 */ 00016 00017 /* $Id: refcount.c,v 1.5 2007/06/19 23:47:17 tbox Exp $ */ 00018 00019 #include <config.h> 00020 00021 #include <stddef.h> 00022 00023 #include <isc/mutex.h> 00024 #include <isc/refcount.h> 00025 #include <isc/result.h> 00026 00027 isc_result_t 00028 isc_refcount_init(isc_refcount_t *ref, unsigned int n) { 00029 REQUIRE(ref != NULL); 00030 00031 ref->refs = n; 00032 #if defined(ISC_PLATFORM_USETHREADS) && !defined(ISC_PLATFORM_HAVEXADD) 00033 return (isc_mutex_init(&ref->lock)); 00034 #else 00035 return (ISC_R_SUCCESS); 00036 #endif 00037 }