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    am33 version.
00003    Copyright (C) 1996,1997,1998,1999,2000,2001, 2004
00004    Free Software Foundation, Inc.
00005    This file is part of the GNU C Library.
00006    Contributed by Alexandre Oliva <aoliva@redhat.com>
00007    Based on ../i386/pt-machine.h.
00008 
00009    The GNU C Library is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU Library General Public License as
00011    published by the Free Software Foundation; either version 2 of the
00012    License, or (at your option) any later version.
00013 
00014    The GNU C Library is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    Library General Public License for more details.
00018 
00019    You should have received a copy of the GNU Library General Public
00020    License along with the GNU C Library; see the file COPYING.LIB.  If not,
00021    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022    Boston, MA 02111-1307, USA.  */
00023 
00024 #ifndef _PT_MACHINE_H
00025 #define _PT_MACHINE_H       1
00026 
00027 #ifndef __ASSEMBLER__
00028 #ifndef PT_EI
00029 # define PT_EI extern inline
00030 #endif
00031 
00032 /* Get some notion of the current stack.  Need not be exactly the top
00033    of the stack, just something somewhere in the current frame.  */
00034 #define CURRENT_STACK_FRAME  __builtin_frame_address (0)
00035 
00036 /* Spinlock implementation; required.  */
00037 PT_EI long int
00038 testandset (int *spinlock)
00039 {
00040   long int ret = 1;
00041 
00042   /* This won't test&set the entire int, only the least significant
00043      byte.  I hope this doesn't matter, since we can't do better.  */
00044   __asm__ __volatile__ ("bset %0, %1; bne 1f; clr %0; 1:" :
00045                      "+d" (ret), "+m" (*(volatile int *)spinlock));
00046 
00047   return ret;
00048 }
00049 
00050 
00051 PT_EI int
00052 get_eflags (void)
00053 {
00054   int res;
00055   __asm__ __volatile__ ("mov psw,%0" : "=d" (res));
00056   return res;
00057 }
00058 
00059 
00060 PT_EI void
00061 set_eflags (int newflags)
00062 {
00063   __asm__ __volatile__ ("mov %0,psw" : : "d" (newflags) : "cc");
00064 }
00065 
00066 #endif /* __ASSEMBLER__ */
00067 
00068 #endif /* pt-machine.h */