Commit f29acca2 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

util: use __typeof__ instead of typeof



'typeof' is a GNU extension - let's use __typeof__
instead which is ISO C compliant.

Allows building SPDK header files with -std=c11 as
long as _GNU_SOURCE is also defined.

Next patch will enable omitting _GNU_SOURCE as well.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ibd6c984627b553d6f87f302800abc52157fe9b1e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8332


Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarJacek Kalwas <jacek.kalwas@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent 74c88aa6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ extern "C" {
 * power-of-two value.
 */
#define SPDK_ALIGN_FLOOR(val, align) \
	(typeof(val))((val) & (~((typeof(val))((align) - 1))))
	(__typeof__(val))((val) & (~((__typeof__(val))((align) - 1))))
/**
 * Macro to align a value to a given power-of-two. The resultant value
 * will be of the same type as the first parameter, and will be no lower
@@ -74,7 +74,7 @@ extern "C" {
 * value.
 */
#define SPDK_ALIGN_CEIL(val, align) \
	SPDK_ALIGN_FLOOR(((val) + ((typeof(val)) (align) - 1)), align)
	SPDK_ALIGN_FLOOR(((val) + ((__typeof__(val)) (align) - 1)), align)

uint32_t spdk_u32log2(uint32_t x);