Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
7d7de521
Commit
7d7de521
authored
Aug 11, 2015
by
A. Samy
Committed by
Rusty Russell
Aug 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cpuid: cpuid_write_info(): have outfile a file pointer instead
parent
2ecac63d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
29 deletions
+6
-29
ccan/cpuid/cpuid.c
ccan/cpuid/cpuid.c
+2
-23
ccan/cpuid/cpuid.h
ccan/cpuid/cpuid.h
+4
-6
No files found.
ccan/cpuid/cpuid.c
View file @
7d7de521
...
@@ -368,32 +368,12 @@ void cpuid(cpuid_t request, uint32_t *buf)
...
@@ -368,32 +368,12 @@ void cpuid(cpuid_t request, uint32_t *buf)
}
}
}
}
bool
cpuid_write_info
(
uint32_t
info
,
uint32_t
featureset
,
const
char
*
out
file
)
bool
cpuid_write_info
(
uint32_t
info
,
uint32_t
featureset
,
FILE
*
file
)
{
{
FILE
*
file
;
char
filename
[
256
];
char
cpu_information
[
64
];
if
(
!
cpuid_sprintf_cputype
(
cpuid_get_cpu_type
(),
cpu_information
))
return
false
;
char
brand
[
48
];
char
brand
[
48
];
cpuid
(
CPUID_PROC_BRAND_STRING
,
(
uint32_t
*
)
brand
);
cpuid
(
CPUID_PROC_BRAND_STRING
,
(
uint32_t
*
)
brand
);
cpu_information
[
12
]
=
'_'
;
fprintf
(
file
,
"-- CPU Information for: %s_%s --
\n\n
"
,
cpuid_get_name
(),
brand
);
memcpy
(
&
cpu_information
[
13
],
brand
,
sizeof
brand
);
if
(
!
outfile
)
strncpy
(
filename
,
cpu_information
,
sizeof
cpu_information
);
else
strncpy
(
filename
,
outfile
,
sizeof
filename
);
file
=
fopen
(
filename
,
"w"
);
if
(
!
file
)
return
false
;
fprintf
(
file
,
"-- CPU Information for CPU: %s --
\n\n
"
,
cpu_information
);
if
(
info
&
CPUID_HIGHEST_EXTENDED_FUNCTION_SUPPORTED
)
if
(
info
&
CPUID_HIGHEST_EXTENDED_FUNCTION_SUPPORTED
)
fprintf
(
file
,
"Highest extended function supported: %#010x
\n\n
"
,
cpuid_highest_ext_func_supported
());
fprintf
(
file
,
"Highest extended function supported: %#010x
\n\n
"
,
cpuid_highest_ext_func_supported
());
...
@@ -675,7 +655,6 @@ bool cpuid_write_info(uint32_t info, uint32_t featureset, const char *outfile)
...
@@ -675,7 +655,6 @@ bool cpuid_write_info(uint32_t info, uint32_t featureset, const char *outfile)
}
}
#undef YON
#undef YON
fclose
(
file
);
return
true
;
return
true
;
}
}
...
...
ccan/cpuid/cpuid.h
View file @
7d7de521
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include <stdbool.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdint.h>
#include <stdio.h>
/**
/**
* enum cpuid - stuff to get information about from the CPU.
* enum cpuid - stuff to get information about from the CPU.
...
@@ -371,20 +372,17 @@ void cpuid(cpuid_t request, uint32_t *buf);
...
@@ -371,20 +372,17 @@ void cpuid(cpuid_t request, uint32_t *buf);
* cpuid_write_info - Write specified CPU information to a file.
* cpuid_write_info - Write specified CPU information to a file.
* @info: Bit set of information to write.
* @info: Bit set of information to write.
* @featureset: Bit set of features to write.
* @featureset: Bit set of features to write.
* @outfile: Output filename (Max 256).
* @outfile: Output file pointer
*
* If @outfile is NULL, a name is choosen in the following format:
* CPUVENDOR_PROCESSORBRAND.cpuid
*
*
* Returns true on success, false otherwise.
* Returns true on success, false otherwise.
*
*
* Example usage:
* Example usage:
* if (!cpuid_write_info(CPUID_VENDORID | CPUID_PROC_BRAND_STRING,
* if (!cpuid_write_info(CPUID_VENDORID | CPUID_PROC_BRAND_STRING,
* CPUID_FEAT_ECX_SSE3 | CPUID_FEAT_EDX_FPU,
* CPUID_FEAT_ECX_SSE3 | CPUID_FEAT_EDX_FPU,
*
"cpuinfo.cpuid"
))
*
fp
))
* ... error ...
* ... error ...
*/
*/
bool
cpuid_write_info
(
uint32_t
info
,
uint32_t
featureset
,
const
char
*
outfile
);
bool
cpuid_write_info
(
uint32_t
info
,
uint32_t
featureset
,
FILE
*
outfile
);
/**
/**
* cpuid_test_feature - Test if @feature is available
* cpuid_test_feature - Test if @feature is available
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment