summaryrefslogtreecommitdiffstats
path: root/include/zix
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-08-18 16:44:41 -0400
committerDavid Robillard <d@drobilla.net>2022-08-18 16:44:41 -0400
commitb9d58f74ea1d072e7a2d1c862dc7a1e0fe5fccb0 (patch)
tree9b01f7f6e96af405457cba746ca85dd21d38a3e5 /include/zix
parent9ac3f4e009fd0d393d2c41449b121498e5b7ad54 (diff)
downloadzix-b9d58f74ea1d072e7a2d1c862dc7a1e0fe5fccb0.tar.gz
zix-b9d58f74ea1d072e7a2d1c862dc7a1e0fe5fccb0.tar.bz2
zix-b9d58f74ea1d072e7a2d1c862dc7a1e0fe5fccb0.zip
Factor out converting errno codes to ZixStatus
Diffstat (limited to 'include/zix')
-rw-r--r--include/zix/common.h5
-rw-r--r--include/zix/thread.h12
2 files changed, 6 insertions, 11 deletions
diff --git a/include/zix/common.h b/include/zix/common.h
index 5919fa9..c0944b5 100644
--- a/include/zix/common.h
+++ b/include/zix/common.h
@@ -33,6 +33,11 @@ ZIX_CONST_API
const char*
zix_strerror(ZixStatus status);
+/// Return an errno value converted to a status code
+ZIX_CONST_API
+ZixStatus
+zix_errno_status(int e);
+
/// Function for comparing two elements
typedef int (*ZixComparator)(const void* a,
const void* b,
diff --git a/include/zix/thread.h b/include/zix/thread.h
index 74bb19b..c80add0 100644
--- a/include/zix/thread.h
+++ b/include/zix/thread.h
@@ -9,7 +9,6 @@
#ifdef _WIN32
# include <windows.h>
#else
-# include <errno.h>
# include <pthread.h>
#endif
@@ -85,16 +84,7 @@ zix_thread_create(ZixThread* thread,
const int ret = pthread_create(thread, NULL, function, arg);
pthread_attr_destroy(&attr);
- switch (ret) {
- case EAGAIN:
- return ZIX_STATUS_NO_MEM;
- case EINVAL:
- return ZIX_STATUS_BAD_ARG;
- case EPERM:
- return ZIX_STATUS_BAD_PERMS;
- }
-
- return ret ? ZIX_STATUS_ERROR : ZIX_STATUS_SUCCESS;
+ return zix_errno_status(ret);
}
static inline ZixStatus