On Sun, 2 Dec 2018 at 03:01, Eliot Miranda <notifications@github.com> wrote:
>
>  
>
> Hi Ben,
>
> platforms/minheadless/windows/sqPlatformSpecific-Win32.c still has to cover both x64 and x86 so IMO the right way to write this:
>
> /* Setup the FPU */
> // x64 does not support _MCW_PC or _MCW_IC (https://msdn.microsoft.com/en-us/library/e9b52ceh.aspx)
>  _controlfp(FPU_DEFAULT, _MCW_EM | _MCW_RC );
>
> is
>
> /* Setup the FPU */
> // x64 does not support _MCW_PC or _MCW_IC (https://msdn.microsoft.com/en-us/library/e9b52ceh.aspx)
>
> #if !defined(_MCW_PC)
> #define _MCW_PC 0
> #endif

> #if !defined(_MCW_IC)
> #define _MCW_IC 0
> #endif
>
> _controlfp(FPU_DEFAULT, _MCW_EM | _MCW_RC | _MCW_PC | _MCW_IC);

Good point. I didn't consider that.
But given that _controlfp is called from two locations, I'm not sure where to put the defines.
* up the top of the c-file
* close to the first call for definition/use locality
* factor both calls out to a function

Also is there any concern about that the possibility of different behaviour between 32-bit and 64-bit?
I would guess not, but just asking.

Then I got curious what those defs actually were...
[1] https://docs.microsoft.com/en-us/previous-versions/c9676k6h(v=vs.140)
[2] https://www.intel.com/content/dam/support/us/en/documents/processors/pentium4/sb/25366521.pdf

_MCW_IC 
Infinity control [1]     
"8.1.6 Infinity Control Flag [2]  The infinity control flag (bit 12 of the x87 FPU control word) is provided for compatibility with the Intel 287 Math Coprocessor; 
it is not meaningful for later version x87 FPU coprocessors or IA-32 processors." 

So it seems redundant, or maybe I will learn something new today.
Do we expect any modern supported machine to be using a 287 Coprocessor?


_MCW_PC 
Precision control [1]    
"8.1.5.2 Precision Control Field  [2] The precision-control (PC) field (bits 8 and 9 of the x87 FPU control word) determines the precision (64, 53, or 24 bits) of floating-point 
calculations made by the x87 FPU (see Table 8-2). The ##>>default precision is double extended precision<<##, which uses the full 64-bit significand available with the double 
extended-precision floating-point format of the x87 FPU data registers. This setting is best suited for most applications, because it allows applications to take full advantage 
of the maximum precision available with the x87 FPU data registers."

So do we ever change the FPU away from the default to 53bits or 24bits?
If not, then it seems redundant.  
The code example of [1] shows how  _MCW_PC and _PC_24  are used to change the FPU precision and back.

cheers -ben