linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* test & set ppc assembly (libgcj vs. threads)
@ 1999-08-02 15:54 Brad Midgley
  1999-08-02 18:49 ` Daniel Jacobowitz
  1999-08-02 19:02 ` David Edelsohn
  0 siblings, 2 replies; 3+ messages in thread
From: Brad Midgley @ 1999-08-02 15:54 UTC (permalink / raw)
  To: linuxppc-dev


hi...

i would like to see libgcj work on ppc. i guess there isn't anyone working
on it because there is missing stuff even in the cvs version. 

could one of you ppc assembly gurus put forward the code to do a test &
set? the header here hopefully provides all the necessary context with
the x86 and alpha implementations... 

brad

#  ifdef LINUX_THREADS
#    include <pthread.h>
#    ifdef __i386__
       inline static int GC_test_and_set(volatile unsigned int *addr) {
          int oldval;
          /* Note: the "xchg" instruction does not need a "lock" prefix */
          __asm__ __volatile__("xchgl %0, %1"
                : "=r"(oldval), "=m"(*(addr))
                : "0"(1), "m"(*(addr)));
          return oldval;
       }
       inline static void GC_clear(volatile unsigned int *addr) {
          *(addr) = 0;
       }
#    elif defined(__alpha__)
       inline static int GC_test_and_set(volatile unsigned int *addr) {
        long oldval, temp;

        __asm__ __volatile__(
              "1:\tldl_l %0,%3\n"
              "\tbne %0,2f\n"
              "\tor $31,1,%1\n"
              "\tstl_c %1,%2\n"
              "\tbeq %1,1b\n"
              "2:\tmb\n"
              : "=&r"(oldval), "=&r"(temp), "=m"(*(addr))
              : "m"(*(addr))
              : "memory");
        return (int)oldval;
       }
       inline static void GC_clear(volatile unsigned int *addr) {
          __asm__ __volatile__("mb": : :"memory");
          *(addr) = 0;
       }
#    else
       -- > Need implementation of GC_test_and_set()
#    endif

[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: test & set ppc assembly (libgcj vs. threads)
  1999-08-02 15:54 test & set ppc assembly (libgcj vs. threads) Brad Midgley
@ 1999-08-02 18:49 ` Daniel Jacobowitz
  1999-08-02 19:02 ` David Edelsohn
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 1999-08-02 18:49 UTC (permalink / raw)
  To: Brad Midgley; +Cc: linuxppc-dev


On Mon, Aug 02, 1999 at 09:54:55AM -0600, Brad Midgley wrote:
> 
> hi...
> 
> i would like to see libgcj work on ppc. i guess there isn't anyone working
> on it because there is missing stuff even in the cvs version. 
> 
> could one of you ppc assembly gurus put forward the code to do a test &
> set? the header here hopefully provides all the necessary context with
> the x86 and alpha implementations... 


Look at the debian package of libgc4.  We patched this a while ago.

The patch is in the .diff.gz on any debian source mirror (<searches>):
/debian/dists/unstable/main/source/libs/libgc4_*



Dan

/--------------------------------\  /--------------------------------\
|       Daniel Jacobowitz        |__|        SCS Class of 2002       |
|   Debian GNU/Linux Developer    __    Carnegie Mellon University   |
|         dan@debian.org         |  |       dmj+@andrew.cmu.edu      |
\--------------------------------/  \--------------------------------/

[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: test & set ppc assembly (libgcj vs. threads)
  1999-08-02 15:54 test & set ppc assembly (libgcj vs. threads) Brad Midgley
  1999-08-02 18:49 ` Daniel Jacobowitz
@ 1999-08-02 19:02 ` David Edelsohn
  1 sibling, 0 replies; 3+ messages in thread
From: David Edelsohn @ 1999-08-02 19:02 UTC (permalink / raw)
  To: Brad Midgley; +Cc: linuxppc-dev


	The PowerPC User's Manuals provide an example in the appendix:

loop:	lwarx	    r5, 0, r3	   # load and reserve
	cmpwi	    r5, 0	   # compare to zero
	bne	    $+12	   # done if not equal
	stwcx.	    r4, 0, r3	   # try to store non-zero
	bne-	    loop	   # loop if lost reservation

r3 = address
r4 = new value
r5 = old value

David

[[ This message was sent via the linuxppc-dev mailing list.  Replies are ]]
[[ not  forced  back  to the list, so be sure to Cc linuxppc-dev if your ]]
[[ reply is of general interest. Please check http://lists.linuxppc.org/ ]]
[[ and http://www.linuxppc.org/ for useful information before posting.   ]]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-08-02 19:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-08-02 15:54 test & set ppc assembly (libgcj vs. threads) Brad Midgley
1999-08-02 18:49 ` Daniel Jacobowitz
1999-08-02 19:02 ` David Edelsohn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).