mirror of
https://github.com/google/cpu_features.git
synced 2025-07-01 05:11:15 +02:00
Avoid leaking internal headers for ppc (#164)
This commit is contained in:

committed by
GitHub

parent
001faefdc3
commit
b3ef4ef49d
@ -20,6 +20,7 @@
|
||||
|
||||
#include "internal/bit_utils.h"
|
||||
#include "internal/filesystem.h"
|
||||
#include "internal/hwcaps.h"
|
||||
#include "internal/stack_line_reader.h"
|
||||
#include "internal/string_view.h"
|
||||
|
||||
@ -133,9 +134,19 @@ static const PPCPlatformStrings kEmptyPPCPlatformStrings;
|
||||
|
||||
PPCPlatformStrings GetPPCPlatformStrings(void) {
|
||||
PPCPlatformStrings strings = kEmptyPPCPlatformStrings;
|
||||
const char* platform = CpuFeatures_GetPlatformPointer();
|
||||
const char* base_platform = CpuFeatures_GetBasePlatformPointer();
|
||||
|
||||
FillProcCpuInfoData(&strings);
|
||||
strings.type = CpuFeatures_GetPlatformType();
|
||||
|
||||
if (platform != NULL)
|
||||
CpuFeatures_StringView_CopyString(str(platform), strings.type.platform,
|
||||
sizeof(strings.type.platform));
|
||||
if (base_platform != NULL)
|
||||
CpuFeatures_StringView_CopyString(str(base_platform),
|
||||
strings.type.base_platform,
|
||||
sizeof(strings.type.base_platform));
|
||||
|
||||
return strings;
|
||||
}
|
||||
|
||||
|
21
src/hwcaps.c
21
src/hwcaps.c
@ -35,7 +35,8 @@ bool CpuFeatures_IsHwCapsSet(const HardwareCapabilities hwcaps_mask,
|
||||
#ifdef CPU_FEATURES_TEST
|
||||
// In test mode, hwcaps_for_testing will define the following functions.
|
||||
HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void);
|
||||
PlatformType CpuFeatures_GetPlatformType(void);
|
||||
const char* CpuFeatures_GetPlatformPointer(void);
|
||||
const char* CpuFeatures_GetBasePlatformPointer(void);
|
||||
#else
|
||||
|
||||
// Debug facilities
|
||||
@ -163,20 +164,12 @@ HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void) {
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
PlatformType kEmptyPlatformType;
|
||||
const char *CpuFeatures_GetPlatformPointer(void) {
|
||||
return (const char *)GetHardwareCapabilitiesFor(AT_PLATFORM);
|
||||
}
|
||||
|
||||
PlatformType CpuFeatures_GetPlatformType(void) {
|
||||
PlatformType type = kEmptyPlatformType;
|
||||
char *platform = (char *)GetHardwareCapabilitiesFor(AT_PLATFORM);
|
||||
char *base_platform = (char *)GetHardwareCapabilitiesFor(AT_BASE_PLATFORM);
|
||||
|
||||
if (platform != NULL)
|
||||
CpuFeatures_StringView_CopyString(str(platform), type.platform,
|
||||
sizeof(type.platform));
|
||||
if (base_platform != NULL)
|
||||
CpuFeatures_StringView_CopyString(str(base_platform), type.base_platform,
|
||||
sizeof(type.base_platform));
|
||||
return type;
|
||||
const char *CpuFeatures_GetBasePlatformPointer(void) {
|
||||
return (const char *)GetHardwareCapabilitiesFor(AT_BASE_PLATFORM);
|
||||
}
|
||||
|
||||
#endif // CPU_FEATURES_TEST
|
||||
|
Reference in New Issue
Block a user