comparison srogue/daemon.c @ 225:4f6e056438eb

Merge the GCC5 and build fix branches.
author John "Elwin" Edwards
date Wed, 02 Mar 2016 21:28:34 -0500
parents 94a0d9dd5ce1
children b67b99f6c92b
comparison
equal deleted inserted replaced
224:4d0f53998e8a 225:4f6e056438eb
32 /* 32 /*
33 * d_insert: 33 * d_insert:
34 * Insert a function in the daemon list. 34 * Insert a function in the daemon list.
35 */ 35 */
36 struct delayed_action * 36 struct delayed_action *
37 d_insert(func, arg, type, time) 37 d_insert(int (*func)(), int arg, int type, int time)
38 int arg, type, time, (*func)();
39 { 38 {
40 reg struct delayed_action *dev; 39 reg struct delayed_action *dev;
41 40
42 if (demoncnt < MAXDAEMONS) { 41 if (demoncnt < MAXDAEMONS) {
43 dev = &d_list[demoncnt]; 42 dev = &d_list[demoncnt];
49 return dev; 48 return dev;
50 } 49 }
51 return NULL; 50 return NULL;
52 } 51 }
53 52
54 d_delete(wire) 53 void
55 struct delayed_action *wire; 54 d_delete(struct delayed_action *wire)
56 { 55 {
57 reg struct delayed_action *d1, *d2; 56 reg struct delayed_action *d1, *d2;
58 57
59 for (d1 = d_list; d1 < &d_list[demoncnt]; d1++) { 58 for (d1 = d_list; d1 < &d_list[demoncnt]; d1++) {
60 if (wire == d1) { 59 if (wire == d1) {
71 /* 70 /*
72 * find_slot: 71 * find_slot:
73 * Find a particular slot in the table 72 * Find a particular slot in the table
74 */ 73 */
75 struct delayed_action * 74 struct delayed_action *
76 find_slot(func) 75 find_slot(int (*func)())
77 int (*func)();
78 { 76 {
79 reg struct delayed_action *dev; 77 reg struct delayed_action *dev;
80 78
81 for (dev = d_list; dev < &d_list[demoncnt]; dev++) 79 for (dev = d_list; dev < &d_list[demoncnt]; dev++)
82 if (dev->d_type != EMPTY && func == dev->d_func) 80 if (dev->d_type != EMPTY && func == dev->d_func)
86 84
87 /* 85 /*
88 * start_daemon: 86 * start_daemon:
89 * Start a daemon, takes a function. 87 * Start a daemon, takes a function.
90 */ 88 */
91 start_daemon(func, arg, type) 89 void
92 int arg, type, (*func)(); 90 start_daemon(int (*func)(), int arg, int type)
93 { 91 {
94 d_insert(func, arg, type, DAEMON); 92 d_insert(func, arg, type, DAEMON);
95 } 93 }
96 94
97 /* 95 /*
98 * do_daemons: 96 * do_daemons:
99 * Run all the daemons that are active with the current 97 * Run all the daemons that are active with the current
100 * flag, passing the argument to the function. 98 * flag, passing the argument to the function.
101 */ 99 */
102 do_daemons(flag) 100 void
103 int flag; 101 do_daemons(int flag)
104 { 102 {
105 reg struct delayed_action *dev; 103 reg struct delayed_action *dev;
106 104
107 for (dev = d_list; dev < &d_list[demoncnt]; dev++) 105 for (dev = d_list; dev < &d_list[demoncnt]; dev++)
108 if (dev->d_type == flag && dev->d_time == DAEMON) 106 if (dev->d_type == flag && dev->d_time == DAEMON)
111 109
112 /* 110 /*
113 * fuse: 111 * fuse:
114 * Start a fuse to go off in a certain number of turns 112 * Start a fuse to go off in a certain number of turns
115 */ 113 */
116 fuse(func, arg, time) 114 void
117 int (*func)(), arg, time; 115 fuse(int (*func)(), int arg, int time)
118 { 116 {
119 d_insert(func, arg, AFTER, time); 117 d_insert(func, arg, AFTER, time);
120 } 118 }
121 119
122 /* 120 /*
123 * lengthen: 121 * lengthen:
124 * Increase the time until a fuse goes off 122 * Increase the time until a fuse goes off
125 */ 123 */
126 lengthen(func, xtime) 124 void
127 int (*func)(), xtime; 125 lengthen(int (*func)(), int xtime)
128 { 126 {
129 reg struct delayed_action *wire; 127 reg struct delayed_action *wire;
130 128
131 for (wire = d_list; wire < &d_list[demoncnt]; wire++) 129 for (wire = d_list; wire < &d_list[demoncnt]; wire++)
132 if (wire->d_type != EMPTY && func == wire->d_func) 130 if (wire->d_type != EMPTY && func == wire->d_func)
135 133
136 /* 134 /*
137 * extinguish: 135 * extinguish:
138 * Put out a fuse. Find all such fuses and kill them. 136 * Put out a fuse. Find all such fuses and kill them.
139 */ 137 */
140 extinguish(func) 138 void
141 int (*func)(); 139 extinguish(int (*func)())
142 { 140 {
143 reg struct delayed_action *dev; 141 reg struct delayed_action *dev;
144 142
145 for (dev = d_list; dev < &d_list[demoncnt]; dev++) 143 for (dev = d_list; dev < &d_list[demoncnt]; dev++)
146 if (dev->d_type != EMPTY && func == dev->d_func) 144 if (dev->d_type != EMPTY && func == dev->d_func)
149 147
150 /* 148 /*
151 * do_fuses: 149 * do_fuses:
152 * Decrement counters and start needed fuses 150 * Decrement counters and start needed fuses
153 */ 151 */
154 do_fuses() 152 void
153 do_fuses(void)
155 { 154 {
156 reg struct delayed_action *dev; 155 reg struct delayed_action *dev;
157 156
158 for (dev = d_list; dev < &d_list[demoncnt]; dev++) { 157 for (dev = d_list; dev < &d_list[demoncnt]; dev++) {
159 if (dev->d_type == AFTER && dev->d_time > DAEMON) { 158 if (dev->d_type == AFTER && dev->d_time > DAEMON) {
168 167
169 /* 168 /*
170 * activity: 169 * activity:
171 * Show wizard number of demaons and memory blocks used 170 * Show wizard number of demaons and memory blocks used
172 */ 171 */
173 activity() 172 void
173 activity(void)
174 { 174 {
175 msg("Daemons = %d : Memory Items = %d : Memory Used = %d", 175 msg("Daemons = %d : Memory Items = %d : Memory Used = %d",
176 demoncnt,total,md_memused()); 176 demoncnt,total,md_memused());
177 } 177 }