OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libpthread/] [linuxthreads/] [sysdeps/] [v850/] [pt-machine.h] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/*
2
 * sysdeps/v850/pt-machine.h -- v850-specific pthread definitions
3
 *
4
 *  Copyright (C) 2002  NEC Electronics Corporation
5
 *  Copyright (C) 2002  Miles Bader <miles@gnu.org>
6
 *
7
 * This file is subject to the terms and conditions of the GNU Lesser
8
 * General Public License.  See the file COPYING.LIB in the main
9
 * directory of this archive for more details.
10
 *
11
 * Written by Miles Bader <miles@gnu.org>
12
 */
13
 
14
#ifndef PT_EI
15
# define PT_EI extern inline
16
#endif
17
 
18
/* Get some notion of the current stack.  Need not be exactly the top
19
   of the stack, just something somewhere in the current frame.  */
20
#define CURRENT_STACK_FRAME  __stack_pointer
21
register char *__stack_pointer __asm__ ("sp");
22
 
23
#define HAS_COMPARE_AND_SWAP
24
 
25
/* Atomically:  If *PTR == OLD, set *PTR to NEW and return true,
26
   otherwise do nothing and return false.  */
27
PT_EI int
28
__compare_and_swap (long *ptr, long old, long new)
29
{
30
  unsigned long psw;
31
 
32
  /* disable interrupts  */
33
  __asm__ __volatile__ ("stsr psw, %0; di" : "=&r" (psw));
34
 
35
  if (likely (*ptr == old))
36
    {
37
      *ptr = new;
38
      __asm__ __volatile__ ("ldsr %0, psw" :: "r" (psw)); /* re-enable */
39
      return 1;
40
    }
41
  else
42
    {
43
      __asm__ __volatile__ ("ldsr %0, psw" :: "r" (psw)); /* re-enable */
44
      return 0;
45
    }
46
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.