From 8de135ff7684ad93f83f4a06975343efcdac8f49 Mon Sep 17 00:00:00 2001 From: ivmai Date: Mon, 5 Oct 2009 16:43:01 +0000 Subject: [PATCH] 2009-10-05 Ivan Maidanski (really Takashi YOSHII) * src/atomic_ops/sysdeps/gcc/sh.h: New file. * src/atomic_ops.h: Include gcc/sh.h if __arm__. * src/atomic_ops/sysdeps/Makefile.am: Add gcc/sh.h entry. --- ChangeLog | 12 +++++++--- src/atomic_ops.h | 4 ++++ src/atomic_ops/sysdeps/Makefile.am | 2 +- src/atomic_ops/sysdeps/gcc/sh.h | 37 ++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 src/atomic_ops/sysdeps/gcc/sh.h diff --git a/ChangeLog b/ChangeLog index cbf2158..8de5720 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,14 @@ +2009-10-05 Ivan Maidanski (really Takashi YOSHII) + + * src/atomic_ops/sysdeps/gcc/sh.h: New file. + * src/atomic_ops.h: Include gcc/sh.h if __arm__. + * src/atomic_ops/sysdeps/Makefile.am: Add gcc/sh.h entry. + 2009-10-02 Ivan Maidanski - * Makefile.am: Add armcc/arm_v6.h, msftc/arm.h, - msftc/common32_defs.h, sunc/x86.h sunc/x86_64.h entries; order all - entries alphabetically. + * src/atomic_ops/sysdeps/Makefile.am: Add armcc/arm_v6.h, + msftc/arm.h, msftc/common32_defs.h, sunc/x86.h sunc/x86_64.h + entries; order all entries alphabetically. * Makefile.in: Regenerate. 2009-10-01 Ivan Maidanski diff --git a/src/atomic_ops.h b/src/atomic_ops.h index 5edcf1a..1424711 100644 --- a/src/atomic_ops.h +++ b/src/atomic_ops.h @@ -241,6 +241,10 @@ # if defined(__mips__) # include "atomic_ops/sysdeps/gcc/mips.h" # endif /* __mips__ */ +# if defined(__sh__) || defined(SH4) +# include "atomic_ops/sysdeps/gcc/sh.h" +# define AO_CAN_EMUL_CAS +# endif /* __sh__ */ #endif /* __GNUC__ && !AO_USE_PTHREAD_DEFS */ #if defined(__INTEL_COMPILER) && !defined(AO_USE_PTHREAD_DEFS) diff --git a/src/atomic_ops/sysdeps/Makefile.am b/src/atomic_ops/sysdeps/Makefile.am index b06d712..d0274f0 100644 --- a/src/atomic_ops/sysdeps/Makefile.am +++ b/src/atomic_ops/sysdeps/Makefile.am @@ -29,7 +29,7 @@ nobase_sysdep_HEADERS= generic_pthread.h \ gcc/alpha.h gcc/arm.h gcc/cris.h \ gcc/hppa.h gcc/ia64.h gcc/m68k.h \ gcc/mips.h gcc/powerpc.h gcc/s390.h \ - gcc/sparc.h gcc/x86.h gcc/x86_64.h \ + gcc/sh.h gcc/sparc.h gcc/x86.h gcc/x86_64.h \ \ hpc/hppa.h hpc/ia64.h \ \ diff --git a/src/atomic_ops/sysdeps/gcc/sh.h b/src/atomic_ops/sysdeps/gcc/sh.h new file mode 100644 index 0000000..95a89c7 --- /dev/null +++ b/src/atomic_ops/sysdeps/gcc/sh.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2009 by Takashi YOSHII. All rights reserved. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +#include "../all_atomic_load_store.h" +#include "../ordered.h" + +/* sh has tas.b(byte) only */ +#include "../test_and_set_t_is_char.h" + +/* FIXME: Is AO_TS_SET redefining needed? */ +/* #undef AO_TS_SET */ +/* #define AO_TS_SET (1<<7) */ + +AO_INLINE AO_TS_VAL_t +AO_test_and_set_full(volatile AO_TS_t *addr) +{ + int oldval; + + __asm__ __volatile__( + "tas.b @%1; movt %0" + : "=r" (oldval) + : "r" (addr) + : "t", "memory"); + return oldval? AO_TS_CLEAR : AO_TS_SET; +} +#define AO_HAVE_test_and_set_full -- 2.40.0