blob: 9c9d0d76a403bd0e063e241288c8fb2796a37ca6 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* Machine-dependent pthreads configuration and inline functions.
2 FR-V version.
3 Copyright (C) 2004 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by Alexandre Oliva <aoliva@redhat.com>
6
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; see the file COPYING.LIB. If
19 not, write to the Free Software Foundation, Inc.,
20 59 Temple Place - Suite 330, 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 __ASSEMBLER__
28
29#ifndef PT_EI
30# define PT_EI __extern_always_inline
31#endif
32
33/* Spinlock implementation; required. */
34PT_EI long int
35testandset (int *spinlock)
36{
37 int i = 1;
38 __asm__ ("swap%I0 %M0, %1" : "+m"(*(volatile int *)spinlock), "+r"(i));
39 return i;
40}
41
42/* We want the OS to assign stack addresses. */
43#define FLOATING_STACKS 1
44
45/* This symbol is defined by the ABI as the stack size requested by
46 the main program. */
47extern char __stacksize;
48#define ARCH_STACK_MAX_SIZE ((unsigned long)&__stacksize)
49
50/* Memory barrier; default is to do nothing */
51#define MEMORY_BARRIER() __asm__ __volatile__("membar" : : : "memory")
52/* Write barrier. */
53#define WRITE_MEMORY_BARRIER() __asm__ __volatile__("membar" : : : "memory")
54
55/* Return the thread descriptor for the current thread. */
56register struct _pthread_descr_struct *THREAD_SELF __asm__ ("gr29");
57#define THREAD_SELF THREAD_SELF
58
59/* Initialize the thread-unique value. */
60#define INIT_THREAD_SELF(descr, nr) \
61 (THREAD_SELF = descr)
62
63/* Get some notion of the current stack. Need not be exactly the top
64 of the stack, just something somewhere in the current frame. */
65#define CURRENT_STACK_FRAME stack_pointer
66register char * stack_pointer __asm__ ("sp");
67
68#endif
69
70#endif /* pt-machine.h */