blob: 140455013f462ecc4b2ce3173c318ce3e21c3e24 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* Machine-dependent pthreads configuration and inline functions.
2 ARM version.
3 Copyright (C) 1997, 1998 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by Philip Blundell <philb@gnu.org>.
6
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
11
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public
18 License along with the GNU C Library; see the file COPYING.LIB. If not,
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22#ifndef _PT_MACHINE_H
23#define _PT_MACHINE_H 1
24
25#include <features.h>
26
27#ifndef PT_EI
28# define PT_EI __extern_always_inline
29#endif
30
31/* Spinlock implementation; required. */
32/* it is weird and dangerous to disable interrupt in userspace, but for nios
33 what else we can do before we have a swap like instruction? This is better
34 than nothing
35 */
36PT_EI long int
37testandset (int *spinlock)
38{
39 unsigned int ret;
40
41 __asm__ __volatile__("pfx 8\n\t"
42 "wrctl %1 ; disable interrupt\n\t"
43 "nop\n\t"
44 "nop\n\t"
45 "ld %0, [%2]\n\t"
46 "st [%2], %1\n\t"
47 "pfx 9\n\t"
48 "wrctl %1 ; enable interrupt\n\t"
49 "nop\n\t"
50 "nop\n\t"
51 : "=&r"(ret)
52 : "r"(1), "r"(spinlock)
53 : "memory");
54
55 return ret;
56}
57
58
59/* Get some notion of the current stack. Need not be exactly the top
60 of the stack, just something somewhere in the current frame. */
61#define CURRENT_STACK_FRAME stack_pointer
62register char * stack_pointer __asm__ ("%sp");
63
64/* nios needs more because of reg windows */
65#define THREAD_MANAGER_STACK_SIZE (32*1024)
66#define STACK_SIZE (32*1024)
67
68#endif /* pt-machine.h */