From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22082 invoked by alias); 14 Jun 2012 22:59:42 -0000 Received: (qmail 22060 invoked by uid 22791); 14 Jun 2012 22:59:41 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_VIA_APNIC,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mo11.iij4u.or.jp (HELO mo.iij4u.or.jp) (210.138.174.79) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Jun 2012 22:59:25 +0000 Received: by mo.iij4u.or.jp (mo11) id q5EMxOQt023671; Fri, 15 Jun 2012 07:59:24 +0900 Received: from localhost (238.152.138.210.bn.2iij.net [210.138.152.238]) by mbox.iij4u.or.jp (mbox10) id q5EMxN3d024970; Fri, 15 Jun 2012 07:59:23 +0900 Date: Thu, 14 Jun 2012 22:59:00 -0000 Message-Id: <20120615.075923.418533941.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 From: Kaz Kojima Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact java-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-patches-owner@gcc.gnu.org X-SW-Source: 2012-q2/txt/msg00020.txt.bz2 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 * 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