fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * This file and its contents are supplied under the terms of the
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * Common Development and Distribution License ("CDDL"), version 1.0.
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * You may only use this file in accordance with the terms of version
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * 1.0 of the CDDL.
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * A full copy of the text of the CDDL should have accompanied this
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * source. A copy of the CDDL is also available via the Internet at
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * Copyright 2016 Joyent, Inc.
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * ISO/IEC C11 thread support.
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * In illumos, the underlying implementation of lock related routines is the
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * same between pthreads and traditional SunOS routines. The same is true with
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * the C11 routines. Their types are actually just typedef's to other things.
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * Thus in the implementation here, we treat this as a wrapper around existing
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * thread related routines and don't sweet the extra indirection.
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * Note that in many places the C standard doesn't allow for errors to be
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * returned. In those cases, if we have an instance of programmer error
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * (something resulting in EINVAL), we opt to abort the program as we don't have
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * much other recourse available.
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchicall_once(once_flag *flag, void (*func)(void))
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi/* ARGSUSED */
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchicnd_timedwait(cnd_t *_RESTRICT_KYWD cnd, mtx_t *_RESTRICT_KYWD mtx,
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi ret = pthread_cond_timedwait(cnd, mtx, ts);
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi/* ARGSUSED */
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * Here, we buck the trend and use the traditional SunOS routine. It's
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * much simpler than fighting with pthread attributes.
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi if (mutex_init((mutex_t *)mtx, mtype, NULL) == 0)
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi const struct timespec *_RESTRICT_KYWD abstime)
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi ret = pthread_mutex_timedlock(mtx, abstime);
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi else if (ret != 0)
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchithrd_create(thrd_t *thr, thrd_start_t func, void *arg)
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi ret = pthread_create(thr, NULL, (void *(*)(void *))func, arg);
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * thrd_sleep has somewhat odd standardized return values. It doesn't use the
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi * same returns values as the thrd_* family of functions at all.
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchithrd_sleep(const struct timespec *rqtp, struct timespec *rmtp)