mirror of
git://repo.or.cz/tinycc.git
synced 2026-07-06 19:39:01 +08:00
Compare commits
No commits in common. "28d7fb85b25ad3667d1d2ca352173e214759d9e8" and "7657d871c1961c3225941e63cd6731a5b70d51d0" have entirely different histories.
28d7fb85b2
...
7657d871c1
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -30,7 +30,7 @@ jobs:
|
||||
run: ./configure && make && make test -k
|
||||
|
||||
test-x86-win32:
|
||||
runs-on: windows-2022
|
||||
runs-on: windows-2019
|
||||
timeout-minutes: 6
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@ -14,12 +14,18 @@
|
||||
abort(); \
|
||||
} while (0)
|
||||
|
||||
#if defined __x86_64__ || defined __aarch64__ || defined __riscv
|
||||
#define HAS_64BITS
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
atomic_flag flag;
|
||||
atomic_uchar uc;
|
||||
atomic_ushort us;
|
||||
atomic_uint ui;
|
||||
#ifdef HAS_64BITS
|
||||
atomic_size_t ul;
|
||||
#endif
|
||||
} counter_type;
|
||||
|
||||
static
|
||||
@ -32,7 +38,9 @@ void *adder_simple(void *arg)
|
||||
atomic_fetch_add_explicit(&counter->uc, 1, memory_order_relaxed);
|
||||
atomic_fetch_add_explicit(&counter->us, 1, memory_order_relaxed);
|
||||
atomic_fetch_add_explicit(&counter->ui, 1, memory_order_relaxed);
|
||||
#ifdef HAS_64BITS
|
||||
atomic_fetch_add_explicit(&counter->ul, 1, memory_order_relaxed);
|
||||
#endif
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -48,11 +56,15 @@ void *adder_cmpxchg(void *arg)
|
||||
unsigned char xchgc;
|
||||
unsigned short xchgs;
|
||||
unsigned int xchgi;
|
||||
#ifdef HAS_64BITS
|
||||
size_t xchgl;
|
||||
#endif
|
||||
unsigned char cmpc = atomic_load_explicit(&counter->uc, memory_order_relaxed);
|
||||
unsigned short cmps = atomic_load_explicit(&counter->us, memory_order_relaxed);
|
||||
unsigned int cmpi = atomic_load_explicit(&counter->ui, memory_order_relaxed);
|
||||
#ifdef HAS_64BITS
|
||||
size_t cmpl = atomic_load_explicit(&counter->ul, memory_order_relaxed);
|
||||
#endif
|
||||
|
||||
do {
|
||||
xchgc = (cmpc + 1);
|
||||
@ -66,10 +78,12 @@ void *adder_cmpxchg(void *arg)
|
||||
xchgi = (cmpi + 1);
|
||||
} while (!atomic_compare_exchange_strong_explicit(&counter->ui,
|
||||
&cmpi, xchgi, memory_order_relaxed, memory_order_relaxed));
|
||||
#ifdef HAS_64BITS
|
||||
do {
|
||||
xchgl = (cmpl + 1);
|
||||
} while (!atomic_compare_exchange_strong_explicit(&counter->ul,
|
||||
&cmpl, xchgl, memory_order_relaxed, memory_order_relaxed));
|
||||
#endif
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -86,7 +100,9 @@ void *adder_test_and_set(void *arg)
|
||||
++counter->uc;
|
||||
++counter->us;
|
||||
++counter->ui;
|
||||
#ifdef HAS_64BITS
|
||||
++counter->ul;
|
||||
#endif
|
||||
atomic_flag_clear(&counter->flag);
|
||||
}
|
||||
|
||||
@ -104,7 +120,9 @@ void atomic_counter_test(void *(*adder)(void *arg))
|
||||
atomic_init(&counter.uc, 0);
|
||||
atomic_init(&counter.us, 0);
|
||||
atomic_init(&counter.ui, 0);
|
||||
#ifdef HAS_64BITS
|
||||
atomic_init(&counter.ul, 0);
|
||||
#endif
|
||||
|
||||
for (index = 0; index < NR_THREADS; ++index)
|
||||
BUG_ON(pthread_create(&thread[index], NULL, adder, (void *)&counter));
|
||||
@ -115,7 +133,9 @@ void atomic_counter_test(void *(*adder)(void *arg))
|
||||
if (atomic_load(&counter.uc) == ((NR_THREADS * NR_STEPS) & 0xffu)
|
||||
&& atomic_load(&counter.us) == ((NR_THREADS * NR_STEPS) & 0xffffu)
|
||||
&& atomic_load(&counter.ui) == (NR_THREADS * NR_STEPS)
|
||||
#ifdef HAS_64BITS
|
||||
&& atomic_load(&counter.ul) == (NR_THREADS * NR_STEPS)
|
||||
#endif
|
||||
)
|
||||
printf("SUCCESS\n");
|
||||
else
|
||||
|
||||
@ -63,7 +63,12 @@ int main()
|
||||
#define OP1(func, v, e1, e2) atomic_##func(&c, v) == e1 && c == e2
|
||||
#define OP2(func, v, e1, e2) atomic_##func(&s, v) == e1 && s == e2
|
||||
#define OP4(func, v, e1, e2) atomic_##func(&i, v) == e1 && i == e2
|
||||
#if defined __x86_64__ || defined __aarch64__ || defined __riscv
|
||||
#define OP8(func, v, e1, e2) atomic_##func(&l, v) == e1 && l == e2
|
||||
#define HAS_64BITS
|
||||
#else
|
||||
#define OP8(func, v, e1, e2) 1
|
||||
#endif
|
||||
|
||||
#define OP(func, v, e1, e2) printf ("%s: %s\n", #func, \
|
||||
OP1(func,v,e1,e2) && OP2(func,v,e1,e2) && \
|
||||
@ -75,12 +80,16 @@ int main()
|
||||
atomic_char c;
|
||||
atomic_short s;
|
||||
atomic_int i;
|
||||
#ifdef HAS_64BITS
|
||||
atomic_size_t l;
|
||||
#endif
|
||||
|
||||
atomic_init(&c, 0);
|
||||
atomic_init(&s, 0);
|
||||
atomic_init(&i, 0);
|
||||
#ifdef HAS_64BITS
|
||||
atomic_init(&l, 0);
|
||||
#endif
|
||||
|
||||
OP(fetch_add, 10, 0, 10);
|
||||
OP(fetch_sub, 5, 10, 5);
|
||||
@ -99,8 +108,13 @@ typedef __SIZE_TYPE__ size64_t;
|
||||
__atomic_##func(&s, v, __ATOMIC_SEQ_CST) == e1 && s == e2
|
||||
#define OP4(func, v, e1, e2)\
|
||||
__atomic_##func(&i, v, __ATOMIC_SEQ_CST) == e1 && i == e2
|
||||
#if defined __x86_64__ || defined __aarch64__ || defined __riscv
|
||||
#define OP8(func, v, e1, e2)\
|
||||
__atomic_##func(&l, v, __ATOMIC_SEQ_CST) == e1 && l == e2
|
||||
#define HAS_64BITS
|
||||
#else
|
||||
#define OP8(func, v, e1, e2) 1
|
||||
#endif
|
||||
|
||||
#define OP(func, v, e1, e2) printf ("%s: %s\n", #func, \
|
||||
OP1(func,v,e1,e2) && OP2(func,v,e1,e2) && \
|
||||
@ -112,12 +126,16 @@ int main()
|
||||
signed char c;
|
||||
short s;
|
||||
int i;
|
||||
#ifdef HAS_64BITS
|
||||
size64_t l;
|
||||
#endif
|
||||
|
||||
atomic_init(&c, 0);
|
||||
atomic_init(&s, 0);
|
||||
atomic_init(&i, 0);
|
||||
#ifdef HAS_64BITS
|
||||
atomic_init(&l, 0);
|
||||
#endif
|
||||
|
||||
OP(fetch_add, 10, 0, 10);
|
||||
OP(fetch_sub, 5, 10, 5);
|
||||
@ -129,7 +147,9 @@ int main()
|
||||
atomic_init(&c, 0);
|
||||
atomic_init(&s, 0);
|
||||
atomic_init(&i, 0);
|
||||
#ifdef HAS_64BITS
|
||||
atomic_init(&l, 0);
|
||||
#endif
|
||||
|
||||
OP(add_fetch, 10, 10, 10);
|
||||
OP(sub_fetch, 5, 5, 5);
|
||||
|
||||
@ -38,22 +38,22 @@ nand_fetch: SUCCESS
|
||||
1
|
||||
|
||||
[test_atomic_error_1]
|
||||
125_atomic_misc.c:156: error: pointer expected
|
||||
125_atomic_misc.c:176: error: pointer expected
|
||||
|
||||
[test_atomic_error_2]
|
||||
125_atomic_misc.c:163: error: integral or integer-sized pointer target type expected
|
||||
125_atomic_misc.c:183: error: integral or integer-sized pointer target type expected
|
||||
|
||||
[test_atomic_error_3]
|
||||
125_atomic_misc.c:170: error: integral or integer-sized pointer target type expected
|
||||
125_atomic_misc.c:190: error: integral or integer-sized pointer target type expected
|
||||
|
||||
[test_atomic_error_4]
|
||||
125_atomic_misc.c:178: error: pointer target type mismatch in argument 2
|
||||
125_atomic_misc.c:198: error: pointer target type mismatch in argument 2
|
||||
|
||||
[test_atomic_warn_1]
|
||||
125_atomic_misc.c:186: warning: assignment makes integer from pointer without a cast
|
||||
125_atomic_misc.c:206: warning: assignment makes integer from pointer without a cast
|
||||
|
||||
[test_atomic_warn_2]
|
||||
125_atomic_misc.c:196: warning: assignment from incompatible pointer type
|
||||
125_atomic_misc.c:216: warning: assignment from incompatible pointer type
|
||||
|
||||
[test_atomic_warn_3]
|
||||
125_atomic_misc.c:204: warning: assignment of read-only location
|
||||
125_atomic_misc.c:224: warning: assignment of read-only location
|
||||
|
||||
Loading…
Reference in New Issue
Block a user