27 lines
513 B
C
27 lines
513 B
C
#include <mie/const.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
void mie_int_init(struct mie_int *out, long long val, unsigned int nr_bits)
|
|
{
|
|
memset(out, 0x0, sizeof *out);
|
|
|
|
mie_value_init(&out->i_base.c_base, MIE_VALUE_CONST);
|
|
|
|
out->i_base.c_type = MIE_CONST_INT;
|
|
out->i_value = val;
|
|
out->i_width = nr_bits;
|
|
}
|
|
|
|
struct mie_int *mie_int_create(long long val, unsigned int nr_bits)
|
|
{
|
|
struct mie_int *out = malloc(sizeof *out);
|
|
|
|
if (!out) {
|
|
return NULL;
|
|
}
|
|
|
|
mie_int_init(out, val, nr_bits);
|
|
return out;
|
|
}
|