Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
85b6d59b
Commit
85b6d59b
authored
13 years ago
by
pcherenkov
Browse files
Options
Downloads
Patches
Plain Diff
cpu_has() returns bool to avoid ambiguity
parent
5072a04c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/cpu_feature.m
+7
-13
7 additions, 13 deletions
core/cpu_feature.m
include/cpu_feature.h
+4
-6
4 additions, 6 deletions
include/cpu_feature.h
with
11 additions
and
19 deletions
core/cpu_feature.m
+
7
−
13
View file @
85b6d59b
...
...
@@ -25,6 +25,7 @@
#include
<
sys
/
types
.
h
>
#include
<
errno
.
h
>
#include
<
stdlib
.
h
>
#include
"cpu_feature.h"
...
...
@@ -186,16 +187,13 @@ get_cpuid(long info, long* eax, long* ebx, long* ecx, long *edx)
/* Check whether CPU has a certain feature. */
int
bool
cpu_has(unsigned int feature)
{
long info = 1, reg[4] = {0,0,0,0};
if (!can_cpuid())
return -EINVAL;
if (feature > LEN_cpu_mask)
return -ERANGE;
if (!can_cpuid() || feature > LEN_cpu_mask)
return false;
get_cpuid(info, ®[eAX], ®[eBX], ®[eCX], ®[eDX]);
...
...
@@ -211,24 +209,20 @@ crc32c_hw(u_int32_t crc, const unsigned char *buf, unsigned int len)
#else /* other (yet unsupported architectures) */
int
bool
cpu_has(unsigned int feature)
{
(void)feature;
return
EINVAL
;
return
false
;
}
u_int32_t
crc32c_hw(u_int32_t crc, const unsigned char *buf, unsigned int len)
{
(void)crc; (void)buf, (void)len;
a
ssert(false
);
a
bort(
);
return 0;
}
#endif /* defined (__i386__) || defined (__x86_64__) */
/* __EOF__ */
This diff is collapsed.
Click to expand it.
include/cpu_feature.h
+
4
−
6
View file @
85b6d59b
...
...
@@ -26,6 +26,7 @@
*/
#include
<sys/types.h>
#include
<stdbool.h>
/* CPU feature capabilities to use with cpu_has (feature). */
...
...
@@ -39,10 +40,9 @@ enum {
*
* @param feature indetifier (see above) of the target feature
*
* @return 1 if feature is available, 0 if unavailable,
* -EINVAL if unsupported CPU, -ERANGE if invalid feature
* @return true if feature is available, false if unavailable.
*/
int
cpu_has
(
unsigned
int
feature
);
bool
cpu_has
(
unsigned
int
feature
);
/* Hardware-calculate CRC32 for the given data buffer.
...
...
@@ -51,7 +51,7 @@ int cpu_has(unsigned int feature);
* @param buf data buffer
* @param len buffer length
*
* @pre
1
== cpu_has (cpuf_sse4_2)
* @pre
true
== cpu_has (cpuf_sse4_2)
* @return CRC32 value
*/
u_int32_t
crc32c_hw
(
u_int32_t
crc
,
const
unsigned
char
*
buf
,
unsigned
int
len
);
...
...
@@ -59,5 +59,3 @@ u_int32_t crc32c_hw(u_int32_t crc, const unsigned char *buf, unsigned int len);
#endif
/* TARANTOOL_CPU_FEATURES_H */
/* __EOF__ */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment