thread_info.h 2.0 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9
/* 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

10 11
#include <linux/types.h>

L
Linus Torvalds 已提交
12
/*
13
 * System call restart block.
L
Linus Torvalds 已提交
14 15 16
 */
struct restart_block {
	long (*fn)(struct restart_block *);
17 18 19 20 21 22 23 24 25
	union {
		struct {
			unsigned long arg0, arg1, arg2, arg3;
		};
		/* For futex_wait */
		struct {
			u32 *uaddr;
			u32 val;
			u32 flags;
26
			u32 bitset;
27 28 29
			u64 time;
		} futex;
	};
L
Linus Torvalds 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
};

extern long do_no_restart_syscall(struct restart_block *parm);

#include <linux/bitops.h>
#include <asm/thread_info.h>

#ifdef __KERNEL__

/*
 * 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)
{
46
	set_bit(flag, (unsigned long *)&ti->flags);
L
Linus Torvalds 已提交
47 48 49 50
}

static inline void clear_ti_thread_flag(struct thread_info *ti, int flag)
{
51
	clear_bit(flag, (unsigned long *)&ti->flags);
L
Linus Torvalds 已提交
52 53 54 55
}

static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag)
{
56
	return test_and_set_bit(flag, (unsigned long *)&ti->flags);
L
Linus Torvalds 已提交
57 58 59 60
}

static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag)
{
61
	return test_and_clear_bit(flag, (unsigned long *)&ti->flags);
L
Linus Torvalds 已提交
62 63 64 65
}

static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
{
66
	return test_bit(flag, (unsigned long *)&ti->flags);
L
Linus Torvalds 已提交
67 68
}

69 70 71 72 73 74 75 76 77 78 79 80 81
#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)

#define set_need_resched()	set_thread_flag(TIF_NEED_RESCHED)
#define clear_need_resched()	clear_thread_flag(TIF_NEED_RESCHED)
L
Linus Torvalds 已提交
82 83 84 85

#endif

#endif /* _LINUX_THREAD_INFO_H */