]> pd.if.org Git - pdclib/blobdiff - includes/threads.h
Add nothrow annotations where appropriate
[pdclib] / includes / threads.h
index 5de3d380b6d96b098aa12260ace771f0a96199fb..c9e3b07f24b656a1730f22f7349f3feb656791eb 100644 (file)
@@ -38,24 +38,24 @@ void call_once(once_flag *flag, void (*func)(void))
 \r
 #if defined(_PDCLIB_MTX_T)\r
 typedef _PDCLIB_MTX_T          mtx_t;\r
-void mtx_destroy(mtx_t *mtx);\r
-int mtx_init(mtx_t *mtx, int type);\r
-int mtx_lock(mtx_t *mtx);\r
-int mtx_timedlock(mtx_t *_PDCLIB_restrict mtx, const struct timespec *_PDCLIB_restrict ts);\r
-int mtx_trylock(mtx_t *mtx);\r
-int mtx_unlock(mtx_t *mtx);\r
+void mtx_destroy(mtx_t *mtx) _PDCLIB_nothrow;\r
+int mtx_init(mtx_t *mtx, int type) _PDCLIB_nothrow;\r
+int mtx_lock(mtx_t *mtx) _PDCLIB_nothrow;\r
+int mtx_timedlock(mtx_t *_PDCLIB_restrict mtx, const struct timespec *_PDCLIB_restrict ts) _PDCLIB_nothrow;\r
+int mtx_trylock(mtx_t *mtx) _PDCLIB_nothrow;\r
+int mtx_unlock(mtx_t *mtx) _PDCLIB_nothrow;\r
 #endif\r
 \r
 #if defined(_PDCLIB_CND_T)\r
 typedef _PDCLIB_CND_T          cnd_t;\r
-int cnd_broadcast(cnd_t *cond);\r
-void cnd_destroy(cnd_t *cond);\r
-int cnd_init(cnd_t *cond);\r
-int cnd_signal(cnd_t *cond);\r
+int cnd_broadcast(cnd_t *cond) _PDCLIB_nothrow;\r
+void cnd_destroy(cnd_t *cond) _PDCLIB_nothrow;\r
+int cnd_init(cnd_t *cond) _PDCLIB_nothrow;\r
+int cnd_signal(cnd_t *cond) _PDCLIB_nothrow;\r
 int cnd_timedwait(cnd_t *_PDCLIB_restrict cond,\r
        mtx_t *_PDCLIB_restrict mtx,\r
-       const struct timespec *_PDCLIB_restrict ts);\r
-int cnd_wait(cnd_t *cond, mtx_t *mtx);\r
+       const struct timespec *_PDCLIB_restrict ts) _PDCLIB_nothrow;\r
+int cnd_wait(cnd_t *cond, mtx_t *mtx) _PDCLIB_nothrow;\r
 #endif\r
 \r
 #if defined(_PDCLIB_THRD_T)\r
@@ -63,17 +63,20 @@ int cnd_wait(cnd_t *cond, mtx_t *mtx);
 typedef _PDCLIB_THRD_T         thrd_t;\r
 typedef int (*)(void*)  thrd_start_t;\r
 \r
-int thrd_create(thrd_t *thr, thrd_start_t func, void *arg);\r
-thrd_t thrd_current(void);\r
-int thrd_detach(thrd_t thr);\r
-int thrd_equal(thrd_t thr0, thrd_t thr1);\r
+int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) _PDCLIB_nothrow;\r
+thrd_t thrd_current(void) _PDCLIB_nothrow;\r
+int thrd_detach(thrd_t thr) _PDCLIB_nothrow;\r
+int thrd_equal(thrd_t thr0, thrd_t thr1) _PDCLIB_nothrow;\r
+\r
+/* Not nothrow: systems may use exceptions at thread exit */\r
 _PDCLIB_noreturn void thrd_exit(int res);\r
+/* Not nothrow: systems may potentially propogate exceptions out of thrd_join?*/\r
 int thrd_join(thrd_t thr, int *res);\r
 #endif\r
 \r
 #if defined(_PDCLIB_THRD_HAVE_MISC)\r
-int thrd_sleep(const struct timespec *duration, struct timespec *remaining);\r
-void thrd_yield(void);\r
+int thrd_sleep(const struct timespec *duration, struct timespec *remaining) _PDCLIB_nothrow;\r
+void thrd_yield(void) _PDCLIB_nothrow;\r
 #endif\r
 \r
 /* The behaviour of tss_t is woefully underspecified in the C11 standard. In \r
@@ -88,10 +91,10 @@ void thrd_yield(void);
 typedef _PDCLIB_TSS_T          tss_t;\r
 typedef void (*tss_dtor_t)(void*);\r
 \r
-int tss_create(tss_t *key, tss_dtor_t dtor);\r
-void tss_delete(tss_t key);\r
-void *tss_get(tss_t key);\r
-int tss_set(tss_t key, void *val);\r
+int tss_create(tss_t *key, tss_dtor_t dtor) _PDCLIB_nothrow;\r
+void tss_delete(tss_t key) _PDCLIB_nothrow;\r
+void *tss_get(tss_t key) _PDCLIB_nothrow;\r
+int tss_set(tss_t key, void *val) _PDCLIB_nothrow;\r
 #endif\r
 \r
 _PDCLIB_END_EXTERN_C\r