Fix compilation with Open Watcom

Open Watcom does not support 64-bit constants at 'case'.

[ hpa: I'm pulling this, but I'm really, *really* questioning its
supportability long term. The OpenWatcom people need to fix this, or
we are just going to have to say "OW is not supported."

At some point we *are* going to move to a "C99 is baseline" policy for
code; there are simply too many features in C99 that are actively
painful to be without.

That is, unless we decide to go to C++, which is under consideration
but is a much bigger job. In that case, the target will probably be
either C++11 or C++14 as those C++ versions contain some pretty
essential features. ]

Signed-off-by: KO Myung-Hun <komh78@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
KO Myung-Hun 2025-10-05 20:56:25 +09:00 committed by H. Peter Anvin (Intel)
parent 013db3d446
commit 29a5aabd7a
2 changed files with 64 additions and 0 deletions

View file

@ -3103,6 +3103,7 @@ static enum match_result matches(const struct itemplate * const itemp,
* If this is an *explicitly* sized immediate,
* allow it to match an extending pattern.
*/
#ifndef __WATCOMC__
switch (isize[i]) {
case BITS8:
if (ttype & BYTEEXTMASK) {
@ -3117,6 +3118,18 @@ static enum match_result matches(const struct itemplate * const itemp,
default:
break;
}
#else
/* Open Watcom does not support 64-bit constants at *case*. */
if (isize[i] == BITS8) {
if (ttype & BYTEEXTMASK) {
isize[i] = tsize[i];
itype[i] |= BYTEEXTMASK;
}
} else if (isize[i] == BITS32) {
if (ttype & DWORDEXTMASK)
isize[i] = tsize[i];
}
#endif
/*
* MOST instructions which take an sdword64 are the only form;

View file

@ -113,6 +113,7 @@ static enum reg_enum whichreg(opflags_t regflags, int regval, uint32_t rex)
*/
static enum reg_enum implicit_reg(opflags_t regflags)
{
#ifndef __WATCOMC__
switch (regflags) {
case REG_AL: return R_AL;
case REG_AX: return R_AX;
@ -139,6 +140,56 @@ static enum reg_enum implicit_reg(opflags_t regflags)
case OPMASK0: return R_K0;
default: return 0;
}
#else
/* Open Watcom does not support 64-bit constants at *case*. */
if (regflags == REG_AL)
return R_AL;
if (regflags == REG_AX)
return R_AX;
if (regflags == REG_EAX)
return R_EAX;
if (regflags == REG_RAX)
return R_RAX;
if (regflags == REG_DL)
return R_DL;
if (regflags == REG_DX)
return R_DX;
if (regflags == REG_EDX)
return R_EDX;
if (regflags == REG_RDX)
return R_RDX;
if (regflags == REG_CL)
return R_CL;
if (regflags == REG_CX)
return R_CX;
if (regflags == REG_ECX)
return R_ECX;
if (regflags == REG_RCX)
return R_RCX;
if (regflags == FPU0)
return R_ST0;
if (regflags == XMM0)
return R_XMM0;
if (regflags == YMM0)
return R_YMM0;
if (regflags == ZMM0)
return R_ZMM0;
if (regflags == REG_ES)
return R_ES;
if (regflags == REG_CS)
return R_CS;
if (regflags == REG_SS)
return R_SS;
if (regflags == REG_DS)
return R_DS;
if (regflags == REG_FS)
return R_FS;
if (regflags == REG_GS)
return R_GS;
if (regflags == OPMASK0)
return R_K0;
return 0;
#endif
}
/*