… | |
… | |
542 | #define ECB_MEMORY_FENCE do { } while (0) |
542 | #define ECB_MEMORY_FENCE do { } while (0) |
543 | #endif |
543 | #endif |
544 | |
544 | |
545 | #ifndef ECB_MEMORY_FENCE |
545 | #ifndef ECB_MEMORY_FENCE |
546 | #if ECB_GCC_VERSION(2,5) |
546 | #if ECB_GCC_VERSION(2,5) |
547 | #if __x86 |
547 | #if __i386__ |
548 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory") |
548 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory") |
549 | #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE /* non-lock xchg might be enough */ |
549 | #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE /* non-lock xchg might be enough */ |
550 | #define ECB_MEMORY_FENCE_RELEASE do { } while (0) /* unlikely to change in future cpus */ |
550 | #define ECB_MEMORY_FENCE_RELEASE do { } while (0) /* unlikely to change in future cpus */ |
551 | #elif __amd64 |
551 | #elif __amd64 |
552 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mfence" : : : "memory") |
552 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mfence" : : : "memory") |
… | |
… | |
554 | #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("sfence") /* play safe - not needed in any current cpu */ |
554 | #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("sfence") /* play safe - not needed in any current cpu */ |
555 | #elif __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__ |
555 | #elif __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__ |
556 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("sync" : : : "memory") |
556 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("sync" : : : "memory") |
557 | #elif defined(__ARM_ARCH_6__ ) || defined(__ARM_ARCH_6J__ ) \ |
557 | #elif defined(__ARM_ARCH_6__ ) || defined(__ARM_ARCH_6J__ ) \ |
558 | || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__) |
558 | || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__) |
559 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mcr p15,0,%0,c7,c10,4" : : "r" (0) : "memory") |
559 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mcr p15,0,%0,c7,c10,5" : : "r" (0) : "memory") |
560 | #elif defined(__ARM_ARCH_7__ ) || defined(__ARM_ARCH_7A__ ) \ |
560 | #elif defined(__ARM_ARCH_7__ ) || defined(__ARM_ARCH_7A__ ) \ |
561 | || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7R__ ) |
561 | || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7R__ ) |
562 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("dsb" : : : "memory") |
562 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("dmb" : : : "memory") |
563 | #endif |
563 | #endif |
564 | #endif |
564 | #endif |
565 | #endif |
565 | #endif |
566 | |
566 | |
567 | #ifndef ECB_MEMORY_FENCE |
567 | #ifndef ECB_MEMORY_FENCE |
… | |
… | |
859 | #endif |
859 | #endif |
860 | |
860 | |
861 | /* ECB.H END */ |
861 | /* ECB.H END */ |
862 | |
862 | |
863 | #if ECB_MEMORY_FENCE_NEEDS_PTHREADS |
863 | #if ECB_MEMORY_FENCE_NEEDS_PTHREADS |
|
|
864 | /* if your architetcure doesn't need memory fences, e.g. because it is |
|
|
865 | * single-cpu/core, or if you use libev in a project that doesn't use libev |
|
|
866 | * from multiple threads, then you can define ECB_AVOID_PTHREADS when compiling |
|
|
867 | * libev, in which casess the memory fences become nops. |
|
|
868 | * alternatively, you can remove this #error and link against libpthread, |
|
|
869 | * which will then provide the memory fences. |
|
|
870 | */ |
|
|
871 | # error "memory fences not defined for your architecture, please report" |
|
|
872 | #endif |
|
|
873 | |
864 | # undef ECB_MEMORY_FENCE |
874 | #ifndef ECB_MEMORY_FENCE |
865 | # undef ECB_MEMORY_FENCE_ACQUIRE |
875 | # define ECB_MEMORY_FENCE do { } while (0) |
866 | # undef ECB_MEMORY_FENCE_RELEASE |
876 | # define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE |
|
|
877 | # define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE |
867 | #endif |
878 | #endif |
868 | |
879 | |
869 | #define expect_false(cond) ecb_expect_false (cond) |
880 | #define expect_false(cond) ecb_expect_false (cond) |
870 | #define expect_true(cond) ecb_expect_true (cond) |
881 | #define expect_true(cond) ecb_expect_true (cond) |
871 | #define noinline ecb_noinline |
882 | #define noinline ecb_noinline |