1 Subject: [PATCH] libpthread: AVR32 support
3 Implement pt-machine.h for AVR32.
6 libpthread/linuxthreads/sysdeps/avr32/pt-machine.h | 92 +++++++++++++++++++++
7 1 file changed, 92 insertions(+)
9 Index: uClibc-0.9.28/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
10 ===================================================================
11 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
12 +++ uClibc-0.9.28/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h 2006-02-07 17:14:47.000000000 +0100
14 +/* Machine-dependent pthreads configuration and inline functions.
16 + Copyright (C) 2005 Atmel Norway
17 + This file is part of the GNU C Library.
19 + The GNU C Library is free software; you can redistribute it and/or
20 + modify it under the terms of the GNU Lesser General Public License as
21 + published by the Free Software Foundation; either version 2.1 of the
22 + License, or (at your option) any later version.
24 + The GNU C Library is distributed in the hope that it will be useful,
25 + but WITHOUT ANY WARRANTY; without even the implied warranty of
26 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 + Lesser General Public License for more details.
29 + You should have received a copy of the GNU Lesser General Public
30 + License along with the GNU C Library; see the file COPYING.LIB. If not,
31 + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
32 + Boston, MA 02111-1307, USA. */
34 +#ifndef _PT_MACHINE_H
35 +#define _PT_MACHINE_H 1
37 +#include <features.h>
40 +_test_and_set (int *p, int v) __THROW
44 + __asm__ __volatile__(
45 + "/* Inline test and set */\n"
53 + : "=&r"(result), "=m"(*p)
61 +# define PT_EI extern inline
64 +extern long int testandset (int *spinlock);
65 +extern int __compare_and_swap (long int *p, long int oldval, long int newval);
67 +/* Spinlock implementation; required. */
69 +testandset (int *spinlock)
71 + return _test_and_set(spinlock, 1);
75 +/* Get some notion of the current stack. Need not be exactly the top
76 + of the stack, just something somewhere in the current frame. */
77 +#define CURRENT_STACK_FRAME stack_pointer
78 +register char * stack_pointer __asm__ ("sp");
80 +/* Compare-and-swap for semaphores. */
82 +#define HAS_COMPARE_AND_SWAP
84 +__compare_and_swap(long int *p, long int oldval, long int newval)
86 + long int result, tmp;
88 + __asm__ __volatile__(
89 + "/* Inline compare and swap */\n"
98 + : "=&r"(result), "=&r"(tmp), "=m"(*p)
99 + : "m"(*p), "r"(newval), "r"(oldval)
105 +#endif /* pt-machine.h */