123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #ifndef _PT_MACHINE_H
- #define _PT_MACHINE_H 1
- #include <features.h>
- #ifndef PT_EI
- # define PT_EI __extern_always_inline
- #endif
- #define MEMORY_BARRIER() __asm__ __volatile__ ("sync" : : : "memory")
- #define CURRENT_STACK_FRAME stack_pointer
- register char * stack_pointer __asm__ ("r1");
- struct _pthread_descr_struct;
- register struct _pthread_descr_struct *__thread_self __asm__("r2");
- #define THREAD_SELF __thread_self
- #define INIT_THREAD_SELF(descr, nr) (__thread_self = (descr))
- #define HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS
- #define IMPLEMENT_TAS_WITH_CAS
- PT_EI int
- __compare_and_swap (long int *p, long int oldval, long int newval)
- {
- int ret;
- __asm__ __volatile__ (
- "0: lwarx %0,0,%1 ;"
- " xor. %0,%3,%0;"
- " bne 1f;"
- " stwcx. %2,0,%1;"
- " bne- 0b;"
- "1: "
- : "=&r"(ret)
- : "r"(p), "r"(newval), "r"(oldval)
- : "cr0", "memory");
-
- __asm__ __volatile__ ("isync" : : : "memory");
- return ret == 0;
- }
- PT_EI int
- __compare_and_swap_with_release_semantics (long int *p,
- long int oldval, long int newval)
- {
- int ret;
- MEMORY_BARRIER ();
- __asm__ __volatile__ (
- "0: lwarx %0,0,%1 ;"
- " xor. %0,%3,%0;"
- " bne 1f;"
- " stwcx. %2,0,%1;"
- " bne- 0b;"
- "1: "
- : "=&r"(ret)
- : "r"(p), "r"(newval), "r"(oldval)
- : "cr0", "memory");
- return ret == 0;
- }
- #endif
|