Changeset: b0272c7fc280 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b0272c7fc280
Modified Files:
        
Branch: headless
Log Message:

Merge with gdk changes.


diffs (truncated from 2450 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1118,210 +1118,249 @@
  * in advance that the head-atom resp. tail-atom of a COL is variable sized.
  * @end itemize
  */
-/* NOTE: `p' is evaluated after a possible upgrade of the heap */
-#define COLputvalue(b, p, v, copyall)                                  \
+
+/* The arguments to COLset are:
+ * COL *b -- the COL being changed;
+ * oid o -- the (0-based, i.e. we add b->first) location;
+ * ptr v -- the pointer to the value (char * in case of string);
+ * int copyall -- only for varsized: when upgrading offset heap, copy all
+ */
+#define COLset(b, o, p, copyall)                                       \
        do {                                                            \
+               assert((b)->first < (b)->capacity);                     \
+               assert((o) < (b)->capacity - (b)->first);               \
                if ((b)->varsized && (b)->type) {                       \
                        var_t _d;                                       \
                        ptr _ptr;                                       \
-                       ATOMput((b)->type, (b)->vheap, &_d, v);         \
+                       ATOMput((b)->type, (b)->vheap, &_d, p);         \
                        if ((b)->width < SIZEOF_VAR_T &&                \
                            ((b)->width <= 2 ? _d - GDK_VAROFFSET : _d) >= 
((size_t) 1 << (8 * (b)->width))) { \
                                /* doesn't fit in current heap, upgrade it */ \
                                COLaccessBegin(b, USE_HEAP, MMAP_SEQUENTIAL); \
-                               GDKupgradevarheap((b), _d, (copyall));  \
-                               COLaccessEnd(b, USE_HEAP, MMAP_SEQUENTIAL);     
\
+                               if (GDKupgradevarheap((b), _d, (copyall)) == 
GDK_FAIL) \
+                                       goto bunins_failed;             \
+                               COLaccessEnd(b, USE_HEAP, MMAP_SEQUENTIAL); \
                        }                                               \
-                       _ptr = (p);                                     \
+                       _ptr = COLelement((b), (b)->first);             \
                        switch ((b)->width) {                           \
                        case 1:                                         \
-                               * (unsigned char *) _ptr = (unsigned char) (_d 
- GDK_VAROFFSET); \
+                               ((unsigned char *) _ptr)[o] = (unsigned char) 
(_d - GDK_VAROFFSET); \
                                break;                                  \
                        case 2:                                         \
-                               * (unsigned short *) _ptr = (unsigned short) 
(_d - GDK_VAROFFSET); \
+                               ((unsigned short *) _ptr)[o] = (unsigned short) 
(_d - GDK_VAROFFSET); \
                                break;                                  \
                        case 4:                                         \
-                               * (unsigned int *) _ptr = (unsigned int) _d; \
+                               ((unsigned int *) _ptr)[o] = (unsigned int) _d; 
\
                                break;                                  \
                        case 8:                                         \
-                               * (var_t *) _ptr = _d;                  \
+                               ((var_t *) _ptr)[o] = _d;               \
                                break;                                  \
                        }                                               \
                } else                                                  \
-                       ATOMput((b)->type, (b)->vheap, (p), v);         \
+                       ATOMput((b)->type, (b)->vheap, COLelement((b), (o)), 
(p)); \
        } while (0)
-#define COLputvalue_str(b, p, v, copyall)                              \
+
+/* The arguments to COLset_* are:
+ * COL *b -- the COL being changed;
+ * oid o -- the (0-based, i.e. we add b->first) location;
+ * TYPE v -- the value (char * in case of string);
+ * int copyall -- only for varsized: when upgrading offset heap, copy all
+ */
+#define COLset_str_err(b, o, v, copyall, onerr)                                
\
        do {                                                            \
                var_t _d;                                               \
                ptr _ptr;                                               \
-               if (strPut((b)->vheap, &_d, (v)) == 0)                  \
-                       goto bunins_failed;                             \
+               assert((b)->type == TYPE_str);                          \
+               assert((b)->first < (b)->capacity);                     \
+               assert((o) < (b)->capacity - (b)->first);               \
+               if (strPut((b)->vheap, &_d, (const char *) (v)) == 0)   \
+                       onerr;                                          \
                if ((b)->width < SIZEOF_VAR_T &&                        \
                    ((b)->width <= 2 ? _d - GDK_VAROFFSET : _d) >= ((size_t) 1 
<< (8 * (b)->width))) { \
                        /* doesn't fit in current heap, upgrade it */   \
                        COLaccessBegin(b, USE_HEAP, MMAP_SEQUENTIAL);   \
-                       GDKupgradevarheap((b), _d, (copyall));          \
+                       if (GDKupgradevarheap((b), _d, (copyall)) == GDK_FAIL) \
+                               onerr;                                  \
                        COLaccessEnd(b, USE_HEAP, MMAP_SEQUENTIAL);     \
                }                                                       \
-               _ptr = (p);                                             \
+               _ptr = COLelement((b), (b)->first);                     \
                switch ((b)->width) {                                   \
                case 1:                                                 \
-                       * (unsigned char *) _ptr = (unsigned char) (_d - 
GDK_VAROFFSET); \
+                       ((unsigned char *) _ptr)[o] = (unsigned char) (_d - 
GDK_VAROFFSET); \
                        break;                                          \
                case 2:                                                 \
-                       * (unsigned short *) _ptr = (unsigned short) (_d - 
GDK_VAROFFSET); \
+                       ((unsigned short *) _ptr)[o] = (unsigned short) (_d - 
GDK_VAROFFSET); \
                        break;                                          \
                case 4:                                                 \
-                       * (unsigned int *) _ptr = (unsigned int) _d;    \
+                       ((unsigned int *) _ptr)[o] = (unsigned int) _d; \
                        break;                                          \
                case 8:                                                 \
-                       * (var_t *) _ptr = _d;                          \
+                       ((var_t *) _ptr)[o] = _d;                       \
                        break;                                          \
                }                                                       \
        } while (0)
-#ifdef NDEBUG
-#define COLputvalue_TYPE(b, p, v, TYPE)                (* (TYPE *) (p) = * 
(TYPE *) (v))
-#else
-#define COLputvalue_TYPE(b, p, v, TYPE)                        \
-       do {                                            \
-               assert((b)->type == TYPE_##TYPE);       \
-               (* (TYPE *) (p) = * (TYPE *) (v));      \
-       } while (0)
-#endif
-#define COLputvalue_chr(b, p, v, copyall)      COLputvalue_TYPE(b, p, v, chr)
-#define COLputvalue_bte(b, p, v, copyall)      COLputvalue_TYPE(b, p, v, bte)
-#define COLputvalue_sht(b, p, v, copyall)      COLputvalue_TYPE(b, p, v, sht)
-#define COLputvalue_int(b, p, v, copyall)      COLputvalue_TYPE(b, p, v, int)
-#define COLputvalue_wrd(b, p, v, copyall)      COLputvalue_TYPE(b, p, v, wrd)
-#define COLputvalue_oid(b, p, v, copyall)      COLputvalue_TYPE(b, p, v, oid)
-#define COLputvalue_lng(b, p, v, copyall)      COLputvalue_TYPE(b, p, v, lng)
-#define COLputvalue_flt(b, p, v, copyall)      COLputvalue_TYPE(b, p, v, flt)
-#define COLputvalue_dbl(b, p, v, copyall)      COLputvalue_TYPE(b, p, v, dbl)
 
-#define COLreplacevalue(b, p, v)                                       \
+#define COLset_str(b, o, v, copyall)                           \
+       COLset_str_err(b, o, v, copyall, goto bunins_failed)
+
+#define COLset_TYPE(b, o, v, TYPE)                             \
+       (assert((b)->type == TYPE_##TYPE),                      \
+        assert((b)->first < (b)->capacity),                    \
+        assert((o) < (b)->capacity - (b)->first),              \
+        (((TYPE *) COLelement((b), (b)->first))[o] = (v)))
+
+#define COLset_chr(b, o, v, copyall)   COLset_TYPE(b, o, v, chr)
+#define COLset_bte(b, o, v, copyall)   COLset_TYPE(b, o, v, bte)
+#define COLset_sht(b, o, v, copyall)   COLset_TYPE(b, o, v, sht)
+#define COLset_int(b, o, v, copyall)   COLset_TYPE(b, o, v, int)
+#define COLset_wrd(b, o, v, copyall)   COLset_TYPE(b, o, v, wrd)
+#define COLset_oid(b, o, v, copyall)   COLset_TYPE(b, o, v, oid)
+#define COLset_lng(b, o, v, copyall)   COLset_TYPE(b, o, v, lng)
+#define COLset_flt(b, o, v, copyall)   COLset_TYPE(b, o, v, flt)
+#define COLset_dbl(b, o, v, copyall)   COLset_TYPE(b, o, v, dbl)
+
+#define COLreplacevalue(b, o, v)                                       \
        do {                                                            \
+               assert((b)->first < (b)->capacity);                     \
+               assert((o) < (b)->capacity - (b)->first);               \
                if ((b)->varsized && (b)->type) {                       \
                        var_t _d;                                       \
                        ptr _ptr;                                       \
-                       _ptr = (p);                                     \
+                       _ptr = COLelement((b), (b)->first);             \
                        switch ((b)->width) {                           \
                        case 1:                                         \
-                               _d = (var_t) * (unsigned char *) _ptr + 
GDK_VAROFFSET; \
+                               _d = (var_t) ((unsigned char *) _ptr)[o] + 
GDK_VAROFFSET; \
                                break;                                  \
                        case 2:                                         \
-                               _d = (var_t) * (unsigned short *) _ptr + 
GDK_VAROFFSET; \
+                               _d = (var_t) ((unsigned short *) _ptr)[o] + 
GDK_VAROFFSET; \
                                break;                                  \
                        case 4:                                         \
-                               _d = (var_t) * (unsigned int *) _ptr;   \
+                               _d = (var_t) ((unsigned int *) _ptr)[o]; \
                                break;                                  \
                        case 8:                                         \
-                               _d = * (var_t *) _ptr;                  \
+                               _d = ((var_t *) _ptr)[o];               \
                                break;                                  \
                        }                                               \
                        ATOMreplace((b)->type, (b)->vheap, &_d, v);     \
                        if ((b)->width < SIZEOF_VAR_T &&                \
                            ((b)->width <= 2 ? _d - GDK_VAROFFSET : _d) >= 
((size_t) 1 << (8 * (b)->width))) { \
                                /* doesn't fit in current heap, upgrade it */ \
-                               GDKupgradevarheap((b), _d, 0);          \
+                               if (GDKupgradevarheap((b), _d, 0) == GDK_FAIL) \
+                                       goto bunins_failed;             \
                        }                                               \
-                       _ptr = (p);                                     \
+                       _ptr = COLelement((b), (b)->first);             \
                        switch ((b)->width) {                           \
                        case 1:                                         \
-                               * (unsigned char *) _ptr = (unsigned char) (_d 
- GDK_VAROFFSET); \
+                               ((unsigned char *) _ptr)[o] = (unsigned char) 
(_d - GDK_VAROFFSET); \
                                break;                                  \
                        case 2:                                         \
-                               * (unsigned short *) _ptr = (unsigned short) 
(_d - GDK_VAROFFSET); \
+                               ((unsigned short *) _ptr)[o] = (unsigned short) 
(_d - GDK_VAROFFSET); \
                                break;                                  \
                        case 4:                                         \
-                               * (unsigned int *) _ptr = (unsigned int) _d; \
+                               ((unsigned int *) _ptr)[o] = (unsigned int) _d; 
\
                                break;                                  \
                        case 8:                                         \
-                               * (var_t *) _ptr = _d;                  \
+                               ((var_t *) _ptr)[o] = _d;               \
                                break;                                  \
                        }                                               \
                } else                                                  \
-                       ATOMreplace((b)->type, (b)->vheap, (p), v);     \
+                       ATOMreplace((b)->type, (b)->vheap, COLelement((b), 
(o)), v); \
        } while (0)
-#define COLreplacevalue_str(b, p, v, copyall)  COLputvalue_str(b, p, v, 
copyall)
-#define COLreplacevalue_chr(b, p, v, copyall)  COLputvalue_TYPE(b, p, v, chr)
-#define COLreplacevalue_bte(b, p, v, copyall)  COLputvalue_TYPE(b, p, v, bte)
-#define COLreplacevalue_sht(b, p, v, copyall)  COLputvalue_TYPE(b, p, v, sht)
-#define COLreplacevalue_int(b, p, v, copyall)  COLputvalue_TYPE(b, p, v, int)
-#define COLreplacevalue_wrd(b, p, v, copyall)  COLputvalue_TYPE(b, p, v, wrd)
-#define COLreplacevalue_oid(b, p, v, copyall)  COLputvalue_TYPE(b, p, v, oid)
-#define COLreplacevalue_lng(b, p, v, copyall)  COLputvalue_TYPE(b, p, v, lng)
-#define COLreplacevalue_flt(b, p, v, copyall)  COLputvalue_TYPE(b, p, v, flt)
-#define COLreplacevalue_dbl(b, p, v, copyall)  COLputvalue_TYPE(b, p, v, dbl)
 
-#define fastins_nocheck(b, p, v, vs)                           \
+#define COLreplacevalue_str(b, o, v, copyall)  COLset_str(b, o, v, copyall)
+#define COLreplacevalue_chr(b, o, v, copyall)  COLset_TYPE(b, o, v, chr)
+#define COLreplacevalue_bte(b, o, v, copyall)  COLset_TYPE(b, o, v, bte)
+#define COLreplacevalue_sht(b, o, v, copyall)  COLset_TYPE(b, o, v, sht)
+#define COLreplacevalue_int(b, o, v, copyall)  COLset_TYPE(b, o, v, int)
+#define COLreplacevalue_wrd(b, o, v, copyall)  COLset_TYPE(b, o, v, wrd)
+#define COLreplacevalue_oid(b, o, v, copyall)  COLset_TYPE(b, o, v, oid)
+#define COLreplacevalue_lng(b, o, v, copyall)  COLset_TYPE(b, o, v, lng)
+#define COLreplacevalue_flt(b, o, v, copyall)  COLset_TYPE(b, o, v, flt)
+#define COLreplacevalue_dbl(b, o, v, copyall)  COLset_TYPE(b, o, v, dbl)
+
+#define COLget_str(b, o)       
((char*)(b)->vheap->base+VarHeapVal((b)->heap.base, (o), (b)->width))
+
+#define COLget_TYPE(b, o, TYPE)                        \
+       (assert(b->type == TYPE_##TYPE),                \
+        (((TYPE *) COLelement(b, b->first))[o]))
+
+#define COLget_bte(b, o)       COLget_TYPE(b, o, bte)
+#define COLget_chr(b, o)       COLget_TYPE(b, o, chr)
+#define COLget_sht(b, o)       COLget_TYPE(b, o, sht)
+#define COLget_int(b, o)       COLget_TYPE(b, o, int)
+#define COLget_wrd(b, o)       COLget_TYPE(b, o, wrd)
+#define COLget_oid(b, o)       COLget_TYPE(b, o, oid)
+#define COLget_lng(b, o)       COLget_TYPE(b, o, lng)
+#define COLget_flt(b, o)       COLget_TYPE(b, o, flt)
+#define COLget_dbl(b, o)       COLget_TYPE(b, o, dbl)
+
+/* special version for TYPE_oid / TYPE_void columns */
+#define COLget_OID(b, o)                                               \
+       ((b)->type == TYPE_void ?                                       \
+        ((b)->seqbase == oid_nil ? oid_nil : (b)->seqbase + (o)) :     \
+        COLget_oid(b, o))
+
+#define fastins_nocheck(b, o, p, vs)                           \
        do {                                                    \
                assert((b)->width == (vs));                     \
                (b)->heap.free += (vs);                         \
-               COLputvalue((b), COLelement((b), (p)), (v), 0); \
+               COLset((b), (o), (p), 0);                       \
        } while (0)
-#define fastins_nocheck_TYPE(b, p, v, TYPE)            \
+#define fastins_nocheck_TYPE(b, o, v, TYPE)            \
        do {                                            \
                assert((b)->width == sizeof(TYPE));     \
                (b)->heap.free += sizeof(TYPE);         \
-               COLputvalue_##TYPE((b), (p), (v), 0);   \
+               COLset_##TYPE((b), (o), (v), 0);        \
        } while (0)
-#define fastins_nocheck_bte(b, p, v)   fastins_nocheck_TYPE(b, p, v, bte)
-#define fastins_nocheck_chr(b, p, v)   fastins_nocheck_TYPE(b, p, v, chr)
-#define fastins_nocheck_sht(b, p, v)   fastins_nocheck_TYPE(b, p, v, sht)
-#define fastins_nocheck_int(b, p, v)   fastins_nocheck_TYPE(b, p, v, int)
-#define fastins_nocheck_wrd(b, p, v)   fastins_nocheck_TYPE(b, p, v, wrd)
-#define fastins_nocheck_oid(b, p, v)   fastins_nocheck_TYPE(b, p, v, oid)
-#define fastins_nocheck_lng(b, p, v)   fastins_nocheck_TYPE(b, p, v, lng)
-#define fastins_nocheck_flt(b, p, v)   fastins_nocheck_TYPE(b, p, v, flt)
-#define fastins_nocheck_dbl(b, p, v)   fastins_nocheck_TYPE(b, p, v, dbl)
-#define fastins_nocheck_str(b, p, v)   fastins_nocheck_TYPE(b, p, v, str)
+#define fastins_nocheck_bte(b, o, v)   fastins_nocheck_TYPE(b, o, v, bte)
+#define fastins_nocheck_chr(b, o, v)   fastins_nocheck_TYPE(b, o, v, chr)
+#define fastins_nocheck_sht(b, o, v)   fastins_nocheck_TYPE(b, o, v, sht)
+#define fastins_nocheck_int(b, o, v)   fastins_nocheck_TYPE(b, o, v, int)
+#define fastins_nocheck_wrd(b, o, v)   fastins_nocheck_TYPE(b, o, v, wrd)
+#define fastins_nocheck_oid(b, o, v)   fastins_nocheck_TYPE(b, o, v, oid)
+#define fastins_nocheck_lng(b, o, v)   fastins_nocheck_TYPE(b, o, v, lng)
+#define fastins_nocheck_flt(b, o, v)   fastins_nocheck_TYPE(b, o, v, flt)
+#define fastins_nocheck_dbl(b, o, v)   fastins_nocheck_TYPE(b, o, v, dbl)
+#define fastins_nocheck_str(b, o, v)   fastins_nocheck_TYPE(b, o, v, str)
 
-#define bunfastins_nocheck(b, p, v, vs)                \
+#define bunfastins_nocheck(b, o, p, vs)                \
        do {                                    \
-               fastins_nocheck(b, p, v, vs);   \
+               fastins_nocheck(b, o, p, vs);   \
                (b)->count++;                   \
        } while (0)
-#define bunfastins_nocheck_TYPE(b, p, v, TYPE)         \
+#define bunfastins_nocheck_TYPE(b, o, v, TYPE)         \
        do {                                            \
-               fastins_nocheck_TYPE(b, p, v, TYPE);    \
+               fastins_nocheck_TYPE(b, o, v, TYPE);    \
                (b)->count++;                           \
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to