mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2024-12-29 13:03:36 +01:00
defs: use auto instead of __auto_type in C++
This commit is contained in:
parent
78bf9dac7d
commit
dbba1d7b1d
1 changed files with 13 additions and 7 deletions
|
@ -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; \
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue