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
0cfb6301
Commit
0cfb6301
authored
Oct 23, 2013
by
Ahmed Samy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cpuid: use a sprintf-like function to get cputype as a string
Signed-off-by:
Ahmed Samy
<
f.fallen45@gmail.com
>
parent
d03f0db1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
8 deletions
+17
-8
ccan/cpuid/cpuid.c
ccan/cpuid/cpuid.c
+7
-2
ccan/cpuid/cpuid.h
ccan/cpuid/cpuid.h
+7
-5
ccan/cpuid/test/run.c
ccan/cpuid/test/run.c
+3
-1
No files found.
ccan/cpuid/cpuid.c
View file @
0cfb6301
...
...
@@ -220,9 +220,14 @@ cputype_t cpuid_get_cpu_type(void)
return
cputype
;
}
const
char
*
cpuid_get_cpu_type_string
(
const
cputype_t
cputype
)
bool
cpuid_sprintf_cputype
(
const
cputype_t
cputype
,
char
*
buf
)
{
return
cpuids
[(
int
)
cputype
];
if
(
cputype
==
CT_NONE
)
return
false
;
memcpy
(
buf
,
cpuids
[(
int
)
cputype
],
12
);
buf
[
12
]
=
'\0'
;
return
true
;
}
uint32_t
cpuid_highest_ext_func_supported
(
void
)
...
...
ccan/cpuid/cpuid.h
View file @
0cfb6301
...
...
@@ -26,7 +26,7 @@
#include <stdint.h>
/**
* enum cpuid - stuff to get information
on
from the CPU.
* enum cpuid - stuff to get information
about
from the CPU.
*
* This is used as a parameter in cpuid().
*
...
...
@@ -124,14 +124,17 @@ typedef enum cputype {
*
* See also: cpuid_get_cpu_type_string()
*/
#define is_intel_cpu() cpuid_get_cpu_type() == CT_INTEL
#define is_amd_cpu() cpuid_get_cpu_type() == CT_AMDK5 || cpuid_get_cpu_type() == CT_AMD
cputype_t
cpuid_get_cpu_type
(
void
);
/**
* cpuid_get_cpu_type_string - Get CPU Type string
* cpuid_sprintf_cputype - Get CPU Type string
* @cputype: a char of atleast 12 bytes in it.
*
* Returns t
he CPU type string based off cputype_t.
* Returns t
rue on success, false on failure
*/
const
char
*
cpuid_get_cpu_type_string
(
const
cputype_t
cputype
);
bool
cpuid_sprintf_cputype
(
const
cputype_t
cputype
,
char
*
buf
);
/**
* cpuid_is_supported - test if the CPUID instruction is supported
...
...
@@ -275,4 +278,3 @@ bool cpuid_has_feature(int feature, bool extended);
#endif
#endif
ccan/cpuid/test/run.c
View file @
0cfb6301
...
...
@@ -10,7 +10,9 @@ int main(void)
return
1
;
}
printf
(
"Vendor ID: %s
\n
"
,
cpuid_get_cpu_type_string
(
cpuid_get_cpu_type
()));
char
cputype
[
12
];
if
(
cpuid_sprintf_cputype
(
cpuid_get_cpu_type
(),
cputype
))
printf
(
"Vendor ID: %s
\n
"
,
cputype
);
char
buf
[
48
];
cpuid
(
CPU_PROC_BRAND_STRING
,
(
uint32_t
*
)
buf
);
...
...
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