mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-01-01 06:23:35 +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) */
|
/* synco instruction (in a form compatible with sh3eb-elf) */
|
||||||
#define synco() __asm__ volatile (".word 0x00ab":::"memory")
|
#define synco() __asm__ volatile (".word 0x00ab":::"memory")
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define GAUTOTYPE auto
|
||||||
|
#else
|
||||||
|
#define GAUTOTYPE __auto_type
|
||||||
|
#endif
|
||||||
|
|
||||||
/* min(), max() (without double evaluation) */
|
/* min(), max() (without double evaluation) */
|
||||||
#define min(a, b) ({ \
|
#define min(a, b) ({ \
|
||||||
__auto_type _a = (a); \
|
GAUTOTYPE _a = (a); \
|
||||||
__auto_type _b = (b); \
|
GAUTOTYPE _b = (b); \
|
||||||
_a < _b ? _a : _b; \
|
_a < _b ? _a : _b; \
|
||||||
})
|
})
|
||||||
#define max(a, b) ({ \
|
#define max(a, b) ({ \
|
||||||
__auto_type _a = (a); \
|
GAUTOTYPE _a = (a); \
|
||||||
__auto_type _b = (b); \
|
GAUTOTYPE _b = (b); \
|
||||||
_a > _b ? _a : _b; \
|
_a > _b ? _a : _b; \
|
||||||
})
|
})
|
||||||
|
|
||||||
/* sgn() (without double evaluation) */
|
/* sgn() (without double evaluation) */
|
||||||
#define sgn(s) ({ \
|
#define sgn(s) ({ \
|
||||||
__auto_type _s = (s); \
|
GAUTOTYPE _s = (s); \
|
||||||
_s < 0 ? -1 : \
|
_s < 0 ? -1 : \
|
||||||
_s > 0 ? +1 : \
|
_s > 0 ? +1 : \
|
||||||
0; \
|
0; \
|
||||||
|
@ -30,13 +36,13 @@
|
||||||
|
|
||||||
/* abs() (without double evaluation) */
|
/* abs() (without double evaluation) */
|
||||||
#define abs(s) ({ \
|
#define abs(s) ({ \
|
||||||
__auto_type _s = (s); \
|
GAUTOTYPE _s = (s); \
|
||||||
_s < 0 ? -s : s; \
|
_s < 0 ? -s : s; \
|
||||||
})
|
})
|
||||||
|
|
||||||
/* swap() - exchange two variables of the same type */
|
/* swap() - exchange two variables of the same type */
|
||||||
#define swap(a, b) ({ \
|
#define swap(a, b) ({ \
|
||||||
__auto_type _tmp = (a); \
|
GAUTOTYPE _tmp = (a); \
|
||||||
(a) = (b); \
|
(a) = (b); \
|
||||||
(b) = _tmp; \
|
(b) = _tmp; \
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue