From dbba1d7b1d8958e1229371b1cbc780f9ba277530 Mon Sep 17 00:00:00 2001 From: Lephe Date: Sat, 1 May 2021 18:30:51 +0200 Subject: [PATCH] defs: use auto instead of __auto_type in C++ --- include/gint/defs/util.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/include/gint/defs/util.h b/include/gint/defs/util.h index 648a613..8182ece 100644 --- a/include/gint/defs/util.h +++ b/include/gint/defs/util.h @@ -8,21 +8,27 @@ /* synco instruction (in a form compatible with sh3eb-elf) */ #define synco() __asm__ volatile (".word 0x00ab":::"memory") +#ifdef __cplusplus +#define GAUTOTYPE auto +#else +#define GAUTOTYPE __auto_type +#endif + /* min(), max() (without double evaluation) */ #define min(a, b) ({ \ - __auto_type _a = (a); \ - __auto_type _b = (b); \ + GAUTOTYPE _a = (a); \ + GAUTOTYPE _b = (b); \ _a < _b ? _a : _b; \ }) #define max(a, b) ({ \ - __auto_type _a = (a); \ - __auto_type _b = (b); \ + GAUTOTYPE _a = (a); \ + GAUTOTYPE _b = (b); \ _a > _b ? _a : _b; \ }) /* sgn() (without double evaluation) */ #define sgn(s) ({ \ - __auto_type _s = (s); \ + GAUTOTYPE _s = (s); \ _s < 0 ? -1 : \ _s > 0 ? +1 : \ 0; \ @@ -30,13 +36,13 @@ /* abs() (without double evaluation) */ #define abs(s) ({ \ - __auto_type _s = (s); \ + GAUTOTYPE _s = (s); \ _s < 0 ? -s : s; \ }) /* swap() - exchange two variables of the same type */ #define swap(a, b) ({ \ - __auto_type _tmp = (a); \ + GAUTOTYPE _tmp = (a); \ (a) = (b); \ (b) = _tmp; \ })