Skip to content

Commit 4d8597a

Browse files
thiru-mcwBlackhex
authored andcommitted
Cygwin: testsuite: Fix compilation for arm64
Introduce a cpu_relax.h header to provide architecture-specific processor idling instructions for the`cancel3` and `cancel5` tests.
1 parent f7a7bb9 commit 4d8597a

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

winsup/testsuite/winsup.api/pthread/cancel3.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
*/
4141

4242
#include "test.h"
43+
#include "cpu_relax.h"
4344

4445
/*
4546
* Create NUMTHREADS threads in addition to the Main thread.
@@ -88,7 +89,7 @@ mythread(void * arg)
8889
{
8990
int i;
9091
for (i = 0; i < 1E7; i++)
91-
__asm__ volatile ("pause":::);
92+
CPU_RELAX();
9293
}
9394
}
9495

winsup/testsuite/winsup.api/pthread/cancel5.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@
3838
*
3939
* Fail Criteria:
4040
* - Process returns non-zero exit status.
41-
*/
42-
43-
#include "test.h"
44-
45-
/*
46-
* Create NUMTHREADS threads in addition to the Main thread.
41+
*/
42+
43+
#include "test.h"
44+
#include "cpu_relax.h"
45+
46+
/*
47+
* Create NUMTHREADS threads in addition to the Main thread.
4748
*/
4849
enum {
4950
NUMTHREADS = 10
@@ -89,7 +90,7 @@ mythread(void * arg)
8990
{
9091
int i;
9192
for (i = 0; i < 1E7; i++)
92-
__asm__ volatile ("pause":::);
93+
CPU_RELAX();
9394
}
9495
}
9596

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef CPU_RELAX_H
2+
#define CPU_RELAX_H
3+
4+
#if defined(__x86_64__) || defined(__i386__) // Check for x86 architectures
5+
#define CPU_RELAX() __asm__ volatile ("pause" :::)
6+
#elif defined(__aarch64__) || defined(__arm__) // Check for ARM architectures
7+
#define CPU_RELAX() __asm__ volatile ("yield" :::)
8+
#else
9+
#error unimplemented for this target
10+
#endif
11+
12+
#endif

0 commit comments

Comments
 (0)