Changeset: 1697eb7f4ad1 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1697eb7f4ad1
Modified Files:
clients/Tests/exports.stable.out
monetdb5/modules/atoms/mtime.c
monetdb5/modules/atoms/mtime.h
Branch: Oct2014
Log Message:
Force lng-compatible alignment on timestamp.
On Sparc, where misaligned access results in a bus error, we need to
make sure that variables of type timestamp are aligned the same as
lng, since that is what's used to copy values when inserting into a BAT.
diffs (103 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1642,7 +1642,7 @@ str MTIMEtime_add_msec_interval_wrap(day
str MTIMEtime_sub_msec_interval_wrap(daytime *ret, const daytime *t, const lng
*msec);
str MTIMEtimestamp(timestamp *ret, const int *sec);
str MTIMEtimestamp2timestamp(timestamp *ret, const timestamp *src);
-str MTIMEtimestamp_add(timestamp *ret, const timestamp *v, const lng *msecs);
+str MTIMEtimestamp_add(timestamp *ret, const timestamp *v, const lng *msec);
str MTIMEtimestamp_add_month_interval_lng_wrap(timestamp *ret, const timestamp
*t, const lng *months);
str MTIMEtimestamp_add_month_interval_wrap(timestamp *ret, const timestamp *t,
const int *months);
str MTIMEtimestamp_bulk(bat *ret, bat *bid);
@@ -1662,7 +1662,7 @@ str MTIMEtimestamp_extract_daytime_defau
str MTIMEtimestamp_fromstr(timestamp *ret, const char *const *d);
str MTIMEtimestamp_hours(int *ret, const timestamp *t);
str MTIMEtimestamp_inside_dst(bit *ret, const timestamp *p, const tzone *z);
-str MTIMEtimestamp_lng(timestamp *ret, const lng *msecs);
+str MTIMEtimestamp_lng(timestamp *ret, const lng *msec);
str MTIMEtimestamp_lng_bulk(bat *ret, bat *bid);
str MTIMEtimestamp_milliseconds(int *ret, const timestamp *t);
str MTIMEtimestamp_minutes(int *ret, const timestamp *t);
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
@@ -1153,22 +1153,22 @@ daytime_add(daytime *ret, const daytime
/* returns the timestamp that comes 'milliseconds' after 'value'. */
str
-MTIMEtimestamp_add(timestamp *ret, const timestamp *v, const lng *msecs)
+MTIMEtimestamp_add(timestamp *ret, const timestamp *v, const lng *msec)
{
- if (!ts_isnil(*v) && *msecs != lng_nil) {
- int days = (int) (*msecs / (24 * 60 * 60 * 1000));
-
- ret->msecs = (int) (v->msecs + (*msecs - ((lng) days) * (24 *
60 * 60 * 1000)));
+ if (!ts_isnil(*v) && *msec != lng_nil) {
+ int day = (int) (*msec / (24 * 60 * 60 * 1000));
+
+ ret->msecs = (int) (v->msecs + (*msec - ((lng) day) * (24 * 60
* 60 * 1000)));
ret->days = v->days;
if (ret->msecs >= (24 * 60 * 60 * 1000)) {
- days++;
+ day++;
ret->msecs -= (24 * 60 * 60 * 1000);
} else if (ret->msecs < 0) {
- days--;
+ day--;
ret->msecs += (24 * 60 * 60 * 1000);
}
- if (days) {
- MTIMEdate_adddays(&ret->days, &ret->days, &days);
+ if (day) {
+ MTIMEdate_adddays(&ret->days, &ret->days, &day);
if (ret->days == int_nil) {
*ret = *timestamp_nil;
}
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
@@ -75,15 +75,20 @@ typedef int daytime;
* @- timestamp
* Timestamp is implemented as a record that contains a date and a time (GMT).
*/
-typedef struct {
+typedef union {
+ lng alignment;
+ struct {
#ifndef WORDS_BIGENDIAN
- daytime msecs;
- date days;
+ daytime p_msecs;
+ date p_days;
#else
- date days;
- daytime msecs;
+ date p_days;
+ daytime p_msecs;
#endif
+ } payload;
} timestamp;
+#define msecs payload.p_msecs
+#define days payload.p_days
/*
* @- rule
@@ -172,7 +177,7 @@ mtime_export str MTIMEdate_adddays(date
mtime_export str MTIMEdate_addmonths(date *ret, const date *v, const int
*delta);
mtime_export str MTIMEdate_diff(int *ret, const date *v1, const date *v2);
mtime_export str MTIMEdate_diff_bulk(bat *ret, const bat *bid1, const bat
*bid2);
-mtime_export str MTIMEtimestamp_add(timestamp *ret, const timestamp *v, const
lng *msecs);
+mtime_export str MTIMEtimestamp_add(timestamp *ret, const timestamp *v, const
lng *msec);
mtime_export str MTIMEtimestamp_diff(lng *ret, const timestamp *v1, const
timestamp *v2);
mtime_export str MTIMEtimestamp_diff_bulk(bat *ret, const bat *bid1, const bat
*bid2);
mtime_export str MTIMEtimestamp_inside_dst(bit *ret, const timestamp *p, const
tzone *z);
@@ -228,7 +233,7 @@ mtime_export str MTIMEunix_epoch(timesta
mtime_export str MTIMEepoch2int(int *res, const timestamp *ts);
mtime_export str MTIMEtimestamp(timestamp *ret, const int *sec);
mtime_export str MTIMEtimestamp_bulk(bat *ret, bat *bid);
-mtime_export str MTIMEtimestamp_lng(timestamp *ret, const lng *msecs);
+mtime_export str MTIMEtimestamp_lng(timestamp *ret, const lng *msec);
mtime_export str MTIMEtimestamp_lng_bulk(bat *ret, bat *bid);
mtime_export str MTIMEruleDef0(rule *ret, const int *m, const int *d, const
int *w, const int *h, const int *mint);
mtime_export str MTIMEruleDef1(rule *ret, const int *m, const char * const
*dnme, const int *w, const int *h, const int *mint);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list