@@ -39,7 +39,7 @@ int send_register_info(write_fn write_fn, void *uc)
switch (op) {
case OP_TESTEND:
- write_fn(&ri, sizeof(ri));
+ write_fn(&ri, reginfo_size());
/* if we are tracing write_fn will return 0 unlike a remote
end, hence we force return of 1 here */
return 1;
@@ -58,7 +58,7 @@ int send_register_info(write_fn write_fn, void *uc)
/* Do a simple register compare on (a) explicit request
* (b) end of test (c) a non-risuop UNDEF
*/
- return write_fn(&ri, sizeof(ri));
+ return write_fn(&ri, reginfo_size());
}
return 0;
}
@@ -101,7 +101,7 @@ int recv_and_compare_register_info(read_fn read_fn,
/* Do a simple register compare on (a) explicit request
* (b) end of test (c) a non-risuop UNDEF
*/
- if (read_fn(&apprentice_ri, sizeof(apprentice_ri))) {
+ if (read_fn(&apprentice_ri, reginfo_size())) {
packet_mismatch = 1;
resp = 2;
} else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) {
@@ -133,4 +133,7 @@ int reginfo_dump(struct reginfo *ri, FILE * f);
/* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */
int reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE *f);
+/* return size of reginfo */
+const int reginfo_size(void);
+
#endif /* RISU_H */
@@ -15,6 +15,8 @@
#include <string.h>
#include <signal.h> /* for FPSIMD_MAGIC */
#include <stdlib.h>
+#include <stddef.h>
+#include <assert.h>
#include "risu.h"
#include "risu_reginfo_aarch64.h"
@@ -27,6 +29,13 @@ void process_arch_opt(int opt, const char *arg)
abort();
}
+const int reginfo_size(void)
+{
+ const int size = offsetof(struct reginfo, simd.end);
+ assert(sizeof(struct reginfo)==size);
+ return size;
+}
+
/* reginfo_init: initialize with a ucontext */
void reginfo_init(struct reginfo *ri, ucontext_t *uc)
{
@@ -71,7 +80,7 @@ void reginfo_init(struct reginfo *ri, ucontext_t *uc)
/* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */
int reginfo_is_eq(struct reginfo *r1, struct reginfo *r2)
{
- return memcmp(r1, r2, sizeof(*r1)) == 0;
+ return memcmp(r1, r2, reginfo_size()) == 0;
}
/* reginfo_dump: print state to a stream, returns nonzero on success */
@@ -15,6 +15,7 @@
struct simd_reginfo {
__uint128_t vregs[32];
+ char end[0];
};
struct reginfo {
@@ -36,6 +36,11 @@ void process_arch_opt(int opt, const char *arg)
abort();
}
+const int reginfo_size(void)
+{
+ return sizeof(struct reginfo);
+}
+
static void reginfo_init_vfp(struct reginfo *ri, ucontext_t *uc)
{
/* Read VFP registers. These live in uc->uc_regspace, which is
@@ -23,6 +23,11 @@ void process_arch_opt(int opt, const char *arg)
abort();
}
+const int reginfo_size(void)
+{
+ return sizeof(struct reginfo);
+}
+
/* reginfo_init: initialize with a ucontext */
void reginfo_init(struct reginfo *ri, ucontext_t *uc)
{
@@ -31,6 +31,11 @@ void process_arch_opt(int opt, const char *arg)
abort();
}
+const int reginfo_size(void)
+{
+ return sizeof(struct reginfo);
+}
+
/* reginfo_init: initialize with a ucontext */
void reginfo_init(struct reginfo *ri, ucontext_t *uc)
{