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    m68k version.
00003    Copyright (C) 1996, 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005    Contributed by Richard Henderson <rth@tamu.edu>.
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
00019    not, write to the Free Software Foundation, Inc.,
00020    59 Temple Place - Suite 330, 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 #ifndef __mcoldfire__
00031 extern int __compare_and_swap (long int *p, long int oldval, long int newval);
00032 #endif
00033 
00034 /* Spinlock implementation; required.  */
00035 PT_EI long int
00036 testandset (int *spinlock)
00037 {
00038   char ret;
00039 
00040   __asm__ __volatile__("tas %1; sne %0"
00041        : "=dm"(ret), "=m"(*spinlock)
00042        : "m"(*spinlock)
00043        : "cc");
00044 
00045   return ret;
00046 }
00047 
00048 
00049 /* Get some notion of the current stack.  Need not be exactly the top
00050    of the stack, just something somewhere in the current frame.  */
00051 #define CURRENT_STACK_FRAME  stack_pointer
00052 register char * stack_pointer __asm__ ("%sp");
00053 
00054 
00055 #ifndef __mcoldfire__
00056 /* Compare-and-swap for semaphores. */
00057 
00058 #define HAS_COMPARE_AND_SWAP
00059 PT_EI int
00060 __compare_and_swap (long int *p, long int oldval, long int newval)
00061 {
00062   char ret;
00063   long int readval;
00064 
00065   __asm__ __volatile__ ("casl %2, %3, %1; seq %0"
00066                      : "=dm" (ret), "=m" (*p), "=d" (readval)
00067                      : "d" (newval), "m" (*p), "2" (oldval));
00068 
00069   return ret;
00070 }
00071 #endif
00072 
00073 #endif /* pt-machine.h */