Changeset: 764b1d6eba25 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/764b1d6eba25
Modified Files:
gdk/gdk.h
gdk/gdk_cand.h
gdk/gdk_hash.h
Branch: default
Log Message:
Convert some macros to inline functions.
diffs (97 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -466,10 +466,26 @@ gdk_export size_t HEAPmemsize(Heap *h);
gdk_export void HEAPdecref(Heap *h, bool remove);
gdk_export void HEAPincref(Heap *h);
-#define VIEWtparent(x) ((x)->theap == NULL || (x)->theap->parentid ==
(x)->batCacheid ? 0 : (x)->theap->parentid)
-#define VIEWvtparent(x) ((x)->tvheap == NULL || (x)->tvheap->parentid
== (x)->batCacheid ? 0 : (x)->tvheap->parentid)
+__attribute__((__pure__))
+static inline bat
+VIEWtparent(const BAT *b)
+{
+ return b->theap == NULL || b->theap->parentid == b->batCacheid ? 0 :
b->theap->parentid;
+}
-#define isVIEW(x) (VIEWtparent(x) != 0 || VIEWvtparent(x) != 0)
+__attribute__((__pure__))
+static inline bat
+VIEWvtparent(const BAT *b)
+{
+ return b->tvheap == NULL || b->tvheap->parentid == b->batCacheid ? 0 :
b->tvheap->parentid;
+}
+
+__attribute__((__pure__))
+static inline bool
+isVIEW(const BAT *b)
+{
+ return VIEWtparent(b) != 0 || VIEWvtparent(b) != 0;
+}
typedef struct {
char *logical; /* logical name (may point at bak) */
diff --git a/gdk/gdk_cand.h b/gdk/gdk_cand.h
--- a/gdk/gdk_cand.h
+++ b/gdk/gdk_cand.h
@@ -143,7 +143,12 @@ candmask_pop(uint32_t x)
#undef BUILTIN_USED
}
-#define canditer_next_dense(ci) ((ci)->seq + (ci)->next++)
+static inline oid
+canditer_next_dense(struct canditer *ci)
+{
+ return ci->seq + ci->next++;
+}
+
static inline oid
canditer_next(struct canditer *ci)
{
@@ -192,7 +197,14 @@ gdk_export oid canditer_peekprev(const s
__attribute__((__pure__));
gdk_export oid canditer_idx(const struct canditer *ci, BUN p)
__attribute__((__pure__));
-#define canditer_idx_dense(ci, p) ((p >= (ci)->ncand)?oid_nil:((ci)->seq + p))
+
+__attribute__((__pure__))
+static inline oid
+canditer_idx_dense(const struct canditer *ci, BUN p)
+{
+ return p >= ci->ncand ? oid_nil : ci->seq + p;
+}
+
gdk_export void canditer_setidx(struct canditer *ci, BUN p);
gdk_export void canditer_reset(struct canditer *ci);
@@ -207,6 +219,7 @@ canditer_search_dense(const struct candi
else
return o - ci->seq;
}
+
gdk_export BUN canditer_search(const struct canditer *ci, oid o, bool next)
__attribute__((__pure__));
@@ -228,6 +241,7 @@ canditer_contains(const struct canditer
}
return canditer_search(ci, o, false) != BUN_NONE;
}
+
gdk_export oid canditer_mask_next(const struct canditer *ci, oid o, bool next)
__attribute__((__pure__));
diff --git a/gdk/gdk_hash.h b/gdk/gdk_hash.h
--- a/gdk/gdk_hash.h
+++ b/gdk/gdk_hash.h
@@ -157,9 +157,9 @@ HASHgetlink(const Hash *h, BUN i)
}
/* mix_bte(0x80) == 0x80 */
-#define mix_bte(X) ((unsigned int) (unsigned char) (X))
+#define mix_bte(X) ((unsigned int) (uint8_t) (X))
/* mix_sht(0x8000) == 0x8000 */
-#define mix_sht(X) ((unsigned int) (unsigned short) (X))
+#define mix_sht(X) ((unsigned int) (uint16_t) (X))
/* mix_int(0x81060038) == 0x80000000 */
#define mix_int(X) (((unsigned int) (X) >> 7) ^ \
((unsigned int) (X) >> 13) ^ \
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]