/* ISO C Runtime Library Copyright (c) 2019 Green Hills Software, Inc. This program is the property of Green Hills Software, Inc, its contents are proprietary information and no part of it is to be disclosed to anyone except employees of Green Hills Software, Inc., or as agreed in writing signed by the President of Green Hills Software, Inc. */ #ifndef _THREADS_H #ifdef __ghs__ #pragma ghs startnomisra #endif #define _THREADS_H #if __STDC_VERSION__ < 201112L #error threads.h is only implemented for C11 and later #endif /* __STDC_VERSION__ < 201112L */ #include /* Thread interface */ typedef void *thrd_t; enum { thrd_success = 0, thrd_nomem = 1, thrd_timedout = 2, thrd_busy = 3, thrd_error = 4 }; typedef int (*thrd_start_t) (void*); int thrd_create( thrd_t *__thr, thrd_start_t __func, void *__arg ); int thrd_create_priority_stack( thrd_t *__thr, long __priority, size_t __stacksize, thrd_start_t __func, void *__arg ); int thrd_equal( thrd_t __lhs, thrd_t __rhs ); thrd_t thrd_current(void); int thrd_sleep( const struct timespec* __duration, struct timespec* __remaining ); void thrd_yield(void); _Noreturn void thrd_exit( int __res ); int thrd_detach( thrd_t __thr ); int thrd_join( thrd_t __thr, int *__res ); /* Mutex interface */ typedef void *mtx_t; enum { mtx_plain = 0x001, mtx_timed = 0x004, mtx_recursive = 0x100 }; int mtx_init(mtx_t* __mutex, int __type); int mtx_lock(mtx_t* __mutex); int mtx_timedlock(mtx_t *restrict __mutex, const struct timespec *restrict __time_point); int mtx_trylock(mtx_t *__mutex); int mtx_unlock (mtx_t *__mutex); void mtx_destroy(mtx_t *__mutex); /* Call once interface */ typedef struct { union { void* __mutex; /* _Mtx_t must also be 'void*' */ _Atomic unsigned long __status; } __status_union; unsigned int __refs; } once_flag; #define ONCE_FLAG_INIT { { 0 }, 0 } void call_once(once_flag* __flag, void (*__func)(void)); /* Condition interface */ typedef void *cnd_t; int cnd_init( cnd_t* __cond ); int cnd_signal( cnd_t *__cond ); int cnd_broadcast( cnd_t *__cond ); int cnd_wait( cnd_t* __cond, mtx_t* __mutex ); int cnd_timedwait( cnd_t* restrict __cond, mtx_t* restrict __mutex, const struct timespec* restrict __time_point ); void cnd_destroy( cnd_t* __cond ); /* Thread local storage interface */ #define thread_local _Thread_local #define TSS_DTOR_ITERATIONS 0 typedef void *tss_t; typedef void(*tss_dtor_t)(void*); int tss_create( tss_t* __tss_key, tss_dtor_t __destructor ); void *tss_get( tss_t __tss_key ); int tss_set( tss_t __tss_id, void *__val ); void tss_delete( tss_t __tss_id ); #ifdef __ghs__ #pragma ghs endnomisra #endif #endif /* _THREADS_H */