Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1#ifndef _ALPHA_THREAD_INFO_H
2#define _ALPHA_THREAD_INFO_H
3
4#ifdef __KERNEL__
5
6#ifndef __ASSEMBLY__
7#include <asm/processor.h>
8#include <asm/types.h>
9#include <asm/hwrpb.h>
10#include <asm/sysinfo.h>
11#endif
12
13#ifndef __ASSEMBLY__
14struct thread_info {
15 struct pcb_struct pcb; /* palcode state */
16
17 struct task_struct *task; /* main task structure */
18 unsigned int flags; /* low level flags */
19 unsigned int ieee_state; /* see fpu.h */
20
21 struct exec_domain *exec_domain; /* execution domain */
22 mm_segment_t addr_limit; /* thread address space */
23 unsigned cpu; /* current CPU */
24 int preempt_count; /* 0 => preemptable, <0 => BUG */
25 unsigned int status; /* thread-synchronous flags */
26
27 int bpt_nsaved;
28 unsigned long bpt_addr[2]; /* breakpoint handling */
29 unsigned int bpt_insn[2];
30};
31
32/*
33 * Macros/functions for gaining access to the thread information structure.
34 */
35#define INIT_THREAD_INFO(tsk) \
36{ \
37 .task = &tsk, \
38 .exec_domain = &default_exec_domain, \
39 .addr_limit = KERNEL_DS, \
40 .preempt_count = INIT_PREEMPT_COUNT, \
41}
42
43#define init_thread_info (init_thread_union.thread_info)
44#define init_stack (init_thread_union.stack)
45
46/* How to get the thread information struct from C. */
47register struct thread_info *__current_thread_info __asm__("$8");
48#define current_thread_info() __current_thread_info
49
50#endif /* __ASSEMBLY__ */
51
52/* Thread information allocation. */
53#define THREAD_SIZE_ORDER 1
54#define THREAD_SIZE (2*PAGE_SIZE)
55
56/*
57 * Thread information flags:
58 * - these are process state flags and used from assembly
59 * - pending work-to-be-done flags come first and must be assigned to be
60 * within bits 0 to 7 to fit in and immediate operand.
61 *
62 * TIF_SYSCALL_TRACE is known to be 0 via blbs.
63 */
64#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
65#define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
66#define TIF_SIGPENDING 2 /* signal pending */
67#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
68#define TIF_SYSCALL_AUDIT 4 /* syscall audit active */
69#define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */
70#define TIF_MEMDIE 13 /* is terminating due to OOM killer */
71#define TIF_POLLING_NRFLAG 14 /* idle is polling for TIF_NEED_RESCHED */
72
73#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
74#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
75#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
76#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
77#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
78#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
79
80/* Work to do on interrupt/exception return. */
81#define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
82 _TIF_NOTIFY_RESUME)
83
84/* Work to do on any return to userspace. */
85#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \
86 | _TIF_SYSCALL_TRACE)
87
88#define TS_UAC_NOPRINT 0x0001 /* ! Preserve the following three */
89#define TS_UAC_NOFIX 0x0002 /* ! flags as they match */
90#define TS_UAC_SIGBUS 0x0004 /* ! userspace part of 'osf_sysinfo' */
91#define TS_RESTORE_SIGMASK 0x0008 /* restore signal mask in do_signal() */
92
93#ifndef __ASSEMBLY__
94#define HAVE_SET_RESTORE_SIGMASK 1
95static inline void set_restore_sigmask(void)
96{
97 struct thread_info *ti = current_thread_info();
98 ti->status |= TS_RESTORE_SIGMASK;
99 WARN_ON(!test_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags));
100}
101static inline void clear_restore_sigmask(void)
102{
103 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
104}
105static inline bool test_restore_sigmask(void)
106{
107 return current_thread_info()->status & TS_RESTORE_SIGMASK;
108}
109static inline bool test_and_clear_restore_sigmask(void)
110{
111 struct thread_info *ti = current_thread_info();
112 if (!(ti->status & TS_RESTORE_SIGMASK))
113 return false;
114 ti->status &= ~TS_RESTORE_SIGMASK;
115 return true;
116}
117#endif
118
119#define SET_UNALIGN_CTL(task,value) ({ \
120 __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \
121 if (value & PR_UNALIGN_NOPRINT) \
122 status |= TS_UAC_NOPRINT; \
123 if (value & PR_UNALIGN_SIGBUS) \
124 status |= TS_UAC_SIGBUS; \
125 if (value & 4) /* alpha-specific */ \
126 status |= TS_UAC_NOFIX; \
127 task_thread_info(task)->status = status; \
128 0; })
129
130#define GET_UNALIGN_CTL(task,value) ({ \
131 __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \
132 __u32 res = 0; \
133 if (status & TS_UAC_NOPRINT) \
134 res |= PR_UNALIGN_NOPRINT; \
135 if (status & TS_UAC_SIGBUS) \
136 res |= PR_UNALIGN_SIGBUS; \
137 if (status & TS_UAC_NOFIX) \
138 res |= 4; \
139 put_user(res, (int __user *)(value)); \
140 })
141
142#endif /* __KERNEL__ */
143#endif /* _ALPHA_THREAD_INFO_H */