changeset 5:a04eccfc69ae

Remove warnings in dpp2
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Fri, 25 Dec 2015 17:15:49 +0900
parents b7d63c5499e7
children 4a68716b7488
files dpp.h dpp2.h dpp_common.h queue.cbc queue.h scheduler.cbc state_db.h
diffstat 7 files changed, 46 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/dpp.h	Fri Dec 25 16:00:52 2015 +0900
+++ b/dpp.h	Fri Dec 25 17:15:49 2015 +0900
@@ -4,6 +4,20 @@
 
 #include "dpp_common.h"
 
+typedef struct phils {
+    int id;
+    struct fork *right_fork;
+    struct fork *left_fork;
+    struct phils *right;
+    struct phils *left;
+    __code (*next)(struct phils *);
+} Phils, *PhilsPtr;
+
+typedef struct fork {
+    int id;
+    struct phils *owner;
+} Fork, *ForkPtr;
+
 extern __code putdown_lfork(PhilsPtr self);
 extern __code putdown_rfork(PhilsPtr self);
 extern __code eating(PhilsPtr self);
--- a/dpp2.h	Fri Dec 25 16:00:52 2015 +0900
+++ b/dpp2.h	Fri Dec 25 17:15:49 2015 +0900
@@ -1,9 +1,27 @@
 #ifndef _DPP2_H_
 #define _DPP2_H_
-#define NULL (0)
 
 #include "dpp_common.h"
-#include "queue.h"
+
+struct task;
+typedef struct phils {
+    int id;
+    struct fork *right_fork;
+    struct fork *left_fork;
+    struct phils *right;
+    struct phils *left;
+    __code (*next)(struct phils *, struct task *);
+} Phils, *PhilsPtr;
+
+typedef struct fork {
+    int id;
+    struct phils *owner;
+} Fork, *ForkPtr;
+
+typedef struct task {
+    struct task *next;
+    struct phils *phils;
+} Task, *TaskPtr;
 
 
 extern __code putdown_lfork(PhilsPtr self, TaskPtr current_task);
--- a/dpp_common.h	Fri Dec 25 16:00:52 2015 +0900
+++ b/dpp_common.h	Fri Dec 25 17:15:49 2015 +0900
@@ -1,22 +1,7 @@
 #ifndef _DPP_COMMON_H_
 #define _DPP_COMMON_H_
-#define NULL (0)
 
 #include<stdio.h>
 #include<stdlib.h>
 
-typedef struct phils {
-	int id;
-	struct fork *right_fork;
-	struct fork *left_fork;
-	struct phils *right;
-	struct phils *left;
-	__code (*next)(struct phils *);
-} Phils, *PhilsPtr;
-
-typedef struct fork {
-	int id;
-	struct phils *owner;
-} Fork, *ForkPtr;
-
 #endif
--- a/queue.cbc	Fri Dec 25 16:00:52 2015 +0900
+++ b/queue.cbc	Fri Dec 25 17:15:49 2015 +0900
@@ -1,7 +1,7 @@
 /*
     OS Scheduler Simulator
 
-** 連絡先: 琉球大学情報工学科 河野 真治  
+** 連絡先: 琉球大学情報工学科 河野 真治
 ** (E-Mail Address: kono@ie.u-ryukyu.ac.jp)
 **
 **    このソースのいかなる複写,改変,修正も許諾します。ただし、
@@ -11,10 +11,10 @@
 **    バイナリの配布の際にはversion messageを保存することを条件とします。
 **    このプログラムについては特に何の保証もしない、悪しからず。
 **
-**    Everyone is permitted to do anything on this program 
+**    Everyone is permitted to do anything on this program
 **    including copying, modifying, improving,
 **    as long as you don't try to pretend that you wrote it.
-**    i.e., the above copyright notice has to appear in all copies.  
+**    i.e., the above copyright notice has to appear in all copies.
 **    Binary distribution requires original version messages.
 **    You don't have to ask before copying, redistribution or publishing.
 **    THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
@@ -46,7 +46,7 @@
 	free(q);
 }
 
-__code lastSearch(__code (*dest)(), TaskPtr list, TaskPtr p, TaskPtr q)
+__code lastSearch(__code (*dest)(TaskPtr), TaskPtr list, TaskPtr p, TaskPtr q)
 {
 	if (p->next) {
 		p = p->next;
@@ -66,7 +66,7 @@
 	goto dest(count,self,q, last);
 }
 
-__code dequeue(__code (*dest)(), TaskPtr list)
+__code dequeue(__code (*dest)(TaskPtr, TaskPtr), TaskPtr list)
 {
 	TaskPtr p = list;
 	if (p) {
@@ -95,14 +95,14 @@
 {
     TaskPtr next;
     if (!self->list) {
-	die_exit("task iterator inconsistency");
+        die_exit("task iterator inconsistency");
     }
     next = self->list->next;
     if (!next) {
-	die_exit("task iterator next inconsistency");
+        die_exit("task iterator next inconsistency");
     }
     if (next == self->last) {
-	return 0;
+        return 0;
     }
     self->list = next;
     return next;
--- a/queue.h	Fri Dec 25 16:00:52 2015 +0900
+++ b/queue.h	Fri Dec 25 17:15:49 2015 +0900
@@ -26,14 +26,9 @@
  */
 #ifndef _QUEUE_H_
 #define _QUEUE_H_
-#include "dpp_common.h"
+#include "dpp2.h"
 #include "state_db.h"
 
-typedef struct task {
-	struct task *next;
-	struct phils *phils;
-} Task, *TaskPtr;
-
 typedef struct task_iterator {
     struct task_iterator *prev;
     StateDB state;
@@ -65,4 +60,6 @@
 extern void free_queue(TaskPtr q);
 extern __code dequeue(__code (*dest)(), TaskPtr list);
 
+extern void die_exit(char*);
+
 #endif
--- a/scheduler.cbc	Fri Dec 25 16:00:52 2015 +0900
+++ b/scheduler.cbc	Fri Dec 25 17:15:49 2015 +0900
@@ -9,7 +9,6 @@
 
 #define NUM_PHILOSOPHER 5    /* A number of philosophers must be more than 2. */
 
-__code (*ret)(int);
 void *env;
 
 __code (*get_next_task)(TaskPtr);
@@ -81,8 +80,7 @@
 
 __code task_entry1(int count, PhilsPtr self, TaskPtr list, TaskPtr last)
 {
-printf("int count %d, PhilsPtr self %x, TaskPtr list %x, TaskPtr last %x\n",
-count, self, list, last);
+printf("int count %d, PhilsPtr self %p, TaskPtr list %p, TaskPtr last %p\n", count, self, list, last);
 
 	if (count++ < NUM_PHILOSOPHER) {
 		self = self->left;
@@ -193,7 +191,6 @@
 
 int main(int argc, char **argv)
 {
-	ret = __return;
 	env = __environment;
 	// srand((unsigned)time(NULL));
 	// srandom((unsigned long)time(NULL));
--- a/state_db.h	Fri Dec 25 16:00:52 2015 +0900
+++ b/state_db.h	Fri Dec 25 17:15:49 2015 +0900
@@ -1,7 +1,6 @@
 #ifndef _STATE_DB_H_
 #define _STATE_DB_H_
 
-
 typedef struct state_db {
     struct memory *memory;
     int hash;