Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_fixcpp/sys/src/cmd/unix/drawterm/posix-arm/tas.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include "u.h"
2
#include "libc.h"
3
 
4
int
5
tas(long *x)
6
{
7
	int     v, t, i = 1;
8
 
9
#if ARMv5
10
	__asm__(
11
		"swp  %0, %1, [%2]"
12
		: "=&r" (v)
13
		: "r" (1), "r" (x)
14
		: "memory"
15
	);
16
#else
17
	__asm__ (
18
		"1:	ldrex	%0, [%2]\n"
19
		"	strex	%1, %3, [%2]\n"
20
		"	teq	%1, #0\n"
21
		"	bne	1b"
22
		: "=&r" (v), "=&r" (t)
23
		: "r" (x), "r" (i)
24
		: "cc");
25
#endif
26
	switch(v) {
27
	case 0:
28
	case 1:
29
		return v;
30
	default:
31
		print("canlock: corrupted 0x%lux\n", v);
32
		return 1;
33
	}
34
}
35