[teklib-general] teklib: removed TTime structure, TTIME is now a profane 64bit in...

Timm S. Mueller tmueller at neoscientists.org
Wed Jan 14 13:36:43 CET 2009


details:   http://hg.teklib.org/teklib/rev/722160b5ac43
changeset: 224:722160b5ac43
user:      Timm S. Mueller <tmueller at neoscientists.org>
date:      Mon Jan 12 17:26:32 2009 +0100
description:
removed TTime structure, TTIME is now a profane 64bit integer

diffs (truncated from 522 to 100 lines):

diff -r 70defb611a32 -r 722160b5ac43 src/date/astro_mod.c
--- a/src/date/astro_mod.c	Mon Jan 12 16:09:57 2009 +0100
+++ b/src/date/astro_mod.c	Mon Jan 12 17:26:32 2009 +0100
@@ -299,8 +299,8 @@
 	db.tdb_Fields = TDB_YEAR | TDB_MONTH | TDB_DAY;
 	if (tm)
 	{
-		db.tdb_Sec = tm->ttm_Sec;
-		db.tdb_USec = tm->ttm_USec;
+		db.tdb_Sec = tm->tdt_Int64 / 1000000;
+		db.tdb_USec = tm->tdt_Int64 % 1000000;
 		db.tdb_Fields |= TDB_SEC | TDB_USEC;
 	}
 	success = TUtilPackDate(astro->util, &db, date);
diff -r 70defb611a32 -r 722160b5ac43 src/date/tests/datetest.c
--- a/src/date/tests/datetest.c	Mon Jan 12 16:09:57 2009 +0100
+++ b/src/date/tests/datetest.c	Mon Jan 12 17:26:32 2009 +0100
@@ -187,8 +187,9 @@
 	TTIME dt;
 	TTIME t0, t1;
 
-	dt.ttm_Sec = 2;
-	dt.ttm_USec = 345678;
+	/*dt.ttm_Sec = 2;
+	dt.ttm_USec = 345678;*/
+	dt.tdt_Int64 = 2345678;
 
 	TExecGetDate(TExecBase, treq, &wait, TNULL);
 	TExecAddDate(TExecBase, &wait, 0, &dt);
@@ -199,7 +200,7 @@
 	TExecQueryTime(TExecBase, treq2, &t1);
 
 	TExecSubTime(TExecBase, &t1, &t0);
-	printf("Done. Time measured: %ds, %dus\n", t1.ttm_Sec, t1.ttm_USec);
+	printf("Done. Time measured: %2.3f\n", (TFLOAT) t1.tdt_Int64 / 1000000);
 }
 
 /*****************************************************************************/
diff -r 70defb611a32 -r 722160b5ac43 src/display_x11/display_x11_inst.c
--- a/src/display_x11/display_x11_inst.c	Mon Jan 12 16:09:57 2009 +0100
+++ b/src/display_x11/display_x11_inst.c	Mon Jan 12 17:26:32 2009 +0100
@@ -381,7 +381,8 @@
 	struct timeval tv;
 
 	/* interval time: 1/50s: */
-	TTIME intt = { 0, 20000 };
+	TTIME intt = { 20000 };
+
 	/* next absolute time to send interval message: */
 	TTIME nextt;
 	TTIME waitt, nowt;
@@ -415,8 +416,9 @@
 		waitt = nextt;
 		TExecSubTime(inst->x11_ExecBase, &waitt, &nowt);
 
-		tv.tv_sec = waitt.ttm_Sec;
-		tv.tv_usec = waitt.ttm_USec;
+		tv.tv_sec = waitt.tdt_Int64 / 1000000;
+		tv.tv_usec = waitt.tdt_Int64 % 1000000;
+
 		/* wait for display, signal fd and timeout: */
 		if (select(inst->x11_fd_max, &rset, NULL, NULL, &tv) > 0)
 			if (FD_ISSET(inst->x11_fd_sigpipe_read, &rset))
diff -r 70defb611a32 -r 722160b5ac43 src/exec/exec_time.c
--- a/src/exec/exec_time.c	Mon Jan 12 16:09:57 2009 +0100
+++ b/src/exec/exec_time.c	Mon Jan 12 17:26:32 2009 +0100
@@ -19,16 +19,7 @@
 EXPORT void
 exec_SubTime(TEXECBASE *tmod, TTIME *a, TTIME *b)
 {
-	if (a->ttm_USec < b->ttm_USec)
-	{
-		a->ttm_Sec = a->ttm_Sec - b->ttm_Sec - 1;
-		a->ttm_USec = 1000000 - (b->ttm_USec - a->ttm_USec);
-	}
-	else
-	{
-		a->ttm_Sec = a->ttm_Sec - b->ttm_Sec;
-		a->ttm_USec = a->ttm_USec - b->ttm_USec;
-	}
+	a->tdt_Int64 -= b->tdt_Int64;
 }
 
 /*****************************************************************************/
@@ -36,13 +27,7 @@
 EXPORT void
 exec_AddTime(TEXECBASE *tmod, TTIME *a, TTIME *b)
 {
-	a->ttm_Sec += b->ttm_Sec;
-	a->ttm_USec += b->ttm_USec;
-	if (a->ttm_USec >= 1000000)
-	{
-		a->ttm_USec -= 1000000;
-		a->ttm_Sec++;
-	}
+	a->tdt_Int64 += b->tdt_Int64;
 }
 
 /*****************************************************************************/
@@ -50,11 +35,9 @@


More information about the teklib-general mailing list