File: tas.c

package info (click to toggle)
drawterm 20110822-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 2,944 kB
  • ctags: 5,508
  • sloc: ansic: 55,192; makefile: 568; sh: 23; asm: 20
file content (23 lines) | stat: -rw-r--r-- 273 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "u.h"
#include "libc.h"

int
tas(long *x)
{
	int     v;

	__asm__(	"movl   $1, %%eax\n\t"
				"xchgl  %%eax,(%%rcx)"
				: "=a" (v)
				: "c" (x)
	);
	switch(v) {
	case 0:
	case 1:
		return v;
	default:
		print("canlock: corrupted 0x%lux\n", v);
		return 1;
	}
}