defs: use auto instead of __auto_type in C++

This commit is contained in:
Lephe 2021-05-01 18:30:51 +02:00
parent 78bf9dac7d
commit dbba1d7b1d
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 13 additions and 7 deletions

View File

@ -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; \
})