summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libclapi/CMakeLists.txt2
-rw-r--r--libclapi/cl_mutex.c24
2 files changed, 23 insertions, 3 deletions
diff --git a/libclapi/CMakeLists.txt b/libclapi/CMakeLists.txt
index 4ec11279..79da0248 100644
--- a/libclapi/CMakeLists.txt
+++ b/libclapi/CMakeLists.txt
@@ -19,5 +19,5 @@ set(LIBCLAPI_SRC
)
add_library(clapi SHARED ${LIBCLAPI_SRC})
-target_link_libraries(clapi dl rt)
+target_link_libraries(clapi dl rt pthread)
install (TARGETS clapi LIBRARY DESTINATION ${BEIGNET_INSTALL_DIR})
diff --git a/libclapi/cl_mutex.c b/libclapi/cl_mutex.c
index b18990c2..f7540b5d 100644
--- a/libclapi/cl_mutex.c
+++ b/libclapi/cl_mutex.c
@@ -119,7 +119,7 @@ static void after_get_the_mutex(pthread_mutex_t* mutex, char* file, int line, in
pthread_mutex_unlock(&cl_mutex_log_lock);
}
-static void after_release_the_mutex(pthread_mutex_t* mutex)
+static void after_release_the_mutex(pthread_mutex_t* mutex, char* file, int line)
{
int i, j;
cl_mutex_log_item item = NULL;
@@ -133,7 +133,20 @@ static void after_release_the_mutex(pthread_mutex_t* mutex)
}
}
- assert(item);
+ if (item == NULL) {
+ printf("At unlock point file: %s, line: %d, we can not find the locked mutex:%p item, fatal\n",
+ file, line, mutex);
+ assert(0);
+ return;
+ }
+
+ if (item->holder.file == NULL) {
+ printf("At unlock point file: %s, line: %d, we can not find the locked mutex:%p info, fatal\n",
+ file, line, mutex);
+ assert(0);
+ return;
+ }
+
item->holder.file = NULL;
item->holder.line = 0;
@@ -177,3 +190,10 @@ LOCAL void cl_mutex_lock(pthread_mutex_t* mutex, char* file, int line)
after_get_the_mutex(mutex, file, line, nth);
}
+LOCAL void cl_mutex_unlock(pthread_mutex_t* mutex, char* file, int line)
+{
+ assert(mutex);
+ pthread_mutex_unlock(mutex);
+ after_release_the_mutex(mutex, file, line);
+}
+