Skip to content

Commit

Permalink
Got rid of birds.h dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert van Renesse committed Jun 2, 2024
1 parent 24f6a54 commit 1d8d13f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions harmony_model_checker/charm/ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@
#include "hashdict.h"
#include "spawn.h"

#ifdef BIRDS
#define main xmain
#include "birds.h"
#undef main
#endif

// Maximum number of arguments of the Nary (N-Ary) HVM operation
#define MAX_ARITY 16
Expand Down Expand Up @@ -1040,22 +1042,27 @@ struct iqueue {
struct bogus_op {
enum {
IQ_NEW, IQ_ENQUEUE, IQ_DEQUEUE,
#ifdef BIRDS
OLB_NEW, OLB_WB_ACQUIRE, OLB_WB_RELEASE,
OLB_EB_ACQUIRE, OLB_EB_RELEASE
#endif
} type;
struct allocator *allocator;
hvalue_t context;
struct {
#ifdef BIRDS
struct {
struct device *olb;
} olb;
#endif
struct {
struct iqueue *iq; // only for enqueue and dequeue;
hvalue_t arg; // only for enqueue
} iq;
} args;
};

#ifdef BIRDS
static void olb_print(struct strbuf *sb, void *ref){
strbuf_printf(sb, "OLB<%p>", ref);
}
Expand All @@ -1065,6 +1072,7 @@ static int olb_compare(void *ref1, void *ref2){
if (ref1 > ref2) return 1;
return 0;
}
#endif

static void iq_print(struct strbuf *sb, void *ref){
strbuf_printf(sb, "IQueue<%p>", ref);
Expand All @@ -1076,11 +1084,13 @@ static int iq_compare(void *ref1, void *ref2){
return 0;
}

#ifdef BIRDS
struct external_descriptor olb_descr = {
.type_name = "OLB",
.print = olb_print,
.compare = olb_compare
};
#endif

struct external_descriptor iq_descr = {
.type_name = "IQueue",
Expand All @@ -1093,6 +1103,7 @@ static void bogus_run(void *arg){

hvalue_t result = 0;
switch (bop->type) {
#ifdef BIRDS
case OLB_NEW:
{
struct device *olb = malloc(sizeof(*olb));
Expand Down Expand Up @@ -1128,6 +1139,7 @@ static void bogus_run(void *arg){
result = VALUE_ADDRESS_SHARED; // None
}
break;
#endif
case IQ_NEW:
{
struct iqueue *iq = calloc(1, sizeof(*iq));
Expand Down Expand Up @@ -1193,6 +1205,7 @@ static hvalue_t direct_getarg(struct step *step){
return arg;
}

#ifdef BIRDS
// Built-in bogus.olb_new method
void op_Bogus_olb_new(const void *env, struct state *state, struct step *step){
if (step->ctx->readonly > 0) {
Expand Down Expand Up @@ -1336,6 +1349,7 @@ void op_Bogus_olb_eb_release(const void *env, struct state *state, struct step *
// Start a native thread to execute the operation.
thread_create(bogus_run, bop);
}
#endif // BIRDS

// Built-in bogus.iq_new method
void op_Bogus_iq_new(const void *env, struct state *state, struct step *step){
Expand Down Expand Up @@ -5157,11 +5171,13 @@ struct op_info op_table[] = {
{ "bogus$iq_enqueue", NULL, op_Bogus_iq_enqueue },
{ "bogus$iq_dequeue", NULL, op_Bogus_iq_dequeue },

#ifdef BIRDS
{ "bogus$olb_new", NULL, op_Bogus_olb_new },
{ "bogus$olb_wb_acquire", NULL, op_Bogus_olb_wb_acquire },
{ "bogus$olb_wb_release", NULL, op_Bogus_olb_wb_release },
{ "bogus$olb_eb_acquire", NULL, op_Bogus_olb_eb_acquire },
{ "bogus$olb_eb_release", NULL, op_Bogus_olb_eb_release },
#endif

{ NULL, NULL, NULL }
};
Expand Down

0 comments on commit 1d8d13f

Please sign in to comment.