From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 5597 invoked from network); 14 Feb 2000 15:48:57 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 14 Feb 2000 15:48:57 -0000 Received: from mailext04.compaq.com (mailext04.compaq.com [207.18.199.42]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id KAA01240 for ; Mon, 14 Feb 2000 10:48:56 -0500 Received: by mailext04.compaq.com (Postfix, from userid 12345) id 6EE6A104D3D; Mon, 14 Feb 2000 09:48:55 -0600 (CST) Received: from mailint02.im.hou.compaq.com (mailint02.compaq.com [207.18.199.35]) by mailext04.compaq.com (Postfix) with ESMTP id 6ABF6FB101 for ; Mon, 14 Feb 2000 09:48:55 -0600 (CST) Received: by mailint02.im.hou.compaq.com (Postfix, from userid 12345) id D7DD3BC4D8; Mon, 14 Feb 2000 09:48:47 -0600 (CST) Received: from pdgsrv.mro.dec.com (pdgsrv.mro.dec.com [16.34.112.86]) by mailint02.im.hou.compaq.com (Postfix) with ESMTP id 94D23B2A43 for ; Mon, 14 Feb 2000 09:48:47 -0600 (CST) Received: from linux08.mro.dec.com by pdgsrv.mro.dec.com; (8.8.8/1.1.8.2/13Dec96-1209PM) id KAA12284; Mon, 14 Feb 2000 10:48:53 -0500 (EST) Received: from linux08.mro.dec.com (localhost [127.0.0.1]) by linux08.mro.dec.com (8.9.3/8.9.3) with ESMTP id KAA24524 for ; Mon, 14 Feb 2000 10:51:08 -0500 Message-Id: <200002141551.KAA24524@linux08.mro.dec.com> To: axp-list@redhat.com Subject: Re: how to simulate an unaligned ldl_l In-reply-to: Your message of Mon, 14 Feb 2000 08:15:23 -0500. <38A7FFEB.9FF8CC1@zk3.dec.com> Reply-To: Joseph.Martin@Compaq.com Date: Mon, 14 Feb 2000 10:51:08 -0500 From: "Joseph A. Martin" > 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. ]