From: curt Date: Mon, 4 Feb 2002 22:38:23 +0000 (+0000) Subject: Various mingwin patches contributed by Norman Vine. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=15399bfe95b1b6e3f60371c514da5a42200de223;p=simgear.git Various mingwin patches contributed by Norman Vine. --- diff --git a/configure.in b/configure.in index 6627ca2f..e857a2fb 100644 --- a/configure.in +++ b/configure.in @@ -34,11 +34,6 @@ AC_PROG_RANLIB AC_PROG_INSTALL AC_PROG_LN_S -# Check to see if this `configure' is being run in the `Cygwin32' environment -AC_CYGWIN -AC_MINGW32 -AC_EXEEXT - AR="ar" OS=`uname -s` if test "$OS" = "IRIX" -o "$OS" = "IRIX64"; then @@ -102,19 +97,31 @@ AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$with_jpeg_factory" = "xyes") dnl Check for MS Windows environment AC_CHECK_HEADER(windows.h) -if test "x$HOSTTYPE" != "xmacintosh" ; then +AC_EGREP_CPP(yes, +[#ifdef __MINGW32__ + yes + #endif +],is_mingw=yes, is_mingw=no) + +echo "IS_MINGW = "$is_mingw +AM_CONDITIONAL(IS_MINGW, test $is_mingw="yes") + +AC_EGREP_CPP(yes, +[#ifdef __CYGWIN__ + yes + #endif +],is_cygwin=yes, is_cygwin=no) + +echo "IS_CYGWIN = "$is_cygwin +AM_CONDITIONAL(IS_CYGWIN, test $is_cygwin="yes") + +if test "x$HOSTTYPE" != "xmacintosh" -a "x$is_mingw" != "xyes"; then dnl extra library and include directories EXTRA_DIRS="/usr/local /usr/local/plib /usr/X11R6" if test -d /opt/X11R6 ; then EXTRA_DIRS="$EXTRA_DIRS /opt/X11R6" fi - - if test "x$ac_cv_header_windows_h" = "xyes" ; then - if test -d /usr/mingw/usr ; then - EXTRA_DIRS="$EXTRA_DIRS /usr/mingw/usr" - fi - fi fi wi_EXTRA_DIRS(no, ${EXTRA_DIRS}) @@ -141,10 +148,6 @@ null_LIBS="$LIBS" AC_CHECK_LIB(m, cos) -if test "x$ac_cv_mingw32" = "xyes" ; then - LIBS="$LIBS -lwsock32" -fi - base_LIBS="$LIBS" dnl Thread related checks @@ -240,8 +243,8 @@ else LIBS="$LIBS -l${WIN32_GLUT} -l${WIN32_GLU} -l${WIN32_OPENGL}" LIBS="$LIBS -luser32 -lgdi32" - if test "x$ac_cv_mingw32" = "xyes" ; then - LIBS="$LIBS -wsock32" + if test "x$is_mingw" = "xyes" ; then + EXTRA_DIRS="${EXTRA_DIRS}" fi echo "Will link apps with $LIBS" fi diff --git a/simgear/io/Makefile.am b/simgear/io/Makefile.am index c6af4897..599d17e0 100644 --- a/simgear/io/Makefile.am +++ b/simgear/io/Makefile.am @@ -26,6 +26,12 @@ else INCLUDES = -I$(top_srcdir) endif +if IS_MINGW +NETWORK_LIB = -lwsock32 +else +NETWORK_LIB = +endif + noinst_PROGRAMS = decode_binobj socktest lowtest socktest_SOURCES = socktest.cxx @@ -51,4 +57,4 @@ decode_binobj_LDADD = \ $(top_builddir)/simgear/misc/libsgmisc.a \ $(top_builddir)/simgear/debug/libsgdebug.a \ $(top_builddir)/simgear/xml/libsgxml.a \ - -lz + $(NETWORK_LIB) -lz diff --git a/simgear/io/socktest.cxx b/simgear/io/socktest.cxx index 38c38a6e..358c32e0 100644 --- a/simgear/io/socktest.cxx +++ b/simgear/io/socktest.cxx @@ -41,6 +41,10 @@ int main() { if ( s.readline( buf, 256 ) > 0 ) { cout << "result = " << buf; } +#ifdef __MINGW32__ + Sleep(100); +#else sleep(1); +#endif } } diff --git a/simgear/sg_inlines.h b/simgear/sg_inlines.h index 0fc86761..89a8b9b8 100644 --- a/simgear/sg_inlines.h +++ b/simgear/sg_inlines.h @@ -28,11 +28,13 @@ #ifndef _SG_INLINES_H #define _SG_INLINES_H +// return the sign of a value template inline const int SG_SIGN(const T x) { return x < T(0) ? -1 : 1; } +// return the minimum of two values template inline const T SG_MIN2(const T a, const T b) { return a < b ? a : b; @@ -44,6 +46,7 @@ inline const T SG_MIN3( const T a, const T b, const T c) { return (a < b ? SG_MIN2 (a, c) : SG_MIN2 (b, c)); } +// return the maximum of two values template inline const T SG_MAX2(const T a, const T b) { return a > b ? a : b; @@ -55,10 +58,47 @@ inline const T SG_MAX3 (const T a, const T b, const T c) { return (a > b ? SG_MAX2 (a, c) : SG_MAX2 (b, c)); } -// +// return the minimum and maximum of three values +template +inline void SG_MIN_MAX3 ( T &min, T &max, const T a, const T b, const T c) { + if( a > b ) { + if( a > c ) { + max = a; + min = SG_MIN2 (b, c); + } else { + max = c; + min = SG_MIN2 (a, b); + } + } else { + if( b > c ) { + max = b; + min = SG_MIN2 (a, c); + } else { + max = c; + min = SG_MIN2 (a, b); + } + } +} + +// swap two values template inline void SG_SWAP( T &a, T &b) { T c = a; a = b; b = c; } +// clamp a value to lie between min and max +template +inline void SG_CLAMP_RANGE(T &x, const T min, const T max ) { + if ( x < min ) { x = min; } + if ( x > max ) { x = max; } +} + +// normalize a value to lie between min and max +template +inline void SG_NORMALIZE_RANGE( T &val, const T min, const T max ) { + T step = max - min; + while( val >= max ) val -= step; + while( val < min ) val += step; +}; + #endif // _SG_INLINES_H diff --git a/simgear/timing/sg_time.cxx b/simgear/timing/sg_time.cxx index 698ae008..66ac4970 100644 --- a/simgear/timing/sg_time.cxx +++ b/simgear/timing/sg_time.cxx @@ -363,14 +363,11 @@ double sgTimeCurrentMJD( long int warp ) { #if defined(_MSC_VER) || defined(__MINGW32__) struct tm m_gmt; // copy of system gmtime(&time_t) structure + struct tm *gmt = &m_gmt; #else struct tm *gmt; #endif -#if defined(_MSC_VER) || defined(__MINGW32__) - tm * gmt = &m_gmt; -#endif - // get current Unix calendar time (in seconds) // warp += warp_delta; time_t cur_time = time(NULL) + warp;