diff options
author | "Steven J. Hill" <sjhill@realitydiluted.com> | 2005-11-16 03:58:35 +0000 |
---|---|---|
committer | "Steven J. Hill" <sjhill@realitydiluted.com> | 2005-11-16 03:58:35 +0000 |
commit | 952a791086e7f408d999e1334ee9338be690d2f7 (patch) | |
tree | a8f09a147807868a83201cd8cc3f9ac9cd6fb25f /libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h | |
parent | 4e19db9216b8781b2b34f9b5ce6d3c61d1574a38 (diff) | |
download | uClibc-alpine-952a791086e7f408d999e1334ee9338be690d2f7.tar.bz2 uClibc-alpine-952a791086e7f408d999e1334ee9338be690d2f7.tar.xz |
Copy from trunk.
Diffstat (limited to 'libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h')
-rw-r--r-- | libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h new file mode 100644 index 000000000..fb41c41e9 --- /dev/null +++ b/libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h @@ -0,0 +1,46 @@ +/* + * sysdeps/v850/pt-machine.h -- v850-specific pthread definitions + * + * Copyright (C) 2002 NEC Electronics Corporation + * Copyright (C) 2002 Miles Bader <miles@gnu.org> + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License. See the file COPYING.LIB in the main + * directory of this archive for more details. + * + * Written by Miles Bader <miles@gnu.org> + */ + +#ifndef PT_EI +# define PT_EI extern inline +#endif + +/* Get some notion of the current stack. Need not be exactly the top + of the stack, just something somewhere in the current frame. */ +#define CURRENT_STACK_FRAME __stack_pointer +register char *__stack_pointer __asm__ ("sp"); + +#define HAS_COMPARE_AND_SWAP + +/* Atomically: If *PTR == OLD, set *PTR to NEW and return true, + otherwise do nothing and return false. */ +PT_EI int +__compare_and_swap (long *ptr, long old, long new) +{ + unsigned long psw; + + /* disable interrupts */ + __asm__ __volatile__ ("stsr psw, %0; di" : "=&r" (psw)); + + if (likely (*ptr == old)) + { + *ptr = new; + __asm__ __volatile__ ("ldsr %0, psw" :: "r" (psw)); /* re-enable */ + return 1; + } + else + { + __asm__ __volatile__ ("ldsr %0, psw" :: "r" (psw)); /* re-enable */ + return 0; + } +} |