Centralized time handling differences.
+++ /dev/null
-#---------------------------------------------------------------------------
-# Makefile
-#
-# Written by Curtis Olson, started May 1997.
-#
-# Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-# $Id$
-# (Log is kept at end of this file)
-#---------------------------------------------------------------------------
-
-ARLIBRARY = libTime.a
-TARGETS = $(ARLIBRARY)
-
-CFILES = event.c fg_time.c fg_timer.c sunpos.c
-CXXFILES =
-
-LDIRT = $(FG_ROOT_LIB)/$(ARLIBRARY)
-
-include $(FG_ROOT_SRC)/commondefs
-
-include $(COMMONRULES)
--- /dev/null
+libdir = ${exec_prefix}/lib
+
+lib_LTLIBRARIES = libTime.la
+libTime_la_SOURCES = \
+ event.c \
+ fg_time.c \
+ fg_timer.c \
+ sunpos.c
+
+INCLUDES += -I..
--- /dev/null
+# Makefile.in generated automatically by automake 1.2h from Makefile.am
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = /bin/sh
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DISTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ../..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_alias = @host_alias@
+host_triplet = @host@
+CC = @CC@
+CXX = @CXX@
+LD = @LD@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+NM = @NM@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+VERSION = @VERSION@
+
+libdir = ${exec_prefix}/lib
+
+lib_LTLIBRARIES = libTime.la
+libTime_la_SOURCES = \
+ event.c \
+ fg_time.c \
+ fg_timer.c \
+ sunpos.c
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = ../../Src/Include/config.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(lib_LTLIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I../../Src/Include
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_LIBS = @X_LIBS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+libTime_la_LDFLAGS =
+libTime_la_LIBADD =
+libTime_la_OBJECTS = event.lo fg_time.lo fg_timer.lo sunpos.lo
+CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
+LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP = --best
+DEP_FILES = .deps/event.P .deps/fg_time.P .deps/fg_timer.P \
+.deps/sunpos.P
+SOURCES = $(libTime_la_SOURCES)
+OBJECTS = $(libTime_la_OBJECTS)
+
+all: Makefile $(LTLIBRARIES)
+
+.SUFFIXES:
+.SUFFIXES: .S .c .lo .o .s
+$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --gnu Src/Time/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-libLTLIBRARIES:
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+
+distclean-libLTLIBRARIES:
+
+maintainer-clean-libLTLIBRARIES:
+
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(libdir)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo "$(LIBTOOL) --mode=install $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \
+ $(LIBTOOL) --mode=install $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \
+ else :; fi; \
+ done
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
+ done
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+.s.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.S.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+
+maintainer-clean-libtool:
+
+libTime.la: $(libTime_la_OBJECTS) $(libTime_la_DEPENDENCIES)
+ $(LINK) -rpath $(libdir) $(libTime_la_LDFLAGS) $(libTime_la_OBJECTS) $(libTime_la_LIBADD) $(LIBS)
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = Src/Time
+
+distdir: $(DISTFILES)
+ here=`cd $(top_builddir) && pwd`; \
+ top_distdir=`cd $(top_distdir) && pwd`; \
+ distdir=`cd $(distdir) && pwd`; \
+ cd $(top_srcdir) \
+ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Src/Time/Makefile
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file; \
+ done
+
+DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
+
+-include $(DEP_FILES)
+
+mostlyclean-depend:
+
+clean-depend:
+
+distclean-depend:
+
+maintainer-clean-depend:
+ -rm -rf .deps
+
+%.o: %.c
+ @echo '$(COMPILE) -c $<'; \
+ $(COMPILE) -Wp,-MD,.deps/$(*F).P -c $<
+
+%.lo: %.c
+ @echo '$(LTCOMPILE) -c $<'; \
+ $(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $<
+ @-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \
+ < .deps/$(*F).p > .deps/$(*F).P
+ @-rm -f .deps/$(*F).p
+info:
+dvi:
+check: all
+ $(MAKE)
+installcheck:
+install-exec: install-libLTLIBRARIES
+ @$(NORMAL_INSTALL)
+
+install-data:
+ @$(NORMAL_INSTALL)
+
+install: install-exec install-data all
+ @:
+
+uninstall: uninstall-libLTLIBRARIES
+
+install-strip:
+ $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
+installdirs:
+ $(mkinstalldirs) $(DATADIR)$(libdir)
+
+
+mostlyclean-generic:
+ -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -rm -f Makefile $(DISTCLEANFILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+mostlyclean: mostlyclean-libLTLIBRARIES mostlyclean-compile \
+ mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
+ mostlyclean-generic
+
+clean: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \
+ clean-depend clean-generic mostlyclean
+
+distclean: distclean-libLTLIBRARIES distclean-compile distclean-libtool \
+ distclean-tags distclean-depend distclean-generic clean
+ -rm -f config.status
+ -rm -f libtool
+
+maintainer-clean: maintainer-clean-libLTLIBRARIES \
+ maintainer-clean-compile maintainer-clean-libtool \
+ maintainer-clean-tags maintainer-clean-depend \
+ maintainer-clean-generic distclean
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
+clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
+uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
+distclean-compile clean-compile maintainer-clean-compile \
+mostlyclean-libtool distclean-libtool clean-libtool \
+maintainer-clean-libtool tags mostlyclean-tags distclean-tags \
+clean-tags maintainer-clean-tags distdir mostlyclean-depend \
+distclean-depend clean-depend maintainer-clean-depend info dvi \
+installcheck install-exec install-data install uninstall all \
+installdirs mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+
+
+INCLUDES += -I..
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
**************************************************************************/
+#include <config.h>
+
#include <string.h>
#include <stdio.h>
-#ifdef USE_FTIME
-# include <stdlib.h>
-# include <sys/timeb.h> /* for ftime() and struct timeb */
-#elif defined(__MWERKS__)
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#if defined( HAVE_WINDOWS_H ) && defined(__MWERKS__)
# include <windows.h> /* For Metrowerks environment */
# include <winbase.h> /* There is no ANSI/MSL time function that */
/* contains milliseconds */
-#else
-# include <sys/time.h> /* for get/setitimer, gettimeofday, struct timeval */
-#endif /* USE_FTIME */
+#endif
+#include "fg_time.h"
#include <Main/fg_debug.h>
#include <Time/event.h>
int status; /* status flag */
long interval; /* interval in ms between each iteration of this event */
-
-#ifdef USE_FTIME
- struct timeb last_run; /* absolute time for last run */
- struct timeb current; /* current time */
- struct timeb next_run; /* absolute time for next run */
-#elif defined(__MWERKS__)
- SYSTEMTIME last_run; /* A type defed structure that holds */
- SYSTEMTIME current; /* the only structure that contains */
- SYSTEMTIME next_run; /* millisecond timing */
-#else
- struct timeval last_run; /* absolute time for last run */
- struct timeval current; /* current time */
- struct timeval next_run; /* absolute time for next run */
- struct timezone tz;
-#endif /* USE_FTIME */
+
+ fg_timestamp last_run;
+ fg_timestamp current;
+ fg_timestamp next_run;
long cum_time; /* cumulative processor time of this event */
long min_time; /* time of quickest execution */
printf("Running %s\n", e->description);
/* record starting time */
-#ifdef USE_FTIME
- ftime(&e->last_run);
-#elif defined(__MWERKS__)
- GetLocalTime(&e->last_run);
-#else
- gettimeofday(&e->last_run, &e->tz);
-#endif /* USE_FTIME */
+ timestamp(&(e->last_run));
/* run the event */
(*e->event)();
e->status = FG_EVENT_READY;
/* calculate duration and stats */
-#ifdef USE_FTIME
- ftime(&e->current);
- duration = 1000 * (e->current.time - e->last_run.time) +
- (e->current.millitm - e->last_run.millitm);
-#elif defined(__MWERKS__)
- GetLocalTime(&e->current);
- duration = 1000 * (e->current.wSecond - e->last_run.wSecond) +
- (e->current.wMilliseconds - e->last_run.wMilliseconds);
-#else
- gettimeofday(&e->current, &e->tz);
- duration = 1000000 * (e->current.tv_sec - e->last_run.tv_sec) +
- (e->current.tv_usec - e->last_run.tv_usec);
- duration /= 1000; /* convert back to milleseconds */
-#endif /* USE_FTIME */
+ timestamp(&(e->current));
+ duration = timediff(&(e->last_run), &(e->current));
e->cum_time += duration;
}
/* determine the next absolute run time */
-#ifdef USE_FTIME
- e->next_run.time = e->last_run.time +
- (e->last_run.millitm + e->interval) / 1000;
- e->next_run.millitm = (e->last_run.millitm + e->interval) % 1000;
-#elif defined(__MWERKS__)
- e->next_run.wSecond = e->last_run.wSecond +
- (e->last_run.wMilliseconds + e->interval) / 1000;
- e->next_run.wMilliseconds =
- (e->last_run.wMilliseconds + e->interval) % 1000;
-#else
- e->next_run.tv_sec = e->last_run.tv_sec +
- (e->last_run.tv_usec + e->interval * 1000) / 1000000;
- e->next_run.tv_usec = (e->last_run.tv_usec + e->interval * 1000) % 1000000;
-#endif /* USE_FTIME */
+ timesum(&(e->next_run), &(e->last_run), e->interval);
}
/* Add pending jobs to the run queue and run the job at the front of
* the queue */
void fgEventProcess( void ) {
-#ifdef USE_FTIME
- struct timeb current;
-#elif defined(__MWERKS__)
- SYSTEMTIME current; /* current time */
-#else
- struct timeval current;
- struct timezone tz;
-#endif /* USE_FTIME */
+ fg_timestamp current;
int i;
fgPrintf(FG_EVENT, FG_DEBUG, "Processing events\n");
/* get the current time */
-#ifdef USE_FTIME
- ftime(¤t);
-#elif defined(__MWERKS__)
- GetLocalTime(¤t);
-#else
- gettimeofday(¤t, &tz);
-#endif /* USE_FTIME */
+ timestamp(¤t);
/* printf("Checking if anything is ready to move to the run queue\n"); */
/* see if anything else is ready to be placed on the run queue */
for ( i = 0; i < event_ptr; i++ ) {
if ( events[i].status == FG_EVENT_READY ) {
-#ifdef USE_FTIME
- if ( current.time > events[i].next_run.time ) {
- addq(i);
- } else if ( (current.time == events[i].next_run.time) &&
- (current.millitm >= events[i].next_run.millitm) ) {
- addq(i);
- }
-#elif defined(__MWERKS__)
- if (current.wSecond > events[i].next_run.wSecond) {
- addq(i);
+ if ( 0 > timediff(¤t,&(events[i].next_run)) ) {
+ addq(i);
}
- else if ( (current.wSecond == events[i].next_run.wSecond) &&
- (current.wMilliseconds >=
- events[i].next_run.wMilliseconds)) {
- addq(i);
- }
-#else
- if ( current.tv_sec > events[i].next_run.tv_sec ) {
- addq(i);
- } else if ( (current.tv_sec == events[i].next_run.tv_sec) &&
- (current.tv_usec >= events[i].next_run.tv_usec) ) {
- addq(i);
- }
-
-#endif /* USE_FTIME */
}
}
/* $Log$
-/* Revision 1.10 1998/03/14 00:28:34 curt
-/* replaced a printf() with an fgPrintf().
+/* Revision 1.11 1998/04/03 22:12:55 curt
+/* Converting to Gnu autoconf system.
+/* Centralized time handling differences.
/*
+ * Revision 1.10 1998/03/14 00:28:34 curt
+ * replaced a printf() with an fgPrintf().
+ *
* Revision 1.9 1998/01/31 00:43:44 curt
* Added MetroWorks patches from Carmen Volpe.
*
**************************************************************************/
+#include <config.h>
+
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
-#ifdef USE_FTIME
+#ifdef HAVE_SYS_TIMEB_H
# include <sys/timeb.h> /* for ftime() and struct timeb */
-#else
+#endif
+#ifdef HAVE_UNISTD_H
# include <unistd.h> /* for gettimeofday() */
+#endif
+#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> /* for get/setitimer, gettimeofday, struct timeval */
-#endif /* USE_FTIME */
+#endif
#include <Time/fg_time.h>
#include <Include/fg_constants.h>
}
+/* Portability wrap to get current time. */
+void timestamp(fg_timestamp *timestamp) {
+#if defined( HAVE_GETTIMEOFDAY )
+ struct timeval current;
+ struct timezone tz;
+ fg_timestamp currtime;
+ gettimeofday(¤t, &tz);
+ timestamp->seconds = current.tv_sec;
+ timestamp->millis = current.tv_usec / 1000;
+#elif defined( HAVE_GETLOCALTIME )
+ SYSTEMTIME current;
+ GetLocalTime(¤t);
+ timestamp->seconds = current.wSecond;
+ timestamp->millis = current.wMilliseconds;
+#elif defined( HAVE_FTIME )
+ struct timeb current;
+ ftime(¤t);
+ timestamp->seconds = current.time;
+ timestamp->millis = current.millitm;
+#else
+# error Port me
+#endif
+}
+
+
+/* Return duration in millis from first to last */
+long timediff(fg_timestamp *first, fg_timestamp *last) {
+ return 1000 * (last->seconds - first->seconds) +
+ (last->millis - first->millis);
+}
+
+
+/* Return new timestamp given a time stamp and an interval to add in */
+void timesum(fg_timestamp *res, fg_timestamp *start, long millis) {
+ res->millis = start->millis + millis;
+ if (1000 < res->millis) {
+ res->seconds = start->millis + 1;
+ res->millis -= 1000;
+ } else {
+ res->seconds = start->millis;
+ }
+}
+
+
/* given a date in months, mn, days, dy, years, yr, return the
* modified Julian date (number of days elapsed since 1900 jan 0.5),
* mjd. Adapted from Xephem. */
struct timeb current;
#endif /* USE_FTIME */
-#ifdef WIN32
+#ifdef __CYGWIN32__
int daylight;
long int timezone;
#endif /* WIN32 */
/* $Log$
-/* Revision 1.36 1998/03/09 22:48:09 curt
-/* Debug message tweaks.
+/* Revision 1.37 1998/04/03 22:12:55 curt
+/* Converting to Gnu autoconf system.
+/* Centralized time handling differences.
/*
+ * Revision 1.36 1998/03/09 22:48:09 curt
+ * Debug message tweaks.
+ *
* Revision 1.35 1998/02/09 15:07:52 curt
* Minor tweaks.
*
#define _FG_TIME_H
-#ifdef WIN32
-# include <windows.h>
-#endif
+// #ifdef WIN32
+// # include <windows.h>
+// #endif
#include <GL/glut.h>
#include <time.h>
extern struct fgLIGHT cur_light_params;
+typedef struct fg_timestamp_t {
+ long seconds;
+ long millis;
+} fg_timestamp;
+
+
+/* Portability wrap to get current time. */
+void timestamp(fg_timestamp *timestamp);
+
+/* Return duration in millis from first to last */
+long timediff(fg_timestamp *first, fg_timestamp *last);
+
+/* Return new timestamp given a time stamp and an interval to add in */
+void timesum(fg_timestamp *res, fg_timestamp *start, long millis);
/* Initialize the time dependent variables */
void fgTimeInit(struct fgTIME *t);
/* $Log$
-/* Revision 1.16 1998/02/07 15:29:47 curt
-/* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
-/* <chotchkiss@namg.us.anritsu.com>
+/* Revision 1.17 1998/04/03 22:12:56 curt
+/* Converting to Gnu autoconf system.
+/* Centralized time handling differences.
/*
+ * Revision 1.16 1998/02/07 15:29:47 curt
+ * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
+ * <chotchkiss@namg.us.anritsu.com>
+ *
* Revision 1.15 1998/01/27 00:48:06 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code.
**************************************************************************/
+#include <config.h>
+
#include <signal.h> /* for timer routines */
#include <stdio.h> /* for printf() */
-#ifdef USE_FTIME
-# include <sys/timeb.h> /* for ftime() and struct timeb */
-#elif defined(__MWERKS__)
-# include <windows.h> /* For Metrowerks environment */
-# include <winbase.h> /* There is no ANSI/MSL time function that */
- /* contains milliseconds */
-#else
+#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> /* for get/setitimer, gettimeofday, struct timeval */
-#endif /* USE_FTIME */
+#endif
+#include <Time/fg_time.h>
#include <Time/fg_timer.h>
unsigned long int fgSimTime;
-#ifdef USE_ITIMER
+#ifdef HAVE_SETITIMER
static struct itimerval t, ot;
static void (*callbackfunc)(int multi_loop);
exit(0);
}
}
-#endif /* HAVE_ITIMER */
+#endif /* HAVE_SETITIMER */
/* This function returns the number of milleseconds since the last
int fgGetTimeInterval( void ) {
int interval;
static int inited = 0;
-
-#ifdef USE_FTIME
- static struct timeb last;
- static struct timeb current;
-#elif defined (__MWERKS__)
- SYSTEMTIME last;
- SYSTEMTIME current;
-#else
- static struct timeval last;
- static struct timeval current;
- static struct timezone tz;
-#endif /* USE_FTIME */
+ static fg_timestamp last;
+ fg_timestamp current;
if ( ! inited ) {
inited = 1;
-
-#ifdef USE_FTIME
- ftime(&last);
-#elif defined (__MWERKS__)
- GetLocalTime(&last);
-#else
- gettimeofday(&last, &tz);
-#endif /* USE_FTIME */
-
+ timestamp(&last);
interval = 0;
} else {
-
-#ifdef USE_FTIME
- ftime(¤t);
- interval = 1000 * (current.time - last.time) +
- (current.millitm - last.millitm);
-#elif defined (__MWERKS__)
- GetLocalTime(¤t);
- interval = 1000 * (current.wSecond - last.wSecond) +
- (current.wMilliseconds - last.wMilliseconds);
-#else
- gettimeofday(¤t, &tz);
- interval = 1000000 * (current.tv_sec - last.tv_sec) +
- (current.tv_usec - last.tv_usec);
- interval /= 1000; /* convert back to milleseconds */
-#endif /* USE_FTIME */
-
- last = current;
+ timestamp(¤t);
+ interval = timediff(&last, ¤t);
+ last.seconds = current.seconds;
+ last.millis = current.millis;
}
return(interval);
/* $Log$
-/* Revision 1.10 1998/01/31 00:43:45 curt
-/* Added MetroWorks patches from Carmen Volpe.
+/* Revision 1.11 1998/04/03 22:12:56 curt
+/* Converting to Gnu autoconf system.
+/* Centralized time handling differences.
/*
+ * Revision 1.10 1998/01/31 00:43:45 curt
+ * Added MetroWorks patches from Carmen Volpe.
+ *
* Revision 1.9 1998/01/19 19:27:21 curt
* Merged in make system changes from Bob Kuehne <rpk@sgi.com>
* This should simplify things tremendously.
light = pow(1.1, -x_10 / 30.0);
ambient = 0.2 * light;
- diffuse = 0.9 * light;
+ diffuse = 1.0 * light;
sky_brightness = 0.85 * pow(1.2, -x_8 / 20.0) + 0.15;
/* $Log$
-/* Revision 1.26 1998/02/23 19:08:00 curt
-/* Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
-/* calculation code between sun display, and other FG sections that use this
-/* for things like lighting.
+/* Revision 1.27 1998/04/03 22:12:57 curt
+/* Converting to Gnu autoconf system.
+/* Centralized time handling differences.
/*
+ * Revision 1.26 1998/02/23 19:08:00 curt
+ * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
+ * calculation code between sun display, and other FG sections that use this
+ * for things like lighting.
+ *
* Revision 1.25 1998/02/09 15:07:53 curt
* Minor tweaks.
*