1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License (the "License"). 7 * You may not use this file except in compliance with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or https://opensource.org/licenses/CDDL-1.0. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 25 * Copyright (c) 2012, 2018 by Delphix. All rights reserved. 26 * Copyright (c) 2012, Joyent, Inc. All rights reserved. 27 */ 28 29 #ifndef _SYS_THREAD_H 30 #define _SYS_THREAD_H 31 32 #include <pthread.h> 33 34 /* 35 * Threads. 36 */ 37 typedef pthread_t kthread_t; 38 39 #define TS_RUN 0x00000002 40 #define TS_JOINABLE 0x00000004 41 42 #define curthread ((void *)(uintptr_t)pthread_self()) 43 #define getcomm() "unknown" 44 45 #define thread_create_named(name, stk, stksize, func, arg, len, \ 46 pp, state, pri) \ 47 zk_thread_create(name, func, arg, stksize, state) 48 #define thread_create(stk, stksize, func, arg, len, pp, state, pri) \ 49 zk_thread_create(#func, func, arg, stksize, state) 50 #define thread_exit() pthread_exit(NULL) 51 #define thread_join(t) pthread_join((pthread_t)(t), NULL) 52 53 #define newproc(f, a, cid, pri, ctp, pid) (ENOSYS) 54 /* 55 * Check if the current thread is a memory reclaim thread. 56 * Always returns false in userspace (no memory reclaim thread). 57 */ 58 #define current_is_reclaim_thread() (0) 59 60 /* in libzpool, p0 exists only to have its address taken */ 61 typedef void (proc_t)(void); 62 extern void p0(void); 63 64 #define curproc (&p0) 65 66 #define PS_NONE -1 67 68 extern kthread_t *zk_thread_create(const char *name, void (*func)(void *), 69 void *arg, size_t stksize, int state); 70 71 #define issig() (FALSE) 72 73 #define KPREEMPT_SYNC (-1) 74 75 #define kpreempt(x) sched_yield() 76 #define kpreempt_disable() ((void)0) 77 #define kpreempt_enable() ((void)0) 78 79 #endif /* _SYS_THREAD_H */ 80