]> git.mxchange.org Git - simgear.git/commitdiff
Add platform defines to SimGear, and a replacement for ulSleep functions.
authorJames Turner <zakalawe@mac.com>
Sat, 30 Oct 2010 18:18:57 +0000 (19:18 +0100)
committerJames Turner <zakalawe@mac.com>
Sat, 30 Oct 2010 18:18:57 +0000 (19:18 +0100)
projects/VC90/SimGear.vcproj
simgear/compiler.h
simgear/misc/Makefile.am
simgear/misc/sg_sleep.cxx [new file with mode: 0644]
simgear/misc/sg_sleep.hxx [new file with mode: 0644]

index fca9e9938a5701b7577e07ac8f173547523250dd..2db0dcc547d43220d2a8c9399333be710cc5a3a3 100644 (file)
                                RelativePath="..\..\simgear\misc\sg_dir.hxx"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\simgear\misc\sg_sleep.cxx"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\simgear\misc\sg_sleep.hxx"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\simgear\misc\sg_path.cxx"\r
                                >\r
index 6a9ec5d84587f6ada8228eabfb6b6db83cf1e5ba..372f571d9d7dd1fa5e0fb4a15d87bf2d2fef8cee 100644 (file)
 
 
 #if defined (__sun)
+#  define SG_UNIX
 #  include <strings.h>
 #  include <memory.h>
 #  if defined ( __cplusplus )
 //
 
 #ifdef __APPLE__
+#  define SG_MAC
+#  define SG_UNIX
 #  ifdef __GNUC__
 #    if ( __GNUC__ > 3 ) || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 3 )
 inline int (isnan)(double r) { return !(r <= 0 || r >= 0); }
@@ -154,6 +157,7 @@ inline int (isnan)(double r) { return !(r <= 0 || r >= 0); }
 #endif
 
 #if defined (__FreeBSD__)
+#  define SG_UNIX
 #include <sys/param.h>
 #  if __FreeBSD_version < 500000
      extern "C" {
@@ -163,9 +167,19 @@ inline int (isnan)(double r) { return !(r <= 0 || r >= 0); }
 #endif
 
 #if defined (__CYGWIN__)
+#  define SG_WINDOWS
+#  define SG_UNIX
 #  include <ieeefp.h>          // isnan
 #endif
 
+// includes both MSVC and mingw compilers
+#if defined(_WIN32) || defined(__WIN32__)
+#  define SG_WINDOWS
+#endif
+
+#if defined(__linux__) || defined(_AIX) || defined ( sgi )
+#  define SG_UNIX
+#endif
 
 //
 // No user modifiable definitions beyond here.
index 4a4b1fb607c7b429e422386d9ea94f2add7e6a1a..ae696e797011e28f4f35a706392a478d0b1cc864 100644 (file)
@@ -14,7 +14,8 @@ include_HEADERS = \
        stdint.hxx \
        PathOptions.hxx \
        sg_dir.hxx \
-       ResourceManager.hxx 
+       ResourceManager.hxx \
+       sg_sleep.hxx
 
 libsgmisc_a_SOURCES = \
        sg_path.cxx \
@@ -26,7 +27,8 @@ libsgmisc_a_SOURCES = \
        interpolator.cxx \
        PathOptions.cxx \
        sg_dir.cxx \
-       ResourceManager.cxx 
+       ResourceManager.cxx \
+       sg_sleep.cxx
 
 #noinst_PROGRAMS = tabbed_value_test swap_test
 
diff --git a/simgear/misc/sg_sleep.cxx b/simgear/misc/sg_sleep.cxx
new file mode 100644 (file)
index 0000000..a52880c
--- /dev/null
@@ -0,0 +1,60 @@
+
+// Written by James Turner, started July 2010.
+//
+// Copyright (C) 2010  Curtis L. Olson - http://www.flightgear.org/~curt
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+// $Id$
+
+#include <simgear/misc/sg_sleep.hxx>
+
+#ifdef SG_WINDOWS
+# include <windows.h>
+#else
+# include <unistd.h>
+#endif
+
+namespace simgear
+{
+
+#ifdef SG_WINDOWS
+
+void sleepForSeconds(int seconds)
+{
+  Sleep(1000 * seconds);
+}
+
+void sleepForMSec(int msec)
+{
+  Sleep(msec);
+}
+
+#else
+
+void sleepForSeconds(int seconds)
+{
+  ::sleep(seconds);
+}
+
+void sleepForMSec(int msec)
+{
+  ::usleep(msec * 1000);
+}
+
+#endif
+
+} // of namespace simhear
+
diff --git a/simgear/misc/sg_sleep.hxx b/simgear/misc/sg_sleep.hxx
new file mode 100644 (file)
index 0000000..389fdff
--- /dev/null
@@ -0,0 +1,41 @@
+
+// Written by James Turner, started July 2010.
+//
+// Copyright (C) 2010  Curtis L. Olson - http://www.flightgear.org/~curt
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//
+// $Id$
+
+
+#ifndef _SG_SLEEP_HXX
+#define _SG_SLEEP_HXX
+
+
+#include <simgear/compiler.h>
+
+
+namespace simgear
+{
+
+void sleepForSeconds(int seconds);
+
+void sleepForMSec(int msec);
+
+} // of namespace simgear
+
+#endif // _SG_SLEEP_HXX
+
+