From c8ef854f01f6be48f58fa787701f7811a4b9fbe7 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 6 Sep 2002 20:05:40 +0000 Subject: [PATCH] Fixes to allow MingW compilation. --- simgear/io/Makefile.am | 8 ++++---- simgear/io/tcp_client.cxx | 9 +++++++++ simgear/serial/Makefile.am | 4 ++-- simgear/threads/SGThread.cxx | 25 +++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/simgear/io/Makefile.am b/simgear/io/Makefile.am index c78df956..9cf9c3a2 100644 --- a/simgear/io/Makefile.am +++ b/simgear/io/Makefile.am @@ -38,7 +38,7 @@ tcp_server_LDADD = \ $(top_builddir)/simgear/bucket/libsgbucket.a \ $(top_builddir)/simgear/misc/libsgmisc.a \ $(top_builddir)/simgear/xml/libsgxml.a \ - -lplibnet -lz + -lplibnet -lplibul -lz $(NETWORK_LIB) tcp_client_SOURCES = tcp_client.cxx @@ -48,7 +48,7 @@ tcp_client_LDADD = \ $(top_builddir)/simgear/bucket/libsgbucket.a \ $(top_builddir)/simgear/misc/libsgmisc.a \ $(top_builddir)/simgear/xml/libsgxml.a \ - -lplibnet -lz + -lplibnet -lplibul -lz $(NETWORK_LIB) socktest_SOURCES = socktest.cxx @@ -58,7 +58,7 @@ socktest_LDADD = \ $(top_builddir)/simgear/debug/libsgdebug.a \ $(top_builddir)/simgear/misc/libsgmisc.a \ $(top_builddir)/simgear/xml/libsgxml.a \ - -lplibnet -lz + -lplibnet -lplibul -lz $(NETWORK_LIB) lowtest_SOURCES = lowtest.cxx @@ -73,4 +73,4 @@ decode_binobj_LDADD = \ $(top_builddir)/simgear/misc/libsgmisc.a \ $(top_builddir)/simgear/debug/libsgdebug.a \ $(top_builddir)/simgear/xml/libsgxml.a \ - $(NETWORK_LIB) -lz + -lz diff --git a/simgear/io/tcp_client.cxx b/simgear/io/tcp_client.cxx index 78548f53..a02e25d3 100644 --- a/simgear/io/tcp_client.cxx +++ b/simgear/io/tcp_client.cxx @@ -1,6 +1,11 @@ #include #include STL_IOSTREAM + +#ifdef _WIN32 +#include +#else #include +#endif #include @@ -72,7 +77,11 @@ main() for (int i = 0; i < 3; ++i) { client.process(); +#ifdef _WIN32 + Sleep(1000); +#else sleep(1); +#endif } //client.close(); diff --git a/simgear/serial/Makefile.am b/simgear/serial/Makefile.am index f39951ce..17af84e2 100644 --- a/simgear/serial/Makefile.am +++ b/simgear/serial/Makefile.am @@ -1,13 +1,13 @@ includedir = @includedir@/serial -noinst_PROGRAMS = testserial - lib_LIBRARIES = libsgserial.a include_HEADERS = serial.hxx libsgserial_a_SOURCES = serial.cxx +noinst_PROGRAMS = testserial + testserial_SOURCES = testserial.cxx testserial_LDADD = \ diff --git a/simgear/threads/SGThread.cxx b/simgear/threads/SGThread.cxx index 4119d7b4..6c5fe682 100644 --- a/simgear/threads/SGThread.cxx +++ b/simgear/threads/SGThread.cxx @@ -49,6 +49,31 @@ SGMutex::trylock() return true; } +#if defined(_MSC_VER) || defined(__MINGW32__) +int gettimeofday(struct timeval* tp, void* tzp) { + LARGE_INTEGER t; + + if(QueryPerformanceCounter(&t)) { + /* hardware supports a performance counter */ + LARGE_INTEGER f; + QueryPerformanceFrequency(&f); + tp->tv_sec = t.QuadPart/f.QuadPart; + tp->tv_usec = ((float)t.QuadPart/f.QuadPart*1000*1000) + - (tp->tv_sec*1000*1000); + } else { + /* hardware doesn't support a performance counter, so get the + time in a more traditional way. */ + DWORD t; + t = timeGetTime(); + tp->tv_sec = t / 1000; + tp->tv_usec = t % 1000; + } + + /* 0 indicates that the call succeeded. */ + return 0; +} +#endif + bool SGCondition::wait( SGMutex& mutex, unsigned long ms ) { -- 2.39.5