Changeset: b41f8504324f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b41f8504324f
Modified Files:
        gdk/gdk.h
        gdk/gdk_atoms.h
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_calc.c
        gdk/gdk_project.c
        gdk/gdk_unique.c
        monetdb5/modules/atoms/batxml.c
        monetdb5/modules/atoms/json.c
        monetdb5/modules/kernel/batcolor.c
        monetdb5/modules/kernel/batstr.c
        monetdb5/modules/mal/pcre.c
Branch: default
Log Message:

Fixes so that this compiles with --enable-optimize --enable-strict on Fedora 28.
Some new macro variants for bunfastapp were introduced for variable
and fixed type bats.


diffs (truncated from 1336 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1045,52 +1045,6 @@ gdk_export bte ATOMelmshift(int sz);
                        ATOMputFIX((b)->ttype, (p), v);                 \
                }                                                       \
        } while (false)
-#define Treplacevalue(b, p, v)                                         \
-       do {                                                            \
-               if ((b)->tvarsized && (b)->ttype) {                     \
-                       var_t _d;                                       \
-                       ptr _ptr;                                       \
-                       _ptr = (p);                                     \
-                       switch ((b)->twidth) {                          \
-                       case 1:                                         \
-                               _d = (var_t) * (uint8_t *) _ptr + 
GDK_VAROFFSET; \
-                               break;                                  \
-                       case 2:                                         \
-                               _d = (var_t) * (uint16_t *) _ptr + 
GDK_VAROFFSET; \
-                               break;                                  \
-                       case 4:                                         \
-                               _d = (var_t) * (uint32_t *) _ptr;       \
-                               break;                                  \
-                       case 8:                                         \
-                               _d = * (var_t *) _ptr;                  \
-                               break;                                  \
-                       }                                               \
-                       ATOMreplaceVAR((b)->ttype, (b)->tvheap, &_d, v); \
-                       if ((b)->twidth < SIZEOF_VAR_T &&               \
-                           ((b)->twidth <= 2 ? _d - GDK_VAROFFSET : _d) >= 
((size_t) 1 << (8 * (b)->twidth))) { \
-                               /* doesn't fit in current heap, upgrade it */ \
-                               if (GDKupgradevarheap((b), _d, false, 
(b)->batRestricted == BAT_READ) != GDK_SUCCEED) \
-                                       goto bunins_failed;             \
-                       }                                               \
-                       _ptr = (p);                                     \
-                       switch ((b)->twidth) {                          \
-                       case 1:                                         \
-                               * (uint8_t *) _ptr = (uint8_t) (_d - 
GDK_VAROFFSET); \
-                               break;                                  \
-                       case 2:                                         \
-                               * (uint16_t *) _ptr = (uint16_t) (_d - 
GDK_VAROFFSET); \
-                               break;                                  \
-                       case 4:                                         \
-                               * (uint32_t *) _ptr = (uint32_t) _d;    \
-                               break;                                  \
-                       case 8:                                         \
-                               * (var_t *) _ptr = _d;                  \
-                               break;                                  \
-                       }                                               \
-               } else {                                                \
-                       ATOMreplaceFIX((b)->ttype, (p), v);             \
-               }                                                       \
-       } while (false)
 #else
 #define Tputvalue(b, p, v, copyall)                                    \
        do {                                                            \
@@ -1120,46 +1074,6 @@ gdk_export bte ATOMelmshift(int sz);
                        ATOMputFIX((b)->ttype, (p), v);                 \
                }                                                       \
        } while (false)
-#define Treplacevalue(b, p, v)                                         \
-       do {                                                            \
-               if ((b)->tvarsized && (b)->ttype) {                     \
-                       var_t _d;                                       \
-                       ptr _ptr;                                       \
-                       _ptr = (p);                                     \
-                       switch ((b)->twidth) {                          \
-                       case 1:                                         \
-                               _d = (var_t) * (uint8_t *) _ptr + 
GDK_VAROFFSET; \
-                               break;                                  \
-                       case 2:                                         \
-                               _d = (var_t) * (uint16_t *) _ptr + 
GDK_VAROFFSET; \
-                               break;                                  \
-                       case 4:                                         \
-                               _d = * (var_t *) _ptr;                  \
-                               break;                                  \
-                       }                                               \
-                       ATOMreplaceVAR((b)->ttype, (b)->tvheap, &_d, v); \
-                       if ((b)->twidth < SIZEOF_VAR_T &&               \
-                           ((b)->twidth <= 2 ? _d - GDK_VAROFFSET : _d) >= 
((size_t) 1 << (8 * (b)->twidth))) { \
-                               /* doesn't fit in current heap, upgrade it */ \
-                               if (GDKupgradevarheap((b), _d, false, 
(b)->batRestricted == BAT_READ) != GDK_SUCCEED) \
-                                       goto bunins_failed;             \
-                       }                                               \
-                       _ptr = (p);                                     \
-                       switch ((b)->twidth) {                          \
-                       case 1:                                         \
-                               * (uint8_t *) _ptr = (uint8_t) (_d - 
GDK_VAROFFSET); \
-                               break;                                  \
-                       case 2:                                         \
-                               * (uint16_t *) _ptr = (uint16_t) (_d - 
GDK_VAROFFSET); \
-                               break;                                  \
-                       case 4:                                         \
-                               * (var_t *) _ptr = _d;                  \
-                               break;                                  \
-                       }                                               \
-               } else {                                                \
-                       ATOMreplaceFIX((b)->ttype, (p), v);             \
-               }                                                       \
-       } while (false)
 #endif
 #define tfastins_nocheck(b, p, v, s)                   \
        do {                                            \
@@ -1168,30 +1082,85 @@ gdk_export bte ATOMelmshift(int sz);
                Tputvalue((b), Tloc((b), (p)), (v), 0); \
        } while (false)
 
-#define bunfastapp_nocheck(b, p, t, ts)                \
+#define bunfastapp_nocheck(b, p, v, ts)                \
        do {                                    \
-               tfastins_nocheck(b, p, t, ts);  \
+               tfastins_nocheck(b, p, v, ts);  \
                (b)->batCount++;                \
        } while (false)
 
-#define bunfastapp_nocheck_inc(b, p, t)                        \
-       do {                                            \
-               bunfastapp_nocheck(b, p, t, Tsize(b));  \
-               p++;                                    \
+#define bunfastapp(b, v)                                               \
+       do {                                                            \
+               if (BATcount(b) >= BATcapacity(b)) {                            
\
+                       if (BATcount(b) == BUN_MAX) {                   \
+                               GDKerror("bunfastapp: too many elements to 
accomodate (" BUNFMT ")\n", BUN_MAX); \
+                               goto bunins_failed;                     \
+                       }                                               \
+                       if (BATextend((b), BATgrows(b)) != GDK_SUCCEED) \
+                               goto bunins_failed;                     \
+               }                                                       \
+               bunfastapp_nocheck(b, (b)->batCount, v, Tsize(b));      \
        } while (false)
 
-#define bunfastapp(b, t)                                               \
+#define bunfastappTYPE(TYPE, b, v)                                     \
        do {                                                            \
-               BUN _p = BUNlast(b);                                    \
-               if (_p >= BATcapacity(b)) {                             \
-                       if (_p == BUN_MAX || BATcount(b) == BUN_MAX) {  \
+               if (BATcount(b) >= BATcapacity(b)) {                    \
+                       if (BATcount(b) == BUN_MAX) {   \
                                GDKerror("bunfastapp: too many elements to 
accomodate (" BUNFMT ")\n", BUN_MAX); \
                                goto bunins_failed;                     \
                        }                                               \
                        if (BATextend((b), BATgrows(b)) != GDK_SUCCEED) \
                                goto bunins_failed;                     \
                }                                                       \
-               bunfastapp_nocheck(b, _p, t, Tsize(b));                 \
+               (b)->theap.dirty = true;                                \
+               (b)->theap.free += sizeof(TYPE);                        \
+               ((TYPE *) (b)->theap.base)[(b)->batCount++] = * (const TYPE *) 
(v); \
+       } while (false)
+
+#define tfastins_nocheckVAR(b, p, v, s)                                        
\
+       do {                                                            \
+               var_t _d;                                               \
+               (b)->theap.free += (s);                                 \
+               (b)->theap.dirty = true;                                \
+               ATOMputVAR((b)->ttype, (b)->tvheap, &_d, v);            \
+               if ((b)->twidth < SIZEOF_VAR_T &&                       \
+                   ((b)->twidth <= 2 ? _d - GDK_VAROFFSET : _d) >= ((size_t) 1 
<< (8 * (b)->twidth))) { \
+                       /* doesn't fit in current heap, upgrade it */   \
+                       if (GDKupgradevarheap((b), _d, 0, (b)->batRestricted == 
BAT_READ) != GDK_SUCCEED) \
+                               goto bunins_failed;                     \
+               }                                                       \
+               switch ((b)->twidth) {                                  \
+               case 1:                                                 \
+                       ((uint8_t *) (b)->theap.base)[p] = (uint8_t) (_d - 
GDK_VAROFFSET); \
+                       break;                                          \
+               case 2:                                                 \
+                       ((uint16_t *) (b)->theap.base)[p] = (uint16_t) (_d - 
GDK_VAROFFSET); \
+                       break;                                          \
+               case 4:                                                 \
+                       ((uint32_t *) (b)->theap.base)[p] = (uint32_t) _d; \
+                       break;                                          \
+               case 8:         /* superfluous on 32-bit archs */       \
+                       ((uint64_t *) (b)->theap.base)[p] = (uint64_t) _d; \
+                       break;                                          \
+               }                                                       \
+       } while (false)
+
+#define bunfastapp_nocheckVAR(b, p, v, ts)             \
+       do {                                            \
+               tfastins_nocheckVAR(b, p, v, ts);       \
+               (b)->batCount++;                        \
+       } while (false)
+
+#define bunfastappVAR(b, v)                                            \
+       do {                                                            \
+               if ((b)->batCount >= BATcapacity(b)) {                  \
+                       if ((b)->batCount == BUN_MAX || BATcount(b) == BUN_MAX) 
{ \
+                               GDKerror("bunfastapp: too many elements to 
accomodate (" BUNFMT ")\n", BUN_MAX); \
+                               goto bunins_failed;                     \
+                       }                                               \
+                       if (BATextend((b), BATgrows(b)) != GDK_SUCCEED) \
+                               goto bunins_failed;                     \
+               }                                                       \
+               bunfastapp_nocheckVAR(b, (b)->batCount, v, Tsize(b));   \
        } while (false)
 
 gdk_export gdk_return GDKupgradevarheap(BAT *b, var_t v, int copyall, bool 
mayshare)
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -284,36 +284,6 @@ gdk_export const ptr ptr_nil;
                *d_ = loc_;                                             \
                ATOMfix(t_, s_);                                        \
        } while (0)
-#define ATOMreplaceFIX(type, dst, src)                 \
-       do {                                            \
-               int t_ = (type);                        \
-               void *d_ = (dst);                       \
-               const void *s_ = (src);                 \
-                                                       \
-               assert(BATatoms[t_].atomPut == NULL);   \
-               ATOMfix(t_, s_);                        \
-               ATOMunfix(t_, d_);                      \
-               switch (ATOMsize(t_)) {                 \
-               case 0:      /* void */                 \
-                       break;                          \
-               case 1:                                 \
-                       * (bte *) d_ = * (bte *) s_;    \
-                       break;                          \
-               case 2:                                 \
-                       * (sht *) d_ = * (sht *) s_;    \
-                       break;                          \
-               case 4:                                 \
-                       * (int *) d_ = * (int *) s_;    \
-                       break;                          \
-               case 8:                                 \
-                       * (lng *) d_ = * (lng *) s_;    \
-                       break;                          \
-               ATOM_CASE_16_hge;                       \
-               default:                                \
-                       memcpy(d_, s_, ATOMsize(t_));   \
-                       break;                          \
-               }                                       \
-       } while (0)
 
 /* string heaps:
  * - strings are 8 byte aligned
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1161,7 +1161,79 @@ BUNinplace(BAT *b, BUN p, const void *t,
        b->tprops = NULL;
        OIDXdestroy(b);
        IMPSdestroy(b);
-       Treplacevalue(b, BUNtloc(bi, p), t);
+       if (b->tvarsized && b->ttype) {
+               var_t _d;
+               ptr _ptr;
+               _ptr = BUNtloc(bi, p);
+               switch (b->twidth) {
+               case 1:
+                       _d = (var_t) * (uint8_t *) _ptr + GDK_VAROFFSET;
+                       break;
+               case 2:
+                       _d = (var_t) * (uint16_t *) _ptr + GDK_VAROFFSET;
+                       break;
+               case 4:
+                       _d = (var_t) * (uint32_t *) _ptr;
+                       break;
+#if SIZEOF_VAR_T == 8
+               case 8:
+                       _d = (var_t) * (uint64_t *) _ptr;
+                       break;
+#endif
+               }
+               ATOMreplaceVAR(b->ttype, b->tvheap, &_d, t);
+               if (b->twidth < SIZEOF_VAR_T &&
+                   (b->twidth <= 2 ? _d - GDK_VAROFFSET : _d) >= ((size_t) 1 
<< (8 * b->twidth))) {
+                       /* doesn't fit in current heap, upgrade it */
+                       if (GDKupgradevarheap(b, _d, false, b->batRestricted == 
BAT_READ) != GDK_SUCCEED)
+                               goto bunins_failed;
+               }
+               _ptr = BUNtloc(bi, p);
+               switch (b->twidth) {
+               case 1:
+                       * (uint8_t *) _ptr = (uint8_t) (_d - GDK_VAROFFSET);
+                       break;
+               case 2:
+                       * (uint16_t *) _ptr = (uint16_t) (_d - GDK_VAROFFSET);
+                       break;
+               case 4:
+                       * (uint32_t *) _ptr = (uint32_t) _d;
+                       break;
+#if SIZEOF_VAR_T == 8
+               case 8:
+                       * (uint64_t *) _ptr = (uint64_t) _d;
+                       break;
+#endif
+               }
+       } else {
+               assert(BATatoms[b->ttype].atomPut == NULL);
+               ATOMfix(b->ttype, t);
+               ATOMunfix(b->ttype, BUNtloc(bi, p));
+               switch (ATOMsize(b->ttype)) {
+               case 0:      /* void */
+                       break;
+               case 1:
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to