Index: arch/ia32/src/debug/panic.s
===================================================================
--- arch/ia32/src/debug/panic.s	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ arch/ia32/src/debug/panic.s	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -28,7 +28,7 @@
 
 .text
-.global panic
+.global panic_printf
 
-panic:
+panic_printf:
 	movl $halt,(%esp)	# fake stack to make printf return to halt
 	jmp printf
Index: arch/ia32/src/interrupt.c
===================================================================
--- arch/ia32/src/interrupt.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ arch/ia32/src/interrupt.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -29,4 +29,5 @@
 #include <arch/interrupt.h>
 #include <print.h>
+#include <debug.h>
 #include <panic.h>
 #include <arch/i8259.h>
@@ -49,10 +50,12 @@
 iroutine trap_register(__u8 n, iroutine f)
 {
+	ASSERT(n < IVT_ITEMS);
+	
 	iroutine old;
-    
+	
 	old = ivt[n];
 	ivt[n] = f;
-    
-    	return old;
+	
+	return old;
 }
 
@@ -63,5 +66,7 @@
 void trap_dispatcher(__u8 n, __u32 stack[])
 {
-	ivt[n](n,stack);
+	ASSERT(n < IVT_ITEMS);
+	
+	ivt[n](n, stack);
 }
 
@@ -113,5 +118,5 @@
 		enable_irqs_function(irqmask);
 	else
-		panic(PANIC "no enable_irqs_function\n");
+		panic("no enable_irqs_function\n");
 }
 
@@ -121,5 +126,5 @@
 		disable_irqs_function(irqmask);
 	else
-		panic(PANIC "no disable_irqs_function\n");
+		panic("no disable_irqs_function\n");
 }
 
@@ -129,5 +134,5 @@
 		eoi_function();
 	else
-		panic(PANIC "no eoi_function\n");
+		panic("no eoi_function\n");
 
 }
Index: arch/ia32/src/pm.c
===================================================================
--- arch/ia32/src/pm.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ arch/ia32/src/pm.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -144,5 +144,5 @@
 		tss_p = (struct tss *) malloc(sizeof(struct tss));
 		if (!tss_p)
-			panic(PANIC "could not allocate TSS\n");
+			panic("could not allocate TSS\n");
 	}
 
Index: arch/ia32/src/smp/mps.c
===================================================================
--- arch/ia32/src/smp/mps.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ arch/ia32/src/smp/mps.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -470,5 +470,5 @@
 		 */
 		if (!(gdt_new = (struct descriptor *) malloc(GDT_ITEMS*sizeof(struct descriptor))))
-			panic(PANIC "couldn't allocate memory for GDT\n");
+			panic("couldn't allocate memory for GDT\n");
 
 		memcopy(gdt, gdt_new, GDT_ITEMS*sizeof(struct descriptor));
Index: arch/ia64/src/fake.s
===================================================================
--- arch/ia64/src/fake.s	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ arch/ia64/src/fake.s	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -48,5 +48,5 @@
 .global map_page_to_frame
 .global memsetb
-.global panic
+.global panic_printf
 
 before_thread_runs_arch:
@@ -69,5 +69,5 @@
 map_page_to_frame:
 memsetb:
-panic:
+panic_printf:
 	br.ret.sptk.many b0
 
Index: arch/mips/src/cache.c
===================================================================
--- arch/mips/src/cache.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ arch/mips/src/cache.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -32,4 +32,4 @@
 void cache_error(void)
 {
-	panic(PANIC "cache_error exception\n");
+	panic("cache_error exception\n");
 }
Index: arch/mips/src/exception.c
===================================================================
--- arch/mips/src/exception.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ arch/mips/src/exception.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -52,5 +52,5 @@
 		case EXC_TLBL:
 		case EXC_TLBS: tlb_invalid(); break;
-		default: panic(PANIC "unhandled exception %d\n", excno); break;
+		default: panic("unhandled exception %d\n", excno); break;
 	}
 	
Index: arch/mips/src/interrupt.c
===================================================================
--- arch/mips/src/interrupt.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ arch/mips/src/interrupt.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -76,5 +76,5 @@
 			    case 0x4:
 			    case 0x5:
-                            case 0x6: panic(PANIC "unhandled interrupt %d\n", i); break;
+                            case 0x6: panic("unhandled interrupt %d\n", i); break;
                             case 0x7:
                                     /* clear timer interrupt */
Index: arch/mips/src/mm/tlb.c
===================================================================
--- arch/mips/src/mm/tlb.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ arch/mips/src/mm/tlb.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -42,10 +42,10 @@
 	}
 	
-	panic(PANIC "tlb_refill exception\n");
+	panic("tlb_refill exception\n");
 }
 
 void tlb_invalid(void)
 {
-	panic(PANIC "%X: TLB exception at %X", cp0_badvaddr_read(), THREAD ? THREAD->saved_epc : 0);
+	panic("%X: TLB exception at %X", cp0_badvaddr_read(), THREAD ? THREAD->saved_epc : 0);
 }
 
Index: arch/mips/src/panic.s
===================================================================
--- arch/mips/src/panic.s	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ arch/mips/src/panic.s	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -33,7 +33,7 @@
 .set nomacro
 
-.global panic
+.global panic_printf
 	
-panic:
+panic_printf:
 	jal printf
 	nop
Index: include/list.h
===================================================================
--- include/list.h	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ include/list.h	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -69,5 +69,5 @@
 }
 
-#define list_empty(head) (((head)->next == (head))?1:0)
+#define list_empty(head) (((head)->next == (head))?true:false)
 
 #define list_get_instance(link,type,member) (type *)(((__u8*)(link))-((__u8*)&(((type *)NULL)->member)))
Index: include/panic.h
===================================================================
--- include/panic.h	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ include/panic.h	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -30,7 +30,11 @@
 #define __PANIC_H__
 
-#define PANIC "KERNEL PANIC: "
+#ifndef NDEBUG
+#	define panic(format, ...) panic_printf("Kernel panic in %s() at %s on line %d: " format, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__);
+#else
+#	define panic(format, ...) panic_printf("Kernel panic: " format, ##__VA_ARGS__);
+#endif
 
-extern void panic(char *fmt, ...);
+extern void panic_printf(char *fmt, ...);
 
 #endif
Index: include/print.h
===================================================================
--- include/print.h	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ include/print.h	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -38,5 +38,5 @@
 static void print_str(const char *str);
 static void print_fixed_hex(const __native num, const int width);
-static void print_number(const __native num, const int base);
+static void print_number(const __native num, const unsigned int base);
 
 extern void putchar(const char c);
Index: include/typedefs.h
===================================================================
--- include/typedefs.h	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ include/typedefs.h	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -35,4 +35,6 @@
 typedef short bool;
 
+typedef unsigned int size_t;
+
 typedef struct config config_t;
 typedef struct cpu_private_data cpu_private_data_t;
Index: src/debug/print.c
===================================================================
--- src/debug/print.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ src/debug/print.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -47,9 +47,9 @@
 void print_str(const char *str)
 {
-        int i = 0;
+	int i = 0;
 	char c;
-    
+	
 	while (c = str[i++])
-	    putchar(c);
+		putchar(c);
 }
 
@@ -85,10 +85,10 @@
  *
  */
-void print_number(const __native num, const int base)
+void print_number(const __native num, const unsigned int base)
 {
 	int val = num;
 	char d[sizeof(__native)*8+1];		/* this is good enough even for base == 2 */
-        int i = sizeof(__native)*8-1;
-    
+	int i = sizeof(__native)*8-1;
+	
 	do {
 		d[i--] = digits[val % base];
Index: src/main/kinit.c
===================================================================
--- src/main/kinit.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ src/main/kinit.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -120,9 +120,9 @@
 	 */
 	m = vm_create();
-	if (!m)	panic(PANIC "vm_create");
+	if (!m)	panic("vm_create");
 	u = task_create(m);
-	if (!u)	panic(PANIC "task_create");
+	if (!u)	panic("task_create");
 	t = thread_create(uinit, NULL, u, THREAD_USER_STACK);
-	if (!t) panic(PANIC "thread_create");
+	if (!t) panic("thread_create");
 
 	/*
@@ -130,5 +130,5 @@
 	 */	
 	a = vm_area_create(m, VMA_TEXT, 1, UTEXT_ADDRESS);
-	if (!a) panic(PANIC "vm_area_create: vm_text");
+	if (!a) panic("vm_area_create: vm_text");
 	memcopy((__address) utext, PA2KA(a->mapping[0]), utext_size < PAGE_SIZE ? utext_size : PAGE_SIZE);		
 
@@ -137,5 +137,5 @@
 	 */
 	a = vm_area_create(m, VMA_STACK, 1, USTACK_ADDRESS);
-	if (!a) panic(PANIC "vm_area_create: vm_stack");
+	if (!a) panic("vm_area_create: vm_stack");
 	
 	thread_ready(t);
Index: src/main/main.c
===================================================================
--- src/main/main.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ src/main/main.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -30,4 +30,5 @@
 #include <arch/context.h>
 #include <print.h>
+#include <panic.h>
 #include <config.h>
 #include <time/clock.h>
Index: src/mm/frame.c
===================================================================
--- src/mm/frame.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ src/mm/frame.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -72,5 +72,5 @@
                 frame_bitmap = (__u8 *) malloc(frame_bitmap_octets);
                 if (!frame_bitmap)
-                        panic(PANIC "malloc/frame_bitmap\n");
+                        panic("malloc/frame_bitmap\n");
 
                 /*
@@ -145,5 +145,5 @@
 			}
 		}
-		panic(PANIC "frames_free inconsistent (%d)\n", frames_free);
+		panic("frames_free inconsistent (%d)\n", frames_free);
 	}
 	spinlock_unlock(&framelock);
@@ -151,8 +151,8 @@
 
 	if (flags & FRAME_PANIC)
-		panic(PANIC "unable to allocate frame\n");
+		panic("unable to allocate frame\n");
 		
 	/* TODO: implement sleeping logic here */
-	panic(PANIC "sleep not supported\n");
+	panic("sleep not supported\n");
 	
 	goto loop;
@@ -196,7 +196,7 @@
 			}	
 		}
-		else panic(PANIC "frame_free: frame already free\n");
-	}
-	else panic(PANIC "frame_free: frame number too big\n");
+		else panic("frame_free: frame already free\n");
+	}
+	else panic("frame_free: frame number too big\n");
 	
 	spinlock_unlock(&framelock);
Index: src/mm/heap.c
===================================================================
--- src/mm/heap.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ src/mm/heap.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -31,4 +31,5 @@
 #include <func.h>
 #include <memstr.h>
+#include <panic.h>
 #include <arch/types.h>
 
Index: src/mm/vm.c
===================================================================
--- src/mm/vm.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ src/mm/vm.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -63,5 +63,5 @@
 	
 	if (addr % PAGE_SIZE)
-		panic(PANIC "addr not aligned to a page boundary");
+		panic("addr not aligned to a page boundary");
 	
 	pri = cpu_priority_high();
@@ -125,5 +125,5 @@
 			break;
 		default:
-			panic(PANIC "unexpected vm_type_t %d", a->type); 
+			panic("unexpected vm_type_t %d", a->type); 
 	}
 	
Index: src/proc/scheduler.c
===================================================================
--- src/proc/scheduler.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ src/proc/scheduler.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -38,4 +38,5 @@
 #include <arch/asm.h>
 #include <list.h>
+#include <panic.h>
 #include <typedefs.h>
 #include <mm/page.h>
Index: src/synch/rwlock.c
===================================================================
--- src/synch/rwlock.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ src/synch/rwlock.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -185,8 +185,8 @@
 				break;
 			case ESYNCH_OK_ATOMIC:
-				panic(PANIC "_mutex_lock_timeout()==ESYNCH_OK_ATOMIC");
+				panic("_mutex_lock_timeout()==ESYNCH_OK_ATOMIC");
 				break;
 			dafault:
-				panic(PANIC "invalid ESYNCH");
+				panic("invalid ESYNCH");
 				break;
 		}
Index: src/time/timeout.c
===================================================================
--- src/time/timeout.c	(revision 45671f481313b28448e49d053b2570066ac4cae6)
+++ src/time/timeout.c	(revision 02a99d21d0192f978464b19bf7f00c5e24b276b7)
@@ -31,4 +31,5 @@
 #include <arch/types.h>
 #include <config.h>
+#include <panic.h>
 #include <synch/spinlock.h>
 #include <func.h>
