NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/38482: C compiler can generate non-restartable code within a RAS



The following reply was made to PR lib/38482; it has been noted by GNATS.

From: Steve Woodford <scw%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: lib-bug-people%netbsd.org@localhost,
 gnats-admin%netbsd.org@localhost,
 netbsd-bugs%netbsd.org@localhost
Subject: Re: lib/38482: C compiler can generate non-restartable code within a 
RAS
Date: Mon, 21 Apr 2008 22:38:52 +0100

 --Boundary-00=_tlQDInHx5ZUGTgu
 Content-Type: text/plain;
   charset="iso-8859-1"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline
 
 A patch which addresses this problem for ARM and m68000 is attached.
 
 The patch adds -D__HAVE_ASM_ATOMIC_CAS_UP to CPPFLAGS in the ARM and 
 m68000 Makefile.inc fragments, which atomic_init_testset.c uses to 
 determine if an asm version of atomic_cas_up() is present.
 
 Once all affected archs have been fixed, -D__HAVE_ASM_ATOMIC_CAS_UP can 
 be removed.
 
 The namespace police may want to give this the once-over. Unless I hear 
 any objections, I'll commit it in a few days.
 
 Cheers, Steve
 
 --Boundary-00=_tlQDInHx5ZUGTgu
 Content-Type: text/x-diff;
   charset="iso-8859-1";
   name="atomic_cas.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
        filename="atomic_cas.diff"
 
 diff -ruN -x CVS 
/export/netbsd/pristine/common/lib/libc/arch/arm/atomic/Makefile.inc 
common/lib/libc/arch/arm/atomic/Makefile.inc
 --- /export/netbsd/pristine/common/lib/libc/arch/arm/atomic/Makefile.inc       
2008-04-21 22:26:12.000000000 +0100
 +++ common/lib/libc/arch/arm/atomic/Makefile.inc       2008-04-21 
22:12:51.000000000 +0100
 @@ -12,5 +12,7 @@
  .if defined(LIB) && (${LIB} == "c")
  
  SRCS+=        atomic_init_testset.c
 +SRCS+=        atomic_cas_up.S
 +CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP
  
  .endif
 diff -ruN -x CVS 
/export/netbsd/pristine/common/lib/libc/arch/arm/atomic/atomic_cas_up.S 
common/lib/libc/arch/arm/atomic/atomic_cas_up.S
 --- /export/netbsd/pristine/common/lib/libc/arch/arm/atomic/atomic_cas_up.S    
1970-01-01 01:00:00.000000000 +0100
 +++ common/lib/libc/arch/arm/atomic/atomic_cas_up.S    2008-04-21 
22:11:57.000000000 +0100
 @@ -0,0 +1,54 @@
 +/*    $NetBSD$        */
 +
 +/*-
 + * Copyright (c) 2008 The NetBSD Foundation, Inc.
 + * All rights reserved.
 + *
 + * This code is derived from software contributed to The NetBSD Foundation
 + * by Steve C. Woodford.
 + *
 + * Redistribution and use in source and binary forms, with or without
 + * modification, are permitted provided that the following conditions
 + * are met:
 + * 1. Redistributions of source code must retain the above copyright
 + *    notice, this list of conditions and the following disclaimer.
 + * 2. Redistributions in binary form must reproduce the above copyright
 + *    notice, this list of conditions and the following disclaimer in the
 + *    documentation and/or other materials provided with the distribution.
 + * 3. All advertising materials mentioning features or use of this software
 + *    must display the following acknowledgement:
 + *        This product includes software developed by the NetBSD
 + *        Foundation, Inc. and its contributors.
 + * 4. Neither the name of The NetBSD Foundation nor the names of its
 + *    contributors may be used to endorse or promote products derived
 + *    from this software without specific prior written permission.
 + *
 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 + * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 + * POSSIBILITY OF SUCH DAMAGE.
 + */
 +
 +#include <machine/asm.h>
 +
 +      .globl  _C_LABEL(_atomic_cas_ras_start)
 +      .type   _C_LABEL(_atomic_cas_ras_start),_ASM_TYPE_FUNCTION
 +
 +      .globl  _C_LABEL(_atomic_cas_ras_end)
 +      .type   _C_LABEL(_atomic_cas_ras_end),_ASM_TYPE_FUNCTION
 +
 +ENTRY_NP(_atomic_cas_up)
 +      mov     r3, r0
 +_C_LABEL(_atomic_cas_ras_start):
 +      ldr     r0, [r3]
 +      cmp     r0, r1
 +      streq   r2, [r3]
 +_C_LABEL(_atomic_cas_ras_end):
 +      RET
 diff -ruN -x CVS 
/export/netbsd/pristine/common/lib/libc/arch/m68k/atomic/Makefile.inc 
common/lib/libc/arch/m68k/atomic/Makefile.inc
 --- /export/netbsd/pristine/common/lib/libc/arch/m68k/atomic/Makefile.inc      
2008-04-21 22:26:12.000000000 +0100
 +++ common/lib/libc/arch/m68k/atomic/Makefile.inc      2008-04-21 
22:13:04.000000000 +0100
 @@ -33,6 +33,8 @@
  .else
  
  SRCS+=        atomic_init_testset.c
 +SRCS+=        atomic_cas_68000.S
 +CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP
  
  .endif
  .endif
 diff -ruN -x CVS 
/export/netbsd/pristine/common/lib/libc/arch/m68k/atomic/atomic_cas_68000.S 
common/lib/libc/arch/m68k/atomic/atomic_cas_68000.S
 --- 
/export/netbsd/pristine/common/lib/libc/arch/m68k/atomic/atomic_cas_68000.S     
   1970-01-01 01:00:00.000000000 +0100
 +++ common/lib/libc/arch/m68k/atomic/atomic_cas_68000.S        2008-04-21 
22:14:12.000000000 +0100
 @@ -0,0 +1,56 @@
 +/*    $NetBSD$        */
 +
 +/*-
 + * Copyright (c) 2008 The NetBSD Foundation, Inc.
 + * All rights reserved.
 + *
 + * This code is derived from software contributed to The NetBSD Foundation
 + * by Steve C. Woodford.
 + *
 + * Redistribution and use in source and binary forms, with or without
 + * modification, are permitted provided that the following conditions
 + * are met:
 + * 1. Redistributions of source code must retain the above copyright
 + *    notice, this list of conditions and the following disclaimer.
 + * 2. Redistributions in binary form must reproduce the above copyright
 + *    notice, this list of conditions and the following disclaimer in the
 + *    documentation and/or other materials provided with the distribution.
 + * 3. All advertising materials mentioning features or use of this software
 + *    must display the following acknowledgement:
 + *    This product includes software developed by the NetBSD
 + *    Foundation, Inc. and its contributors.
 + * 4. Neither the name of The NetBSD Foundation nor the names of its
 + *    contributors may be used to endorse or promote products derived
 + *    from this software without specific prior written permission.
 + *      
 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 + * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 + * POSSIBILITY OF SUCH DAMAGE.
 + */
 +
 +#include "atomic_op_asm.h"
 +
 +      .text
 +
 +      .globl  _C_LABEL(_atomic_cas_ras_start)
 +      .globl  _C_LABEL(_atomic_cas_ras_end)
 +
 +ENTRY_NOPROFILE(_atomic_cas_up)
 +      movl    %sp@(4), %a0            /* Fetch ptr */
 +
 +_C_LABEL(_atomic_cas_ras_start):
 +      movl    %a0@, d0                /* d0 = *ptr */
 +      cmp     %sp@(8), d0             /* Same as old? */
 +      jne     1f                      /* Nope */
 +      movl    %sp@(12), %a0@          /* *ptr = new */
 +_C_LABEL(_atomic_cas_ras_end):
 +1:    rts
 +
 diff -ruN -x CVS 
/export/netbsd/pristine/common/lib/libc/atomic/atomic_init_testset.c 
common/lib/libc/atomic/atomic_init_testset.c
 --- /export/netbsd/pristine/common/lib/libc/atomic/atomic_init_testset.c       
2008-04-21 22:26:12.000000000 +0100
 +++ common/lib/libc/atomic/atomic_init_testset.c       2008-04-21 
22:13:38.000000000 +0100
 @@ -66,6 +66,9 @@
  
  RAS_DECL(_atomic_cas);
  
 +#ifdef        __HAVE_ASM_ATOMIC_CAS_UP
 +extern uint32_t _atomic_cas_up(volatile uint32_t *, uint32_t, uint32_t);
 +#else
  static uint32_t
  _atomic_cas_up(volatile uint32_t *ptr, uint32_t old, uint32_t new)
  {
 @@ -81,6 +84,7 @@
  
        return ret;
  }
 +#endif
  
  static uint32_t
  _atomic_cas_mp(volatile uint32_t *ptr, uint32_t old, uint32_t new)
 
 --Boundary-00=_tlQDInHx5ZUGTgu--
 


Home | Main Index | Thread Index | Old Index