/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* bos72X src/bos/usr/include/threads.h 1.2 */ /* */ /* Licensed Materials - Property of IBM */ /* */ /* COPYRIGHT International Business Machines Corp. 2013,2021 */ /* All Rights Reserved */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /* */ /* IBM_PROLOG_END_TAG */ /* @(#)10 1.2 src/bos/usr/include/threads.h, libcmisc, bos72X, x2021_20A5 4/5/21 23:47:43 */ #ifndef _THREADS_H #define _THREADS_H /*#if (defined(__STDC_VERSION__) && (__STDC_VERSION >= 201112L) && !defined(__STDC_NO_THREADS__)) || defined(_ALL_SOURCE)*/ #include #include #include #ifdef __cplusplus extern "C" { #endif /* MACROS */ #define thread_local _Thread_local #define ONCE_FLAG_INIT PTHREAD_ONCE_INIT/* should be a value to initialize an object of type once_flag */ /* typedefs */ typedef pthread_t thrd_t ; typedef void*(*thrd_start_t)(void *); typedef pthread_cond_t cnd_t ; typedef pthread_mutex_t mtx_t ; typedef pthread_once_t once_t ; typedef pthread_once_t once_flag ; typedef struct timespec ts ; typedef pthread_key_t tss_t ; typedef void(*tss_dtor_t)(void *); /* enumerations */ /* * The following enumeration constants can be passed to mtx_init() to decide * what type of mutex object is created */ typedef enum mtx_type { mtx_plain = 1, /* for mutex object that supports neither timeout nor test and return */ mtx_recursive = 4, /* for mutex object that supports recursive locking */ mtx_timed = 2 /* for mutex object that supports timeout */ }mtxType_t; /* * The following enumeration constants can be returned by functions */ typedef enum thrd_return_type { thrd_timedout=-5,/* returned by a timed wait function to indicate that the time specified in the call was reached without acquiring the requested resource*/ thrd_busy=-4, /* returned by a function to indicate that the requested operation failed because a resource requested by a test and return function is already in use */ thrd_nomem=-3, /* returned by a function to indicate that the requested operation failed because it was unable to allocate memory */ thrd_error=-2, /* returned by a function to indicate that the requested operation failed */ thrd_sigint=-1, /* returned when any thread API is interrupted by a Signal handler*/ thrd_success=0 /* returned by a function to indicate that the requested operation succeeded */ }thrdRetType_t; /* Functions */ extern void call_once(once_flag *flag, void (*func)(void)); /* * thread specific data */ extern int tss_create(tss_t *key, tss_dtor_t dtor); extern void tss_delete(tss_t key); extern void * tss_get(tss_t key); extern int tss_set(tss_t key, void *val); /* * threads */ extern int thrd_create(thrd_t *thr, thrd_start_t func,void *arg); extern int thrd_detach(thrd_t thr); extern int thrd_equal(thrd_t thr0, thrd_t thr1); extern #if (defined(__STDC_VERSION__) && (__STDC_VERSION >= 201112L)) _Noreturn #endif void thrd_exit(int res); extern thrd_t thrd_current(void); extern int thrd_join(thrd_t thr, int *res); extern int thrd_sleep(const struct timespec *duration,struct timespec *remaining); extern void thrd_yield(void); /* condition variable related */ extern int cnd_broadcast(cnd_t *cond); extern void cnd_destroy(cnd_t *cond); extern int cnd_init(cnd_t *cond); extern int cnd_signal(cnd_t *cond); extern int cnd_timedwait(cnd_t *__restrict__ cond,mtx_t *__restrict__ mtx,const struct timespec *__restrict__ ts); extern int cnd_wait(cnd_t *cond, mtx_t *mtx); /* mutex related */ extern void mtx_destroy(mtx_t *mtx); extern int mtx_init(mtx_t *mtx, int type); extern int mtx_lock(mtx_t *mtx); extern int mtx_trylock(mtx_t *mtx); extern int mtx_unlock(mtx_t *mtx); extern int mtx_timedlock(mtx_t *__restrict__ mtx,const struct timespec *__restrict__ ts); #ifdef __cplusplus } #endif /*#endif*/ #endif