Skip to content

libc: Add some Microsoft FPU control and status extensions #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JayFoxRox
Copy link
Owner

Depends on nxdk-pdclib PR 29.

Code was stolen from mingw, wine and some other projects. I don't think this is algorithmic enough to qualify for copyright. I also made a number of changes to formatting and removed SSE2 portions to make the code more concise.

The code was never tested.


unsigned int _control87(unsigned int new, unsigned int mask);
unsigned int _controlfp(unsigned int new, unsigned int mask);
int __control87_2(unsigned int new, unsigned int mask, unsigned int* x86_cw, unsigned int* sse2_cw);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of new trips my syntax highlighter. I worry that C++ might be problematic.


unsigned int _status87(void);
unsigned int _statusfp(void);
void _statusfp2(unsigned int *px86, unsigned int *pSSE2);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument style of this differs from the other functions (but I believe all of this came from MSDN).

if (flags & _EM_UNDERFLOW) fpword |= 0x10;
if (flags & _EM_INEXACT) fpword |= 0x20;

switch (flags & _MCW_RC) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These deserve some comment

#define _SW_OVERFLOW 0x00000004
#define _SW_ZERODIVIDE 0x00000008
#define _SW_INVALID 0x00000010
#define _SW_DENORMAL 0x00080000
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wine uses these, but they don't seem to be from MS. But I was unable to find a MS FLOAT.H to verify.

We could also use _EM_*, but I felt it was ugly to assume that cw and sw used the same layout (even though they mostly do).

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @thrimbor, master of Microsoft / mingw header files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant