Changeset: 63a5f7d817df for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=63a5f7d817df
Modified Files:
gdk/gdk_calc.c
Branch: int128
Log Message:
added int128 / "hge" support in gdk/gdk_calc.c (except multiplication)
multiplication still needs to be done,
updating the existing use of type __int128 accordingly
diffs (truncated from 4063 to 300 lines):
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -36,15 +36,31 @@
* the candidates, all other values are NIL (so that the output is
* still aligned). */
-/* format strings for the six basic types we deal with */
+/* format strings for the seven/eight basic types we deal with */
#define FMTbte "%d"
#define FMTsht "%d"
#define FMTint "%d"
#define FMTlng LLFMT
+#ifdef HAVE_HGE
+#define FMThge "%.40g"
+#endif
#define FMTflt "%.9g"
#define FMTdbl "%.17g"
#define FMToid OIDFMT
+/* casts; only required for type hge, since there is no genuine format
+ * string for it (i.e., for __int128) (yet?) */
+#define CSTbte
+#define CSTsht
+#define CSTint
+#define CSTlng
+#ifdef HAVE_HGE
+#define CSThge (dbl)
+#endif
+#define CSTflt
+#define CSTdbl
+#define CSToid
+
/* Most of the internal routines return a count of the number of NIL
* values they produced. They indicate an error by returning a value
* >= BUN_NONE. BUN_NONE means that the error was dealt with by
@@ -156,8 +172,8 @@ checkbats(BAT *b1, BAT *b2, const char *
GDKerror("%s: shift operand too large
in " \
#FUNC"("FMT##TYPE1","FMT##TYPE2").\n", \
func, \
- ((const TYPE1 *) lft)[i], \
- ((const TYPE2 *) rgt)[j]); \
+ CST##TYPE1 ((const TYPE1 *)
lft)[i], \
+ CST##TYPE2 ((const TYPE2 *)
rgt)[j]); \
goto checkfail; \
} \
((TYPE3 *)dst)[k] = TYPE3##_nil; \
@@ -210,6 +226,11 @@ BATcalcnot(BAT *b, BAT *s)
case TYPE_lng:
UNARY_2TYPE_FUNC(lng, lng, NOT);
break;
+#ifdef HAVE_HGE
+ case TYPE_hge:
+ UNARY_2TYPE_FUNC(hge, hge, NOT);
+ break;
+#endif
default:
BBPunfix(bn->batCacheid);
GDKerror("BATcalcnot: type %s not supported.\n",
@@ -275,6 +296,14 @@ VARcalcnot(ValPtr ret, const ValRecord *
else
ret->val.lval = ~v->val.lval;
break;
+#ifdef HAVE_HGE
+ case TYPE_hge:
+ if (v->val.hval == hge_nil)
+ ret->val.hval = hge_nil;
+ else
+ ret->val.hval = ~v->val.hval;
+ break;
+#endif
default:
GDKerror("VARcalcnot: bad input type %s.\n",
ATOMname(v->vtype));
@@ -318,6 +347,11 @@ BATcalcnegate(BAT *b, BAT *s)
case TYPE_lng:
UNARY_2TYPE_FUNC(lng, lng, NEGATE);
break;
+#ifdef HAVE_HGE
+ case TYPE_hge:
+ UNARY_2TYPE_FUNC(hge, hge, NEGATE);
+ break;
+#endif
case TYPE_flt:
UNARY_2TYPE_FUNC(flt, flt, NEGATE);
break;
@@ -382,6 +416,14 @@ VARcalcnegate(ValPtr ret, const ValRecor
else
ret->val.lval = -v->val.lval;
break;
+#ifdef HAVE_HGE
+ case TYPE_hge:
+ if (v->val.hval == hge_nil)
+ ret->val.hval = hge_nil;
+ else
+ ret->val.hval = -v->val.hval;
+ break;
+#endif
case TYPE_flt:
if (v->val.fval == flt_nil)
ret->val.fval = flt_nil;
@@ -435,6 +477,11 @@ BATcalcabsolute(BAT *b, BAT *s)
case TYPE_lng:
UNARY_2TYPE_FUNC(lng, lng, ABSOLUTE);
break;
+#ifdef HAVE_HGE
+ case TYPE_hge:
+ UNARY_2TYPE_FUNC(hge, hge, ABSOLUTE);
+ break;
+#endif
case TYPE_flt:
UNARY_2TYPE_FUNC(flt, flt, ABSOLUTE);
break;
@@ -501,6 +548,14 @@ VARcalcabsolute(ValPtr ret, const ValRec
else
ret->val.lval = ABSOLUTE(v->val.lval);
break;
+#ifdef HAVE_HGE
+ case TYPE_hge:
+ if (v->val.hval == hge_nil)
+ ret->val.hval = hge_nil;
+ else
+ ret->val.hval = ABSOLUTE(v->val.hval);
+ break;
+#endif
case TYPE_flt:
if (v->val.fval == flt_nil)
ret->val.fval = flt_nil;
@@ -556,6 +611,11 @@ BATcalciszero(BAT *b, BAT *s)
case TYPE_lng:
UNARY_2TYPE_FUNC(lng, bit, ISZERO);
break;
+#ifdef HAVE_HGE
+ case TYPE_hge:
+ UNARY_2TYPE_FUNC(hge, bit, ISZERO);
+ break;
+#endif
case TYPE_flt:
UNARY_2TYPE_FUNC(flt, bit, ISZERO);
break;
@@ -619,6 +679,14 @@ VARcalciszero(ValPtr ret, const ValRecor
else
ret->val.btval = ISZERO(v->val.lval);
break;
+#ifdef HAVE_HGE
+ case TYPE_hge:
+ if (v->val.hval == hge_nil)
+ ret->val.btval = bit_nil;
+ else
+ ret->val.btval = ISZERO(v->val.hval);
+ break;
+#endif
case TYPE_flt:
if (v->val.fval == flt_nil)
ret->val.btval = bit_nil;
@@ -675,6 +743,11 @@ BATcalcsign(BAT *b, BAT *s)
case TYPE_lng:
UNARY_2TYPE_FUNC(lng, bte, SIGN);
break;
+#ifdef HAVE_HGE
+ case TYPE_hge:
+ UNARY_2TYPE_FUNC(hge, bte, SIGN);
+ break;
+#endif
case TYPE_flt:
UNARY_2TYPE_FUNC(flt, bte, SIGN);
break;
@@ -741,6 +814,14 @@ VARcalcsign(ValPtr ret, const ValRecord
else
ret->val.btval = SIGN(v->val.lval);
break;
+#ifdef HAVE_HGE
+ case TYPE_hge:
+ if (v->val.hval == hge_nil)
+ ret->val.btval = bte_nil;
+ else
+ ret->val.btval = SIGN(v->val.hval);
+ break;
+#endif
case TYPE_flt:
if (v->val.fval == flt_nil)
ret->val.btval = bte_nil;
@@ -834,6 +915,11 @@ BATcalcisnil(BAT *b, BAT *s)
case TYPE_lng:
ISNIL_TYPE(lng);
break;
+#ifdef HAVE_HGE
+ case TYPE_hge:
+ ISNIL_TYPE(hge);
+ break;
+#endif
case TYPE_flt:
ISNIL_TYPE(flt);
break;
@@ -892,7 +978,7 @@ VARcalcisnotnil(ValPtr ret, const ValRec
do { \
GDKerror("22003!overflow in calculation " \
FMT##TYPE1 OP FMT##TYPE2 ".\n", \
- lft[i], rgt[j]); \
+ CST##TYPE1 lft[i], CST##TYPE2 rgt[j]);
\
return BUN_NONE; \
} while (0)
@@ -957,6 +1043,9 @@ ADD_3TYPE_enlarge(bte, bte, sht)
#ifdef FULL_IMPLEMENTATION
ADD_3TYPE_enlarge(bte, bte, int)
ADD_3TYPE_enlarge(bte, bte, lng)
+#ifdef HAVE_HGE
+ADD_3TYPE_enlarge(bte, bte, hge)
+#endif
ADD_3TYPE_enlarge(bte, bte, flt)
ADD_3TYPE_enlarge(bte, bte, dbl)
#endif
@@ -964,20 +1053,36 @@ ADD_3TYPE(bte, sht, sht)
ADD_3TYPE_enlarge(bte, sht, int)
#ifdef FULL_IMPLEMENTATION
ADD_3TYPE_enlarge(bte, sht, lng)
+#ifdef HAVE_HGE
+ADD_3TYPE_enlarge(bte, sht, hge)
+#endif
ADD_3TYPE_enlarge(bte, sht, flt)
ADD_3TYPE_enlarge(bte, sht, dbl)
#endif
ADD_3TYPE(bte, int, int)
ADD_3TYPE_enlarge(bte, int, lng)
#ifdef FULL_IMPLEMENTATION
+#ifdef HAVE_HGE
+ADD_3TYPE_enlarge(bte, int, hge)
+#endif
ADD_3TYPE_enlarge(bte, int, flt)
ADD_3TYPE_enlarge(bte, int, dbl)
#endif
ADD_3TYPE(bte, lng, lng)
+#ifdef HAVE_HGE
+ADD_3TYPE_enlarge(bte, lng, hge)
+#endif
#ifdef FULL_IMPLEMENTATION
ADD_3TYPE_enlarge(bte, lng, flt)
ADD_3TYPE_enlarge(bte, lng, dbl)
#endif
+#ifdef HAVE_HGE
+ADD_3TYPE(bte, hge, hge)
+#ifdef FULL_IMPLEMENTATION
+ADD_3TYPE_enlarge(bte, hge, flt)
+ADD_3TYPE_enlarge(bte, hge, dbl)
+#endif
+#endif
ADD_3TYPE(bte, flt, flt)
ADD_3TYPE_enlarge(bte, flt, dbl)
ADD_3TYPE(bte, dbl, dbl)
@@ -985,6 +1090,9 @@ ADD_3TYPE(sht, bte, sht)
ADD_3TYPE_enlarge(sht, bte, int)
#ifdef FULL_IMPLEMENTATION
ADD_3TYPE_enlarge(sht, bte, lng)
+#ifdef HAVE_HGE
+ADD_3TYPE_enlarge(sht, bte, hge)
+#endif
ADD_3TYPE_enlarge(sht, bte, flt)
ADD_3TYPE_enlarge(sht, bte, dbl)
#endif
@@ -992,72 +1100,156 @@ ADD_3TYPE(sht, sht, sht)
ADD_3TYPE_enlarge(sht, sht, int)
#ifdef FULL_IMPLEMENTATION
ADD_3TYPE_enlarge(sht, sht, lng)
+#ifdef HAVE_HGE
+ADD_3TYPE_enlarge(sht, sht, hge)
+#endif
ADD_3TYPE_enlarge(sht, sht, flt)
ADD_3TYPE_enlarge(sht, sht, dbl)
#endif
ADD_3TYPE(sht, int, int)
ADD_3TYPE_enlarge(sht, int, lng)
#ifdef FULL_IMPLEMENTATION
+#ifdef HAVE_HGE
+ADD_3TYPE_enlarge(sht, int, hge)
+#endif
ADD_3TYPE_enlarge(sht, int, flt)
ADD_3TYPE_enlarge(sht, int, dbl)
#endif
ADD_3TYPE(sht, lng, lng)
+#ifdef HAVE_HGE
+ADD_3TYPE_enlarge(sht, lng, hge)
+#endif
#ifdef FULL_IMPLEMENTATION
ADD_3TYPE_enlarge(sht, lng, flt)
ADD_3TYPE_enlarge(sht, lng, dbl)
#endif
+#ifdef HAVE_HGE
+ADD_3TYPE(sht, hge, hge)
+#ifdef FULL_IMPLEMENTATION
+ADD_3TYPE_enlarge(sht, hge, flt)
+ADD_3TYPE_enlarge(sht, hge, dbl)
+#endif
+#endif
ADD_3TYPE(sht, flt, flt)
ADD_3TYPE_enlarge(sht, flt, dbl)
ADD_3TYPE(sht, dbl, dbl)
ADD_3TYPE(int, bte, int)
ADD_3TYPE_enlarge(int, bte, lng)
#ifdef FULL_IMPLEMENTATION
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list