Listing 4 Header for runtime library

////////////////////////////////////////////////////////////
// runtime.h
//
// Runtime library with patches to track working papers.

#ifndef RUNTIME_H
#define RUNTIME_H

#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <malloc.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <iostreams.h>

// Boolean type.
typedef int bool;

// Exceptions.
struct exception { virtual ~exception(){} };
struct bad_alloc : exception {};

// Low level memory allocation functions.
void* allocate(size_t) throw();
void deallocate(void*) throw();

// Installable new handler.
typedef void (*new_handler)();
new_handler set_new_handler(new_handler) throw();

// Standard memory allocation operators.
void* operator new(size_t) throw(bad_alloc);
void* operator new[](size_t) throw(bad_alloc);
void operator delete(void*);
void operator delete[](void*);

// Default allocator.
template<class T> struct allocator {
   void* allocate(size_t size) throw(bad_alloc) {
      return ::operator new(n);
   }
   void deallocate(T* p) throw() { :: operator delete(p); }
};

// Allocate via an allocator.
template<class Allocator> inline void*
operator new(size_t n,Allocator& r) throw(bad_alloc) {
   return r.allocate(n);
};
template<class Allocator> inline void*
operator new[](size_t n,Allocator& r) throw(bad_alloc) {
    return r.allocate(n);
};

// Allocate in place.
inline void* operator new(size_t n,void* p) throw() {
   return p;
}
inline void* operator new[](size_t n,void* p) throw() {
   return p;
}

#endif

/* End of File */