summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2024-03-09 07:18:51 +0100
committerGravatar default2024-03-09 07:18:51 +0100
commite12af777993ca655f285e852ad0dbee6bdca014f (patch)
treebedce5c0ed79d2ba05c3a46a825954ba05327b16
parentShortened the maximum conversation levels. (diff)
downloadpenes-snac2-e12af777993ca655f285e852ad0dbee6bdca014f.tar.gz
penes-snac2-e12af777993ca655f285e852ad0dbee6bdca014f.tar.xz
penes-snac2-e12af777993ca655f285e852ad0dbee6bdca014f.zip
Backport from xs.
-rw-r--r--xs.h20
-rw-r--r--xs_version.h2
2 files changed, 12 insertions, 10 deletions
diff --git a/xs.h b/xs.h
index b0f13c7..7df7346 100644
--- a/xs.h
+++ b/xs.h
@@ -154,8 +154,15 @@ xs_val xs_stock_true[] = { XSTYPE_TRUE };
154xs_val xs_stock_false[] = { XSTYPE_FALSE }; 154xs_val xs_stock_false[] = { XSTYPE_FALSE };
155xs_val xs_stock_0[] = { XSTYPE_NUMBER, '0', '\0' }; 155xs_val xs_stock_0[] = { XSTYPE_NUMBER, '0', '\0' };
156xs_val xs_stock_1[] = { XSTYPE_NUMBER, '1', '\0' }; 156xs_val xs_stock_1[] = { XSTYPE_NUMBER, '1', '\0' };
157
158#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
157xs_val xs_stock_list[] = { XSTYPE_LIST, 0, 0, 0, 1 + _XS_TYPE_SIZE + 1, XSTYPE_EOM }; 159xs_val xs_stock_list[] = { XSTYPE_LIST, 0, 0, 0, 1 + _XS_TYPE_SIZE + 1, XSTYPE_EOM };
158xs_val xs_stock_dict[] = { XSTYPE_DICT, 0, 0, 0, 1 + _XS_TYPE_SIZE + 1, XSTYPE_EOM }; 160xs_val xs_stock_dict[] = { XSTYPE_DICT, 0, 0, 0, 1 + _XS_TYPE_SIZE + 1, XSTYPE_EOM };
161#else
162xs_val xs_stock_list[] = { XSTYPE_LIST, 1 + _XS_TYPE_SIZE + 1, 0, 0, 0, XSTYPE_EOM };
163xs_val xs_stock_dict[] = { XSTYPE_DICT, 1 + _XS_TYPE_SIZE + 1, 0, 0, 0, XSTYPE_EOM };
164#endif
165
159 166
160void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char *func) 167void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char *func)
161{ 168{
@@ -274,21 +281,16 @@ xstype xs_type(const xs_val *data)
274void _xs_put_size(xs_val *ptr, int i) 281void _xs_put_size(xs_val *ptr, int i)
275/* must match _XS_TYPE_SIZE */ 282/* must match _XS_TYPE_SIZE */
276{ 283{
277 unsigned char *p = (unsigned char *)ptr; 284 memcpy(ptr, &i, sizeof(i));
278
279 p[0] = (i >> 24) & 0x7f;
280 p[1] = (i >> 16) & 0xff;
281 p[2] = (i >> 8) & 0xff;
282 p[3] = i & 0xff;
283} 285}
284 286
285 287
286int _xs_get_size(const xs_val *ptr) 288int _xs_get_size(const xs_val *ptr)
287/* must match _XS_TYPE_SIZE */ 289/* must match _XS_TYPE_SIZE */
288{ 290{
289 unsigned char *p = (unsigned char *)ptr; 291 int i;
290 292 memcpy(&i, ptr, sizeof(i));
291 return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; 293 return i;
292} 294}
293 295
294 296
diff --git a/xs_version.h b/xs_version.h
index c49d866..3e76a99 100644
--- a/xs_version.h
+++ b/xs_version.h
@@ -1 +1 @@
/* 98305e8badd7ed505bb6e667c202bad63e4e79ef 2024-02-20T05:16:49+01:00 */ /* 73ff6e75bec88fa0b908b039462180a8ac1401de 2024-03-08T07:17:30+01:00 */