1170222Sdougb/* 2193149Sdougb * Copyright (C) 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 3170222Sdougb * 4193149Sdougb * Permission to use, copy, modify, and/or distribute this software for any 5170222Sdougb * purpose with or without fee is hereby granted, provided that the above 6170222Sdougb * copyright notice and this permission notice appear in all copies. 7170222Sdougb * 8170222Sdougb * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 9170222Sdougb * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 10170222Sdougb * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 11170222Sdougb * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 12170222Sdougb * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 13170222Sdougb * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 14170222Sdougb * PERFORMANCE OF THIS SOFTWARE. 15170222Sdougb */ 16170222Sdougb 17234010Sdougb/* $Id: refcount.c,v 1.5 2007/06/19 23:47:17 tbox Exp $ */ 18170222Sdougb 19170222Sdougb#include <config.h> 20170222Sdougb 21170222Sdougb#include <stddef.h> 22170222Sdougb 23170222Sdougb#include <isc/mutex.h> 24170222Sdougb#include <isc/refcount.h> 25170222Sdougb#include <isc/result.h> 26170222Sdougb 27170222Sdougbisc_result_t 28170222Sdougbisc_refcount_init(isc_refcount_t *ref, unsigned int n) { 29170222Sdougb REQUIRE(ref != NULL); 30170222Sdougb 31170222Sdougb ref->refs = n; 32170222Sdougb#if defined(ISC_PLATFORM_USETHREADS) && !defined(ISC_PLATFORM_HAVEXADD) 33170222Sdougb return (isc_mutex_init(&ref->lock)); 34170222Sdougb#else 35170222Sdougb return (ISC_R_SUCCESS); 36170222Sdougb#endif 37170222Sdougb} 38