forked from ceph/ceph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For now, just a check to see if we have SSE4.2. Signed-off-by: Sage Weil <[email protected]>
- Loading branch information
Sage Weil
committed
Aug 22, 2013
1 parent
841a695
commit f008ac4
Showing
5 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "arch/probe.h" | ||
|
||
/* flags we export */ | ||
int ceph_arch_intel_sse42 = 0; | ||
|
||
|
||
/* this probably isn't specific enough for x86_64? fix me someday */ | ||
#ifdef __LP64__ | ||
|
||
/* intel cpu? */ | ||
static void do_cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, | ||
unsigned int *edx) | ||
{ | ||
int id = *eax; | ||
|
||
asm("movl %4, %%eax;" | ||
"cpuid;" | ||
"movl %%eax, %0;" | ||
"movl %%ebx, %1;" | ||
"movl %%ecx, %2;" | ||
"movl %%edx, %3;" | ||
: "=r" (*eax), "=r" (*ebx), "=r" (*ecx), "=r" (*edx) | ||
: "r" (id) | ||
: "eax", "ebx", "ecx", "edx"); | ||
} | ||
|
||
int ceph_arch_intel_probe(void) | ||
{ | ||
/* i know how to check this on x86_64... */ | ||
unsigned int eax = 1, ebx, ecx, edx; | ||
do_cpuid(&eax, &ebx, &ecx, &edx); | ||
if ((ecx & (1 << 20)) != 0) { | ||
ceph_arch_intel_sse42 = 1; | ||
} | ||
return 0; | ||
} | ||
|
||
#else // __LP64__ | ||
|
||
int ceph_arch_intel_probe(void) | ||
{ | ||
/* no features */ | ||
return 0; | ||
} | ||
|
||
#endif // __LP64__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef CEPH_ARCH_INTEL_H | ||
#define CEPH_ARCH_INTEL_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
extern int ceph_arch_intel_sse42; /* true if we have sse 4.2 features */ | ||
|
||
extern int ceph_arch_intel_probe(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- | ||
// vim: ts=8 sw=2 smarttab | ||
|
||
#include "arch/probe.h" | ||
|
||
#include "arch/intel.h" | ||
|
||
int ceph_arch_probe(void) | ||
{ | ||
if (ceph_arch_probed) | ||
return 1; | ||
|
||
ceph_arch_intel_probe(); | ||
|
||
ceph_arch_probed = 1; | ||
return 1; | ||
} | ||
|
||
// do this once using the magic of c++. | ||
int ceph_arch_probed = ceph_arch_probe(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef CEPH_ARCH_PROBE_H | ||
#define CEPH_ARCH_PROBE_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
extern int ceph_arch_probed; /* non-zero if we've probed features */ | ||
|
||
extern int ceph_arch_probe(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |