gcc/ 2012-06-18 Mikael Pettersson * config/m68k/linux-atomic.c: Update description and attribution. Remove ARM and little-endian specific code. (__kernel_cmpxchg): Replace with clone of libjava/sysdep/m68k/locks.h (compare_and_swap), negate return value to match different calling convention. (__kernel_dmb): Replace with clone of libjava/sysdep/m68k/locks.h (write_barrier). --- gcc-4.6.3/gcc/config/m68k/linux-atomic.c.~1~ 2012-06-18 22:12:40.000000000 +0200 +++ gcc-4.6.3/gcc/config/m68k/linux-atomic.c 2012-06-18 22:34:08.000000000 +0200 @@ -1,6 +1,7 @@ -/* Linux-specific atomic operations for ARM EABI. +/* Linux-specific atomic operations for M68K Linux. Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. - Contributed by CodeSourcery. + Based on code contributed by CodeSourcery for ARM EABI Linux. + Modifications for M68K Linux by Mikael Pettersson This file is part of GCC. @@ -23,13 +24,38 @@ a copy of the GCC Runtime Library Except see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ -/* Kernel helper for compare-and-exchange. */ -typedef int (__kernel_cmpxchg_t) (int oldval, int newval, int *ptr); -#define __kernel_cmpxchg (*(__kernel_cmpxchg_t *) 0xffff0fc0) - -/* Kernel helper for memory barrier. */ -typedef void (__kernel_dmb_t) (void); -#define __kernel_dmb (*(__kernel_dmb_t *) 0xffff0fa0) +#if (defined(__mc68020__) || defined(__mc68030__) \ + || defined(__mc68040__) || defined(__mc68060__)) \ + && !defined(__mcpu32__) + +/* The target has CAS. */ + +static inline int +__kernel_cmpxchg (int oldval, int newval, int *ptr) +{ + char success; + + __asm__ __volatile__ ( + "cas.l %2,%3,%0\n\t" + "seq %1" + : "+m" (*ptr), "=d" (success), "+d" (oldval) + : "d" (newval) + : "memory", "cc"); + return !success; /* Callers expect failure return, not success. */ +} + +static inline void +__kernel_dmb (void) +{ + /* M68K does not reorder writes. Ensure that gcc also does not. */ + __asm__ __volatile__("" : : : "memory"); +} + +#else /* !mc680[2346] */ + +#error "NYI: use kernel helpers for non-mc680[2346]0 ISAs" + +#endif /* !mc680[2346] */ /* Note: we implement byte, short and int versions of atomic operations using the above kernel helpers, but there is no support for "long long" (64-bit) @@ -37,13 +63,9 @@ typedef void (__kernel_dmb_t) (void); #define HIDDEN __attribute__ ((visibility ("hidden"))) -#ifdef __ARMEL__ -#define INVERT_MASK_1 0 -#define INVERT_MASK_2 0 -#else +/* Big endian masks */ #define INVERT_MASK_1 24 #define INVERT_MASK_2 16 -#endif #define MASK_1 0xffu #define MASK_2 0xffffu