Skip to content

Commit 29a5aab

Browse files
komhH. Peter Anvin (Intel)
authored andcommitted
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>
1 parent 013db3d commit 29a5aab

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

asm/assemble.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,6 +3103,7 @@ static enum match_result matches(const struct itemplate * const itemp,
31033103
* If this is an *explicitly* sized immediate,
31043104
* allow it to match an extending pattern.
31053105
*/
3106+
#ifndef __WATCOMC__
31063107
switch (isize[i]) {
31073108
case BITS8:
31083109
if (ttype & BYTEEXTMASK) {
@@ -3117,6 +3118,18 @@ static enum match_result matches(const struct itemplate * const itemp,
31173118
default:
31183119
break;
31193120
}
3121+
#else
3122+
/* Open Watcom does not support 64-bit constants at *case*. */
3123+
if (isize[i] == BITS8) {
3124+
if (ttype & BYTEEXTMASK) {
3125+
isize[i] = tsize[i];
3126+
itype[i] |= BYTEEXTMASK;
3127+
}
3128+
} else if (isize[i] == BITS32) {
3129+
if (ttype & DWORDEXTMASK)
3130+
isize[i] = tsize[i];
3131+
}
3132+
#endif
31203133

31213134
/*
31223135
* MOST instructions which take an sdword64 are the only form;

disasm/disasm.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static enum reg_enum whichreg(opflags_t regflags, int regval, uint32_t rex)
113113
*/
114114
static enum reg_enum implicit_reg(opflags_t regflags)
115115
{
116+
#ifndef __WATCOMC__
116117
switch (regflags) {
117118
case REG_AL: return R_AL;
118119
case REG_AX: return R_AX;
@@ -139,6 +140,56 @@ static enum reg_enum implicit_reg(opflags_t regflags)
139140
case OPMASK0: return R_K0;
140141
default: return 0;
141142
}
143+
#else
144+
/* Open Watcom does not support 64-bit constants at *case*. */
145+
if (regflags == REG_AL)
146+
return R_AL;
147+
if (regflags == REG_AX)
148+
return R_AX;
149+
if (regflags == REG_EAX)
150+
return R_EAX;
151+
if (regflags == REG_RAX)
152+
return R_RAX;
153+
if (regflags == REG_DL)
154+
return R_DL;
155+
if (regflags == REG_DX)
156+
return R_DX;
157+
if (regflags == REG_EDX)
158+
return R_EDX;
159+
if (regflags == REG_RDX)
160+
return R_RDX;
161+
if (regflags == REG_CL)
162+
return R_CL;
163+
if (regflags == REG_CX)
164+
return R_CX;
165+
if (regflags == REG_ECX)
166+
return R_ECX;
167+
if (regflags == REG_RCX)
168+
return R_RCX;
169+
if (regflags == FPU0)
170+
return R_ST0;
171+
if (regflags == XMM0)
172+
return R_XMM0;
173+
if (regflags == YMM0)
174+
return R_YMM0;
175+
if (regflags == ZMM0)
176+
return R_ZMM0;
177+
if (regflags == REG_ES)
178+
return R_ES;
179+
if (regflags == REG_CS)
180+
return R_CS;
181+
if (regflags == REG_SS)
182+
return R_SS;
183+
if (regflags == REG_DS)
184+
return R_DS;
185+
if (regflags == REG_FS)
186+
return R_FS;
187+
if (regflags == REG_GS)
188+
return R_GS;
189+
if (regflags == OPMASK0)
190+
return R_K0;
191+
return 0;
192+
#endif
142193
}
143194

144195
/*

0 commit comments

Comments
 (0)