Back to index

glibc  2.9
pt-machine.h
Go to the documentation of this file.
00001 /* Machine-dependent pthreads configuration and inline functions.
00002    ARM version.
00003    Copyright (C) 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005    Contributed by Philip Blundell <philb@gnu.org>.
00006 
00007    The GNU C Library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public License as
00009    published by the Free Software Foundation; either version 2.1 of the
00010    License, or (at your option) any later version.
00011 
00012    The GNU C Library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Lesser General Public License for more details.
00016 
00017    You should have received a copy of the GNU Lesser General Public
00018    License along with the GNU C Library; see the file COPYING.LIB.  If not,
00019    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020    Boston, MA 02111-1307, USA.  */
00021 
00022 #ifndef _PT_MACHINE_H
00023 #define _PT_MACHINE_H   1
00024 
00025 #ifndef PT_EI
00026 # define PT_EI extern inline __attribute__ ((always_inline))
00027 #endif
00028 
00029 extern long int testandset (int *spinlock);
00030 extern int __compare_and_swap (long int *p, long int oldval, long int newval);
00031 
00032 /* This will not work on ARM1 or ARM2 because SWP is lacking on those
00033    machines.  Unfortunately we have no way to detect this at compile
00034    time; let's hope nobody tries to use one.  */
00035 
00036 /* Spinlock implementation; required.  */
00037 PT_EI long int
00038 testandset (int *spinlock)
00039 {
00040   register unsigned int ret;
00041 
00042   __asm__ __volatile__("swp %0, %1, [%2]"
00043                      : "=r"(ret)
00044                      : "0"(1), "r"(spinlock));
00045 
00046   return ret;
00047 }
00048 
00049 
00050 /* Get some notion of the current stack.  Need not be exactly the top
00051    of the stack, just something somewhere in the current frame.  */
00052 #define CURRENT_STACK_FRAME  stack_pointer
00053 register char * stack_pointer __asm__ ("sp");
00054 
00055 #endif /* pt-machine.h */