mirror of
https://github.com/anrieff/libcpuid
synced 2025-10-13 11:10:39 +00:00
* Support for stdin/stdout for (de)serializing cpu_raw_data_t;
* set_warn_function renamed to cpuid_set_warn_function; * Updated Doxygen documentation: added manpage output, generic mainpage intro, default module named correctly; * Updated doxy libcpuid.h documentation, fixed some bugs; * Warnings are now printed to stderr by default, not stdout; * Some constants in AMD code did not reflected their meaning well, fixed; * The cpuid_tool utility thoroughly redesigned; now a multiple-function program, perhaps close to the finalized state. git-svn-id: https://svn.code.sf.net/p/libcpuid/code/HEAD/libcpuid@19 3b4be424-7ac5-41d7-8526-f4ddcb85d872
This commit is contained in:
parent
5c348fd6bd
commit
c5c0539372
7 changed files with 638 additions and 99 deletions
|
@ -38,7 +38,7 @@
|
|||
|
||||
static int _libcpiud_errno = ERR_OK;
|
||||
|
||||
static int set_error(cpuid_error_t err)
|
||||
static int set_error(cpu_error_t err)
|
||||
{
|
||||
_libcpiud_errno = (int) err;
|
||||
return (int) err;
|
||||
|
@ -291,7 +291,10 @@ int cpuid_serialize_raw_data(struct cpu_raw_data_t* data, const char* filename)
|
|||
int i;
|
||||
FILE *f;
|
||||
|
||||
f = fopen(filename, "wt");
|
||||
if (!strcmp(filename, ""))
|
||||
f = stdout;
|
||||
else
|
||||
f = fopen(filename, "wt");
|
||||
if (!f) return set_error(ERR_OPEN);
|
||||
|
||||
fprintf(f, "version=%s\n", VERSION);
|
||||
|
@ -308,7 +311,8 @@ int cpuid_serialize_raw_data(struct cpu_raw_data_t* data, const char* filename)
|
|||
data->intel_fn4[i][0], data->intel_fn4[i][1],
|
||||
data->intel_fn4[i][2], data->intel_fn4[i][3]);
|
||||
|
||||
fclose(f);
|
||||
if (strcmp(filename, ""))
|
||||
fclose(f);
|
||||
return set_error(ERR_OK);
|
||||
}
|
||||
|
||||
|
@ -325,7 +329,10 @@ int cpuid_deserialize_raw_data(struct cpu_raw_data_t* data, const char* filename
|
|||
|
||||
raw_data_t_constructor(data);
|
||||
|
||||
f = fopen(filename, "rt");
|
||||
if (!strcmp(filename, ""))
|
||||
f = stdin;
|
||||
else
|
||||
f = fopen(filename, "rt");
|
||||
if (!f) return set_error(ERR_OPEN);
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
++cur_line;
|
||||
|
@ -360,7 +367,8 @@ int cpuid_deserialize_raw_data(struct cpu_raw_data_t* data, const char* filename
|
|||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
if (strcmp(filename, ""))
|
||||
fclose(f);
|
||||
return set_error(ERR_OK);
|
||||
}
|
||||
|
||||
|
@ -489,7 +497,7 @@ const char* cpu_feature_str(cpu_feature_t feature)
|
|||
|
||||
const char* cpuid_error(void)
|
||||
{
|
||||
const struct { cpuid_error_t error; const char *description; }
|
||||
const struct { cpu_error_t error; const char *description; }
|
||||
matchtable[] = {
|
||||
{ ERR_OK , "No error"},
|
||||
{ ERR_NO_CPUID , "CPUID instruction is not supported"},
|
||||
|
@ -513,7 +521,7 @@ const char* cpuid_lib_version(void)
|
|||
return VERSION;
|
||||
}
|
||||
|
||||
libcpuid_warn_fn_t set_warn_function(libcpuid_warn_fn_t new_fn)
|
||||
libcpuid_warn_fn_t cpuid_set_warn_function(libcpuid_warn_fn_t new_fn)
|
||||
{
|
||||
libcpuid_warn_fn_t ret = _warn_fun;
|
||||
_warn_fun = new_fn;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue