projects
/
muddle-interpreter.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Endian-aware FIX32 layout.
[muddle-interpreter.git]
/
src
/
object.h
diff --git
a/src/object.h
b/src/object.h
index 54281f2396ebf7c629be3f6bdd7d4fad09d5ab73..56f17b6425d598aee2174f1edcdd40cb66f0f2c5 100644
(file)
--- a/
src/object.h
+++ b/
src/object.h
@@
-122,8
+122,17
@@
typedef union object object;
typedef struct
{
typedef struct
{
- alignas (8) uint32_t _pad;
+ alignas (8)
+ // layout so that value can be upcast by reinterpreting as a fix64
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ int32_t n;
+ uint32_t _pad;
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ uint32_t _pad;
int32_t n;
int32_t n;
+#else
+#error Unusual endianness?
+#endif
} fix32_val;
typedef struct
{
} fix32_val;
typedef struct
{
@@
-410,6
+419,13
@@
object *stack_push (vector_object * v);
Checked downcasts.
*/
Checked downcasts.
*/
+static inline fix32_object *
+as_fix32 (object * o)
+{
+ assert (TYPEPRIM_EQ (o->type, TYPEPRIM_FIX32));
+ return &o->fix32;
+}
+
static inline list_object *
as_list (object * o)
{
static inline list_object *
as_list (object * o)
{