summaryrefslogtreecommitdiffhomepage
path: root/include/stc
diff options
context:
space:
mode:
Diffstat (limited to 'include/stc')
-rw-r--r--include/stc/ccommon.h26
-rw-r--r--include/stc/cspan.h6
-rw-r--r--include/stc/priv/cqueue_imp.h2
3 files changed, 17 insertions, 17 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 80cbc5e4..0a8c439a 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -69,10 +69,10 @@ typedef long long _llong;
#define c_new(T, ...) ((T*)memcpy(malloc(sizeof(T)), ((T[]){__VA_ARGS__}), sizeof(T)))
#define c_LITERAL(T) (T)
#endif
-#define c_new_n(T, n) ((T*)malloc(sizeof(T)*c_i2u(n)))
-#define c_malloc(sz) malloc(c_i2u(sz))
-#define c_calloc(n, sz) calloc(c_i2u(n), c_i2u(sz))
-#define c_realloc(p, sz) realloc(p, c_i2u(sz))
+#define c_new_n(T, n) ((T*)malloc(sizeof(T)*c_i2u_size(n)))
+#define c_malloc(sz) malloc(c_i2u_size(sz))
+#define c_calloc(n, sz) calloc(c_i2u_size(n), c_i2u_size(sz))
+#define c_realloc(p, sz) realloc(p, c_i2u_size(sz))
#define c_free(p) free(p)
#define c_delete(T, ptr) do { T *_tp = ptr; T##_drop(_tp); free(_tp); } while (0)
@@ -86,17 +86,17 @@ typedef long long _llong;
#define c_const_cast(T, p) ((T)(1 ? (p) : (T)0))
#define c_swap(T, xp, yp) do { T *_xp = xp, *_yp = yp, \
_tv = *_xp; *_xp = *_yp; *_yp = _tv; } while (0)
-// use with gcc -Wsign-conversion
+// use with gcc -Wconversion
#define c_sizeof (intptr_t)sizeof
#define c_strlen(s) (intptr_t)strlen(s)
-#define c_strncmp(a, b, ilen) strncmp(a, b, c_i2u(ilen))
-#define c_memcpy(d, s, ilen) memcpy(d, s, c_i2u(ilen))
-#define c_memmove(d, s, ilen) memmove(d, s, c_i2u(ilen))
-#define c_memset(d, val, ilen) memset(d, val, c_i2u(ilen))
-#define c_memcmp(a, b, ilen) memcmp(a, b, c_i2u(ilen))
-#define c_u2i(u) (intptr_t)(1 ? (u) : (size_t)1)
-#define c_i2u(i) (size_t)(1 ? (i) : -1)
-#define c_LTu(a, b) ((size_t)(a) < (size_t)(b))
+#define c_strncmp(a, b, ilen) strncmp(a, b, c_i2u_size(ilen))
+#define c_memcpy(d, s, ilen) memcpy(d, s, c_i2u_size(ilen))
+#define c_memmove(d, s, ilen) memmove(d, s, c_i2u_size(ilen))
+#define c_memset(d, val, ilen) memset(d, val, c_i2u_size(ilen))
+#define c_memcmp(a, b, ilen) memcmp(a, b, c_i2u_size(ilen))
+#define c_u2i_size(u) (intptr_t)(1 ? (u) : (size_t)1)
+#define c_i2u_size(i) (size_t)(1 ? (i) : -1)
+#define c_less_unsigned(a, b) ((size_t)(a) < (size_t)(b))
// x and y are i_keyraw* type, defaults to i_key*:
#define c_default_cmp(x, y) (c_default_less(y, x) - c_default_less(x, y))
diff --git a/include/stc/cspan.h b/include/stc/cspan.h
index e058c0e8..1bc57e2b 100644
--- a/include/stc/cspan.h
+++ b/include/stc/cspan.h
@@ -201,7 +201,7 @@ STC_INLINE void _cspan_transpose(int32_t shape[], intptr_t stride[], int rank) {
STC_INLINE intptr_t _cspan_index(int rank, const int32_t shape[], const intptr_t stride[], const int32_t a[]) {
intptr_t off = 0;
while (rank--) {
- c_assert(c_LTu(a[rank], shape[rank]));
+ c_assert(c_less_unsigned(a[rank], shape[rank]));
off += stride[rank]*a[rank];
}
return off;
@@ -265,13 +265,13 @@ STC_DEF intptr_t _cspan_slice(int32_t oshape[], intptr_t ostride[], int* orank,
for (; i < rank; ++i) {
off += stride[i]*a[i][0];
switch (a[i][1]) {
- case 0: c_assert(c_LTu(a[i][0], shape[i])); continue;
+ case 0: c_assert(c_less_unsigned(a[i][0], shape[i])); continue;
case -1: end = shape[i]; break;
default: end = a[i][1];
}
oshape[oi] = end - a[i][0];
ostride[oi] = stride[i];
- c_assert((oshape[oi] > 0) & !c_LTu(shape[i], end));
+ c_assert((oshape[oi] > 0) & !c_less_unsigned(shape[i], end));
++oi;
}
*orank = oi;
diff --git a/include/stc/priv/cqueue_imp.h b/include/stc/priv/cqueue_imp.h
index 18c1bb15..65711fc0 100644
--- a/include/stc/priv/cqueue_imp.h
+++ b/include/stc/priv/cqueue_imp.h
@@ -26,7 +26,7 @@ STC_DEF _cx_iter _cx_MEMB(_advance)(_cx_iter it, intptr_t n) {
intptr_t pos = it.pos, idx = _cdeq_toidx(it._s, pos);
it.pos = (pos + n) & it._s->capmask;
it.ref += it.pos - pos;
- if (!c_LTu(idx + n, len)) it.ref = NULL;
+ if (!c_less_unsigned(idx + n, len)) it.ref = NULL;
return it;
}