Skip to content

Commit 8b1cd37

Browse files
committed
fixup define checks. Cleans up some oopses from #5.
- use "#if defined(foo)" rather than "#if foo" - Use the same guard for the cpuid header and the function
1 parent 6b1508d commit 8b1cd37

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

port/port_posix.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <stdio.h>
99
#include <string.h>
1010

11-
#if defined(__GNUC__)
11+
#if (defined(__x86_64__) || defined(__i386__)) && defined(__GNUC__)
1212
#include <cpuid.h>
1313
#endif
1414

@@ -54,7 +54,7 @@ void InitOnce(OnceType* once, void (*initializer)()) {
5454
}
5555

5656
bool HasAcceleratedCRC32C() {
57-
#if (__x86_64__ || __i386__) && defined(__GNUC__)
57+
#if (defined(__x86_64__) || defined(__i386__)) && defined(__GNUC__)
5858
unsigned int eax, ebx, ecx, edx;
5959
__get_cpuid(1, &eax, &ebx, &ecx, &edx);
6060
return (ecx & (1 << 20)) != 0;

port/port_win.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void AtomicPointer::NoBarrier_Store(void* v) {
145145
}
146146

147147
bool HasAcceleratedCRC32C() {
148-
#if (__x86_64__ || __i386__)
148+
#if defined(__x86_64__) || defined(__i386__)
149149
int cpu_info[4];
150150
__cpuid(cpu_info, 1);
151151
return (cpu_info[2] & (1 << 20)) != 0;

0 commit comments

Comments
 (0)