util: Generate multiple versions of spdk_u32log2
Generate multiple versions for various architectures automatically. Fixes issue #713 Change-Id: I757a1d05e54c938b66dd5b2ec255ad960bb89945 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463550 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
236dbd9550
commit
de03082191
@ -57,6 +57,12 @@ extern "C" {
|
||||
/* Ceiling division of unsigned integers */
|
||||
#define SPDK_CEIL_DIV(x,y) (((x)+(y)-1)/(y))
|
||||
|
||||
/* The following will automatically generate several version of
|
||||
* this function, targeted at different architectures. This
|
||||
* is only supported by GCC 6 or newer. */
|
||||
#if defined(__GNUC__) && __GNUC__ >= 6 && !defined(__clang__)
|
||||
__attribute__((target_clones("bmi", "arch=core2", "arch=atom", "default")))
|
||||
#endif
|
||||
static inline uint32_t
|
||||
spdk_u32log2(uint32_t x)
|
||||
{
|
||||
@ -73,6 +79,12 @@ spdk_align32pow2(uint32_t x)
|
||||
return 1u << (1 + spdk_u32log2(x - 1));
|
||||
}
|
||||
|
||||
/* The following will automatically generate several version of
|
||||
* this function, targeted at different architectures. This
|
||||
* is only supported by GCC 6 or newer. */
|
||||
#if defined(__GNUC__) && __GNUC__ >= 6 && !defined(__clang__)
|
||||
__attribute__((target_clones("bmi", "arch=core2", "arch=atom", "default")))
|
||||
#endif
|
||||
static inline uint64_t
|
||||
spdk_u64log2(uint64_t x)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user