Changeset: 786895ff8e3a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/786895ff8e3a
Modified Files:
gdk/gdk_calc_private.h
gdk/gdk_join.c
monetdb5/modules/mal/pp_algebra.c
monetdb_config.h.in
tools/monetdbe/monetdbe.c
Branch: default
Log Message:
Unify 128 bit integer types.
Even if we don't support the type hge, the compiler may still support
128 bit integers. But if it does, it may use the name __int128 or
__int128_t. If either type is available, we define a type int128_t and
define the macro HAVE_INT128_T. So, HAVE_HGE implies HAVE_INT128_T, but
not the other way round.
diffs (123 lines):
diff --git a/gdk/gdk_calc_private.h b/gdk/gdk_calc_private.h
--- a/gdk/gdk_calc_private.h
+++ b/gdk/gdk_calc_private.h
@@ -149,9 +149,9 @@
#ifdef HAVE_HGE
#define LNGMUL_CHECK(lft, rgt, dst, max, on_overflow) \
MULI4_WITH_CHECK(lft, rgt, lng, dst, max, hge, on_overflow)
-#elif defined(HAVE___INT128)
+#elif defined(HAVE_INT128_T)
#define LNGMUL_CHECK(lft, rgt, dst, max, on_overflow) \
- MULI4_WITH_CHECK(lft, rgt, lng, dst, max, __int128, on_overflow)
+ MULI4_WITH_CHECK(lft, rgt, lng, dst, max, int128_t, on_overflow)
#elif defined(_MSC_VER) && defined(_M_AMD64) && !defined(__INTEL_COMPILER)
#include <intrin.h>
#pragma intrinsic(_mul128)
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -5320,28 +5320,11 @@ bandjoin(BAT **r1p, BAT **r2p, BATiter *
break;
}
#else
-#ifdef HAVE___INT128
+#ifdef HAVE_INT128_T
case TYPE_lng: {
if (is_lng_nil(*(const lng *) vr))
continue;
- __int128 v1 = (__int128) *(const lng *) vr, v2;
- v2 = v1;
- v1 -= *(const lng *)c1;
- if (*(const lng *)vl <= v1 &&
- (!linc || *(const lng *)vl != v1))
- continue;
- v2 += *(const lng *)c2;
- if (*(const lng *)vl >= v2 &&
- (!hinc || *(const lng *)vl != v2))
- continue;
- break;
- }
-#else
-#ifdef HAVE___INT128_T
- case TYPE_lng: {
- if (is_lng_nil(*(const lng *) vr))
- continue;
- __int128_t v1 = (__int128_t) *(const lng *) vr,
v2;
+ int128_t v1 = (int128_t) *(const lng *) vr, v2;
v2 = v1;
v1 -= *(const lng *)c1;
if (*(const lng *)vl <= v1 &&
@@ -5382,7 +5365,6 @@ bandjoin(BAT **r1p, BAT **r2p, BATiter *
}
#endif
#endif
-#endif
#ifdef HAVE_HGE
case TYPE_hge: {
if (is_hge_nil(*(const hge *) vr))
diff --git a/monetdb5/modules/mal/pp_algebra.c
b/monetdb5/modules/mal/pp_algebra.c
--- a/monetdb5/modules/mal/pp_algebra.c
+++ b/monetdb5/modules/mal/pp_algebra.c
@@ -346,7 +346,7 @@ mulmod(lng a, lng b, lng c)
* Note that the last term is only the fraction (i.e. strictly between
* -1 and 1), so (a*b)%c is the remainder.
*/
-#ifdef HAVE___INT128
+#ifdef HAVE_INT128_T
#define avg_aggr_comb(T, a1, r1, n1, a2, r2, n2)
\
do {
\
if (is_##T##_nil(a2)) {
\
@@ -365,8 +365,8 @@ mulmod(lng a, lng b, lng c)
a = 0;
\
r = 0;
\
} else {
\
- a = (T) ((a1 / n) * N1 + ((a1 % n) * (__int128)
N1) / n + \
- (a2 / n) * N2 + ((a2 % n) *
(__int128) N2) / n + \
+ a = (T) ((a1 / n) * N1 + ((a1 % n) * (int128_t)
N1) / n + \
+ (a2 / n) * N2 + ((a2 % n) *
(int128_t) N2) / n + \
(r1 + r2) / n);
\
r = mulmod(a1, N1, n) + mulmod(a2, N2, n) + (r1
+ r2) % n; \
while (r >= n) {
\
diff --git a/monetdb_config.h.in b/monetdb_config.h.in
--- a/monetdb_config.h.in
+++ b/monetdb_config.h.in
@@ -508,16 +508,16 @@ typedef int64_t ssize_t;
#cmakedefine HAVE___UINT128_T 1
#cmakedefine HAVE_HGE 1
-#ifdef HAVE_HGE
/* define types int128_t and uint128_t for 128 bit integers in the style
* of stdint.h */
#ifdef HAVE___INT128
typedef __int128 int128_t;
typedef unsigned __int128 uint128_t;
+#define HAVE_INT128_T 1
#elif defined(HAVE___INT128_T) && defined(HAVE___UINT128_T)
typedef __int128_t int128_t;
typedef __uint128_t uint128_t;
-#endif
+#define HAVE_INT128_T 1
#endif
// End Section: monetdb configure sizes
diff --git a/tools/monetdbe/monetdbe.c b/tools/monetdbe/monetdbe.c
--- a/tools/monetdbe/monetdbe.c
+++ b/tools/monetdbe/monetdbe.c
@@ -2004,7 +2004,7 @@ GENERATE_BASE_FUNCTIONS(int8_t, bool, bi
GENERATE_BASE_FUNCTIONS(int32_t, int32_t, int)
GENERATE_BASE_FUNCTIONS(int64_t, int64_t, lng)
#ifdef HAVE_HGE
- GENERATE_BASE_FUNCTIONS(__int128, int128_t, hge)
+ GENERATE_BASE_FUNCTIONS(int128_t, int128_t, hge)
#endif
GENERATE_BASE_FUNCTIONS(size_t, size_t, oid)
@@ -2718,7 +2718,7 @@ monetdbe_result_fetch(monetdbe_result* m
GENERATE_BAT_INPUT(b, int64_t, int64_t, lng);
#ifdef HAVE_HGE
} else if (bat_type == TYPE_hge) {
- GENERATE_BAT_INPUT(b, __int128, int128_t, hge);
+ GENERATE_BAT_INPUT(b, int128_t, int128_t, hge);
#endif
} else if (bat_type == TYPE_flt) {
GENERATE_BAT_INPUT(b, float, float, flt);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]