From a95cabb3ad6480db975fb7741b2a8552af307268 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 4 May 2023 10:32:58 -0400 Subject: [PATCH] Introduce rseq_scalar_type_to_expr to eliminate code duplication Signed-off-by: Mathieu Desnoyers Change-Id: I6fd0aa556b4f486db5d5fb86fd78e3cb1ff9c35b --- include/rseq/compiler.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/rseq/compiler.h b/include/rseq/compiler.h index 1d86a99..6b89bfa 100644 --- a/include/rseq/compiler.h +++ b/include/rseq/compiler.h @@ -49,6 +49,11 @@ #define rseq_unqual_scalar_typeof(x) \ std::remove_cv::type>::type #else + +#define rseq_scalar_type_to_expr(type) \ + unsigned type: (unsigned type)0, \ + signed type: (signed type)0 + /* * Use C11 _Generic to express unqualified type from expression. This removes * volatile qualifier from expression type. @@ -57,16 +62,11 @@ __typeof__( \ _Generic((x), \ char: (char)0, \ - unsigned char: (unsigned char)0, \ - signed char: (signed char)0, \ - unsigned short: (unsigned short)0, \ - signed short: (signed short)0, \ - unsigned int: (unsigned int)0, \ - signed int: (signed int)0, \ - unsigned long: (unsigned long)0, \ - signed long: (signed long)0, \ - unsigned long long: (unsigned long long)0, \ - signed long long: (signed long long)0, \ + rseq_scalar_type_to_expr(char), \ + rseq_scalar_type_to_expr(short), \ + rseq_scalar_type_to_expr(int), \ + rseq_scalar_type_to_expr(long), \ + rseq_scalar_type_to_expr(long long), \ default: (x) \ ) \ ) -- 2.34.1