blob: cabd4e33c0aa4657da4355ea14da3a627c5e40e9 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* Machine-dependent pthreads configuration and inline functions.
2 C6x version.
3 Copyright (C) 2004 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by Aurelien Jacquiot <aurelien.jacquiot@jaluna.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 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#ifndef PT_EI
26# define PT_EI extern inline
27#endif
28
29extern int __compare_and_swap (long int *p, long int oldval, long int newval);
30
31/* Spinlock implementation; required. */
32static inline long int
33testandset (int *spinlock)
34{
35 register unsigned int ret = 1;
36 int dummy;
37 __asm__ __volatile__ ("mvc .s2 CSR, %0\n\tand .s2 -2, %0, %0\n\tmvc .s2 %0, CSR\n"
38 : "=b" (dummy));
39
40 if (*spinlock == 0) {
41 *spinlock = 1;
42 ret = 0;
43 }
44 __asm__ __volatile__ ("mvc .s2 CSR, %0\n\tor .s2 1, %0, %0\n\tmvc .s2 %0, CSR\n"
45 : "=b" (dummy));
46 return ret;
47}
48
49#define WRITE_MEMORY_BARRIER()
50#define READ_MEMORY_BARRIER()
51
52/* Get some notion of the current stack. Need not be exactly the top
53 of the stack, just something somewhere in the current frame. */
54#define CURRENT_STACK_FRAME get_stack_pointer()
55static inline char * get_stack_pointer(void)
56{
57 char *sp;
58 __asm__ __volatile__ ("mv .d2 B15, %0" : "=b" (sp));
59 return sp;
60}
61
62#define THREAD_STACK_OFFSET 8
63
64#endif /* pt-machine.h */