mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
Backport from xs.
This commit is contained in:
parent
093f4af282
commit
e12af77799
2 changed files with 12 additions and 10 deletions
20
xs.h
20
xs.h
|
@ -154,8 +154,15 @@ xs_val xs_stock_true[] = { XSTYPE_TRUE };
|
||||||
xs_val xs_stock_false[] = { XSTYPE_FALSE };
|
xs_val xs_stock_false[] = { XSTYPE_FALSE };
|
||||||
xs_val xs_stock_0[] = { XSTYPE_NUMBER, '0', '\0' };
|
xs_val xs_stock_0[] = { XSTYPE_NUMBER, '0', '\0' };
|
||||||
xs_val xs_stock_1[] = { XSTYPE_NUMBER, '1', '\0' };
|
xs_val xs_stock_1[] = { XSTYPE_NUMBER, '1', '\0' };
|
||||||
|
|
||||||
|
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
xs_val xs_stock_list[] = { XSTYPE_LIST, 0, 0, 0, 1 + _XS_TYPE_SIZE + 1, XSTYPE_EOM };
|
xs_val xs_stock_list[] = { XSTYPE_LIST, 0, 0, 0, 1 + _XS_TYPE_SIZE + 1, XSTYPE_EOM };
|
||||||
xs_val xs_stock_dict[] = { XSTYPE_DICT, 0, 0, 0, 1 + _XS_TYPE_SIZE + 1, XSTYPE_EOM };
|
xs_val xs_stock_dict[] = { XSTYPE_DICT, 0, 0, 0, 1 + _XS_TYPE_SIZE + 1, XSTYPE_EOM };
|
||||||
|
#else
|
||||||
|
xs_val xs_stock_list[] = { XSTYPE_LIST, 1 + _XS_TYPE_SIZE + 1, 0, 0, 0, XSTYPE_EOM };
|
||||||
|
xs_val xs_stock_dict[] = { XSTYPE_DICT, 1 + _XS_TYPE_SIZE + 1, 0, 0, 0, XSTYPE_EOM };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char *func)
|
void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char *func)
|
||||||
{
|
{
|
||||||
|
@ -274,21 +281,16 @@ xstype xs_type(const xs_val *data)
|
||||||
void _xs_put_size(xs_val *ptr, int i)
|
void _xs_put_size(xs_val *ptr, int i)
|
||||||
/* must match _XS_TYPE_SIZE */
|
/* must match _XS_TYPE_SIZE */
|
||||||
{
|
{
|
||||||
unsigned char *p = (unsigned char *)ptr;
|
memcpy(ptr, &i, sizeof(i));
|
||||||
|
|
||||||
p[0] = (i >> 24) & 0x7f;
|
|
||||||
p[1] = (i >> 16) & 0xff;
|
|
||||||
p[2] = (i >> 8) & 0xff;
|
|
||||||
p[3] = i & 0xff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int _xs_get_size(const xs_val *ptr)
|
int _xs_get_size(const xs_val *ptr)
|
||||||
/* must match _XS_TYPE_SIZE */
|
/* must match _XS_TYPE_SIZE */
|
||||||
{
|
{
|
||||||
unsigned char *p = (unsigned char *)ptr;
|
int i;
|
||||||
|
memcpy(&i, ptr, sizeof(i));
|
||||||
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
/* 98305e8badd7ed505bb6e667c202bad63e4e79ef 2024-02-20T05:16:49+01:00 */
|
/* 73ff6e75bec88fa0b908b039462180a8ac1401de 2024-03-08T07:17:30+01:00 */
|
||||||
|
|
Loading…
Reference in a new issue