/[qemu]/qemu/cpu-i386.h
ViewVC logotype

Diff of /qemu/cpu-i386.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25 by bellard, Wed May 14 18:59:24 2003 UTC revision 1.26 by bellard, Wed May 14 21:51:13 2003 UTC
# Line 542  static inline TranslationBlock *tb_find( Line 542  static inline TranslationBlock *tb_find(
542  #define offsetof(type, field) ((size_t) &((type *)0)->field)  #define offsetof(type, field) ((size_t) &((type *)0)->field)
543  #endif  #endif
544    
545    #ifdef __powerpc__
546    static inline int testandset (int *p)
547    {
548        int ret;
549        __asm__ __volatile__ (
550                              "0:    lwarx %0,0,%1 ;"
551                              "      xor. %0,%3,%0;"
552                              "      bne 1f;"
553                              "      stwcx. %2,0,%1;"
554                              "      bne- 0b;"
555                              "1:    "
556                              : "=&r" (ret)
557                              : "r" (p), "r" (1), "r" (0)
558                              : "cr0", "memory");
559        return ret;
560    }
561    #endif
562    
563    #ifdef __i386__
564    static inline int testandset (int *p)
565    {
566        char ret;
567        long int readval;
568        
569        __asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0"
570                              : "=q" (ret), "=m" (*p), "=a" (readval)
571                              : "r" (1), "m" (*p), "a" (0)
572                              : "memory");
573        return ret;
574    }
575    #endif
576    
577    #ifdef __s390__
578    static inline int testandset (int *p)
579    {
580        int ret;
581    
582        __asm__ __volatile__ ("0: cs    %0,%1,0(%2)\n"
583                              "   jl    0b"
584                              : "=&d" (ret)
585                              : "r" (1), "a" (p), "0" (*p)
586                              : "cc", "memory" );
587        return ret;
588    }
589    #endif
590    
591    #ifdef __alpha__
592    int testandset (int *p)
593    {
594        int ret;
595        unsigned long one;
596    
597        __asm__ __volatile__ ("0:   mov 1,%2\n"
598                              "     ldl_l %0,%1\n"
599                              "     stl_c %2,%1\n"
600                              "     beq %2,1f\n"
601                              ".subsection 2\n"
602                              "1:   br 0b\n"
603                              ".previous"
604                              : "=r" (ret), "=m" (*p), "=r" (one)
605                              : "m" (*p));
606        return ret;
607    }
608    #endif
609    
610    #ifdef __sparc__
611    static inline int testandset (int *p)
612    {
613            int ret;
614    
615            __asm__ __volatile__("ldstub    [%1], %0"
616                                 : "=r" (ret)
617                                 : "r" (p)
618                                 : "memory");
619    
620            return (ret ? 1 : 0);
621    }
622    #endif
623    
624    typedef int spinlock_t;
625    
626    #define SPIN_LOCK_UNLOCKED 0
627    
628    static inline void spin_lock(spinlock_t *lock)
629    {
630        while (testandset(lock));
631    }
632    
633    static inline void spin_unlock(spinlock_t *lock)
634    {
635        *lock = 0;
636    }
637    
638    static inline int spin_trylock(spinlock_t *lock)
639    {
640        return !testandset(lock);
641    }
642    
643    extern spinlock_t tb_lock;
644    
645  #endif /* CPU_I386_H */  #endif /* CPU_I386_H */

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26