]> git.mxchange.org Git - flightgear.git/commitdiff
Build only static libraries.
authorcurt <curt>
Fri, 12 Jun 1998 00:59:52 +0000 (00:59 +0000)
committercurt <curt>
Fri, 12 Jun 1998 00:59:52 +0000 (00:59 +0000)
Declare memmove/memset for Sloaris.
Rewrote fg_time.c routine to get LST start seconds to better handle
  Solaris, and be easier to port, and understand the GMT vs. local
  timezone issues.

Time/Makefile.am
Time/event.cxx
Time/event.hxx
Time/fg_time.cxx

index 50a761c58b4a661116cb246cacac6d95198398c5..a74e3874b2815797fb405793294c5041d2f52055 100644 (file)
@@ -6,11 +6,9 @@ if HAVE_TIMEZONE
 DEFS += -DHAVE_TIMEZONE
 endif
 
-libdir = ${exec_prefix}/lib
+noinst_LIBRARIES = libTime.a
 
-lib_LTLIBRARIES = libTime.la
-
-libTime_la_SOURCES = \
+libTime_a_SOURCES = \
        event.cxx event.hxx \
        fg_time.cxx fg_time.hxx \
        fg_timer.cxx fg_timer.hxx \
index 2dfaae93657733ae8351137e6bf5d65a409edd7c..51af1d0797ae1c4166908286a67c59cbe60ee997 100644 (file)
 #include "event.hxx"
 
 
-#ifdef __sun__
-extern "C" {
-  extern void *memmove(void *, const void *, size_t);
-}
-#endif
-
-
 fgEVENT_MGR global_events;
 
 
@@ -242,6 +235,13 @@ void fgEventPrintStats( void ) {
 
 
 // $Log$
+// Revision 1.5  1998/06/12 00:59:52  curt
+// Build only static libraries.
+// Declare memmove/memset for Sloaris.
+// Rewrote fg_time.c routine to get LST start seconds to better handle
+//   Solaris, and be easier to port, and understand the GMT vs. local
+//   timezone issues.
+//
 // Revision 1.4  1998/06/05 18:18:12  curt
 // Incorporated some automake conditionals to try to support mktime() correctly
 // on a wider variety of platforms.
index 198fe58a5a937a22eedce65d301365b4059421b6..0f10d78a64eed952a6fa97af48314717a94e2a97 100644 (file)
 #endif                                   
 
 
+#ifdef __sun__
+extern "C" void *memmove(void *, const void *, size_t);
+extern "C" void *memset(void *, int, size_t);
+#endif
+
+
 #include <deque>        // STL double ended queue
 #include <list>         // STL list
 
@@ -115,6 +121,13 @@ extern fgEVENT_MGR global_events;
 
 
 // $Log$
+// Revision 1.4  1998/06/12 00:59:52  curt
+// Build only static libraries.
+// Declare memmove/memset for Sloaris.
+// Rewrote fg_time.c routine to get LST start seconds to better handle
+//   Solaris, and be easier to port, and understand the GMT vs. local
+//   timezone issues.
+//
 // Revision 1.3  1998/06/03 00:48:12  curt
 // No .h for STL includes.
 //
index 9c0510df17685c14b753bee16fef1c532fc8e298..aa40066247bcda9fdd4f86c7ce69400c56c6e072 100644 (file)
@@ -53,6 +53,9 @@
 #define DEGHR(x)        ((x)/15.)
 #define RADHR(x)        DEGHR(x*RAD_TO_DEG)
 
+// #define MK_TIME_IS_GMT 0         // default value
+// #define TIME_ZONE_OFFSET_WORK 0  // default value
+
 
 fgTIME cur_time_params;
 
@@ -210,108 +213,112 @@ double sidereal_precise (double mjd, double lng) {
 }
 
 
-// return a courser but cheaper estimate of sidereal time
-double sidereal_course(struct tm *gmt, time_t now, double lng) {
-    time_t start, start_gmt;
-    struct tm mt;
-    long int offset;
-    double diff, part, days, hours, lst;
-
-    // I believe the mktime() has a SYSV vs. BSD behavior difference.
+// Fix up timezone if using ftime()
+long int fix_up_timezone( long int timezone_orig ) {
+#if !defined( HAVE_GETTIMEOFDAY ) && defined( HAVE_FTIME )
+    // ftime() needs a little extra help finding the current timezone
+    struct timeb current;
+    ftime(&current);
+    return( current.timezone * 60 );
+#else
+    return( timezone_orig );
+#endif
+}
 
-    // The BSD style mktime() is nice because it returns its result
-    // assuming you have specified the input time in GMT
 
-    // The SYSV style mktime() is a pain because it returns its result
-    // assuming you have specified the input time in your local
-    // timezone.  Therefore you have to go to extra trouble to convert
-    // back to GMT.
+// Return time_t for Sat Mar 21 12:00:00 GMT
+//
+// I believe the mktime() has a SYSV vs. BSD behavior difference.
+//
+// The BSD style mktime() is nice because it returns its result
+// assuming you have specified the input time in GMT
+//
+// The SYSV style mktime() is a pain because it returns its result
+// assuming you have specified the input time in your local timezone.
+// Therefore you have to go to extra trouble to convert back to GMT.
+//
+// If you are having problems with incorrectly positioned astronomical
+// bodies, this is a really good place to start looking.
 
-    // If you are having problems with incorrectly positioned
-    // astronomical bodies, this is a really good place to start
-    // looking.
+time_t get_start_gmt(int year) {
+    struct tm mt;
 
-#if !defined(HAVE_DAYLIGHT)
     // For now we assume that if daylight is not defined in
     // /usr/include/time.h that we have a machine with a BSD behaving
     // mktime()
-    int mktime_is_gmt = 1;
-
-    // only used for systems with SYSV style mktime() to compensate
-    // for mktime() assuming local timezone but we need to define this
-    // to keep the compiler happy
-    int daylight;
-#else
-    int mktime_is_gmt = 0;
-#endif
+#   if !defined(HAVE_DAYLIGHT)
+#       define MK_TIME_IS_GMT 1
+#   endif
 
-#if !defined(HAVE_TIMEZONE)
-    // only used for systems with SYSV style mktime() to compensate
-    // for mktime() assuming local timezone but we need to define this
-    // to keep the compiler happy
-    long int timezone;
-#endif
-
-    // ftime() needs a little extra help finding the current timezone
-#if defined( HAVE_GETTIMEOFDAY )
-#elif defined( HAVE_FTIME )
-    struct timeb current;
-#else
-# error Port me
-#endif
-
-    fgPrintf(FG_EVENT, FG_DEBUG, 
-            "  COURSE: GMT = %d/%d/%2d %d:%02d:%02d\n", 
-            gmt->tm_mon, gmt->tm_mday, gmt->tm_year,
-            gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
+    // timezone seems to work as a proper offset for Linux & Solaris
+#   if defined( __linux__ ) || defined( __sun__ ) 
+#       define TIMEZONE_OFFSET_WORKS 1
+#   endif
 
     mt.tm_mon = 2;
     mt.tm_mday = 21;
-    mt.tm_year = gmt->tm_year;
+    mt.tm_year = year;
     mt.tm_hour = 12;
     mt.tm_min = 0;
     mt.tm_sec = 0;
     mt.tm_isdst = -1; // let the system determine the proper time zone
 
-    if ( mktime_is_gmt ) {
-       start_gmt = mktime(&mt);
-    } else {
-       start = mktime(&mt);
-       daylight = mt.tm_isdst;
+#   if defined( MK_TIME_IS_GMT )
+    return ( mktime(&mt) );
+#   else // ! defined ( MK_TIME_IS_GMT )
 
-       fgPrintf( FG_EVENT, FG_DEBUG, "start1 = %ld\n", start);
-       fgPrintf( FG_EVENT, FG_DEBUG, "start2 = %s (tm_isdst = %d)", 
-                 ctime(&start), mt.tm_isdst);
+    long int start = mktime(&mt);
 
-       // ftime() needs a little extra help finding the current timezone
-#if defined( HAVE_GETTIMEOFDAY )
-#elif defined( HAVE_FTIME )
-       ftime(&current);
-       timezone = current.timezone * 60;
-#else
-# error Port me
-#endif
+    fgPrintf( FG_EVENT, FG_DEBUG, "start1 = %ld\n", start);
+    fgPrintf( FG_EVENT, FG_DEBUG, "start2 = %s", ctime(&start));
+    fgPrintf( FG_EVENT, FG_DEBUG, "(tm_isdst = %d)\n", mt.tm_isdst);
+
+    timezone = fix_up_timezone( timezone );
+
+#   if defined( TIMEZONE_OFFSET_WORKS )
+    fgPrintf( FG_EVENT, FG_DEBUG, 
+             "start = %ld, timezone = %ld\n", start, timezone );
+    return( start - timezone );
+#   else // ! defined( TIMEZONE_OFFSET_WORKS )
+
+    daylight = mt.tm_isdst;
+    if ( daylight > 0 ) {
+       daylight = 1;
+    } else if ( daylight < 0 ) {
+       fgPrintf( FG_EVENT, FG_WARN, 
+                 "OOOPS, problem in fg_time.cxx, no daylight savings info.\n");
+    }
+
+    long int offset = -(timezone / 3600 - daylight);
+
+    fgPrintf( FG_EVENT, FG_DEBUG,
+             "  Raw time zone offset = %ld\n", timezone);
+    fgPrintf( FG_EVENT, FG_DEBUG,
+             "  Daylight Savings = %d\n", daylight);
+    fgPrintf( FG_EVENT, FG_DEBUG,
+             "  Local hours from GMT = %ld\n", offset);
+    
+    long int start_gmt = start - timezone + (daylight * 3600);
+    
+    fgPrintf( FG_EVENT, FG_DEBUG, "  March 21 noon (CST) = %ld\n", start);
 
-       if ( daylight > 0 ) {
-           daylight = 1;
-       } else if ( daylight < 0 ) {
-           fgPrintf( FG_EVENT, FG_WARN, 
-                     "OOOPS, big time problem in fg_time.c, no daylight savings info.\n");
-       }
+    return ( start_gmt );
+#   endif // ! defined( TIMEZONE_OFFSET_WORKS )
+#   endif // ! defined ( MK_TIME_IS_GMT )
+}
 
-       offset = -(timezone / 3600 - daylight);
 
-       fgPrintf( FG_EVENT, FG_DEBUG,
-                 "  Raw time zone offset = %ld\n", timezone);
-       fgPrintf( FG_EVENT, FG_DEBUG,
-                 "  Daylight Savings = %d\n", daylight);
-       fgPrintf( FG_EVENT, FG_DEBUG,
-                 "  Local hours from GMT = %ld\n", offset);
+// return a courser but cheaper estimate of sidereal time
+double sidereal_course(struct tm *gmt, time_t now, double lng) {
+    time_t start_gmt;
+    double diff, part, days, hours, lst;
 
-       start_gmt = start - timezone + (daylight * 3600);
+    start_gmt = get_start_gmt(gmt->tm_year);
 
-       fgPrintf( FG_EVENT, FG_DEBUG, "  March 21 noon (CST) = %ld\n", start);
-    }
+    fgPrintf(FG_EVENT, FG_DEBUG, 
+            "  COURSE: GMT = %d/%d/%2d %d:%02d:%02d\n", 
+            gmt->tm_mon, gmt->tm_mday, gmt->tm_year,
+            gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
 
     fgPrintf( FG_EVENT, FG_DEBUG, "  March 21 noon (GMT) = %ld\n", start_gmt);
 
@@ -402,6 +409,13 @@ void fgTimeUpdate(fgFLIGHT *f, fgTIME *t) {
 
 
 // $Log$
+// Revision 1.9  1998/06/12 00:59:53  curt
+// Build only static libraries.
+// Declare memmove/memset for Sloaris.
+// Rewrote fg_time.c routine to get LST start seconds to better handle
+//   Solaris, and be easier to port, and understand the GMT vs. local
+//   timezone issues.
+//
 // Revision 1.8  1998/06/05 18:18:13  curt
 // Incorporated some automake conditionals to try to support mktime() correctly
 // on a wider variety of platforms.