Skip to content

Commit

Permalink
fix build on ARM
Browse files Browse the repository at this point in the history
Protect x86 specific features by ifdef

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  • Loading branch information
ffontaine committed Mar 25, 2019
1 parent a8a7e11 commit 9730e05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions openpgm/pgm/checksum.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
#ifdef _MSC_VER
# include <intrin.h>
#else
#if defined(__i386__) || defined(__x86_64__)
# include <x86intrin.h>
#endif
#endif


/* locals */
Expand Down
9 changes: 9 additions & 0 deletions openpgm/pgm/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ _xgetbv(uint32_t xcr) {
#endif


#if defined(__i386__) || defined(__x86_64__)
PGM_GNUC_INTERNAL
void
pgm_cpuid (pgm_cpu_t* cpu)
Expand Down Expand Up @@ -93,5 +94,13 @@ pgm_cpuid (pgm_cpu_t* cpu)
(_xgetbv(0) & 6) == 6 /* XSAVE enabled by kernel */;
cpu->has_avx2 = cpu->has_avx && (cpu_info7[1] & 0x00000020) != 0;
}
#else
PGM_GNUC_INTERNAL
void
pgm_cpuid (pgm_cpu_t* cpu)
{
memset(cpu, 0, sizeof(pgm_cpu_t));
}
#endif

/* eof */

2 comments on commit 9730e05

@antoniomontero-carrier

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__cpuidex() is pre-compiler dependent on #ifndef _MSC_VER which would include ARM however, xchg is not available for ARM which leads to compiler error:
cpu.c: In function ‘__cpuidex’:
cpu.c:40:3: error: impossible constraint in ‘asm’
asm volatile (
^~~~~~~
Makefile:656: recipe for target 'libpgm_noinst_la-cpu.lo' failed

@steve-o
Copy link
Owner

@steve-o steve-o commented on 9730e05 Apr 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antoniomontero-carrier Windows x ARM hasn't been tested yet, hence the issue. Please feel free to submit a patch as there are a few assembler statements across the library.

Please sign in to comment.