changeset 10:35d0358b3fe6

update Modern CbC Compiler
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Mon, 01 Jul 2019 22:18:03 +0900
parents cef74c1054c1
children 190dadd8405b
files dpp3.cbc ltl.cbc main.cbc scheduler.cbc tableau.cbc tableau2.cbc tableau3.cbc
diffstat 7 files changed, 60 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/dpp3.cbc	Fri Dec 25 18:47:23 2015 +0900
+++ b/dpp3.cbc	Mon Jul 01 22:18:03 2019 +0900
@@ -37,12 +37,12 @@
 {
     if (self->right_fork->owner == NULL) {
 	//printf("%d: pickup_rfork:%d\n", self->id, self->right_fork->id);
-	self->right_fork->owner = self;
-	self->next = PutDownFork;
-	goto scheduler(self, current_task);
+      self->right_fork->owner = self;
+      self->next = PutDownFork;
+      goto scheduler(self, current_task);
     } else {
-	self->next = PickUpRightFork;
-	goto scheduler(self, current_task);
+      self->next = PickUpRightFork;
+      goto scheduler(self, current_task);
     }
 }
 
@@ -50,12 +50,12 @@
 {
     if (self->left_fork->owner == NULL) {
 	//printf("%d: pickup_lfork:%d\n", self->id, self->left_fork->id);
-	self->left_fork->owner = self;
-	self->next = PickUpRightFork;
-	goto scheduler(self, current_task);
+      self->left_fork->owner = self;
+      self->next = PickUpRightFork;
+      goto scheduler(self, current_task);
     } else {
-	self->next = PickUpLeftFork;
-	goto scheduler(self, current_task);
+      self->next = PickUpLeftFork;
+      goto scheduler(self, current_task);
     }
 }
 
--- a/ltl.cbc	Fri Dec 25 18:47:23 2015 +0900
+++ b/ltl.cbc	Mon Jul 01 22:18:03 2019 +0900
@@ -11,8 +11,8 @@
 
     if (last->left_fork->owner == NULL) return 0;
     while (current != last) {
-	if (current->left_fork->owner == NULL) return 0;
-	current = current->right;
+      if (current->left_fork->owner == NULL) return 0;
+      current = current->right;
     }
     return 1;
 }
@@ -20,7 +20,7 @@
 __code check(int *always_flag, PhilsPtr phils, TaskPtr list)
 {
     if (p(list->phils)) {
-	*always_flag = 0;
+      *always_flag = 0;
     }
     goto tableau(list);
 }
@@ -29,8 +29,8 @@
 show_result(int always_flag)
 {
     if (always_flag == 1) {
-	printf("[]~p is valid.\n");
+      printf("[]~p is valid.\n");
     } else {
-	printf("[]~p is not valid.\n");
+      printf("[]~p is not valid.\n");
     }
 }
--- a/main.cbc	Fri Dec 25 18:47:23 2015 +0900
+++ b/main.cbc	Mon Jul 01 22:18:03 2019 +0900
@@ -111,7 +111,7 @@
 
 int main(void)
 {
-    env = __environment;
+    env = _CbC_environment;
 
     goto init_fork1(NUM_PHILOSOPHER);
 }
--- a/scheduler.cbc	Fri Dec 25 18:47:23 2015 +0900
+++ b/scheduler.cbc	Mon Jul 01 22:18:03 2019 +0900
@@ -218,7 +218,7 @@
 
 int main(int argc, char **argv)
 {
-	env = __environment;
+	env = _CbC_environment;
 	// srand((unsigned)time(NULL));
 	// srandom((unsigned long)time(NULL));
 	get_next_task = get_next_task_fifo;
--- a/tableau.cbc	Fri Dec 25 18:47:23 2015 +0900
+++ b/tableau.cbc	Mon Jul 01 22:18:03 2019 +0900
@@ -87,7 +87,7 @@
 get_task(int num, TaskPtr list)
 {
     while (num-- > 0) {
-	list = list->next;
+      list = list->next;
     }
     return list;
 }
@@ -114,28 +114,28 @@
     if (lookup_StateDB(&st, &state_db, &out)) {
 	// found in the state database
 	//printf("found %d\n",count);
-	while(!(list = next_task_iterator(task_iter))) {
-	    // no more branch, go back to the previous one
-	    TaskIteratorPtr prev_iter = task_iter->prev;
-	    if (!prev_iter) {
-		printf("All done count %d\n",count);
-		memory_usage();
-        exit(0);
-	    }
-	    //printf("no more branch %d\n",count);
-	    depth--;
-	    free_task_iterator(task_iter);
-	    task_iter = prev_iter;
-	}
+      while(!(list = next_task_iterator(task_iter))) {
+          // no more branch, go back to the previous one
+          TaskIteratorPtr prev_iter = task_iter->prev;
+          if (!prev_iter) {
+            printf("All done count %d\n",count);
+            memory_usage();
+            exit(0);
+          }
+          //printf("no more branch %d\n",count);
+          depth--;
+          free_task_iterator(task_iter);
+          task_iter = prev_iter;
+      }
 	// return to previous state
 	//    here we assume task list is fixed, we don't have to
 	//    recover task list itself
-	restore_memory(task_iter->state->memory);
+      restore_memory(task_iter->state->memory);
 	//printf("restore list %x next %x\n",(int)list,(int)(list->next));
     } else {
 	// one step further
-	depth++;
-	task_iter = create_task_iterator(list,out,task_iter);
+      depth++;
+      task_iter = create_task_iterator(list,out,task_iter);
     }
     //printf("depth %d count %d\n", depth, count++);
     count++;
@@ -166,10 +166,10 @@
 __code task_entry2(int count,PhilsPtr self, TaskPtr list,TaskPtr last, TaskPtr q)
 {
     if (!q) {
-	goto die("Can't allocate Task\n");
+      goto die("Can't allocate Task\n");
     } else {
-	add_memory_range(q,sizeof(Task),&mem);
-	goto enqueue(count, self, list, last, q, task_entry1);
+      add_memory_range(q,sizeof(Task),&mem);
+      goto enqueue(count, self, list, last, q, task_entry1);
     }
 }
 
@@ -182,18 +182,18 @@
     */
 
     if (count++ < NUM_PHILOSOPHER) {
-	self = self->left;
-	goto create_queue(count,self,list,last,task_entry2);
+      self = self->left;
+      goto create_queue(count,self,list,last,task_entry2);
     } else {
 	// make circular task list
-	last->next = list;
-	st.memory = mem;
-	st.hash = get_memory_hash(mem,0);
-	lookup_StateDB(&st, &state_db, &out);
-	task_iter = create_task_iterator(list,out,0);
+      last->next = list;
+      st.memory = mem;
+      st.hash = get_memory_hash(mem,0);
+      lookup_StateDB(&st, &state_db, &out);
+      task_iter = create_task_iterator(list,out,0);
 	// start first task
 	//goto list->phils->next(list->phils,list);
-    goto do_action(list->phils,list);
+      goto do_action(list->phils,list);
     }
 }
 
@@ -218,7 +218,7 @@
 
     tmp_self = (PhilsPtr)malloc(sizeof(Phils));
     if (!tmp_self) {
-	goto die("Can't allocate Phils\n");
+      goto die("Can't allocate Phils\n");
     }
     self->right = tmp_self;
     tmp_self->id = id;
@@ -233,9 +233,9 @@
     id++;
 
     if (count == 0) {
-	goto init_final(tmp_self);
+      goto init_final(tmp_self);
     } else {
-	goto init_fork2(tmp_self, count, id);
+      goto init_fork2(tmp_self, count, id);
     }
 }
 
@@ -245,7 +245,7 @@
 
     tmp_fork = (ForkPtr)malloc(sizeof(Fork));
     if (!tmp_fork) {
-	goto die("Can't allocate Fork\n");
+      goto die("Can't allocate Fork\n");
     }
     tmp_fork->id = id;
     tmp_fork->owner = NULL;
@@ -261,7 +261,7 @@
 
     self = (PhilsPtr)malloc(sizeof(Phils));
     if (!self) {
-	goto die("Can't allocate Phils\n");
+      goto die("Can't allocate Phils\n");
     }
     phils_list = self;
     self->id = id;
@@ -285,7 +285,7 @@
 
     fork = (ForkPtr)malloc(sizeof(Fork));
     if (!fork) {
-	goto die("Can't allocate Fork\n");
+      goto die("Can't allocate Fork\n");
     }
     fork->id = id;
     fork->owner = NULL;
@@ -302,18 +302,18 @@
 
 int main(int ac, char *av[])
 {
-    env = __environment;
+    env = _CbC_environment;
     // srand((unsigned)time(NULL));
     // srandom((unsigned long)time(NULL));
     srandom(555);
 
     if (ac==2) {
-	NUM_PHILOSOPHER = atoi(av[1]);
-	if (NUM_PHILOSOPHER >10 ||NUM_PHILOSOPHER < 2) {
-	    printf("illegal number of philosopher = %d\n", NUM_PHILOSOPHER );
-	    return 1;
-	}
-	printf("number of philosopher = %d\n", NUM_PHILOSOPHER );
+      NUM_PHILOSOPHER = atoi(av[1]);
+      if (NUM_PHILOSOPHER >10 ||NUM_PHILOSOPHER < 2) {
+        printf("illegal number of philosopher = %d\n", NUM_PHILOSOPHER );
+        return 1;
+      }
+      printf("number of philosopher = %d\n", NUM_PHILOSOPHER );
     }
 
     goto init_fork1(NUM_PHILOSOPHER);
--- a/tableau2.cbc	Fri Dec 25 18:47:23 2015 +0900
+++ b/tableau2.cbc	Mon Jul 01 22:18:03 2019 +0900
@@ -305,7 +305,7 @@
 
 int main(int ac, char *av[])
 {
-    env = __environment;
+    env = _CbC_environment;
     // srand((unsigned)time(NULL));
     // srandom((unsigned long)time(NULL));
     srandom(555);
--- a/tableau3.cbc	Fri Dec 25 18:47:23 2015 +0900
+++ b/tableau3.cbc	Mon Jul 01 22:18:03 2019 +0900
@@ -309,7 +309,7 @@
 
 int main(int ac, char *av[])
 {
-    env = __environment;
+    env = _CbC_environment;
     // srand((unsigned)time(NULL));
     // srandom((unsigned long)time(NULL));
     reset_state_count();