Skip to content

Commit

Permalink
fixup define checks. Cleans up some oopses from #5.
Browse files Browse the repository at this point in the history
- use "#if defined(foo)" rather than "#if foo"
- Use the same guard for the cpuid header and the function
  • Loading branch information
theuni committed Jul 31, 2017
1 parent 6b1508d commit 8b1cd37
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions port/port_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <stdio.h>
#include <string.h>

#if defined(__GNUC__)
#if (defined(__x86_64__) || defined(__i386__)) && defined(__GNUC__)
#include <cpuid.h>
#endif

Expand Down Expand Up @@ -54,7 +54,7 @@ void InitOnce(OnceType* once, void (*initializer)()) {
}

bool HasAcceleratedCRC32C() {
#if (__x86_64__ || __i386__) && defined(__GNUC__)
#if (defined(__x86_64__) || defined(__i386__)) && defined(__GNUC__)
unsigned int eax, ebx, ecx, edx;
__get_cpuid(1, &eax, &ebx, &ecx, &edx);
return (ecx & (1 << 20)) != 0;
Expand Down
2 changes: 1 addition & 1 deletion port/port_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void AtomicPointer::NoBarrier_Store(void* v) {
}

bool HasAcceleratedCRC32C() {
#if (__x86_64__ || __i386__)
#if defined(__x86_64__) || defined(__i386__)
int cpu_info[4];
__cpuid(cpu_info, 1);
return (cpu_info[2] & (1 << 20)) != 0;
Expand Down

0 comments on commit 8b1cd37

Please sign in to comment.