summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-09-06 17:17:23 +0100
committerAlasdair Armstrong2018-09-06 17:17:23 +0100
commiteae01f8c348235ea552c67ce323a1ada3dbc8b08 (patch)
tree93248a495e8fb4ce44fc1f00f0722fe3736a3d17 /lib
parentb04f8c9dfa599b48544bac024eaa78e6b93c29d4 (diff)
RISCV: Get enough of the RISCV platform into C to run some tests
Diffstat (limited to 'lib')
-rw-r--r--lib/sail.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/sail.c b/lib/sail.c
index 886f6a37..42ee8209 100644
--- a/lib/sail.c
+++ b/lib/sail.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include<assert.h>
#include<inttypes.h>
#include<stdbool.h>
@@ -1111,9 +1112,13 @@ void string_of_int(sail_string *str, const sail_int i)
gmp_asprintf(str, "%Zd", i);
}
+/* asprinf is a GNU extension, but it should exist on BSD */
void string_of_mach_bits(sail_string *str, const mach_bits op)
{
- exit(EXIT_FAILURE);
+ int bytes = asprintf(str, "0x%" PRIx64, op);
+ if (bytes == -1) {
+ fprintf(stderr, "Could not print bits 0x%" PRIx64 "\n", op);
+ }
}
void string_of_sail_bits(sail_string *str, const sail_bits op)