update AVR32 binutils patches
[openwrt.git] / toolchain / uClibc / patches / 411-libpthread-avr32.patch
1 Subject: [PATCH] libpthread: AVR32 support
2
3 Implement pt-machine.h for AVR32.
4 ---
5
6 libpthread/linuxthreads/sysdeps/avr32/pt-machine.h | 92 +++++++++++++++++++++
7 1 file changed, 92 insertions(+)
8
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
13 @@ -0,0 +1,92 @@
14 +/* Machine-dependent pthreads configuration and inline functions.
15 +
16 + Copyright (C) 2005 Atmel Norway
17 + This file is part of the GNU C Library.
18 +
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.
23 +
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.
28 +
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. */
33 +
34 +#ifndef _PT_MACHINE_H
35 +#define _PT_MACHINE_H 1
36 +
37 +#include <features.h>
38 +
39 +static inline int
40 +_test_and_set (int *p, int v) __THROW
41 +{
42 + int result;
43 +
44 + __asm__ __volatile__(
45 + "/* Inline test and set */\n"
46 + "1: ssrf 5\n"
47 + " ld.w %0, %2\n"
48 + " tst %0, %3\n"
49 + " breq 2f\n"
50 + " stcond %1, %3\n"
51 + " brne 1b\n"
52 + "2:"
53 + : "=&r"(result), "=m"(*p)
54 + : "m"(*p), "r"(v)
55 + : "memory", "cc");
56 +
57 + return result;
58 +}
59 +
60 +#ifndef PT_EI
61 +# define PT_EI extern inline
62 +#endif
63 +
64 +extern long int testandset (int *spinlock);
65 +extern int __compare_and_swap (long int *p, long int oldval, long int newval);
66 +
67 +/* Spinlock implementation; required. */
68 +PT_EI long int
69 +testandset (int *spinlock)
70 +{
71 + return _test_and_set(spinlock, 1);
72 +}
73 +
74 +
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");
79 +
80 +/* Compare-and-swap for semaphores. */
81 +
82 +#define HAS_COMPARE_AND_SWAP
83 +PT_EI int
84 +__compare_and_swap(long int *p, long int oldval, long int newval)
85 +{
86 + long int result, tmp;
87 +
88 + __asm__ __volatile__(
89 + "/* Inline compare and swap */\n"
90 + "1: ssrf 5\n"
91 + " ld.w %1, %3\n"
92 + " cp.w %1, %5\n"
93 + " sreq %0\n"
94 + " brne 2f\n"
95 + " stcond %2, %4\n"
96 + " brne 1b\n"
97 + "2:"
98 + : "=&r"(result), "=&r"(tmp), "=m"(*p)
99 + : "m"(*p), "r"(newval), "r"(oldval)
100 + : "cc", "memory");
101 +
102 + return result;
103 +}
104 +
105 +#endif /* pt-machine.h */
This page took 0.045874 seconds and 5 git commands to generate.