/* * Copyright © 2012 Intel Corporation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . * */ #ifndef __CL_MUTEX_H__ #define __CL_MUTEX_H__ #include #include #define CL_DEBUG_MUTEX 1 #ifdef CL_DEBUG_MUTEX extern void cl_mutex_debug_init(void); #define CL_MUTEX_DEBUG_INIT() cl_mutex_debug_init() extern void cl_mutex_destory(pthread_mutex_t* mutex, char* file, int line); #define CL_MUTEX_DESTORY(mutex) cl_mutex_destory(mutex, __FILE__, __LINE__) extern void cl_mutex_lock(pthread_mutex_t* mutex, char* file, int line); #define CL_MUTEX_LOCK(mutex) cl_mutex_lock(mutex, __FILE__, __LINE__) extern void cl_mutex_unlock(pthread_mutex_t* mutex, char* file, int line); #define CL_MUTEX_UNLOCK(mutex) cl_mutex_unlock(mutex, __FILE__, __LINE__) extern int cl_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex, char* file, int line); #define CL_COND_WAIT(cond, mutex) cl_cond_wait(cond, mutex, __FILE__, __LINE__) extern int cl_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime, char* file, int line); #define CL_COND_TIMEDWAIT(cond, mutex, abstime) cl_cond_timedwait(cond, mutex, abstime, __FILE__, __LINE__) void cl_mutex_report(void); #define CL_MUTEX_REPORT() cl_mutex_report() #else #define CL_MUTEX_DEBUG_INIT() #define CL_MUTEX_DESTORY(mutex) pthread_mutex_destory(mutex) #define CL_MUTEX_LOCK(mutex) pthread_mutex_lock(mutex) #define CL_MUTEX_UNLOCK(mutex) pthread_mutex_unlock(mutex) #define CL_COND_WAIT(cond, mutex) pthread_cond_wait(cond, mutex) #define CL_COND_TIMEDWAIT(cond, mutex, abstime) pthread_cond_timedwait(cond, mutex, abstime) #define CL_MUTEX_REPORT() #endif /* End of CL_DEBUG_MUTEX */ #define CL_MUTEX_INIT(mutex) pthread_mutex_init(mutex, NULL) #define CL_COND_INIT(cond) pthread_cond_init(cond, NULL) #define CL_MUTEX_DESTROY(mutex) pthread_mutex_destroy(mutex) #define CL_COND_DESTROY(cond) pthread_cond_destroy(cond) #define CL_COND_BROADCAST(cond) pthread_cond_broadcast(cond) #endif /* __CL_MUTEX_H__ */