2006-02-09 Joseph S. Myers <joseph@codesourcery.com>
[glibc-ports.git] / sysdeps / am33 / linuxthreads / pt-machine.h
blobba80bfb5ef22d678cefcc38fe6ecc57c7a372e9d
1 /* Machine-dependent pthreads configuration and inline functions.
2 am33 version.
3 Copyright (C) 1996,1997,1998,1999,2000,2001, 2004
4 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
6 Contributed by Alexandre Oliva <aoliva@redhat.com>
7 Based on ../i386/pt-machine.h.
9 The GNU C Library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version.
14 The GNU C Library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
19 You should have received a copy of the GNU Library General Public
20 License along with the GNU C Library; see the file COPYING.LIB. If not,
21 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
24 #ifndef _PT_MACHINE_H
25 #define _PT_MACHINE_H 1
27 #ifndef __ASSEMBLER__
28 #ifndef PT_EI
29 # define PT_EI extern inline
30 #endif
32 /* Get some notion of the current stack. Need not be exactly the top
33 of the stack, just something somewhere in the current frame. */
34 #define CURRENT_STACK_FRAME __builtin_frame_address (0)
36 /* Spinlock implementation; required. */
37 PT_EI long int
38 testandset (int *spinlock)
40 long int ret = 1;
42 /* This won't test&set the entire int, only the least significant
43 byte. I hope this doesn't matter, since we can't do better. */
44 __asm__ __volatile__ ("bset %0, %1; bne 1f; clr %0; 1:" :
45 "+d" (ret), "+m" (*(volatile int *)spinlock));
47 return ret;
51 PT_EI int
52 get_eflags (void)
54 int res;
55 __asm__ __volatile__ ("mov psw,%0" : "=d" (res));
56 return res;
60 PT_EI void
61 set_eflags (int newflags)
63 __asm__ __volatile__ ("mov %0,psw" : : "d" (newflags) : "cc");
66 #endif /* __ASSEMBLER__ */
68 #endif /* pt-machine.h */