Skip to content
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

add support for MinGW32 compiler #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/common/gsplatformutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,11 @@ static void GenerateID(char* keyval)
LARGE_INTEGER l1;
UINT seed;
if (QueryPerformanceCounter(&l1))
#ifdef __MINGW32__
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't gate this change behind just mingw, it should work for msvc as well.

seed = (l1.u.LowPart ^ l1.u.HighPart);
#else
seed = (l1.LowPart ^ l1.HighPart);
#endif
else
seed = 0;
Util_RandSeed(seed ^ GetTickCount() ^ (unsigned long)time(NULL) ^ clock());
Expand Down
11 changes: 11 additions & 0 deletions src/gt2/gt2encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,24 @@ void gt2MemCopy(char* out, char const* in, int size)

#else

#ifdef __MINGW32__
#define GT_ENCODE_ELEM(TYPE, b, l, args) \
{ \
if (l < sizeof(TYPE)) \
return -1; \
TYPE temp = va_arg(*args, TYPE); \
Copy link
Contributor

Choose a reason for hiding this comment

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

Again no need to gate this behind mingw, but it would need fixing to C89 standards, so TYPE temp; needs to go at the top of the scope. A better fix is just to add || defined(__MINGW32__) next to the || defined(_X360) above IMO though as it seems MINGW should take the same path as the _UNIX define does.

gt2MemCopy(b, (const char*)&temp, sizeof(TYPE)); \
return sizeof(TYPE); \
}
#else
#define GT_ENCODE_ELEM(TYPE, b, l, args) \
{ \
if (l < sizeof(TYPE)) \
return -1; \
gt2MemCopy(b, (const char*)&va_arg(*args, TYPE), sizeof(TYPE)); \
return sizeof(TYPE); \
}
#endif
#define GT_DECODE_ELEM(TYPE, b, l, args) \
{ \
if (l < sizeof(TYPE)) \
Expand Down