Changeset: c627c18f06c8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c627c18f06c8
Modified Files:
        gdk/gdk.h
        gdk/gdk_search.c
        gdk/gdk_search.h
Branch: default
Log Message:

define and use BUN8, BUN8type, & BUN8_NONE only when they make sense,
i.e., only when SIZEOF_BUN > 4


diffs (89 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -555,15 +555,21 @@ typedef size_t BUN;
 #define BUN1 1
 #define BUN2 2
 #define BUN4 4
+#if SIZEOF_BUN > 4
 #define BUN8 8
+#endif
 typedef uint8_t  BUN1type;
 typedef uint16_t BUN2type;
 typedef uint32_t BUN4type;
+#if SIZEOF_BUN > 4
 typedef uint64_t BUN8type;
+#endif
 #define BUN1_NONE ((BUN1type) 0xFF)
 #define BUN2_NONE ((BUN2type) 0xFFFF)
 #define BUN4_NONE ((BUN4type) 0xFFFFFFFF)
+#if SIZEOF_BUN > 4
 #define BUN8_NONE ((BUN8type) LL_CONSTANT(0xFFFFFFFFFFFFFFFF))
+#endif
 
 
 /*
diff --git a/gdk/gdk_search.c b/gdk/gdk_search.c
--- a/gdk/gdk_search.c
+++ b/gdk/gdk_search.c
@@ -96,8 +96,12 @@ static int
 HASHwidth(BUN hashsize){
        if (hashsize <= (BUN) BUN1_NONE) return BUN1;
        if (hashsize <= (BUN) BUN2_NONE) return BUN2;
+#if SIZEOF_BUN <= 4
+       return BUN4;
+#else
        if (hashsize <= (BUN) BUN4_NONE) return BUN4;
        return BUN8;
+#endif
 }
 
 BUN
@@ -145,9 +149,11 @@ HASHnew(Heap *hp, int tpe, BUN size, BUN
        case BUN4:
                h->nil = (BUN) BUN4_NONE;
                break;
+#if SIZEOF_BUN > 4
        case BUN8:
                h->nil = (BUN) BUN8_NONE;
                break;
+#endif
        default:
                assert(0);
        }
diff --git a/gdk/gdk_search.h b/gdk/gdk_search.h
--- a/gdk/gdk_search.h
+++ b/gdk/gdk_search.h
@@ -37,6 +37,24 @@ gdk_export BUN HASHlist(Hash *h, BUN i);
 #define HASHnil(H)     H->nil
 
 /* play around with h->Hash[i] and h->Link[j] */
+#if SIZEOF_BUN <= 4
+#define HASHget(h,i)   \
+       ((BUN)  (h->width == BUN4 ? ((BUN4type*) h->Hash)[i] : \
+               (h->width == BUN2 ? ((BUN2type*) h->Hash)[i] : \
+                                   ((BUN1type*) h->Hash)[i] )))
+#define HASHput(h,i,v) \
+       (void)  (h->width == BUN4 ? (((BUN4type*) h->Hash)[i] = (BUN4type) v) : 
\
+               (h->width == BUN2 ? (((BUN2type*) h->Hash)[i] = (BUN2type) v) : 
\
+                                   (((BUN1type*) h->Hash)[i] = (BUN1type) v) ))
+#define HASHgetlink(h,i)       \
+       ((BUN)  (h->width == BUN4 ? ((BUN4type*) h->Link)[i] : \
+               (h->width == BUN2 ? ((BUN2type*) h->Link)[i] : \
+                                   ((BUN1type*) h->Link)[i] )))
+#define HASHputlink(h,i,v)     \
+       (void)  (h->width == BUN4 ? (((BUN4type*) h->Link)[i] = (BUN4type) v) : 
\
+               (h->width == BUN2 ? (((BUN2type*) h->Link)[i] = (BUN2type) v) : 
\
+                                   (((BUN1type*) h->Link)[i] = (BUN1type) v) ))
+#else
 #define HASHget(h,i)   \
        ((BUN)  (h->width == BUN8 ? ((BUN8type*) h->Hash)[i] : \
                (h->width == BUN4 ? ((BUN4type*) h->Hash)[i] : \
@@ -57,6 +75,7 @@ gdk_export BUN HASHlist(Hash *h, BUN i);
                (h->width == BUN4 ? (((BUN4type*) h->Link)[i] = (BUN4type) v) : 
\
                (h->width == BUN2 ? (((BUN2type*) h->Link)[i] = (BUN2type) v) : 
\
                                    (((BUN1type*) h->Link)[i] = (BUN1type) v) 
)))
+#endif
 
 #define mix_sht(X)            (((X)>>7)^(X))
 #define mix_int(X)            (((X)>>7)^((X)>>13)^((X)>>21)^(X))
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to