2017-10-04 16:33:43 +00:00
|
|
|
/*
|
2010-05-17 22:18:00 +00:00
|
|
|
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
|
|
|
|
* Copyright (C) 2007 The Regents of the University of California.
|
|
|
|
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
|
|
|
|
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
|
2008-05-26 04:38:26 +00:00
|
|
|
* UCRL-CODE-235197
|
|
|
|
*
|
2010-05-17 22:18:00 +00:00
|
|
|
* This file is part of the SPL, Solaris Porting Layer.
|
2008-05-26 04:38:26 +00:00
|
|
|
*
|
2010-05-17 22:18:00 +00:00
|
|
|
* The SPL is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* The SPL is distributed in the hope that it will be useful, but WITHOUT
|
2008-05-26 04:38:26 +00:00
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
2010-05-17 22:18:00 +00:00
|
|
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
2017-10-04 16:33:43 +00:00
|
|
|
*/
|
2008-05-26 04:38:26 +00:00
|
|
|
|
2008-02-28 00:52:31 +00:00
|
|
|
#ifndef _SPL_THREAD_H
|
2018-02-07 19:49:38 +00:00
|
|
|
#define _SPL_THREAD_H
|
2008-02-26 20:36:04 +00:00
|
|
|
|
2008-02-27 19:09:51 +00:00
|
|
|
#include <linux/module.h>
|
2008-02-26 20:36:04 +00:00
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/spinlock.h>
|
2008-04-04 04:44:16 +00:00
|
|
|
#include <linux/kthread.h>
|
2008-03-01 00:45:59 +00:00
|
|
|
#include <sys/types.h>
|
2008-03-04 18:22:31 +00:00
|
|
|
#include <sys/sysmacros.h>
|
2010-11-30 17:51:46 +00:00
|
|
|
#include <sys/tsd.h>
|
2008-02-26 20:36:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Thread interfaces
|
|
|
|
*/
|
2018-02-07 19:49:38 +00:00
|
|
|
#define TP_MAGIC 0x53535353
|
2008-02-26 20:36:04 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
#define TS_SLEEP TASK_INTERRUPTIBLE
|
|
|
|
#define TS_RUN TASK_RUNNING
|
|
|
|
#define TS_ZOMB EXIT_ZOMBIE
|
|
|
|
#define TS_STOPPED TASK_STOPPED
|
2008-02-26 20:36:04 +00:00
|
|
|
|
2008-03-10 19:25:20 +00:00
|
|
|
typedef void (*thread_func_t)(void *);
|
|
|
|
|
2020-07-29 16:43:33 +00:00
|
|
|
#define thread_create_named(name, stk, stksize, func, arg, len, \
|
|
|
|
pp, state, pri) \
|
|
|
|
__thread_create(stk, stksize, (thread_func_t)func, \
|
|
|
|
name, arg, len, pp, state, pri)
|
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
#define thread_create(stk, stksize, func, arg, len, pp, state, pri) \
|
2022-01-21 16:07:15 +00:00
|
|
|
__thread_create(stk, stksize, (thread_func_t)func, #func, \
|
|
|
|
arg, len, pp, state, pri)
|
2018-02-07 19:49:38 +00:00
|
|
|
|
|
|
|
#define thread_exit() __thread_exit()
|
|
|
|
#define thread_join(t) VERIFY(0)
|
|
|
|
#define curthread current
|
|
|
|
#define getcomm() current->comm
|
|
|
|
#define getpid() current->pid
|
2008-02-26 20:36:04 +00:00
|
|
|
|
2008-02-27 19:09:51 +00:00
|
|
|
extern kthread_t *__thread_create(caddr_t stk, size_t stksize,
|
2018-02-07 19:49:38 +00:00
|
|
|
thread_func_t func, const char *name, void *args, size_t len, proc_t *pp,
|
|
|
|
int state, pri_t pri);
|
2008-02-27 19:09:51 +00:00
|
|
|
extern void __thread_exit(void);
|
2014-04-09 18:40:12 +00:00
|
|
|
extern struct task_struct *spl_kthread_create(int (*func)(void *),
|
2018-02-15 01:01:15 +00:00
|
|
|
void *data, const char namefmt[], ...);
|
|
|
|
|
|
|
|
extern proc_t p0;
|
2014-03-26 13:29:24 +00:00
|
|
|
|
2021-04-15 20:34:35 +00:00
|
|
|
#ifdef HAVE_SIGINFO
|
|
|
|
typedef kernel_siginfo_t spl_kernel_siginfo_t;
|
|
|
|
#else
|
|
|
|
typedef siginfo_t spl_kernel_siginfo_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SET_SPECIAL_STATE
|
|
|
|
#define spl_set_special_state(x) set_special_state((x))
|
|
|
|
#else
|
|
|
|
#define spl_set_special_state(x) __set_current_state((x))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2008-02-28 00:52:31 +00:00
|
|
|
#endif /* _SPL_THREAD_H */
|