summaryrefslogtreecommitdiffstats
path: root/include/asm-arm/current.h
blob: b2b83ebb7b641f8a35babb6cb1b155014c59e452 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef _ASMARM_CURRENT_H
#define _ASMARM_CURRENT_H

static inline unsigned long get_sp(void)
{
	unsigned long sp;
	__asm__ ("mov	%0,sp" : "=r" (sp));
	return sp;
}

/* Old compilers seem to generate bad code if we allow `current' to be
   non volatile.  */
#if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ > 90)
static inline struct task_struct *get_current(void) __attribute__ (( __const__ ));
#define __VOLATILE_CURRENT
#else
#define __VOLATILE_CURRENT volatile
#endif

static inline struct task_struct *get_current(void)
{
	struct task_struct *ts;
	__asm__ __VOLATILE_CURRENT (
	"bic	%0, sp, #0x1f00		@ get_current
	bic	%0, %0, #0x00ff" 
	: "=r" (ts));
	return ts;
}

#define current (get_current())

#endif /* _ASMARM_CURRENT_H */