16418SN/A/*- 214575Sbpb * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org> 36418SN/A * Copyright (c) 2013 iXsystems, Inc. 46418SN/A * All rights reserved. 56418SN/A * 66418SN/A * Redistribution and use in source and binary forms, with or without 76418SN/A * modification, are permitted provided that the following conditions 86418SN/A * are met: 96418SN/A * 1. Redistributions of source code must retain the above copyright 106418SN/A * notice, this list of conditions and the following disclaimer. 116418SN/A * 2. Redistributions in binary form must reproduce the above copyright 126418SN/A * notice, this list of conditions and the following disclaimer in the 136418SN/A * documentation and/or other materials provided with the distribution. 146418SN/A * 156418SN/A * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 166418SN/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 176418SN/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 186418SN/A * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 196418SN/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 206418SN/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 216418SN/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 226418SN/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 236418SN/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 246418SN/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 256418SN/A * SUCH DAMAGE. 266418SN/A * 276418SN/A * $FreeBSD$ 286418SN/A */ 296418SN/A 306418SN/A#ifndef _OPENSOLARIS_SYS_CONDVAR_H_ 316418SN/A#define _OPENSOLARIS_SYS_CONDVAR_H_ 326418SN/A 336418SN/A#include <sys/param.h> 346418SN/A#include <sys/proc.h> 356418SN/A 366418SN/A#ifdef _KERNEL 376418SN/A 386418SN/A#include <sys/mutex.h> 396418SN/A#include <sys/condvar.h> 406418SN/A#include <sys/time.h> 416418SN/A 426418SN/Atypedef struct cv kcondvar_t; 436418SN/A 446418SN/Atypedef enum { 456418SN/A CV_DEFAULT, 466418SN/A CV_DRIVER 476418SN/A} kcv_type_t; 486418SN/A 496418SN/A#define zfs_cv_init(cv, name, type, arg) do { \ 506418SN/A const char *_name; \ 516418SN/A ASSERT((type) == CV_DEFAULT); \ 526418SN/A for (_name = #cv; *_name != '\0'; _name++) { \ 536418SN/A if (*_name >= 'a' && *_name <= 'z') \ 546418SN/A break; \ 556418SN/A } \ 566418SN/A if (*_name == '\0') \ 576418SN/A _name = #cv; \ 586418SN/A cv_init((cv), _name); \ 596418SN/A} while (0) 606418SN/A#define cv_init(cv, name, type, arg) zfs_cv_init(cv, name, type, arg) 616418SN/A 626418SN/Astatic clock_t 636418SN/Acv_timedwait_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, hrtime_t res, 646418SN/A int flag) 656418SN/A{ 666418SN/A sbintime_t sbt; 676418SN/A sbintime_t pr; 686418SN/A 696418SN/A sbt = tim * SBT_1NS; 706418SN/A pr = res * SBT_1NS; 716418SN/A 726418SN/A return (cv_timedwait_sbt(cvp, mp, sbt, pr, 0)); 736418SN/A} 746418SN/A 756418SN/A#endif /* _KERNEL */ 766418SN/A 779000SN/A#endif /* _OPENSOLARIS_SYS_CONDVAR_H_ */ 786418SN/A