-
Notifications
You must be signed in to change notification settings - Fork 362
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
linux and unix build support #37
base: dev/crossplatform
Are you sure you want to change the base?
linux and unix build support #37
Conversation
set(GGPO_LIB_SRC_NOFILTER | ||
${GGPO_LIB_SRC_NOFILTER} | ||
"lib/ggpo/platform_linux.h" | ||
"lib/ggpo/platform_linux.cpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
platform_linux.*
and platform_unix.*
are almost identical. We can probably just use platform_unix.*
on both MacOS and Linux (potentially with an #ifdef or two).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally agree.
#endif | ||
} // namespace neosmart | ||
|
||
#else //_WIN32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only include pevents.h
for Unix-like platforms so we could just delete everything in this else clause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the work! Most of these changes look good and can be pulled once some feedback has been addressed. There are two big issues which would prevent the pull:
- It looks like this will conflict with some of the
GGPO_EXPORT
work done in a different pull request. - I'd prefer writing POSIX native implementations in the Platform object to pulling in Win32 Events for POSIX.
#1 can be fixed by pulling a new version of ponder:dev/crossplatform
into your branch and resolving conflicts, I think. For #2, maybe it makes sense to revert those changes and re-submit the pull request. It won't actually compile, but it will get us closer and will avoid future conflicts as we move toward a cross platform world (specifically, the OSX people would be happy to get the other changes, I'm sure).
Thanks!
@@ -168,7 +168,7 @@ GDIRenderer::DrawConnectState(HDC hdc, Ship &ship, PlayerConnectionInfo &info, C | |||
|
|||
case Disconnecting: | |||
sprintf(status, "Waiting for player..."); | |||
progress = (timeGetTime() - info.disconnect_start) * 100 / info.disconnect_timeout; | |||
progress = (Platform::GetCurrentTimeMS() - info.disconnect_start) * 100 / info.disconnect_timeout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Platform
type is an internal implementation detail of the GGPO SDK. Ideally the sample code wouldn't use it (or even be able to include those dependencies)
@@ -8,6 +8,21 @@ | |||
#ifndef _GGPONET_H_ | |||
#define _GGPONET_H_ | |||
|
|||
#if defined(_MSC_VER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request did something similar which will conflict with a lot of these changes. Could you re-pull dev/crossplatform
into your fork and restage?
@@ -167,7 +167,9 @@ SyncTestBackend::RaiseSyncError(const char *fmt, ...) | |||
va_end(args); | |||
|
|||
puts(buf); | |||
#ifdef _WIN32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just delete this instead of the #ifdef
@@ -11,12 +11,18 @@ | |||
#include "backends/spectator.h" | |||
#include "ggponet.h" | |||
|
|||
#ifdef _WIN32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move these functions into the platform specific files instead (e.g. DllMain
goes into platform_windows.cpp
)?
@@ -83,7 +90,11 @@ Udp::OnLoopPoll(void *cookie) | |||
{ | |||
uint8 recv_buf[MAX_UDP_PACKET_SIZE]; | |||
sockaddr_in recv_addr; | |||
#ifdef _WIN32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the definition of socklen_t
is in WS2tcpip.h
. Let's just include that in platform_window.h
and remove these ifdefs.
@@ -296,8 +296,13 @@ UdpProtocol::HandlesMsg(sockaddr_in &from, | |||
if (!_udp) { | |||
return false; | |||
} | |||
#ifdef _WIN32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows has a #define s_addr S_un.S_addr
in WinSock2.h
, so I bet you can just use the else
version on all platforms.
|
||
return ((current.tv_sec - start.tv_sec) * 1000) + | ||
((current.tv_nsec - start.tv_nsec ) / 1000000) + | ||
uint32_t Platform::GetCurrentTimeMS() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's my understanding... GGPO will use this function to measure elapsed time (i.e. subtracting one time from another). gettimeofday
will return the time according to the system clock, which might get adjusted based on an update from an NTP time source between the two calls. This could make it appear as if an operation took a negative amount of time. See https://blog.habets.se/2010/09/gettimeofday-should-never-be-used-to-measure-time.html for more information. Thoughts?
set(GGPO_LIB_SRC_NOFILTER | ||
${GGPO_LIB_SRC_NOFILTER} | ||
"lib/ggpo/platform_linux.h" | ||
"lib/ggpo/platform_linux.cpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally agree.
@@ -0,0 +1,42 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you only need this to implement Poll
. IMO, it would be better to move the functionality of Poll
into Platform
and write a POSIX native implementation rather than mapping to the Win32 API.
|
||
#include "pevents.h" | ||
|
||
#define DebugBreak() (raise(SIGTRAP)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, none of the definitions from here to line 44 would be required, since they're specifically platform specific.
I admit I'm not usually this far into the weeds on open source projects, so I'm sure there's something obvious I'm missing trying to build this on Kubuntu right now, but my build is failing on strncat_s and sprintf_s calls, which appear to have been committed to the repo specifically to resolve compiler issues. The best answers I can find on Google are that these are Microsoft-oriented C++ extensions, but the commits also coincide with the multiplatform efforts timestamps on this project. Is there a step I'm missing to get this building properly on Linux? With other operating systems labeled as still "in progress", the wiki build instructions are a little light. |
What's the build process for this? |
Merges #17 and #21 to conform to the new cross-platform abstraction. Build succeeded on OSX and Ubuntu.