mutex.h revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
230N/A/*
230N/A * Copyright (C) 1998-2000 Internet Software Consortium.
230N/A *
230N/A * Permission to use, copy, modify, and distribute this software for any
230N/A * purpose with or without fee is hereby granted, provided that the above
230N/A * copyright notice and this permission notice appear in all copies.
230N/A *
230N/A * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
230N/A * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
230N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
230N/A * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
230N/A * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
230N/A * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
230N/A * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
230N/A * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
230N/A */
230N/A
230N/A/* $Id: mutex.h,v 1.16 2000/08/01 01:31:06 tale Exp $ */
230N/A
230N/A#ifndef ISC_MUTEX_H
230N/A#define ISC_MUTEX_H 1
230N/A
230N/A#include <pthread.h>
230N/A
230N/A#include <isc/result.h> /* for ISC_R_ codes */
230N/A
230N/Atypedef pthread_mutex_t isc_mutex_t;
230N/A
230N/A/* XXX We could do fancier error handling... */
230N/A
230N/A#define isc_mutex_init(mp) \
230N/A ((pthread_mutex_init((mp), NULL) == 0) ? \
618N/A ISC_R_SUCCESS : ISC_R_UNEXPECTED)
230N/A#define isc_mutex_lock(mp) \
230N/A ((pthread_mutex_lock((mp)) == 0) ? \
230N/A ISC_R_SUCCESS : ISC_R_UNEXPECTED)
230N/A#define isc_mutex_unlock(mp) \
230N/A ((pthread_mutex_unlock((mp)) == 0) ? \
230N/A ISC_R_SUCCESS : ISC_R_UNEXPECTED)
230N/A#define isc_mutex_trylock(mp) \
230N/A ((pthread_mutex_trylock((mp)) == 0) ? \
230N/A ISC_R_SUCCESS : ISC_R_LOCKBUSY)
230N/A#define isc_mutex_destroy(mp) \
230N/A ((pthread_mutex_destroy((mp)) == 0) ? \
230N/A ISC_R_SUCCESS : ISC_R_UNEXPECTED)
230N/A
230N/A#endif /* ISC_MUTEX_H */
230N/A