0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-09-22 10:43:39 -04:00

compiler.h: only use watcom_switch_hack() if necessary

Use sizeof() to prevent the compiler from invoking
watcom_switch_hack() unnecessarily.  Hopefully the optimizer would be
smart enough to recognize this inherently, but this is an old compiler
we are dealing with, so make life a little easier for it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin
2017-02-23 17:22:58 -08:00
parent 4d32674144
commit e3cd70bc46

View File

@@ -261,7 +261,7 @@ static inline unsigned int watcom_switch_hack(uint64_t x)
return (unsigned int)x;
}
# define switch(x) switch(watcom_switch_hack(x))
# define switch(x) switch(sizeof(x) > sizeof(unsigned int) ? watcom_switch_hack(x) : (x))
# define default case BOGUS_CASE: default
#endif