2005-04-16 15:20:36 -07:00
|
|
|
/* thread_info.h: common low-level thread information accessors
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2002 David Howells (dhowells@redhat.com)
|
|
|
|
|
* - Incorporating suggestions made by Linus Torvalds
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _LINUX_THREAD_INFO_H
|
|
|
|
|
#define _LINUX_THREAD_INFO_H
|
|
|
|
|
|
2007-12-05 15:46:09 +01:00
|
|
|
#include <linux/types.h>
|
2012-04-27 13:42:45 -04:00
|
|
|
#include <linux/bug.h>
|
2007-12-05 15:46:09 +01:00
|
|
|
|
2008-02-10 09:04:12 +01:00
|
|
|
struct timespec;
|
|
|
|
|
struct compat_timespec;
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
2007-12-05 15:46:09 +01:00
|
|
|
* System call restart block.
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
|
|
|
|
struct restart_block {
|
|
|
|
|
long (*fn)(struct restart_block *);
|
2007-12-05 15:46:09 +01:00
|
|
|
union {
|
2009-04-03 13:40:49 -07:00
|
|
|
/* For futex_wait and futex_wait_requeue_pi */
|
2007-12-05 15:46:09 +01:00
|
|
|
struct {
|
2010-09-14 21:43:47 +09:00
|
|
|
u32 __user *uaddr;
|
2007-12-05 15:46:09 +01:00
|
|
|
u32 val;
|
|
|
|
|
u32 flags;
|
2008-02-01 17:45:14 +01:00
|
|
|
u32 bitset;
|
2007-12-05 15:46:09 +01:00
|
|
|
u64 time;
|
2010-09-14 21:43:47 +09:00
|
|
|
u32 __user *uaddr2;
|
2007-12-05 15:46:09 +01:00
|
|
|
} futex;
|
2008-02-10 09:04:12 +01:00
|
|
|
/* For nanosleep */
|
|
|
|
|
struct {
|
2011-05-20 13:05:15 +02:00
|
|
|
clockid_t clockid;
|
2008-02-10 09:04:12 +01:00
|
|
|
struct timespec __user *rmtp;
|
|
|
|
|
#ifdef CONFIG_COMPAT
|
|
|
|
|
struct compat_timespec __user *compat_rmtp;
|
|
|
|
|
#endif
|
|
|
|
|
u64 expires;
|
|
|
|
|
} nanosleep;
|
2008-08-31 08:19:15 -07:00
|
|
|
/* For poll */
|
|
|
|
|
struct {
|
|
|
|
|
struct pollfd __user *ufds;
|
|
|
|
|
int nfds;
|
|
|
|
|
int has_timeout;
|
|
|
|
|
unsigned long tv_sec;
|
|
|
|
|
unsigned long tv_nsec;
|
|
|
|
|
} poll;
|
2007-12-05 15:46:09 +01:00
|
|
|
};
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern long do_no_restart_syscall(struct restart_block *parm);
|
|
|
|
|
|
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
|
#include <asm/thread_info.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
2012-05-05 15:05:41 +00:00
|
|
|
#ifdef CONFIG_DEBUG_STACK_USAGE
|
2016-01-14 15:18:21 -08:00
|
|
|
# define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_NOTRACK | \
|
|
|
|
|
__GFP_ZERO)
|
2012-05-05 15:05:41 +00:00
|
|
|
#else
|
2016-01-14 15:18:21 -08:00
|
|
|
# define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_NOTRACK)
|
2012-05-05 15:05:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
|
* flag set/clear/test wrappers
|
|
|
|
|
* - pass TIF_xxxx constants to these functions
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static inline void set_ti_thread_flag(struct thread_info *ti, int flag)
|
|
|
|
|
{
|
2008-01-30 13:30:55 +01:00
|
|
|
set_bit(flag, (unsigned long *)&ti->flags);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void clear_ti_thread_flag(struct thread_info *ti, int flag)
|
|
|
|
|
{
|
2008-01-30 13:30:55 +01:00
|
|
|
clear_bit(flag, (unsigned long *)&ti->flags);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag)
|
|
|
|
|
{
|
2008-01-30 13:30:55 +01:00
|
|
|
return test_and_set_bit(flag, (unsigned long *)&ti->flags);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag)
|
|
|
|
|
{
|
2008-01-30 13:30:55 +01:00
|
|
|
return test_and_clear_bit(flag, (unsigned long *)&ti->flags);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
|
|
|
|
|
{
|
2008-01-30 13:30:55 +01:00
|
|
|
return test_bit(flag, (unsigned long *)&ti->flags);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
2005-11-13 16:06:59 -08:00
|
|
|
#define set_thread_flag(flag) \
|
|
|
|
|
set_ti_thread_flag(current_thread_info(), flag)
|
|
|
|
|
#define clear_thread_flag(flag) \
|
|
|
|
|
clear_ti_thread_flag(current_thread_info(), flag)
|
|
|
|
|
#define test_and_set_thread_flag(flag) \
|
|
|
|
|
test_and_set_ti_thread_flag(current_thread_info(), flag)
|
|
|
|
|
#define test_and_clear_thread_flag(flag) \
|
|
|
|
|
test_and_clear_ti_thread_flag(current_thread_info(), flag)
|
|
|
|
|
#define test_thread_flag(flag) \
|
|
|
|
|
test_ti_thread_flag(current_thread_info(), flag)
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2013-09-11 12:43:13 +02:00
|
|
|
#define tif_need_resched() test_thread_flag(TIF_NEED_RESCHED)
|
|
|
|
|
|
2008-04-30 00:53:06 -07:00
|
|
|
#endif /* __KERNEL__ */
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
#endif /* _LINUX_THREAD_INFO_H */
|