threads.h revision fc2512cfb727d49529d8ed99164db871f4829b73
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*/
/*
* Copyright 2016 Joyent, Inc.
*/
#ifndef _THREADS_H
#define _THREADS_H
/*
*/
#include <sys/feature_tests.h>
#include <limits.h>
#include <time.h>
#include <pthread.h>
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11)
#if !defined(_NORETURN_KYWD)
#if __STDC_VERSION__ - 0 >= 201112L
#define _NORETURN_KYWD _Noreturn
#else
#define _NORETURN_KYWD
#endif /* __STDC_VERSION__ - 0 >= 201112L */
#endif /* !defined(_NORETURN_KYWD) */
#define thread_local _Thread_local
#define ONCE_FLAG_INIT PTHREAD_ONCE_INIT
typedef pthread_cond_t cnd_t;
typedef pthread_key_t tss_t;
typedef pthread_mutex_t mtx_t;
typedef void (*tss_dtor_t)(void *);
typedef int (*thrd_start_t)(void *);
typedef pthread_once_t once_flag;
enum {
mtx_plain = 0x1,
mtx_recursive = 0x2,
mtx_timed = 0x4
};
enum {
thrd_success = 0,
thrd_error = 1,
thrd_busy = 2,
thrd_timedout = 3,
thrd_nomem = 4
};
extern int cnd_broadcast(cnd_t *);
extern void cnd_destroy(cnd_t *);
extern int cnd_signal(cnd_t *);
const struct timespec *_RESTRICT_KYWD);
extern void mtx_destroy(mtx_t *);
const struct timespec *_RESTRICT_KYWD);
extern int mtx_trylock(mtx_t *);
extern int mtx_unlock(mtx_t *);
extern thrd_t thrd_current(void);
extern int thrd_detach(thrd_t);
extern void thrd_yield(void);
extern void tss_delete(tss_t);
#endif /* !_STRICT_SYMBOLS | _STDC_C11 */
#ifdef __cplusplus
}
#endif
#endif /* _THREADS_H */