Unified · Split
| @@ -14,18 +14,12 @@ · 13 unmodified lines | ||
| 14 | 14 | abort(); \ |
| 15 | 15 | } while (0) |
| 16 | 16 | |
| 17 | −#if defined __x86_64__ || defined __aarch64__ || defined __riscv | |
| 18 | −#define HAS_64BITS | |
| 19 | −#endif | |
| 20 | − | |
| 21 | 17 | typedef struct { |
| 22 | 18 | atomic_flag flag; |
| 23 | 19 | atomic_uchar uc; |
| 24 | 20 | atomic_ushort us; |
| 25 | 21 | atomic_uint ui; |
| 26 | −#ifdef HAS_64BITS | |
| 27 | 22 | atomic_size_t ul; |
| 28 | −#endif | |
| 29 | 23 | } counter_type; |
| 30 | 24 | |
| 31 | 25 | static |
| @@ -38,9 +32,7 @@ void *adder_simple(void *arg) · 6 unmodified lines | ||
| 38 | 32 | atomic_fetch_add_explicit(&counter->uc, 1, memory_order_relaxed); |
| 39 | 33 | atomic_fetch_add_explicit(&counter->us, 1, memory_order_relaxed); |
| 40 | 34 | atomic_fetch_add_explicit(&counter->ui, 1, memory_order_relaxed); |
| 41 | −#ifdef HAS_64BITS | |
| 42 | 35 | atomic_fetch_add_explicit(&counter->ul, 1, memory_order_relaxed); |
| 43 | −#endif | |
| 44 | 36 | } |
| 45 | 37 | |
| 46 | 38 | return NULL; |
| @@ -56,15 +48,11 @@ void *adder_cmpxchg(void *arg) · 9 unmodified lines | ||
| 56 | 48 | unsigned char xchgc; |
| 57 | 49 | unsigned short xchgs; |
| 58 | 50 | unsigned int xchgi; |
| 59 | −#ifdef HAS_64BITS | |
| 60 | 51 | size_t xchgl; |
| 61 | −#endif | |
| 62 | 52 | unsigned char cmpc = atomic_load_explicit(&counter->uc, memory_order_relaxed); |
| 63 | 53 | unsigned short cmps = atomic_load_explicit(&counter->us, memory_order_relaxed); |
| 64 | 54 | unsigned int cmpi = atomic_load_explicit(&counter->ui, memory_order_relaxed); |
| 65 | −#ifdef HAS_64BITS | |
| 66 | 55 | size_t cmpl = atomic_load_explicit(&counter->ul, memory_order_relaxed); |
| 67 | −#endif | |
| 68 | 56 | |
| 69 | 57 | do { |
| 70 | 58 | xchgc = (cmpc + 1); |
| @@ -78,12 +66,10 @@ void *adder_cmpxchg(void *arg) · 7 unmodified lines | ||
| 78 | 66 | xchgi = (cmpi + 1); |
| 79 | 67 | } while (!atomic_compare_exchange_strong_explicit(&counter->ui, |
| 80 | 68 | &cmpi, xchgi, memory_order_relaxed, memory_order_relaxed)); |
| 81 | −#ifdef HAS_64BITS | |
| 82 | 69 | do { |
| 83 | 70 | xchgl = (cmpl + 1); |
| 84 | 71 | } while (!atomic_compare_exchange_strong_explicit(&counter->ul, |
| 85 | 72 | &cmpl, xchgl, memory_order_relaxed, memory_order_relaxed)); |
| 86 | −#endif | |
| 87 | 73 | } |
| 88 | 74 | |
| 89 | 75 | return NULL; |
| @@ -100,9 +86,7 @@ void *adder_test_and_set(void *arg) · 10 unmodified lines | ||
| 100 | 86 | ++counter->uc; |
| 101 | 87 | ++counter->us; |
| 102 | 88 | ++counter->ui; |
| 103 | −#ifdef HAS_64BITS | |
| 104 | 89 | ++counter->ul; |
| 105 | −#endif | |
| 106 | 90 | atomic_flag_clear(&counter->flag); |
| 107 | 91 | } |
| 108 | 92 | |
| @@ -120,9 +104,7 @@ void atomic_counter_test(void *(*adder)(void *arg)) · 11 unmodified lines | ||
| 120 | 104 | atomic_init(&counter.uc, 0); |
| 121 | 105 | atomic_init(&counter.us, 0); |
| 122 | 106 | atomic_init(&counter.ui, 0); |
| 123 | −#ifdef HAS_64BITS | |
| 124 | 107 | atomic_init(&counter.ul, 0); |
| 125 | −#endif | |
| 126 | 108 | |
| 127 | 109 | for (index = 0; index < NR_THREADS; ++index) |
| 128 | 110 | BUG_ON(pthread_create(&thread[index], NULL, adder, (void *)&counter)); |
| @@ -133,9 +115,7 @@ void atomic_counter_test(void *(*adder)(void *arg)) · 4 unmodified lines | ||
| 133 | 115 | if (atomic_load(&counter.uc) == ((NR_THREADS * NR_STEPS) & 0xffu) |
| 134 | 116 | && atomic_load(&counter.us) == ((NR_THREADS * NR_STEPS) & 0xffffu) |
| 135 | 117 | && atomic_load(&counter.ui) == (NR_THREADS * NR_STEPS) |
| 136 | −#ifdef HAS_64BITS | |
| 137 | 118 | && atomic_load(&counter.ul) == (NR_THREADS * NR_STEPS) |
| 138 | −#endif | |
| 139 | 119 | ) |
| 140 | 120 | printf("SUCCESS\n"); |
| 141 | 121 | else |
| @@ -63,12 +63,7 @@ int main() · 62 unmodified lines | ||
| 63 | 63 | #define OP1(func, v, e1, e2) atomic_##func(&c, v) == e1 && c == e2 |
| 64 | 64 | #define OP2(func, v, e1, e2) atomic_##func(&s, v) == e1 && s == e2 |
| 65 | 65 | #define OP4(func, v, e1, e2) atomic_##func(&i, v) == e1 && i == e2 |
| 66 | −#if defined __x86_64__ || defined __aarch64__ || defined __riscv | |
| 67 | 66 | #define OP8(func, v, e1, e2) atomic_##func(&l, v) == e1 && l == e2 |
| 68 | −#define HAS_64BITS | |
| 69 | −#else | |
| 70 | −#define OP8(func, v, e1, e2) 1 | |
| 71 | −#endif | |
| 72 | 67 | |
| 73 | 68 | #define OP(func, v, e1, e2) printf ("%s: %s\n", #func, \ |
| 74 | 69 | OP1(func,v,e1,e2) && OP2(func,v,e1,e2) && \ |
| @@ -80,16 +75,12 @@ int main() · 5 unmodified lines | ||
| 80 | 75 | atomic_char c; |
| 81 | 76 | atomic_short s; |
| 82 | 77 | atomic_int i; |
| 83 | −#ifdef HAS_64BITS | |
| 84 | 78 | atomic_size_t l; |
| 85 | −#endif | |
| 86 | 79 | |
| 87 | 80 | atomic_init(&c, 0); |
| 88 | 81 | atomic_init(&s, 0); |
| 89 | 82 | atomic_init(&i, 0); |
| 90 | −#ifdef HAS_64BITS | |
| 91 | 83 | atomic_init(&l, 0); |
| 92 | −#endif | |
| 93 | 84 | |
| 94 | 85 | OP(fetch_add, 10, 0, 10); |
| 95 | 86 | OP(fetch_sub, 5, 10, 5); |
| @@ -108,13 +99,8 @@ typedef __SIZE_TYPE__ size64_t; · 12 unmodified lines | ||
| 108 | 99 | __atomic_##func(&s, v, __ATOMIC_SEQ_CST) == e1 && s == e2 |
| 109 | 100 | #define OP4(func, v, e1, e2)\ |
| 110 | 101 | __atomic_##func(&i, v, __ATOMIC_SEQ_CST) == e1 && i == e2 |
| 111 | −#if defined __x86_64__ || defined __aarch64__ || defined __riscv | |
| 112 | 102 | #define OP8(func, v, e1, e2)\ |
| 113 | 103 | __atomic_##func(&l, v, __ATOMIC_SEQ_CST) == e1 && l == e2 |
| 114 | −#define HAS_64BITS | |
| 115 | −#else | |
| 116 | −#define OP8(func, v, e1, e2) 1 | |
| 117 | −#endif | |
| 118 | 104 | |
| 119 | 105 | #define OP(func, v, e1, e2) printf ("%s: %s\n", #func, \ |
| 120 | 106 | OP1(func,v,e1,e2) && OP2(func,v,e1,e2) && \ |
| @@ -126,16 +112,12 @@ int main() · 5 unmodified lines | ||
| 126 | 112 | signed char c; |
| 127 | 113 | short s; |
| 128 | 114 | int i; |
| 129 | −#ifdef HAS_64BITS | |
| 130 | 115 | size64_t l; |
| 131 | −#endif | |
| 132 | 116 | |
| 133 | 117 | atomic_init(&c, 0); |
| 134 | 118 | atomic_init(&s, 0); |
| 135 | 119 | atomic_init(&i, 0); |
| 136 | −#ifdef HAS_64BITS | |
| 137 | 120 | atomic_init(&l, 0); |
| 138 | −#endif | |
| 139 | 121 | |
| 140 | 122 | OP(fetch_add, 10, 0, 10); |
| 141 | 123 | OP(fetch_sub, 5, 10, 5); |
| @@ -147,9 +129,7 @@ int main() · 5 unmodified lines | ||
| 147 | 129 | atomic_init(&c, 0); |
| 148 | 130 | atomic_init(&s, 0); |
| 149 | 131 | atomic_init(&i, 0); |
| 150 | −#ifdef HAS_64BITS | |
| 151 | 132 | atomic_init(&l, 0); |
| 152 | −#endif | |
| 153 | 133 | |
| 154 | 134 | OP(add_fetch, 10, 10, 10); |
| 155 | 135 | OP(sub_fetch, 5, 5, 5); |
| @@ -38,22 +38,22 @@ nand_fetch: SUCCESS · 37 unmodified lines | ||
| 38 | 38 | 1 |
| 39 | 39 | |
| 40 | 40 | [test_atomic_error_1] |
| 41 | −125_atomic_misc.c:176: error: pointer expected | |
| 41 | +125_atomic_misc.c:156: error: pointer expected | |
| 42 | 42 | |
| 43 | 43 | [test_atomic_error_2] |
| 44 | −125_atomic_misc.c:183: error: integral or integer-sized pointer target type expected | |
| 44 | +125_atomic_misc.c:163: error: integral or integer-sized pointer target type expected | |
| 45 | 45 | |
| 46 | 46 | [test_atomic_error_3] |
| 47 | −125_atomic_misc.c:190: error: integral or integer-sized pointer target type expected | |
| 47 | +125_atomic_misc.c:170: error: integral or integer-sized pointer target type expected | |
| 48 | 48 | |
| 49 | 49 | [test_atomic_error_4] |
| 50 | −125_atomic_misc.c:198: error: pointer target type mismatch in argument 2 | |
| 50 | +125_atomic_misc.c:178: error: pointer target type mismatch in argument 2 | |
| 51 | 51 | |
| 52 | 52 | [test_atomic_warn_1] |
| 53 | −125_atomic_misc.c:206: warning: assignment makes integer from pointer without a cast | |
| 53 | +125_atomic_misc.c:186: warning: assignment makes integer from pointer without a cast | |
| 54 | 54 | |
| 55 | 55 | [test_atomic_warn_2] |
| 56 | −125_atomic_misc.c:216: warning: assignment from incompatible pointer type | |
| 56 | +125_atomic_misc.c:196: warning: assignment from incompatible pointer type | |
| 57 | 57 | |
| 58 | 58 | [test_atomic_warn_3] |
| 59 | −125_atomic_misc.c:224: warning: assignment of read-only location | |
| 59 | +125_atomic_misc.c:204: warning: assignment of read-only location | |