Commit 9044565e authored by Lubomir Bulej's avatar Lubomir Bulej
Browse files

Don't use check_std_error in threads.h

The pthreads functions do not set errno. Rather, they return a value
that can be interpreted as errno, but that would need an extra
function.
parent 4648ef0c
......@@ -61,14 +61,14 @@ mutex_destroy (mutex_t * mutex) {
static inline void
thread_create (thread_t * thread, void * (* thread_fn) (void *), void * data) {
int result = pthread_create (thread, NULL, thread_fn, data);
check_std_error (result != 0, "failed to create thread");
check_error (result != 0, "failed to create thread");
}
static inline void
thread_join (thread_t * thread) {
int result = pthread_join (*thread, NULL);
check_std_error (result != 0, "failed to join thread");
check_error (result != 0, "failed to join thread");
}
......@@ -76,28 +76,28 @@ thread_join (thread_t * thread) {
static inline void
mutex_init (mutex_t * mutex) {
int result = pthread_mutex_init (mutex, NULL);
check_std_error (result != 0, "failed to initialize mutex");
check_error (result != 0, "failed to initialize mutex");
}
static inline void
mutex_lock (mutex_t * mutex) {
int result = pthread_mutex_lock (mutex);
check_std_error (result != 0, "failed to lock mutex");
check_error (result != 0, "failed to lock mutex");
}
static inline void
mutex_unlock (mutex_t * mutex) {
int result = pthread_mutex_unlock (mutex);
check_std_error (result != 0, "failed to release mutex");
check_error (result != 0, "failed to release mutex");
}
static inline void
mutex_destroy (mutex_t * mutex) {
int result = pthread_mutex_destroy (mutex);
check_std_error (result != 0, "failed to destroy mutex");
check_error (result != 0, "failed to destroy mutex");
}
#endif /* !MINGW */
......
......@@ -61,14 +61,14 @@ mutex_destroy (mutex_t * mutex) {
static inline void
thread_create (thread_t * thread, void * (* thread_fn) (void *), void * data) {
int result = pthread_create (thread, NULL, thread_fn, data);
check_std_error (result != 0, "failed to create thread");
check_error (result != 0, "failed to create thread");
}
static inline void
thread_join (thread_t * thread) {
int result = pthread_join (*thread, NULL);
check_std_error (result != 0, "failed to join thread");
check_error (result != 0, "failed to join thread");
}
......@@ -76,28 +76,28 @@ thread_join (thread_t * thread) {
static inline void
mutex_init (mutex_t * mutex) {
int result = pthread_mutex_init (mutex, NULL);
check_std_error (result != 0, "failed to initialize mutex");
check_error (result != 0, "failed to initialize mutex");
}
static inline void
mutex_lock (mutex_t * mutex) {
int result = pthread_mutex_lock (mutex);
check_std_error (result != 0, "failed to lock mutex");
check_error (result != 0, "failed to lock mutex");
}
static inline void
mutex_unlock (mutex_t * mutex) {
int result = pthread_mutex_unlock (mutex);
check_std_error (result != 0, "failed to release mutex");
check_error (result != 0, "failed to release mutex");
}
static inline void
mutex_destroy (mutex_t * mutex) {
int result = pthread_mutex_destroy (mutex);
check_std_error (result != 0, "failed to destroy mutex");
check_error (result != 0, "failed to destroy mutex");
}
#endif /* !MINGW */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment