Changeset: 617886a65f23 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=617886a65f23
Modified Files:
        
Branch: default
Log Message:

Merge with Oct2010 branch.


diffs (156 lines):

diff -r 38c43f30e98e -r 617886a65f23 MonetDB/src/gdk/gdk_utils.mx
--- a/MonetDB/src/gdk/gdk_utils.mx      Mon Sep 06 10:13:40 2010 +0200
+++ b/MonetDB/src/gdk/gdk_utils.mx      Mon Sep 06 12:39:41 2010 +0200
@@ -39,7 +39,6 @@
 gdk_export lng GDKusec(void);
 gdk_export int GDKms(void);
 
-gdk_export int gdk_alloc_map;
 gdk_export BAT *GDKenv;
 
 @c
@@ -47,9 +46,9 @@
 
 #include "gdk.h"
 
-int gdk_alloc_map = 0;
-char GDKdbfarmStr[PATHLENGTH] = { "dbfarm" };
-char GDKdbnameStr[PATHLENGTH] = { 0 };
+static int gdk_alloc_map = 0;
+static char GDKdbfarmStr[PATHLENGTH] = { "dbfarm" };
+static char GDKdbnameStr[PATHLENGTH] = { 0 };
 
 BAT *GDKenv = NULL;
 
@@ -1452,7 +1451,7 @@
 gdk_export int GDKrecovery;
 
 @c
-int GDKtime_startsec, GDKrecovery = 0;
+int GDKrecovery = 0;
 
 @h
 gdk_export int GDKinit(opt *set, int setlen);
@@ -1593,24 +1592,6 @@
 #endif
        GDKlockHome();
 
-       /* init time */
-#ifdef HAVE_GETTIMEOFDAY
-       {
-               struct timeval tp;
-
-               gettimeofday(&tp, NULL);
-               GDKtime_startsec = tp.tv_sec;
-       }
-#else
-#ifdef HAVE_FTIME
-       {
-               struct timeb tb;
-
-               ftime(&tb);
-               GDKtime_startsec = (int) tb.time;
-       }
-#endif
-#endif
        /* Mserver by default takes 80% of all memory as a default */
        GDK_mem_maxsize_max = (size_t) ((double) MT_npages() * (double) 
MT_pagesize() * 0.815);
        GDK_mmap_minsize = GDK_mem_maxsize = GDK_mem_maxsize_max;
@@ -2176,17 +2157,44 @@
 lng
 GDKusec(void)
 {
+       /* Return the time in milliseconds since an epoch.  The epoch
+          is roughly the time this program started. */
+#ifdef HAVE_QUERYPERFORMANCECOUNTER
+       static LARGE_INTEGER freq, start;       /* automatically initialized to 
0 */
+       LARGE_INTEGER ctr;
+
+       if (start.QuadPart == 0 &&
+           (!QueryPerformanceFrequency(&freq) ||
+            !QueryPerformanceCounter(&start)))
+               start.QuadPart = -1;
+       if (start.QuadPart > 0) {
+               QueryPerformanceCounter(&ctr);
+               return (lng) (((ctr.QuadPart - start.QuadPart) * 1000000) / 
freq.QuadPart);
+       }
+#endif
 #ifdef HAVE_GETTIMEOFDAY
-       struct timeval tp;
+       {
+               static struct timeval tpbase;   /* automatically initialized to 
0 */
+               struct timeval tp;
 
-       gettimeofday(&tp, NULL);
-       return ((lng) (tp.tv_sec - GDKtime_startsec)) * LL_CONSTANT(1000000) + 
(lng) tp.tv_usec;
+               if (tpbase.tv_sec == 0)
+                       gettimeofday(&tpbase, NULL);
+               gettimeofday(&tp, NULL);
+               tp.tv_sec -= tpbase.tv_sec;
+               return (lng) tp.tv_sec * 1000000 + (lng) tp.tv_usec;
+       }
 #else
 #ifdef HAVE_FTIME
-       struct timeb tb;
+       {
+               static struct timeb tbbase;     /* automatically initialized to 
0 */
+               struct timeb tb;
 
-       ftime(&tb);
-       return ((lng) (tb.time - GDKtime_startsec)) * LL_CONSTANT(1000000) + 
((lng) tb.millitm) * LL_CONSTANT(1000);
+               if (tbbase.time == 0)
+                       ftime(&tbbase);
+               ftime(&tb);
+               tb.time -= tbbase.time;
+               return (lng) tb.time * 1000000 + (lng) tb.millitm * 1000;
+       }
 #endif
 #endif
 }
@@ -2195,19 +2203,7 @@
 int
 GDKms(void)
 {
-#ifdef HAVE_GETTIMEOFDAY
-       struct timeval tp;
-
-       gettimeofday(&tp, NULL);
-       return (tp.tv_sec - GDKtime_startsec) * 1000 + tp.tv_usec / 1000;
-#else
-#ifdef HAVE_FTIME
-       struct timeb tb;
-
-       ftime(&tb);
-       return (int) ((tb.time - GDKtime_startsec) * 1000 + tb.millitm);
-#endif
-#endif
+       return (int) (GDKusec() / 1000);
 }
 
 @}
diff -r 38c43f30e98e -r 617886a65f23 buildtools/conf/winconfig.h
--- a/buildtools/conf/winconfig.h       Mon Sep 06 10:13:40 2010 +0200
+++ b/buildtools/conf/winconfig.h       Mon Sep 06 12:39:41 2010 +0200
@@ -358,6 +358,9 @@
 /* Define to 1 if you have the <pwd.h> header file. */
 /* #undef HAVE_PWD_H */
 
+/* Define to 1 if you have the `QueryPerformanceCounter' function. */
+#define HAVE_QUERYPERFORMANCECOUNTER 1
+
 /* Define to 1 if you have the <regex.h> header file. */
 /* #undef HAVE_REGEX_H */
 
diff -r 38c43f30e98e -r 617886a65f23 clients/NT/clients_config.h.in
--- a/clients/NT/clients_config.h.in    Mon Sep 06 10:13:40 2010 +0200
+++ b/clients/NT/clients_config.h.in    Mon Sep 06 12:39:41 2010 +0200
@@ -29,9 +29,6 @@
 /* Define to 1 if you have the <odbcinst.h> header file. */
 #define HAVE_ODBCINST_H 1
 
-/* Define to 1 if you have the `QueryPerformanceCounter' function. */
-#define HAVE_QUERYPERFORMANCECOUNTER 1
-
 /* Define to 1 if you have the `SQLGetPrivateProfileString' function. */
 #define HAVE_SQLGETPRIVATEPROFILESTRING 1
 
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to