2017-10-04 19:33:43 +03:00
|
|
|
/*
|
2010-05-18 02:18:00 +04: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 08:38:26 +04:00
|
|
|
* UCRL-CODE-235197
|
|
|
|
*
|
2010-05-18 02:18:00 +04:00
|
|
|
* This file is part of the SPL, Solaris Porting Layer.
|
2008-05-26 08:38:26 +04:00
|
|
|
*
|
2010-05-18 02:18:00 +04: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 08:38:26 +04: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-18 02:18:00 +04:00
|
|
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
2017-10-04 19:33:43 +03:00
|
|
|
*/
|
2008-05-26 08:38:26 +04:00
|
|
|
|
2008-02-28 03:52:31 +03:00
|
|
|
#ifndef _SPL_THREAD_H
|
2018-02-07 22:49:38 +03:00
|
|
|
#define _SPL_THREAD_H
|
2008-02-26 23:36:04 +03:00
|
|
|
|
2008-02-27 22:09:51 +03:00
|
|
|
#include <linux/module.h>
|
2008-02-26 23:36:04 +03:00
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/spinlock.h>
|
2008-04-04 08:44:16 +04:00
|
|
|
#include <linux/kthread.h>
|
2008-03-01 03:45:59 +03:00
|
|
|
#include <sys/types.h>
|
2008-03-04 21:22:31 +03:00
|
|
|
#include <sys/sysmacros.h>
|
2010-11-30 20:51:46 +03:00
|
|
|
#include <sys/tsd.h>
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Thread interfaces
|
|
|
|
*/
|
2018-02-07 22:49:38 +03:00
|
|
|
#define TP_MAGIC 0x53535353
|
2008-02-26 23:36:04 +03:00
|
|
|
|
2018-02-07 22:49:38 +03:00
|
|
|
#define TS_SLEEP TASK_INTERRUPTIBLE
|
|
|
|
#define TS_RUN TASK_RUNNING
|
|
|
|
#define TS_ZOMB EXIT_ZOMBIE
|
|
|
|
#define TS_STOPPED TASK_STOPPED
|
2008-02-26 23:36:04 +03:00
|
|
|
|
2008-03-10 22:25:20 +03:00
|
|
|
typedef void (*thread_func_t)(void *);
|
|
|
|
|
2020-07-29 19:43:33 +03: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 22:49:38 +03:00
|
|
|
/* BEGIN CSTYLED */
|
|
|
|
#define thread_create(stk, stksize, func, arg, len, pp, state, pri) \
|
|
|
|
__thread_create(stk, stksize, (thread_func_t)func, \
|
|
|
|
#func, arg, len, pp, state, pri)
|
|
|
|
/* END CSTYLED */
|
|
|
|
|
|
|
|
#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 23:36:04 +03:00
|
|
|
|
2008-02-27 22:09:51 +03:00
|
|
|
extern kthread_t *__thread_create(caddr_t stk, size_t stksize,
|
2018-02-07 22:49:38 +03:00
|
|
|
thread_func_t func, const char *name, void *args, size_t len, proc_t *pp,
|
|
|
|
int state, pri_t pri);
|
2008-02-27 22:09:51 +03:00
|
|
|
extern void __thread_exit(void);
|
2014-04-09 22:40:12 +04:00
|
|
|
extern struct task_struct *spl_kthread_create(int (*func)(void *),
|
2018-02-15 04:01:15 +03:00
|
|
|
void *data, const char namefmt[], ...);
|
|
|
|
|
|
|
|
extern proc_t p0;
|
2014-03-26 17:29:24 +04:00
|
|
|
|
2021-04-15 23:34:35 +03: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 03:52:31 +03:00
|
|
|
#endif /* _SPL_THREAD_H */
|