]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/libpthread/linuxthreads.old/sysdeps/sh64/pt-machine.c
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / libpthread / linuxthreads.old / sysdeps / sh64 / pt-machine.c
1 /* Cloned for uClibc by Paul Mundt, December 2003 */
2 /* Modified by SuperH, Inc. September 2003 */
3
4 /* Machine-dependent pthreads configuration and inline functions.
5    SH5 version.
6    Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
7    This file is part of the GNU C Library.
8    Contributed by Niibe Yutaka <gniibe@m17n.org>.
9
10    The GNU C Library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Library General Public License as
12    published by the Free Software Foundation; either version 2 of the
13    License, or (at your option) any later version.
14
15    The GNU C Library is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    Library General Public License for more details.
19
20    You should have received a copy of the GNU Library General Public
21    License along with the GNU C Library; see the file COPYING.LIB.  If not,
22    see <http://www.gnu.org/licenses/>.  */
23
24 #include "pt-machine.h"
25
26 /* Spinlock implementation; required.  */
27
28 /* The SH5 does not have a suitable test-and-set instruction (SWAP only
29    operates on an aligned quad word). So we use the SH4 version instead.
30    This must be seperately compiled in SHcompact mode, so it cannot be
31    inline. */
32
33 long int testandset (int *spinlock)
34 {
35   int ret;
36
37   __asm__ __volatile__(
38        "tas.b   @%1\n\t"
39        "movt    %0"
40        : "=r" (ret)
41        : "r" (spinlock)
42        : "memory", "cc");
43
44   return (ret == 0);
45 }
46