We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
INLINE atom_t abstraction_cas( volatile atom_t *destination, atom_t exchange, atom_t compare ) { atom_t original_destination, stored_flag; __sync_synchronize(); __asm__ __volatile__ ( "dmb;" : : : "memory" ); do { __asm__ __volatile__ ( "ldrex %1, [%2];" "mov %0, #0;" "teq %1, %3;" "strexeq %0, %4, [%2];" // output : "=&r" (stored_flag), "=&r" (original_destination) // input : "r" (destination), "Ir" (compare), "r" (exchange) // clobbered : "memory", "cc" ); } while( stored_flag == 1 ); __asm__ __volatile__ ( "dmb;" : : : "memory" ); __sync_synchronize(); return( original_destination ); }
do { __asm__ __volatile__ ( "ldrex %1, [%2];" "mov %0, #1;" "teq %1, %3;" "strexeq %0, %4, [%2];" // output : "=&r" (stored_flag), "=&r" (original_destination) // input : "r" (destination), "r" (compare), "r" (exchange) // clobbered : "memory", "cc" ); } while( stored_flag == 1 );