comparison xrogue/daemon.c @ 239:837044d2c362

Merge the GCC5 and build fix branches. This fixes all warnings produced by GCC 5, except the ones related to system functions. Those could be fixed by including the proper headers, but it would be better to replace the system-dependent code with functions from mdport.c.
author John "Elwin" Edwards
date Fri, 11 Mar 2016 19:47:52 -0500
parents e1cd27c5464f
children
comparison
equal deleted inserted replaced
232:bac2c81fec78 239:837044d2c362
72 * find_slot: 72 * find_slot:
73 * Find a particular slot in the table 73 * Find a particular slot in the table
74 */ 74 */
75 75
76 struct delayed_action * 76 struct delayed_action *
77 find_slot(int (*func)()) 77 find_slot(void (*func)())
78 { 78 {
79 reg int i; 79 reg int i;
80 reg struct delayed_action *dev; 80 reg struct delayed_action *dev;
81 81
82 for (i = 0, dev = f_list; i < MAXFUSES; i++, dev++) 82 for (i = 0, dev = f_list; i < MAXFUSES; i++, dev++)
89 * start_daemon: 89 * start_daemon:
90 * Start a daemon, takes a function. 90 * Start a daemon, takes a function.
91 */ 91 */
92 92
93 void 93 void
94 start_daemon(int (*dfunc)(), VOID *arg, int type) 94 start_daemon(void (*dfunc)(), void *arg, int type)
95 { 95 {
96 reg struct delayed_action *dev; 96 reg struct delayed_action *dev;
97 97
98 dev = d_slot(); 98 dev = d_slot();
99 if (dev != NULL) { 99 if (dev != NULL) {
109 * kill_daemon: 109 * kill_daemon:
110 * Remove a daemon from the list 110 * Remove a daemon from the list
111 */ 111 */
112 112
113 void 113 void
114 kill_daemon(int (*dfunc)()) 114 kill_daemon(void (*dfunc)())
115 { 115 {
116 reg struct delayed_action *dev; 116 reg struct delayed_action *dev;
117 reg int i; 117 reg int i;
118 118
119 for (i = 0, dev = d_list; i < MAXDAEMONS; i++, dev++) { 119 for (i = 0, dev = d_list; i < MAXDAEMONS; i++, dev++) {
162 * fuse: 162 * fuse:
163 * Start a fuse to go off in a certain number of turns 163 * Start a fuse to go off in a certain number of turns
164 */ 164 */
165 165
166 void 166 void
167 fuse(int (*dfunc)(), VOID *arg, int time, int type) 167 fuse(void (*dfunc)(), void *arg, int time, int type)
168 { 168 {
169 reg struct delayed_action *wire; 169 reg struct delayed_action *wire;
170 170
171 wire = f_slot(); 171 wire = f_slot();
172 if (wire != NULL) { 172 if (wire != NULL) {
173 wire->d_type = type; 173 wire->d_type = type;
174 wire->d_func = dfunc; 174 wire->d_func = dfunc;
175 wire->d_arg.vp = arg; 175 if (dfunc == changeclass || dfunc == res_strength)
176 wire->d_arg.i = *(int *) arg;
177 else
178 wire->d_arg.vp = arg;
176 wire->d_time = time; 179 wire->d_time = time;
177 fusecnt += 1; /* update count */ 180 fusecnt += 1; /* update count */
178 } 181 }
179 } 182 }
180 183
182 * lengthen: 185 * lengthen:
183 * Increase the time until a fuse goes off 186 * Increase the time until a fuse goes off
184 */ 187 */
185 188
186 void 189 void
187 lengthen(int (*dfunc)(), int xtime) 190 lengthen(void (*dfunc)(), int xtime)
188 { 191 {
189 reg struct delayed_action *wire; 192 reg struct delayed_action *wire;
190 193
191 if ((wire = find_slot(dfunc)) == NULL) 194 if ((wire = find_slot(dfunc)) == NULL)
192 return; 195 return;
197 * extinguish: 200 * extinguish:
198 * Put out a fuse 201 * Put out a fuse
199 */ 202 */
200 203
201 void 204 void
202 extinguish(int (*dfunc)()) 205 extinguish(void (*dfunc)())
203 { 206 {
204 reg struct delayed_action *wire; 207 reg struct delayed_action *wire;
205 208
206 if ((wire = find_slot(dfunc)) == NULL) 209 if ((wire = find_slot(dfunc)) == NULL)
207 return; 210 return;
218 */ 221 */
219 222
220 void 223 void
221 do_fuses(int flag) 224 do_fuses(int flag)
222 { 225 {
223 struct delayed_action *wire; 226 struct delayed_action *wire;
224 int i; 227 int i;
225 228
226 /* 229 /*
227 * Step though the list 230 * Step though the list
228 */ 231 */
229 for (i = 0; i < MAXFUSES; i++) { 232 for (i = 0; i < MAXFUSES; i++) {
230 wire = &f_list[i]; 233 wire = &f_list[i];
231 /* 234 /*
232 * Decrementing counters and starting things we want. We also need 235 * Decrementing counters and starting things we want. We also need
233 * to remove the fuse from the list once it has gone off. 236 * to remove the fuse from the list once it has gone off.
234 */ 237 */
235 if(flag == wire->d_type && wire->d_time > 0 && 238 if(flag == wire->d_type && wire->d_time > 0 &&
236 --wire->d_time == 0) { 239 --wire->d_time == 0) {
237 wire->d_type = EMPTY; 240 wire->d_type = EMPTY;
238 if (wire->d_func != NULL) 241 if (*wire->d_func == changeclass || *wire->d_func == res_strength)
239 (*wire->d_func)(wire->d_arg.vp); 242 (*wire->d_func)(wire->d_arg.i);
240 fusecnt -= 1; 243 else if (wire->d_func != NULL)
241 } 244 (*wire->d_func)(wire->d_arg.vp);
242 } 245 fusecnt -= 1;
246 }
247 }
243 } 248 }
244 249
245 /* 250 /*
246 * activity: 251 * activity:
247 * Show wizard number of demaons and memory blocks used 252 * Show wizard number of demaons and memory blocks used