From 274ba49906f0206b38d5ac29563ea3d351db2110 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 5 Jun 1998 18:18:12 +0000 Subject: [PATCH] Incorporated some automake conditionals to try to support mktime() correctly on a wider variety of platforms. Added the declaration of memmove needed by the stl which apparently solaris only defines for cc compilations and not for c++ (__STDC__) --- Time/Makefile.am | 8 ++++++++ Time/event.cxx | 13 +++++++++++++ Time/fg_time.cxx | 37 +++++++++++++++++++++++++++++++++---- 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/Time/Makefile.am b/Time/Makefile.am index f2916865a..50a761c58 100644 --- a/Time/Makefile.am +++ b/Time/Makefile.am @@ -1,3 +1,11 @@ +if HAVE_DAYLIGHT +DEFS += -DHAVE_DAYLIGHT +endif + +if HAVE_TIMEZONE +DEFS += -DHAVE_TIMEZONE +endif + libdir = ${exec_prefix}/lib lib_LTLIBRARIES = libTime.la diff --git a/Time/event.cxx b/Time/event.cxx index 15acbd6c3..2dfaae936 100644 --- a/Time/event.cxx +++ b/Time/event.cxx @@ -44,6 +44,13 @@ #include "event.hxx" +#ifdef __sun__ +extern "C" { + extern void *memmove(void *, const void *, size_t); +} +#endif + + fgEVENT_MGR global_events; @@ -235,6 +242,12 @@ void fgEventPrintStats( void ) { // $Log$ +// 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. +// Added the declaration of memmove needed by the stl which apparently +// solaris only defines for cc compilations and not for c++ (__STDC__) +// // Revision 1.3 1998/05/22 21:14:53 curt // Rewrote event.cxx in C++ as a class using STL for the internal event list // and run queue this removes the arbitrary list sizes and makes things much diff --git a/Time/fg_time.cxx b/Time/fg_time.cxx index f74529f24..9c0510df1 100644 --- a/Time/fg_time.cxx +++ b/Time/fg_time.cxx @@ -217,18 +217,41 @@ double sidereal_course(struct tm *gmt, time_t now, double lng) { long int offset; double diff, part, days, hours, lst; - // I believe the following is Unix vs. Win32 behavior difference. + // 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. -#ifdef WIN32 - int daylight; // not used but need to keep the compiler happy - long int timezone; // not used but need to keep the compiler happy + +#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_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 ) @@ -379,6 +402,12 @@ void fgTimeUpdate(fgFLIGHT *f, fgTIME *t) { // $Log$ +// 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. +// Added the declaration of memmove needed by the stl which apparently +// solaris only defines for cc compilations and not for c++ (__STDC__) +// // Revision 1.7 1998/05/30 01:57:25 curt // misc updates. //