Skip to content

Commit

Permalink
Set LIBCPUID_DEPRECATED macro to deprecate attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTumultuousUnicornOfDarkness committed Jun 28, 2024
1 parent f5514f0 commit edce711
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ if(UNIX)
set(exec_prefix "\${prefix}")
set(libdir "\${exec_prefix}/lib")
set(includedir "\${prefix}/include")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wuninitialized -Wstrict-prototypes -Wformat -Wformat-security -Wunused-parameter")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wuninitialized -Wstrict-prototypes -Wformat -Wformat-security -Wunused-parameter -Wno-deprecated-declarations")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libcpuid.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libcpuid.pc" ESCAPE_QUOTES
@ONLY)
install(FILES "${PROJECT_BINARY_DIR}/libcpuid.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
Expand Down
28 changes: 19 additions & 9 deletions libcpuid/libcpuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@
/* Some limits and other constants */
#include "libcpuid_constants.h"

#ifndef LIBCPUID_DEPRECATED
# if defined(__GNUC__) || defined(__clang__)
# define LIBCPUID_DEPRECATED(msg) __attribute__((deprecated(msg)))
# elif defined(_MSC_VER)
# define LIBCPUID_DEPRECATED(msg) __declspec(deprecated(msg))
# else
# define LIBCPUID_DEPRECATED(msg)
# endif
#endif /* LIBCPUID_DEPRECATED */

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -496,32 +506,32 @@ struct cpu_id_t {
* CPU family (BaseFamily[3:0])
* @deprecated replaced by \ref x86_id_t::family (prefix member with `x86.`, e.g. `id.x86.family`)
*/
int32_t family;
int32_t family LIBCPUID_DEPRECATED("replace with '.x86.family' in your code to fix the warning");

/**
* CPU model (BaseModel[3:0])
* @deprecated replaced by \ref x86_id_t::model (prefix member with `x86.`, e.g. `id.x86.model`)
*/
int32_t model;
int32_t model LIBCPUID_DEPRECATED("replace with '.x86.model' in your code to fix the warning");

/**
* CPU stepping
* @deprecated replaced by \ref x86_id_t::stepping (prefix member with `x86.`, e.g. `id.x86.stepping`)
*/
int32_t stepping;
int32_t stepping LIBCPUID_DEPRECATED("replace with '.x86.stepping' in your code to fix the warning");

/**
* CPU display ("true") family (computed as BaseFamily[3:0]+ExtendedFamily[7:0])
* @deprecated replaced by \ref x86_id_t::ext_family (prefix member with `x86.`, e.g. `id.x86.ext_family`)
*/
int32_t ext_family;
int32_t ext_family LIBCPUID_DEPRECATED("replace with '.x86.ext_family' in your code to fix the warning");

/**
* CPU display ("true") model (computed as (ExtendedModel[3:0]<<4) + BaseModel[3:0])
* For detailed discussion about what BaseModel / ExtendedModel / Model are, see Github issue #150.
* @deprecated replaced by \ref x86_id_t::ext_model (prefix member with `x86.`, e.g. `id.x86.ext_model`)
*/
int32_t ext_model;
int32_t ext_model LIBCPUID_DEPRECATED("replace with '.x86.ext_model' in your code to fix the warning");

/**
* contains architecture specific info.
Expand Down Expand Up @@ -587,7 +597,7 @@ struct cpu_id_t {
/** Cache associativity for the L1 data cache. -1 if undetermined
* @deprecated replaced by \ref cpu_id_t::l1_data_assoc
*/
int32_t l1_assoc;
int32_t l1_assoc LIBCPUID_DEPRECATED("replace with 'l1_data_assoc' in your code to fix the warning");

/** Cache associativity for the L1 data cache. -1 if undetermined */
int32_t l1_data_assoc;
Expand All @@ -607,7 +617,7 @@ struct cpu_id_t {
/** Cache-line size for L1 data cache. -1 if undetermined
* @deprecated replaced by \ref cpu_id_t::l1_data_cacheline
*/
int32_t l1_cacheline;
int32_t l1_cacheline LIBCPUID_DEPRECATED("replace with 'l1_data_cacheline' in your code to fix the warning");

/** Cache-line size for L1 data cache. -1 if undetermined */
int32_t l1_data_cacheline;
Expand Down Expand Up @@ -659,7 +669,7 @@ struct cpu_id_t {
* SSE execution unit size (64 or 128; -1 if N/A)
* @deprecated replaced by \ref x86_id_t::sse_size (prefix member with `x86.`, e.g. `id.x86.sse_size`)
*/
int32_t sse_size;
int32_t sse_size LIBCPUID_DEPRECATED("replace with '.x86.sse_size' in your code to fix the warning");

/**
* contain miscellaneous detection information. Used to test about specifics of
Expand All @@ -672,7 +682,7 @@ struct cpu_id_t {
* contains information about SGX features if the processor, if present
* @deprecated replaced by \ref x86_id_t::sgx (prefix member with `x86.`, e.g. `id.x86.sgx`)
*/
struct cpu_sgx_t sgx;
struct cpu_sgx_t sgx LIBCPUID_DEPRECATED("replace with '.x86.sgx' in your code to fix the warning");

/** bitmask of the affinity ids this processor type is occupying */
cpu_affinity_mask_t affinity_mask;
Expand Down

0 comments on commit edce711

Please sign in to comment.