123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- #ifndef _PT_MACHINE_H
- #define _PT_MACHINE_H 1
- #ifndef PT_EI
- # define PT_EI __extern_always_inline
- #endif
- extern long int testandset (int *spinlock);
- extern int __compare_and_swap (long int *p, long int oldval, long int newval);
- #define MEMORY_BARRIER() __asm__ __volatile__ ("bcr 15,0" : : : "memory")
- PT_EI long int
- testandset (int *spinlock)
- {
- int ret;
- __asm__ __volatile__(
- " la 1,%1\n"
- " lhi 0,1\n"
- " l %0,%1\n"
- "0: cs %0,0,0(1)\n"
- " jl 0b"
- : "=&d" (ret), "+m" (*spinlock)
- : : "0", "1", "cc");
- return ret;
- }
- #define CURRENT_STACK_FRAME stack_pointer
- register char * stack_pointer __asm__ ("15");
- #ifdef USE_TLS
- # define THREAD_SELF ((pthread_descr) __builtin_thread_pointer ())
- #define INIT_THREAD_SELF(descr, nr) __builtin_set_thread_pointer (descr)
- #else
- #define THREAD_SELF ({ \
- register pthread_descr __self; \
- __asm__ ("ear %0,%%a0" : "=d" (__self) ); \
- __self; \
- })
- #define INIT_THREAD_SELF(descr, nr) ({ \
- __asm__ ("sar %%a0,%0" : : "d" (descr) ); \
- })
- #endif
- #define THREAD_GETMEM(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
- #define THREAD_GETMEM_NC(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
- #define THREAD_SETMEM(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
- #define THREAD_SETMEM_NC(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
- #define FLOATING_STACKS 1
- #define ARCH_STACK_MAX_SIZE 8*1024*1024
- #define HAS_COMPARE_AND_SWAP
- PT_EI int
- __compare_and_swap(long int *p, long int oldval, long int newval)
- {
- int retval;
- __asm__ __volatile__(
- " la 1,%1\n"
- " lr 0,%2\n"
- " cs 0,%3,0(1)\n"
- " ipm %0\n"
- " srl %0,28\n"
- "0:"
- : "=&d" (retval), "+m" (*p)
- : "d" (oldval) , "d" (newval)
- : "cc", "0", "1" );
- return retval == 0;
- }
- #endif /* pt-machine.h */
|