public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kaz Kojima <kkojima@rr.iij4u.or.jp>
To: java-patches@gcc.gnu.org
Cc: gcc-patches@gcc.gnu.org
Subject: [patch committed libjava] Update sysdep/sh/locks.h with atomic builtins
Date: Thu, 14 Jun 2012 22:59:00 -0000	[thread overview]
Message-ID: <20120615.075923.418533941.kkojima@rr.iij4u.or.jp> (raw)

Hi,

I've applied the attached patch which updates libjava/sysdep/sh/locks.h
with new atomic builtins.  Tested on sh4-unknown-linux-gnu with no new
failures.

Regards,
	kaz
--
2012-06-14  Kaz Kojima  <kkojima@gcc.gnu.org>

	* sysdep/sh/locks.h (__cas_lock): Remove.
	(__cas_start_atomic, __cas_end_atomic): Likewise.
	(compare_and_swap): Call __sync_bool_compare_and_swap.

--- ORIG/trunk/libjava/sysdep/sh/locks.h	2007-01-13 09:53:55.000000000 +0900
+++ trunk/libjava/sysdep/sh/locks.h	2012-06-14 19:18:34.000000000 +0900
@@ -14,45 +14,11 @@ details.  */
 typedef size_t obj_addr_t;	/* Integer type big enough for object	*/
 				/* address.				*/
 
-static unsigned char __cas_lock = 0;
-
-inline static void
-__cas_start_atomic (void)
-{
-  unsigned int val;
-
-  do
-    __asm__ __volatile__ ("tas.b @%1; movt %0"
-			  : "=r" (val)
-			  : "r" (&__cas_lock)
-			  : "memory");
-  while (val == 0);
-}
-
-inline static void
-__cas_end_atomic (void)
-{
-  __asm__ __volatile__ (" " : : : "memory");
-  __cas_lock = 0;
-}
-
 inline static bool
 compare_and_swap (volatile obj_addr_t *addr, obj_addr_t old,
 		  obj_addr_t new_val)
 {
-  bool ret;
-
-  __cas_start_atomic ();
-  if (*addr != old)
-    ret = false;
-  else
-    {
-      *addr = new_val;
-      ret = true;
-    }
-  __cas_end_atomic ();
-
-  return ret;
+  return __sync_bool_compare_and_swap (addr, old, new_val);
 }
 
 inline static void

                 reply	other threads:[~2012-06-14 22:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120615.075923.418533941.kkojima@rr.iij4u.or.jp \
    --to=kkojima@rr.iij4u.or.jp \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=java-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).