Skip Tavakkolian schrieb:
>>gcc -Wall -Wno-missing-braces -ggdb -I.. -I../include -I../kern -c
>>-I/usr/X11R6/include -D_THREAD_SAFE -pthread -O2 tas.c
>>/tmp/cc4SeP4G.s: Assembler messages:
> 
> 
> what's $arch set to? was G4 support added recently?

My PowerBook (also with Ubuntu Linux) sets it to "ppc", via uname -m, as
per Make.unix. For MacOS X, $arch is appearently set to "power", so as a
quick work-around to the assembly problems, I copied posix-power to
posix-ppc and changed tas.c as attached. The only problem seems to be a
slight disagreement in assembly syntax between MacOS and Linux. *shrug*

Regards,
Sven Moritz

PS. In fact, the only thing different on Linux is that register names
are not profixed with 'r', so, for example, instead of "li r0,0" on
MacOS, it's just "li 0,0" on Linux...

PPS. Do I hear the #ifdef's calling? *duck* No! No! No!
#include "u.h"
#include "libc.h"

/*
 * first argument (l) is in r3 at entry.
 * r3 contains return value upon return.
 */
int
tas(long *x)
{
	int     v;
	/*
	 * this __asm__ works with gcc 2.95.2 (mac os x 10.1).
	 * this assembly language destroys r0 (0), some other register (v),
	 * r4 (x) and r5 (temp).
	 */
	__asm__("\n	sync\n"
	"	li	0,0\n"
	"	mr	4,%1		/* &l->val */\n"
	"	lis	5,0xdead	/* assemble constant 0xdeaddead */\n"
	"	ori	5,5,0xdead	/* \" */\n"
	"tas1:\n"
	"	dcbf	4,0	/* cache flush; \"fix for 603x bug\" */\n"
	"	lwarx	%0,4,0	/* v = l->val with reservation */\n"
	"	cmp	cr0,0,%0,0	/* v == 0 */\n"
	"	bne	tas0\n"
	"	stwcx.	5,4,0   /* if (l->val same) l->val = 0xdeaddead */\n"
	"	bne	tas1\n"
	"tas0:\n"
	"	sync\n"
	"	isync\n"
	: "=r" (v)
	: "r"  (x)
	: "cc", "memory", "r0", "r4", "r5"
	);
	switch(v) {
	case 0:		return 0;
	case 0xdeaddead: return 1;
	default:	print("tas: corrupted 0x%lux\n", v);
	}
	return 0;
}

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to