diff options
| author | Alasdair | 2018-07-05 21:34:23 +0100 |
|---|---|---|
| committer | Alasdair | 2018-07-05 21:36:23 +0100 |
| commit | 79c9c884536cb522ac54c51aad70ab810ea4a420 (patch) | |
| tree | 23769072f45d4623d6a55650d8ac7d99da9747b3 /lib | |
| parent | b909248ac4599401312d121fc434f0520770454b (diff) | |
Fix equality comparisons for variants in C
Makes sure equality comparisons for variants are compiled correctly. Needed for CHERI and mips, which have structs containing
variants. Also make sure that struct equality works for structs containing other structs.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sail.c | 11 | ||||
| -rw-r--r-- | lib/sail.h | 4 |
2 files changed, 15 insertions, 0 deletions
@@ -134,6 +134,12 @@ void concat_str(sail_string *stro, const sail_string str1, const sail_string str /* ***** Sail integers ***** */ +inline +bool EQUAL(mach_int)(const mach_int op1, const mach_int op2) +{ + return op1 == op2; +} + #ifndef USE_INT128 inline @@ -341,6 +347,11 @@ void pow2(sail_int *rop, const sail_int exp) { /* ***** Sail bitvectors ***** */ +bool EQUAL(mach_bits)(const mach_bits op1, const mach_bits op2) +{ + return op1 == op2; +} + void CREATE(sail_bits)(sail_bits *rop) { rop->bits = malloc(sizeof(mpz_t)); @@ -82,6 +82,8 @@ void concat_str(sail_string *stro, const sail_string str1, const sail_string str typedef int64_t mach_int; +bool EQUAL(mach_int)(const mach_int, const mach_int); + /* * Integers can be either stack-allocated as 128-bit integers if * __int128 is available, or use GMP arbitrary precision @@ -165,6 +167,8 @@ typedef uint64_t mach_bits; bool eq_bit(const mach_bits a, const mach_bits b); +bool EQUAL(mach_bits)(const mach_bits, const mach_bits); + typedef struct { mp_bitcnt_t len; mpz_t *bits; |
