mirror of
https://github.com/anrieff/libcpuid
synced 2025-01-23 20:06:41 +00:00
Allow to build libcpuid without deprecated attributes
It helps to track internal usage of deprecated attributes.
This commit is contained in:
parent
e740cbe798
commit
c6a72849b8
4 changed files with 25 additions and 9 deletions
|
@ -20,6 +20,12 @@ if("${MSVC_CXX_ARCHITECTURE_ID}" MATCHES "x64")
|
||||||
list(APPEND cpuid_sources masm-x64.asm)
|
list(APPEND cpuid_sources masm-x64.asm)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(SUPPORT_DEPRECATED "Build support of deprecated attributes" ON)
|
||||||
|
if(NOT SUPPORT_DEPRECATED)
|
||||||
|
message(AUTHOR_WARNING "Deprecated attributes will not be available, the library will be not backward compatible")
|
||||||
|
add_compile_definitions(LIBCPUID_DISABLE_DEPRECATED)
|
||||||
|
endif(NOT SUPPORT_DEPRECATED)
|
||||||
|
|
||||||
add_library(cpuid ${cpuid_sources})
|
add_library(cpuid ${cpuid_sources})
|
||||||
set_property(TARGET cpuid PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
set_property(TARGET cpuid PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||||
target_include_directories(cpuid SYSTEM PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
target_include_directories(cpuid SYSTEM PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||||
|
|
|
@ -80,8 +80,8 @@ static void cpu_id_t_constructor(struct cpu_id_t* id)
|
||||||
id->feature_level = FEATURE_LEVEL_UNKNOWN;
|
id->feature_level = FEATURE_LEVEL_UNKNOWN;
|
||||||
id->vendor = VENDOR_UNKNOWN;
|
id->vendor = VENDOR_UNKNOWN;
|
||||||
id->l1_data_cache = id->l1_instruction_cache = id->l2_cache = id->l3_cache = id->l4_cache = -1;
|
id->l1_data_cache = id->l1_instruction_cache = id->l2_cache = id->l3_cache = id->l4_cache = -1;
|
||||||
id->l1_assoc = id->l1_data_assoc = id->l1_instruction_assoc = id->l2_assoc = id->l3_assoc = id->l4_assoc = -1;
|
id->l1_data_assoc = id->l1_instruction_assoc = id->l2_assoc = id->l3_assoc = id->l4_assoc = -1;
|
||||||
id->l1_cacheline = id->l1_data_cacheline = id->l1_instruction_cacheline = id->l2_cacheline = id->l3_cacheline = id->l4_cacheline = -1;
|
id->l1_data_cacheline = id->l1_instruction_cacheline = id->l2_cacheline = id->l3_cacheline = id->l4_cacheline = -1;
|
||||||
id->l1_data_instances = id->l1_instruction_instances = id->l2_instances = id->l3_instances = id->l4_instances = -1;
|
id->l1_data_instances = id->l1_instruction_instances = id->l2_instances = id->l3_instances = id->l4_instances = -1;
|
||||||
id->x86.sse_size = -1;
|
id->x86.sse_size = -1;
|
||||||
init_affinity_mask(&id->affinity_mask);
|
init_affinity_mask(&id->affinity_mask);
|
||||||
|
@ -1376,8 +1376,11 @@ int cpu_ident_internal(struct cpu_raw_data_t* raw, struct cpu_id_t* data, struct
|
||||||
r = cpuid_identify_arm(raw, data);
|
r = cpuid_identify_arm(raw, data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return cpuid_set_error(ERR_CPU_UNKN);
|
r = ERR_CPU_UNKN;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef LIBCPUID_DISABLE_DEPRECATED
|
||||||
/* Backward compatibility */
|
/* Backward compatibility */
|
||||||
/* - Deprecated since v0.5.0 */
|
/* - Deprecated since v0.5.0 */
|
||||||
data->l1_assoc = data->l1_data_assoc;
|
data->l1_assoc = data->l1_data_assoc;
|
||||||
|
@ -1390,6 +1393,7 @@ int cpu_ident_internal(struct cpu_raw_data_t* raw, struct cpu_id_t* data, struct
|
||||||
data->ext_model = data->x86.ext_model;
|
data->ext_model = data->x86.ext_model;
|
||||||
data->sse_size = data->x86.sse_size;
|
data->sse_size = data->x86.sse_size;
|
||||||
data->sgx = data->x86.sgx;
|
data->sgx = data->x86.sgx;
|
||||||
|
#endif /* LIBCPUID_DISABLE_DEPRECATED */
|
||||||
|
|
||||||
return cpuid_set_error(r);
|
return cpuid_set_error(r);
|
||||||
}
|
}
|
||||||
|
|
|
@ -523,6 +523,7 @@ struct cpu_id_t {
|
||||||
*/
|
*/
|
||||||
uint8_t flags[CPU_FLAGS_MAX];
|
uint8_t flags[CPU_FLAGS_MAX];
|
||||||
|
|
||||||
|
#ifndef LIBCPUID_DISABLE_DEPRECATED
|
||||||
/**
|
/**
|
||||||
* CPU family (BaseFamily[3:0])
|
* CPU family (BaseFamily[3:0])
|
||||||
* @deprecated replaced by \ref x86_id_t::family (prefix member with `x86.`, e.g. `id.x86.family`)
|
* @deprecated replaced by \ref x86_id_t::family (prefix member with `x86.`, e.g. `id.x86.family`)
|
||||||
|
@ -558,6 +559,7 @@ struct cpu_id_t {
|
||||||
*/
|
*/
|
||||||
LIBCPUID_DEPRECATED("replace with '.x86.ext_model' in your code to fix the warning")
|
LIBCPUID_DEPRECATED("replace with '.x86.ext_model' in your code to fix the warning")
|
||||||
int32_t ext_model;
|
int32_t ext_model;
|
||||||
|
#endif /* LIBCPUID_DISABLE_DEPRECATED */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* contains architecture specific info.
|
* contains architecture specific info.
|
||||||
|
@ -620,11 +622,13 @@ struct cpu_id_t {
|
||||||
/** L4 cache size in KB. Zero on most systems */
|
/** L4 cache size in KB. Zero on most systems */
|
||||||
int32_t l4_cache;
|
int32_t l4_cache;
|
||||||
|
|
||||||
|
#ifndef LIBCPUID_DISABLE_DEPRECATED
|
||||||
/** Cache associativity for the L1 data cache. -1 if undetermined
|
/** Cache associativity for the L1 data cache. -1 if undetermined
|
||||||
* @deprecated replaced by \ref cpu_id_t::l1_data_assoc
|
* @deprecated replaced by \ref cpu_id_t::l1_data_assoc
|
||||||
*/
|
*/
|
||||||
LIBCPUID_DEPRECATED("replace with 'l1_data_assoc' in your code to fix the warning")
|
LIBCPUID_DEPRECATED("replace with 'l1_data_assoc' in your code to fix the warning")
|
||||||
int32_t l1_assoc;
|
int32_t l1_assoc;
|
||||||
|
#endif /* LIBCPUID_DISABLE_DEPRECATED */
|
||||||
|
|
||||||
/** Cache associativity for the L1 data cache. -1 if undetermined */
|
/** Cache associativity for the L1 data cache. -1 if undetermined */
|
||||||
int32_t l1_data_assoc;
|
int32_t l1_data_assoc;
|
||||||
|
@ -641,11 +645,13 @@ struct cpu_id_t {
|
||||||
/** Cache associativity for the L4 cache. -1 if undetermined */
|
/** Cache associativity for the L4 cache. -1 if undetermined */
|
||||||
int32_t l4_assoc;
|
int32_t l4_assoc;
|
||||||
|
|
||||||
|
#ifndef LIBCPUID_DISABLE_DEPRECATED
|
||||||
/** Cache-line size for L1 data cache. -1 if undetermined
|
/** Cache-line size for L1 data cache. -1 if undetermined
|
||||||
* @deprecated replaced by \ref cpu_id_t::l1_data_cacheline
|
* @deprecated replaced by \ref cpu_id_t::l1_data_cacheline
|
||||||
*/
|
*/
|
||||||
LIBCPUID_DEPRECATED("replace with 'l1_data_cacheline' in your code to fix the warning")
|
LIBCPUID_DEPRECATED("replace with 'l1_data_cacheline' in your code to fix the warning")
|
||||||
int32_t l1_cacheline;
|
int32_t l1_cacheline;
|
||||||
|
#endif /* LIBCPUID_DISABLE_DEPRECATED */
|
||||||
|
|
||||||
/** Cache-line size for L1 data cache. -1 if undetermined */
|
/** Cache-line size for L1 data cache. -1 if undetermined */
|
||||||
int32_t l1_data_cacheline;
|
int32_t l1_data_cacheline;
|
||||||
|
|
|
@ -734,13 +734,13 @@ static int msr_platform_info_supported(struct msr_info_t *info)
|
||||||
|
|
||||||
if(info->id->vendor == VENDOR_INTEL) {
|
if(info->id->vendor == VENDOR_INTEL) {
|
||||||
for(i = 0; i < COUNT_OF(msr_platform_info); i++) {
|
for(i = 0; i < COUNT_OF(msr_platform_info); i++) {
|
||||||
if((info->id->ext_family == msr_platform_info[i].ext_family) && (info->id->ext_model == msr_platform_info[i].ext_model)) {
|
if((info->id->x86.ext_family == msr_platform_info[i].ext_family) && (info->id->x86.ext_model == msr_platform_info[i].ext_model)) {
|
||||||
debugf(2, "Intel CPU with CPUID signature %02X_%02XH supports MSR_PLATFORM_INFO.\n", info->id->ext_family, info->id->ext_model);
|
debugf(2, "Intel CPU with CPUID signature %02X_%02XH supports MSR_PLATFORM_INFO.\n", info->id->x86.ext_family, info->id->x86.ext_model);
|
||||||
supported = 1;
|
supported = 1;
|
||||||
return supported;
|
return supported;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debugf(2, "Intel CPU with CPUID signature %02X_%02XH does not support MSR_PLATFORM_INFO.\n", info->id->ext_family, info->id->ext_model);
|
debugf(2, "Intel CPU with CPUID signature %02X_%02XH does not support MSR_PLATFORM_INFO.\n", info->id->x86.ext_family, info->id->x86.ext_model);
|
||||||
}
|
}
|
||||||
|
|
||||||
supported = 0;
|
supported = 0;
|
||||||
|
@ -830,13 +830,13 @@ static int msr_perf_status_supported(struct msr_info_t *info)
|
||||||
|
|
||||||
if(info->id->vendor == VENDOR_INTEL) {
|
if(info->id->vendor == VENDOR_INTEL) {
|
||||||
for(i = 0; i < COUNT_OF(msr_perf_status); i++) {
|
for(i = 0; i < COUNT_OF(msr_perf_status); i++) {
|
||||||
if((info->id->ext_family == msr_perf_status[i].ext_family) && (info->id->ext_model == msr_perf_status[i].ext_model)) {
|
if((info->id->x86.ext_family == msr_perf_status[i].ext_family) && (info->id->x86.ext_model == msr_perf_status[i].ext_model)) {
|
||||||
debugf(2, "Intel CPU with CPUID signature %02X_%02XH supports MSR_PERF_STATUS.\n", info->id->ext_family, info->id->ext_model);
|
debugf(2, "Intel CPU with CPUID signature %02X_%02XH supports MSR_PERF_STATUS.\n", info->id->x86.ext_family, info->id->x86.ext_model);
|
||||||
supported = 1;
|
supported = 1;
|
||||||
return supported;
|
return supported;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debugf(2, "Intel CPU with CPUID signature %02X_%02XH does not support MSR_PERF_STATUS.\n", info->id->ext_family, info->id->ext_model);
|
debugf(2, "Intel CPU with CPUID signature %02X_%02XH does not support MSR_PERF_STATUS.\n", info->id->x86.ext_family, info->id->x86.ext_model);
|
||||||
}
|
}
|
||||||
|
|
||||||
supported = 0;
|
supported = 0;
|
||||||
|
|
Loading…
Reference in a new issue