--- trunk/src/interrupt.c 2007/10/08 16:21:17 34 +++ trunk/src/interrupt.c 2007/10/08 16:22:56 44 @@ -25,11 +25,11 @@ * SUCH DAMAGE. * * - * $Id: interrupt.c,v 1.7 2007/02/03 16:41:42 debug Exp $ + * $Id: interrupt.c,v 1.13 2007/08/29 20:36:49 debug Exp $ * * The interrupt subsystem. * - * Interrupts have a "path", e.g. "emul[0].machine[0].cpu.5". A device which + * Interrupts have a "path", e.g. "machine[0].cpu.5". A device which * wishes to cause this interrupt needs to connect to it. * * The possible interrupt paths are registered by CPUs, interrupt controllers, @@ -49,6 +49,9 @@ #include "misc.h" +/* #define INTERRUPT_DEBUG */ + + struct interrupt_handler { struct interrupt template; int nr_of_exclusive_users; @@ -73,7 +76,7 @@ * Add an interrupt handler to the interrupt subsystem. The 'template' * needs to have all members set. * - * Name is of the form "emul[0].machine[0].cpu[0].irq[3].isa[14]" etc. + * Name is of the form "machine[0].cpu[0].irq[3].isa[14]" etc. * * If there already is a handler with this name, the emulator aborts. */ @@ -81,7 +84,7 @@ { int i; -#ifdef UNSTABLE_DEVEL +#ifdef INTERRUPT_DEBUG printf("interrupt_handler_register(\"%s\")\n", template->name); #endif @@ -98,17 +101,12 @@ } nr_of_interrupt_handlers ++; - interrupt_handlers = realloc(interrupt_handlers, - nr_of_interrupt_handlers * sizeof(struct interrupt_handler)); - if (interrupt_handlers == NULL) { - fprintf(stderr, "out of memory in " - "ninterrupt_handler_register().\n"); - exit(1); - } + CHECK_ALLOCATION(interrupt_handlers = realloc(interrupt_handlers, + nr_of_interrupt_handlers * sizeof(struct interrupt_handler))); interrupt_handlers[nr_of_interrupt_handlers-1].template = *template; - interrupt_handlers[nr_of_interrupt_handlers-1].template.name = - strdup(template->name); + CHECK_ALLOCATION(interrupt_handlers[nr_of_interrupt_handlers-1]. + template.name = strdup(template->name)); } @@ -123,7 +121,7 @@ { int i; -#ifdef UNSTABLE_DEVEL +#ifdef INTERRUPT_DEBUG printf("interrupt_handler_remove(\"%s\")\n", name); #endif @@ -170,7 +168,7 @@ { int i; -#ifdef UNSTABLE_DEVEL +#ifdef INTERRUPT_DEBUG printf("interrupt_handler_lookup(\"%s\")\n", name); #endif @@ -189,8 +187,12 @@ return 1; } - printf("interrupt_handler_lookup(\"%s\") failed. Aborting.\n", name); - abort(); + /* The 'if' is an ugly hack to prevent a Compaq CC warning. */ + if (i >= nr_of_interrupt_handlers) { + printf("interrupt_handler_lookup(\"%s\") failed. " + "Aborting.\n", name); + abort(); + } return 0; } @@ -205,7 +207,7 @@ { int i; -#ifdef UNSTABLE_DEVEL +#ifdef INTERRUPT_DEBUG printf("interrupt_connect(\"%s\")\n", in->name); #endif