Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/defs.hfa

    rdca5802 r8a13c47  
    1010// Created On       : Thu Nov  9 13:24:10 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  8 16:22:41 2018
    13 // Update Count     : 8
     12// Last Modified On : Tue Jan 28 22:38:27 2020
     13// Update Count     : 9
    1414//
    1515
     
    3434
    3535#ifdef __cforall
    36 void abort ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     36void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     37void abort( bool signalAbort, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    3738extern "C" {
    3839#endif
     
    5354    return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
    5455}
    55 
    56 // #define __CFA_NO_BIT_TEST_AND_SET__
    57 
    58 #if defined( __i386 )
    59 static inline bool __atomic_bts(volatile unsigned long int * target, unsigned long int bit ) {
    60         #if defined(__CFA_NO_BIT_TEST_AND_SET__)
    61         unsigned long int mask = 1ul << bit;
    62         unsigned long int ret = __atomic_fetch_or(target, mask, (int)__ATOMIC_RELAXED);
    63         return (ret & mask) != 0;
    64     #else
    65         int result = 0;
    66         asm volatile(
    67             "LOCK btsl %[bit], %[target]\n\t"
    68             : "=@ccc" (result)
    69             : [target] "m" (*target), [bit] "r" (bit)
    70         );
    71         return result != 0;
    72     #endif
    73 }
    74 
    75 static inline bool __atomic_btr(volatile unsigned long int * target, unsigned long int bit ) {
    76         #if defined(__CFA_NO_BIT_TEST_AND_SET__)
    77         unsigned long int mask = 1ul << bit;
    78         unsigned long int ret = __atomic_fetch_and(target, ~mask, (int)__ATOMIC_RELAXED);
    79         return (ret & mask) != 0;
    80         #else
    81         int result = 0;
    82         asm volatile(
    83             "LOCK btrl %[bit], %[target]\n\t"
    84             :"=@ccc" (result)
    85             : [target] "m" (*target), [bit] "r" (bit)
    86         );
    87         return result != 0;
    88     #endif
    89 }
    90 #elif defined( __x86_64 )
    91 static inline bool __atomic_bts(volatile unsigned long long int * target, unsigned long long int bit ) {
    92         #if defined(__CFA_NO_BIT_TEST_AND_SET__)
    93         unsigned long long int mask = 1ul << bit;
    94         unsigned long long int ret = __atomic_fetch_or(target, mask, (int)__ATOMIC_RELAXED);
    95         return (ret & mask) != 0;
    96     #else
    97         int result = 0;
    98         asm volatile(
    99             "LOCK btsq %[bit], %[target]\n\t"
    100             : "=@ccc" (result)
    101             : [target] "m" (*target), [bit] "r" (bit)
    102         );
    103         return result != 0;
    104     #endif
    105 }
    106 
    107 static inline bool __atomic_btr(volatile unsigned long long int * target, unsigned long long int bit ) {
    108         #if defined(__CFA_NO_BIT_TEST_AND_SET__)
    109         unsigned long long int mask = 1ul << bit;
    110         unsigned long long int ret = __atomic_fetch_and(target, ~mask, (int)__ATOMIC_RELAXED);
    111         return (ret & mask) != 0;
    112         #else
    113         int result = 0;
    114         asm volatile(
    115             "LOCK btrq %[bit], %[target]\n\t"
    116             :"=@ccc" (result)
    117             : [target] "m" (*target), [bit] "r" (bit)
    118         );
    119         return result != 0;
    120     #endif
    121 }
    122 #elif defined( __ARM_ARCH )
    123     #error __atomic_bts and __atomic_btr not implemented for arm
    124 #else
    125         #error uknown hardware architecture
    126 #endif
Note: See TracChangeset for help on using the changeset viewer.