This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "events.h"
#include <signal.h>
+#include <stdlib.h>
#if !defined (SIM_EVENTS_POLL_RATE)
#define SIM_EVENTS_POLL_RATE 0x1000
while (event != NULL) {
event_entry *dead = event;
event = event->next;
- zfree(dead);
+ free(dead);
}
queue->held = NULL;
queue->held_end = &queue->held;
while (event != NULL) {
event_entry *dead = event;
event = event->next;
- zfree(dead);
+ free(dead);
}
queue->queue = NULL;
events->time_of_event = current_time - 1;
events->time_from_event = -1;
}
+ if (WITH_TRACE && ppc_trace[trace_events])
+ {
+ event_entry *event;
+ int i;
+ for (event = events->queue, i = 0;
+ event != NULL;
+ event = event->next, i++)
+ {
+ TRACE(trace_events, ("event time-from-event - time %ld, delta %ld - event %d, tag 0x%lx, time %ld, handler 0x%lx, data 0x%lx\n",
+ (long)current_time,
+ (long)events->time_from_event,
+ i,
+ (long)event,
+ (long)event->time_of_event,
+ (long)event->handler,
+ (long)event->data));
+ }
+ }
ASSERT(current_time == event_queue_time(events));
- ASSERT((events->time_from_event >= 0) == (events->queue != NULL));
}
STATIC_INLINE_EVENTS\
(long)current->time_of_event,
(long)current->handler,
(long)current->data));
- zfree(current);
+ free(current);
update_time_from_event(events);
}
else {
event_handler *handler = to_do->handler;
void *data = to_do->data;
events->queue = to_do->next;
- TRACE(trace_events, ("event issued at %ld - tag 0x%lx - handler 0x%lx, data 0x%lx\n",
+ TRACE(trace_events, ("event issued at %ld - tag 0x%lx - time %ld, handler 0x%lx, data 0x%lx\n",
(long)event_time,
(long)to_do,
+ (long)to_do->time_of_event,
(long)handler,
(long)data));
- zfree(to_do);
+ free(to_do);
+ /* Always re-compute the time to the next event so that HANDLER()
+ can safely insert new events into the queue. */
+ update_time_from_event(events);
handler(data);
}
events->processing = 0;
- /* re-caculate time for new events */
- update_time_from_event(events);
+ ASSERT(events->time_from_event > 0);
+ ASSERT(events->queue != NULL); /* always poll event */
}