mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-19 18:00:23 +08:00
watcom.h: horrific hack to support OpenWatcom switch limitations
OpenWatcom still doesn't have proper support for 64-bit switch statements. Hack around it in a truly vile way. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
2902fbc1d8
commit
9b4b92b014
@ -69,5 +69,6 @@
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
#define STDC_HEADERS 1
|
||||
#define inline __inline
|
||||
|
||||
#endif /* NASM_CONFIG_WATCOM_H */
|
||||
|
@ -81,6 +81,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
@ -248,4 +249,20 @@ char *strsep(char **, const char *);
|
||||
# define pure_func
|
||||
#endif
|
||||
|
||||
/* Watcom doesn't handle switch statements with 64-bit types, hack around it */
|
||||
#ifdef __WATCOM__
|
||||
# define BOGUS_CASE 0x76543210
|
||||
|
||||
static inline unsigned int watcom_switch_hack(uint64_t x)
|
||||
{
|
||||
if (x > UINT_MAX)
|
||||
return BOGUS_CASE;
|
||||
else
|
||||
return (unsigned int)x;
|
||||
}
|
||||
|
||||
# define switch(x) switch(watcom_switch_hack(x))
|
||||
# define default case BOGUS_CASE: default
|
||||
#endif
|
||||
|
||||
#endif /* NASM_COMPILER_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user