Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: "Joseph A. Martin" <jmartin@linux08.mro.dec.com>
To: axp-list@redhat.com
Subject: Re: how to simulate an unaligned ldl_l
Date: Mon, 14 Feb 2000 10:51:08 -0500	[thread overview]
Message-ID: <200002141551.KAA24524@linux08.mro.dec.com> (raw)
In-Reply-To: Your message of Mon, 14 Feb 2000 08:15:23 -0500. <38A7FFEB.9FF8CC1@zk3.dec.com>

> i'm looking at a number of routines that use these instructions for
> atomicity, via clear_bit(), set_bit(), etc. in asm/bitops.h.  is there any
> clever way to circumvent this problem?  the only hack i can think of at
> the moment is to use ldl_u to extract it, put it into an aligned longword
> buffer and do the ldl_l on that address instead.  i feel like i'd have to
> be insane to try this, however :)

Doesn't sound like it would work either, since you're not effectively
locking the transfer between the aligned memory word and the unaligned
memory.  I like the __aligned(32) suggestion best, but if you want to
muck with the bitop functions instead of the data structures, consider
a modification like this:

extern __inline__ void set_bit(unsigned long nr, volatile void * addr)
{
	unsigned long oldbit;
	unsigned long temp;
#ifdef UNALIGNED_addr
	unsigned int * m;
	nr += ((unsigned long)addr & 3) << 3;
	addr = (void *)((unsigned long)addr & ~(3L));
	m = ((unsigned int *) addr) + (nr >> 5);
#else
	unsigned int * m = ((unsigned int *) addr) + (nr >> 5);
#endif

	__asm__ __volatile__(
	"1:	ldl_l %0,%1\n"
	"	and %0,%3,%2\n"
	"	bne %2,2f\n"
	"	xor %0,%3,%0\n"
	"	stl_c %0,%1\n"
	"	beq %0,3f\n"
	"2:\n"
	".section .text2,\"ax\"\n"
	"3:	br 1b\n"
	".previous"
	:"=&r" (temp), "=m" (*m), "=&r" (oldbit)
	:"Ir" (1UL << (nr & 31)), "m" (*m));
}




\Joe   [Joseph.Martin@Compaq.com	Joseph A. Martin
			 		Compaq Computer Corporation
					200 Forest Street MRO1-2/K20
 (508) 467-2100				Marlboro, MA  01752  U.S.A.
 ]


  parent reply	other threads:[~2000-02-14 15:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-13 23:20 how to simulate an unaligned ldl_l Ross A. Knepper
2000-02-14  5:07 ` Jay.Estabrook
2000-02-14 13:15   ` Peter Rival
2000-02-14 15:26     ` set_program_attributes message J. Pedro Sousa do Amaral
2000-02-14 15:51     ` Joseph A. Martin [this message]
2000-02-15  3:08 ` how to simulate an unaligned ldl_l Richard Henderson
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox