Changeset: bd3ce169cf96 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bd3ce169cf96
Modified Files:
        monetdb5/modules/atoms/mtime.c
        monetdb5/modules/atoms/mtime.h
        monetdb5/modules/atoms/mtime_analytic.c
Branch: mtime
Log Message:

Fixes to get this to compile on Windows.


diffs (110 lines):

diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c
--- a/monetdb5/modules/atoms/mtime.c
+++ b/monetdb5/modules/atoms/mtime.c
@@ -29,6 +29,10 @@
 #include "mtime.h"
 #include "mal_exception.h"
 
+#ifndef HAVE_STRPTIME
+extern char *strptime(const char *, const char *, struct tm *);
+#endif
+
 #define YEAR_MIN               (-4712) /* 4713 BC */
 #define YEAR_MAX               (YEAR_MIN+(1<<21)/12)
 
@@ -455,7 +459,7 @@ timestamp_diff(timestamp t1, timestamp t
 }
 
 /* GDK level atom functions with some helpers */
-static size_t
+static ssize_t
 fleximatch(const char *s, const char *pat, size_t min)
 {
        size_t hit;
@@ -478,10 +482,10 @@ fleximatch(const char *s, const char *pa
        return (hit >= min) ? hit : 0;
 }
 
-static int
+static ssize_t
 parse_substr(int *ret, const char *s, size_t min, const char *list[], int size)
 {
-       size_t j = 0;
+       ssize_t j = 0;
        int i = 0;
 
        *ret = int_nil;
@@ -1136,7 +1140,7 @@ MTIMEdate_sub_msec_interval(date *ret, c
        if (is_date_nil(*d) || is_lng_nil(*ms))
                *ret = date_nil;
        else {
-               *ret = date_add_day(*d, -*ms / (24*60*60*1000));
+               *ret = date_add_day(*d, (int) (-*ms / (24*60*60*1000)));
                if (is_date_nil(*ret))
                        throw(MAL, "mtime.date_sub_msec_interval",
                                  SQLSTATE(22003) "overflow in calculation");
@@ -1150,7 +1154,7 @@ MTIMEdate_add_msec_interval(date *ret, c
        if (is_date_nil(*d) || is_lng_nil(*ms))
                *ret = date_nil;
        else {
-               *ret = date_add_day(*d, *ms / (24*60*60*1000));
+               *ret = date_add_day(*d, (int) (*ms / (24*60*60*1000)));
                if (is_date_nil(*ret))
                        throw(MAL, "mtime.date_add_msec_interval",
                                  SQLSTATE(22003) "overflow in calculation");
@@ -2252,7 +2256,7 @@ MTIMEtime_to_str(str *ret, const daytime
        dt /= 60;
        tm.tm_min = dt % 60;
        dt /= 60;
-       tm.tm_hour = dt;
+       tm.tm_hour = (int) dt;
        if (mktime(&tm) == (time_t) -1)
                throw(MAL, "mtime.time_to_str", "cannot convert time");
        if (strftime(buf, sizeof(buf), *format, &tm) == 0)
@@ -2314,7 +2318,7 @@ MTIMEtimestamp_to_str(str *ret, const ti
        t /= 60;
        tm.tm_min = t % 60;
        t /= 60;
-       tm.tm_hour = t;
+       tm.tm_hour = (int) t;
        if (mktime(&tm) == (time_t) -1)
                throw(MAL, "mtime.timestamp_to_str", "cannot convert 
timestamp");
        if (strftime(buf, sizeof(buf), *format, &tm) == 0)
diff --git a/monetdb5/modules/atoms/mtime.h b/monetdb5/modules/atoms/mtime.h
--- a/monetdb5/modules/atoms/mtime.h
+++ b/monetdb5/modules/atoms/mtime.h
@@ -12,17 +12,17 @@
 #include "mal.h"
 #include <time.h>                              /* for time_t */
 
-extern int TYPE_date;
+mal_export int TYPE_date;
 typedef int date;                              /* we use 26 bits out of 32 */
 #define date_nil                               ((date) {int_nil})
 #define is_date_nil(x)                 ((x) == date_nil)
 
-extern int TYPE_daytime;
+mal_export int TYPE_daytime;
 typedef lng daytime;                   /* we use 37 bits out of 64 */
 #define daytime_nil                            ((daytime) {lng_nil})
 #define is_daytime_nil(x)              ((x) == daytime_nil)
 
-extern int TYPE_timestamp;
+mal_export int TYPE_timestamp;
 typedef lng timestamp;                 /* we use 26+37=63 bits out of 64 */
 #define timestamp_nil                  ((timestamp) {lng_nil})
 #define is_timestamp_nil(x)            ((x) == timestamp_nil)
diff --git a/monetdb5/modules/atoms/mtime_analytic.c 
b/monetdb5/modules/atoms/mtime_analytic.c
--- a/monetdb5/modules/atoms/mtime_analytic.c
+++ b/monetdb5/modules/atoms/mtime_analytic.c
@@ -23,8 +23,8 @@
 
 #define daytime_add_msec(D,M)          daytime_add_usec(D, 1000*(M))
 #define daytime_sub_msec(D,M)          daytime_add_usec(D, -1000*(M))
-#define date_add_msec(D,M)                     
date_add_day(D,(M)/(24*60*60*1000))
-#define date_sub_msec(D,M)                     
date_add_day(D,-(M)/(24*60*60*1000))
+#define date_add_msec(D,M)                     date_add_day(D,(int) 
((M)/(24*60*60*1000)))
+#define date_sub_msec(D,M)                     date_add_day(D,(int) 
(-(M)/(24*60*60*1000)))
 #define timestamp_add_msec(T,M)                timestamp_add_usec(T, (M)*1000)
 #define timestamp_sub_msec(T,M)                timestamp_add_usec(T, -(M)*1000)
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to