Skip to content
Snippets Groups Projects
Commit 85b6d59b authored by pcherenkov's avatar pcherenkov
Browse files

cpu_has() returns bool to avoid ambiguity

parent 5072a04c
No related branches found
No related tags found
No related merge requests found
......@@ -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, &reg[eAX], &reg[eBX], &reg[eCX], &reg[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;
assert(false);
abort();
return 0;
}
#endif /* defined (__i386__) || defined (__x86_64__) */
/* __EOF__ */
......@@ -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__ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment