Skip to content

Commit 1b23663

Browse files
authored
Merge 6f1fdbb into 128b467
2 parents 128b467 + 6f1fdbb commit 1b23663

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

platforms/Cross/plugins/IA32ABI/x64win64abicc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ extern
3838
#endif
3939
struct VirtualMachine* interpreterProxy;
4040

41+
#ifdef _MSC_VER
42+
# define alloca _alloca
43+
#endif
4144
#if __GNUC__
4245
# define setsp(sp) __asm__ volatile ("movq %0,%%rsp" : : "m"(sp))
4346
# define getsp() ({ void *sp; __asm__ volatile ("movq %%rsp,%0" : "=r"(sp) : ); sp;})

platforms/minheadless/windows/sqPlatformSpecific-Win32.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,19 @@
4848

4949
# define fopen_for_append(filename) fopen(filename,"a+t")
5050

51-
/* default fpu control word:
52-
_RC_NEAR: round to nearest
53-
_PC_53 : double precision arithmetic (instead of extended)
54-
_EM_XXX: silent operations (no signals please)
51+
/* default fpu control word:
52+
_MCW_RC: Rounding control
53+
_RC_NEAR: round to nearest
54+
_MCW_PC: Precision control
55+
_PC_53: double precision arithmetic (instead of extended)
56+
_MCW_EM: Interupt exception mask
57+
_EM_XXX: silent operations (no signals please)
58+
https://docs.microsoft.com/en-us/previous-versions/e9b52ceh%28v%3dvs.140%29
5559
*/
60+
#if !defined(_MCW_PC) // x64 does not support _MCW_PC
61+
# define _MCW_PC 0
62+
#endif
63+
#define FPU_MASK (_MCW_EM | _MCW_RC | _MCW_PC)
5664
#define FPU_DEFAULT (_RC_NEAR + _PC_53 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT + _EM_DENORMAL)
5765

5866
#define MAXFRAMES 64
@@ -116,7 +124,7 @@ void
116124
ioInitPlatformSpecific(void)
117125
{
118126
/* Setup the FPU */
119-
_controlfp(FPU_DEFAULT, _MCW_EM | _MCW_RC | _MCW_PC | _MCW_IC);
127+
_controlfp(FPU_DEFAULT, FPU_MASK);
120128

121129
/* Create the wake up event. */
122130
vmWakeUpEvent = CreateEvent(NULL, 1, 0, NULL);
@@ -363,8 +371,9 @@ static LONG CALLBACK squeakExceptionHandler(LPEXCEPTION_POINTERS exp)
363371
DWORD code = exp->ExceptionRecord->ExceptionCode;
364372
if((code >= EXCEPTION_FLT_DENORMAL_OPERAND) && (code <= EXCEPTION_FLT_UNDERFLOW))
365373
{
366-
/* turn on the default masking of exceptions in the FPU and proceed */
367-
_controlfp(FPU_DEFAULT, _MCW_EM | _MCW_RC | _MCW_PC | _MCW_IC);
374+
/* in case FFI callout to foreign code changed FP mode */
375+
/* restore our default masking of exceptions in the FPU and proceed */
376+
_controlfp(FPU_DEFAULT, FP_MASK);
368377
result = EXCEPTION_CONTINUE_EXECUTION;
369378
}
370379
}
@@ -799,3 +808,4 @@ void *os_exports[][3] =
799808
{
800809
{ 0, 0, 0 }
801810
};
811+

platforms/minheadless/windows/sqPlatformSpecific-Win32.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ size_t sqImageFileWrite(const void *ptr, size_t sz, size_t count, sqImageFile h)
114114
error "Not Win32!"
115115
#endif /* WIN32 */
116116

117-
int ioSetCursorARGB(sqInt bitsIndex, sqInt w, sqInt h, sqInt x, sqInt y);
117+
sqInt ioSetCursorARGB(sqInt bitsIndex, sqInt w, sqInt h, sqInt x, sqInt y);
118118

119119
/* poll and profile thread priorities. The stack vm uses a thread to cause the
120120
* VM to poll for I/O, check for delay expiry et al at regular intervals. Both
@@ -185,4 +185,4 @@ extern const unsigned long tltiIndex;
185185
#define TRY
186186
#define EXCEPT(filter) if (0)
187187
#define FINALLY
188-
#endif
188+
#endif

0 commit comments

Comments
 (0)