pthread_arch.h 719 B

123456789101112131415161718192021222324252627282930
  1. #if ((__ARM_ARCH_6K__ || __ARM_ARCH_6ZK__) && !__thumb__) \
  2. || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7
  3. static inline pthread_t __pthread_self()
  4. {
  5. char *p;
  6. __asm__ __volatile__ ( "mrc p15,0,%0,c13,c0,3" : "=r"(p) );
  7. return (void *)(p+8-sizeof(struct pthread));
  8. }
  9. #else
  10. static inline pthread_t __pthread_self()
  11. {
  12. #ifdef __clang__
  13. char *p;
  14. __asm__ __volatile__ ( "bl __a_gettp\n\tmov %0,r0" : "=r"(p) : : "cc", "r0", "lr" );
  15. #else
  16. register char *p __asm__("r0");
  17. __asm__ __volatile__ ( "bl __a_gettp" : "=r"(p) : : "cc", "lr" );
  18. #endif
  19. return (void *)(p+8-sizeof(struct pthread));
  20. }
  21. #endif
  22. #define TLS_ABOVE_TP
  23. #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) - 8)
  24. #define MC_PC arm_pc