Skip to content

Commit 717a510

Browse files
committed
Enable atomic test for all targets
1 parent 7657d87 commit 717a510

File tree

3 files changed

+7
-47
lines changed

3 files changed

+7
-47
lines changed

tests/tests2/124_atomic_counter.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,12 @@
1414
abort(); \
1515
} while (0)
1616

17-
#if defined __x86_64__ || defined __aarch64__ || defined __riscv
18-
#define HAS_64BITS
19-
#endif
20-
2117
typedef struct {
2218
atomic_flag flag;
2319
atomic_uchar uc;
2420
atomic_ushort us;
2521
atomic_uint ui;
26-
#ifdef HAS_64BITS
2722
atomic_size_t ul;
28-
#endif
2923
} counter_type;
3024

3125
static
@@ -38,9 +32,7 @@ void *adder_simple(void *arg)
3832
atomic_fetch_add_explicit(&counter->uc, 1, memory_order_relaxed);
3933
atomic_fetch_add_explicit(&counter->us, 1, memory_order_relaxed);
4034
atomic_fetch_add_explicit(&counter->ui, 1, memory_order_relaxed);
41-
#ifdef HAS_64BITS
4235
atomic_fetch_add_explicit(&counter->ul, 1, memory_order_relaxed);
43-
#endif
4436
}
4537

4638
return NULL;
@@ -56,15 +48,11 @@ void *adder_cmpxchg(void *arg)
5648
unsigned char xchgc;
5749
unsigned short xchgs;
5850
unsigned int xchgi;
59-
#ifdef HAS_64BITS
6051
size_t xchgl;
61-
#endif
6252
unsigned char cmpc = atomic_load_explicit(&counter->uc, memory_order_relaxed);
6353
unsigned short cmps = atomic_load_explicit(&counter->us, memory_order_relaxed);
6454
unsigned int cmpi = atomic_load_explicit(&counter->ui, memory_order_relaxed);
65-
#ifdef HAS_64BITS
6655
size_t cmpl = atomic_load_explicit(&counter->ul, memory_order_relaxed);
67-
#endif
6856

6957
do {
7058
xchgc = (cmpc + 1);
@@ -78,12 +66,10 @@ void *adder_cmpxchg(void *arg)
7866
xchgi = (cmpi + 1);
7967
} while (!atomic_compare_exchange_strong_explicit(&counter->ui,
8068
&cmpi, xchgi, memory_order_relaxed, memory_order_relaxed));
81-
#ifdef HAS_64BITS
8269
do {
8370
xchgl = (cmpl + 1);
8471
} while (!atomic_compare_exchange_strong_explicit(&counter->ul,
8572
&cmpl, xchgl, memory_order_relaxed, memory_order_relaxed));
86-
#endif
8773
}
8874

8975
return NULL;
@@ -100,9 +86,7 @@ void *adder_test_and_set(void *arg)
10086
++counter->uc;
10187
++counter->us;
10288
++counter->ui;
103-
#ifdef HAS_64BITS
10489
++counter->ul;
105-
#endif
10690
atomic_flag_clear(&counter->flag);
10791
}
10892

@@ -120,9 +104,7 @@ void atomic_counter_test(void *(*adder)(void *arg))
120104
atomic_init(&counter.uc, 0);
121105
atomic_init(&counter.us, 0);
122106
atomic_init(&counter.ui, 0);
123-
#ifdef HAS_64BITS
124107
atomic_init(&counter.ul, 0);
125-
#endif
126108

127109
for (index = 0; index < NR_THREADS; ++index)
128110
BUG_ON(pthread_create(&thread[index], NULL, adder, (void *)&counter));
@@ -133,9 +115,7 @@ void atomic_counter_test(void *(*adder)(void *arg))
133115
if (atomic_load(&counter.uc) == ((NR_THREADS * NR_STEPS) & 0xffu)
134116
&& atomic_load(&counter.us) == ((NR_THREADS * NR_STEPS) & 0xffffu)
135117
&& atomic_load(&counter.ui) == (NR_THREADS * NR_STEPS)
136-
#ifdef HAS_64BITS
137118
&& atomic_load(&counter.ul) == (NR_THREADS * NR_STEPS)
138-
#endif
139119
)
140120
printf("SUCCESS\n");
141121
else

tests/tests2/125_atomic_misc.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ int main()
6363
#define OP1(func, v, e1, e2) atomic_##func(&c, v) == e1 && c == e2
6464
#define OP2(func, v, e1, e2) atomic_##func(&s, v) == e1 && s == e2
6565
#define OP4(func, v, e1, e2) atomic_##func(&i, v) == e1 && i == e2
66-
#if defined __x86_64__ || defined __aarch64__ || defined __riscv
6766
#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
7267

7368
#define OP(func, v, e1, e2) printf ("%s: %s\n", #func, \
7469
OP1(func,v,e1,e2) && OP2(func,v,e1,e2) && \
@@ -80,16 +75,12 @@ int main()
8075
atomic_char c;
8176
atomic_short s;
8277
atomic_int i;
83-
#ifdef HAS_64BITS
8478
atomic_size_t l;
85-
#endif
8679

8780
atomic_init(&c, 0);
8881
atomic_init(&s, 0);
8982
atomic_init(&i, 0);
90-
#ifdef HAS_64BITS
9183
atomic_init(&l, 0);
92-
#endif
9384

9485
OP(fetch_add, 10, 0, 10);
9586
OP(fetch_sub, 5, 10, 5);
@@ -108,13 +99,8 @@ typedef __SIZE_TYPE__ size64_t;
10899
__atomic_##func(&s, v, __ATOMIC_SEQ_CST) == e1 && s == e2
109100
#define OP4(func, v, e1, e2)\
110101
__atomic_##func(&i, v, __ATOMIC_SEQ_CST) == e1 && i == e2
111-
#if defined __x86_64__ || defined __aarch64__ || defined __riscv
112102
#define OP8(func, v, e1, e2)\
113103
__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
118104

119105
#define OP(func, v, e1, e2) printf ("%s: %s\n", #func, \
120106
OP1(func,v,e1,e2) && OP2(func,v,e1,e2) && \
@@ -126,16 +112,12 @@ int main()
126112
signed char c;
127113
short s;
128114
int i;
129-
#ifdef HAS_64BITS
130115
size64_t l;
131-
#endif
132116

133117
atomic_init(&c, 0);
134118
atomic_init(&s, 0);
135119
atomic_init(&i, 0);
136-
#ifdef HAS_64BITS
137120
atomic_init(&l, 0);
138-
#endif
139121

140122
OP(fetch_add, 10, 0, 10);
141123
OP(fetch_sub, 5, 10, 5);
@@ -147,9 +129,7 @@ int main()
147129
atomic_init(&c, 0);
148130
atomic_init(&s, 0);
149131
atomic_init(&i, 0);
150-
#ifdef HAS_64BITS
151132
atomic_init(&l, 0);
152-
#endif
153133

154134
OP(add_fetch, 10, 10, 10);
155135
OP(sub_fetch, 5, 5, 5);

tests/tests2/125_atomic_misc.expect

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ nand_fetch: SUCCESS
3838
1
3939

4040
[test_atomic_error_1]
41-
125_atomic_misc.c:176: error: pointer expected
41+
125_atomic_misc.c:156: error: pointer expected
4242

4343
[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
4545

4646
[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
4848

4949
[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
5151

5252
[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
5454

5555
[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
5757

5858
[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

0 commit comments

Comments
 (0)