Index: libcfa/src/Makefile.am
===================================================================
--- libcfa/src/Makefile.am	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ libcfa/src/Makefile.am	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -19,19 +19,16 @@
 ARFLAGS = cr
 
+include $(srcdir)/../../src/cfa.make
+
 libdir = ${CFA_LIBDIR}
 lib_LIBRARIES =  libcfa.a
 
-libcfa-prelude.o : libcfa-prelude.c
-	 ${AM_V_GEN}gcc  -Wall -O2 -c -o $@ $<
-
-EXTRA_FLAGS = -g -Wall -Wno-unused-function -imacros libcfa-prelude.c  $(DEFAULT_INCLUDES)
-
-AM_CCASFLAGS =
-
-#CFLAGS for most libcfa src
-#use -no-include-stdhdr to prevent rebuild cycles
-#The built sources must not depend on the installed headers
-CFLAGS = -quiet -no-include-stdhdr -XCFA -t -B@DRIVER_DIR@ ${EXTRA_FLAGS}
-CC = @CFACC@
+# AM_CFLAGS for all cfa source
+# AM_CFAFLAGS for only cfa source
+# use -no-include-stdhdr to prevent rebuild cycles
+# The built sources must not depend on the installed headers
+AM_CFAFLAGS = -quiet -no-include-stdhdr -XCFA -t -B@DRIVER_DIR@ -imacros prelude.c -I$(srcdir)/stdhdr
+AM_CFLAGS = -g -Wall -Wno-unused-function
+CFACC = @CFACC@
 
 headers = fstream iostream iterator limits rational time stdlib common \
@@ -42,9 +39,9 @@
 
 libobjs = ${headers:=.o}
-libsrc = libcfa-prelude.c startup.c interpose.c bits/debug.c assert.c exception.c virtual.c heap.c \
-	${headers:=.c}
+libsrc = prelude.c startup.cfa interpose.cfa bits/debug.cfa assert.cfa exception.c virtual.c heap.cfa \
+	${headers:=.cfa}
 
 # not all platforms support concurrency, add option do disable it
-libsrc += concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c concurrency/invoke.c concurrency/preemption.c
+libsrc += concurrency/CtxSwitch-@host_alias@.S concurrency/alarm.cfa concurrency/invoke.c concurrency/preemption.cfa
 
 # extensionless header files are overridden by -o flag in default makerule => explicitly override default rule to silently do nothing
@@ -59,17 +56,8 @@
 	false
 
-concurrency/invoke.o : concurrency/invoke.c
-	${AM_V_CC}gcc -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
 
-exception.o : exception.c
-	${AM_V_CC}gcc -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
-
-virtual.o : virtual.c
-	${AM_V_CC}gcc -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
-
-${libobjs} : @CFACPP@ ${cfalib_DATA} # add dependency to cfa-cpp so all libraries are rebuilt with new translator
+${libobjs} : ${cfalib_DATA} # add dependency to cfa-cpp so all libraries are rebuilt with new translator
 
 libcfa_a_SOURCES = ${libsrc}
-libcfa_a_CFLAGS = -nodebug -O2
 
 stdhdr = ${shell find ${srcdir}/stdhdr -type f -printf "%p "}
@@ -89,5 +77,5 @@
 	concurrency/invoke.h
 
-CLEANFILES = libcfa-prelude.c
+CLEANFILES = prelude.c
 
 maintainer-clean-local:
Index: libcfa/src/Makefile.in
===================================================================
--- libcfa/src/Makefile.in	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ libcfa/src/Makefile.in	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -140,26 +140,18 @@
 libcfa_a_LIBADD =
 am__dirstamp = $(am__leading_dot)dirstamp
-am__objects_1 = libcfa_a-fstream.$(OBJEXT) libcfa_a-iostream.$(OBJEXT) \
-	libcfa_a-iterator.$(OBJEXT) libcfa_a-limits.$(OBJEXT) \
-	libcfa_a-rational.$(OBJEXT) libcfa_a-time.$(OBJEXT) \
-	libcfa_a-stdlib.$(OBJEXT) libcfa_a-common.$(OBJEXT) \
-	containers/libcfa_a-maybe.$(OBJEXT) \
-	containers/libcfa_a-pair.$(OBJEXT) \
-	containers/libcfa_a-result.$(OBJEXT) \
-	containers/libcfa_a-vector.$(OBJEXT) \
-	concurrency/libcfa_a-coroutine.$(OBJEXT) \
-	concurrency/libcfa_a-thread.$(OBJEXT) \
-	concurrency/libcfa_a-kernel.$(OBJEXT) \
-	concurrency/libcfa_a-monitor.$(OBJEXT) \
-	concurrency/libcfa_a-mutex.$(OBJEXT)
-am__objects_2 = libcfa_a-libcfa-prelude.$(OBJEXT) \
-	libcfa_a-startup.$(OBJEXT) libcfa_a-interpose.$(OBJEXT) \
-	bits/libcfa_a-debug.$(OBJEXT) libcfa_a-assert.$(OBJEXT) \
-	libcfa_a-exception.$(OBJEXT) libcfa_a-virtual.$(OBJEXT) \
-	libcfa_a-heap.$(OBJEXT) $(am__objects_1) \
-	concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT) \
-	concurrency/libcfa_a-alarm.$(OBJEXT) \
-	concurrency/libcfa_a-invoke.$(OBJEXT) \
-	concurrency/libcfa_a-preemption.$(OBJEXT)
+am__objects_1 = fstream.$(OBJEXT) iostream.$(OBJEXT) \
+	iterator.$(OBJEXT) limits.$(OBJEXT) rational.$(OBJEXT) \
+	time.$(OBJEXT) stdlib.$(OBJEXT) common.$(OBJEXT) \
+	containers/maybe.$(OBJEXT) containers/pair.$(OBJEXT) \
+	containers/result.$(OBJEXT) containers/vector.$(OBJEXT) \
+	concurrency/coroutine.$(OBJEXT) concurrency/thread.$(OBJEXT) \
+	concurrency/kernel.$(OBJEXT) concurrency/monitor.$(OBJEXT) \
+	concurrency/mutex.$(OBJEXT)
+am__objects_2 = prelude.$(OBJEXT) startup.$(OBJEXT) \
+	interpose.$(OBJEXT) bits/debug.$(OBJEXT) assert.$(OBJEXT) \
+	exception.$(OBJEXT) virtual.$(OBJEXT) heap.$(OBJEXT) \
+	$(am__objects_1) concurrency/CtxSwitch-@host_alias@.$(OBJEXT) \
+	concurrency/alarm.$(OBJEXT) concurrency/invoke.$(OBJEXT) \
+	concurrency/preemption.$(OBJEXT)
 am_libcfa_a_OBJECTS = $(am__objects_2)
 libcfa_a_OBJECTS = $(am_libcfa_a_OBJECTS)
@@ -186,8 +178,4 @@
 am__v_CPPAS_0 = @echo "  CPPAS   " $@;
 am__v_CPPAS_1 = 
-AM_V_lt = $(am__v_lt_@AM_V@)
-am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
-am__v_lt_0 = --silent
-am__v_lt_1 = 
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -229,5 +217,5 @@
 ETAGS = etags
 CTAGS = ctags
-am__DIST_COMMON = $(srcdir)/Makefile.in \
+am__DIST_COMMON = $(srcdir)/../../src/cfa.make $(srcdir)/Makefile.in \
 	$(top_srcdir)/./automake/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -239,5 +227,5 @@
 AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
-CC = @CFACC@
+CC = @CC@
 CCAS = @CCAS@
 CCASDEPMODE = @CCASDEPMODE@
@@ -250,9 +238,5 @@
 CFA_LIBDIR = @CFA_LIBDIR@
 CFA_PREFIX = @CFA_PREFIX@
-
-#CFLAGS for most libcfa src
-#use -no-include-stdhdr to prevent rebuild cycles
-#The built sources must not depend on the installed headers
-CFLAGS = -quiet -no-include-stdhdr -XCFA -t -B@DRIVER_DIR@ ${EXTRA_FLAGS}
+CFLAGS = @CFLAGS@
 CONFIGURATION = @CONFIGURATION@
 CPPFLAGS = @CPPFLAGS@
@@ -349,7 +333,17 @@
 AUTOMAKE_OPTIONS = subdir-objects
 ARFLAGS = cr
+CFACOMPILE = $(CFACC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) $(AM_CFLAGS) $(CFLAGS)
+AM_V_CFA = $(am__v_CFA_@AM_V@)
+am__v_CFA_ = $(am__v_CFA_@AM_DEFAULT_V@)
+am__v_CFA_0 = @echo "  CFA     " $@;
+am__v_CFA_1 = 
 lib_LIBRARIES = libcfa.a
-EXTRA_FLAGS = -g -Wall -Wno-unused-function -imacros libcfa-prelude.c  $(DEFAULT_INCLUDES)
-AM_CCASFLAGS = 
+
+# AM_CFLAGS for all cfa source
+# AM_CFAFLAGS for only cfa source
+# use -no-include-stdhdr to prevent rebuild cycles
+# The built sources must not depend on the installed headers
+AM_CFAFLAGS = -quiet -no-include-stdhdr -XCFA -t -B@DRIVER_DIR@ -imacros prelude.c -I$(srcdir)/stdhdr
+AM_CFLAGS = -g -Wall -Wno-unused-function
 
 # not all platforms support concurrency, add option do disable it
@@ -361,10 +355,9 @@
 
 # not all platforms support concurrency, add option do disable it
-libsrc = libcfa-prelude.c startup.c interpose.c bits/debug.c assert.c \
-	exception.c virtual.c heap.c ${headers:=.c} \
-	concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \
-	concurrency/invoke.c concurrency/preemption.c
+libsrc = prelude.c startup.cfa interpose.cfa bits/debug.cfa assert.cfa \
+	exception.c virtual.c heap.cfa ${headers:=.cfa} \
+	concurrency/CtxSwitch-@host_alias@.S concurrency/alarm.cfa \
+	concurrency/invoke.c concurrency/preemption.cfa
 libcfa_a_SOURCES = ${libsrc}
-libcfa_a_CFLAGS = -nodebug -O2
 stdhdr = ${shell find ${srcdir}/stdhdr -type f -printf "%p "}
 cfa_includedir = $(CFA_INCDIR)
@@ -382,10 +375,10 @@
 	concurrency/invoke.h
 
-CLEANFILES = libcfa-prelude.c
+CLEANFILES = prelude.c
 all: all-am
 
 .SUFFIXES:
-.SUFFIXES: .S .c .o .obj
-$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+.SUFFIXES: .S .c .cfa .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/../../src/cfa.make $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
@@ -407,4 +400,5 @@
 	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
 	esac;
+$(srcdir)/../../src/cfa.make $(am__empty):
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -453,5 +447,5 @@
 	@$(MKDIR_P) bits/$(DEPDIR)
 	@: > bits/$(DEPDIR)/$(am__dirstamp)
-bits/libcfa_a-debug.$(OBJEXT): bits/$(am__dirstamp) \
+bits/debug.$(OBJEXT): bits/$(am__dirstamp) \
 	bits/$(DEPDIR)/$(am__dirstamp)
 containers/$(am__dirstamp):
@@ -461,11 +455,11 @@
 	@$(MKDIR_P) containers/$(DEPDIR)
 	@: > containers/$(DEPDIR)/$(am__dirstamp)
-containers/libcfa_a-maybe.$(OBJEXT): containers/$(am__dirstamp) \
+containers/maybe.$(OBJEXT): containers/$(am__dirstamp) \
 	containers/$(DEPDIR)/$(am__dirstamp)
-containers/libcfa_a-pair.$(OBJEXT): containers/$(am__dirstamp) \
+containers/pair.$(OBJEXT): containers/$(am__dirstamp) \
 	containers/$(DEPDIR)/$(am__dirstamp)
-containers/libcfa_a-result.$(OBJEXT): containers/$(am__dirstamp) \
+containers/result.$(OBJEXT): containers/$(am__dirstamp) \
 	containers/$(DEPDIR)/$(am__dirstamp)
-containers/libcfa_a-vector.$(OBJEXT): containers/$(am__dirstamp) \
+containers/vector.$(OBJEXT): containers/$(am__dirstamp) \
 	containers/$(DEPDIR)/$(am__dirstamp)
 concurrency/$(am__dirstamp):
@@ -475,23 +469,22 @@
 	@$(MKDIR_P) concurrency/$(DEPDIR)
 	@: > concurrency/$(DEPDIR)/$(am__dirstamp)
-concurrency/libcfa_a-coroutine.$(OBJEXT): concurrency/$(am__dirstamp) \
+concurrency/coroutine.$(OBJEXT): concurrency/$(am__dirstamp) \
 	concurrency/$(DEPDIR)/$(am__dirstamp)
-concurrency/libcfa_a-thread.$(OBJEXT): concurrency/$(am__dirstamp) \
+concurrency/thread.$(OBJEXT): concurrency/$(am__dirstamp) \
 	concurrency/$(DEPDIR)/$(am__dirstamp)
-concurrency/libcfa_a-kernel.$(OBJEXT): concurrency/$(am__dirstamp) \
+concurrency/kernel.$(OBJEXT): concurrency/$(am__dirstamp) \
 	concurrency/$(DEPDIR)/$(am__dirstamp)
-concurrency/libcfa_a-monitor.$(OBJEXT): concurrency/$(am__dirstamp) \
+concurrency/monitor.$(OBJEXT): concurrency/$(am__dirstamp) \
 	concurrency/$(DEPDIR)/$(am__dirstamp)
-concurrency/libcfa_a-mutex.$(OBJEXT): concurrency/$(am__dirstamp) \
+concurrency/mutex.$(OBJEXT): concurrency/$(am__dirstamp) \
 	concurrency/$(DEPDIR)/$(am__dirstamp)
-concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT):  \
+concurrency/CtxSwitch-@host_alias@.$(OBJEXT):  \
 	concurrency/$(am__dirstamp) \
 	concurrency/$(DEPDIR)/$(am__dirstamp)
-concurrency/libcfa_a-alarm.$(OBJEXT): concurrency/$(am__dirstamp) \
+concurrency/alarm.$(OBJEXT): concurrency/$(am__dirstamp) \
 	concurrency/$(DEPDIR)/$(am__dirstamp)
-concurrency/libcfa_a-invoke.$(OBJEXT): concurrency/$(am__dirstamp) \
+concurrency/invoke.$(OBJEXT): concurrency/$(am__dirstamp) \
 	concurrency/$(DEPDIR)/$(am__dirstamp)
-concurrency/libcfa_a-preemption.$(OBJEXT):  \
-	concurrency/$(am__dirstamp) \
+concurrency/preemption.$(OBJEXT): concurrency/$(am__dirstamp) \
 	concurrency/$(DEPDIR)/$(am__dirstamp)
 
@@ -510,33 +503,9 @@
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-assert.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-common.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-exception.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-fstream.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-heap.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-interpose.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-iostream.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-iterator.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-libcfa-prelude.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-limits.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-rational.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-startup.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-stdlib.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-time.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-virtual.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@bits/$(DEPDIR)/libcfa_a-debug.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/CtxSwitch-@MACHINE_TYPE@.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-alarm.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-coroutine.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-invoke.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-kernel.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-monitor.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-mutex.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-preemption.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-thread.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_a-maybe.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_a-pair.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_a-result.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_a-vector.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exception.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prelude.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/virtual.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/CtxSwitch-@host_alias@.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/invoke.Po@am__quote@
 
 .S.o:
@@ -571,396 +540,4 @@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-
-libcfa_a-libcfa-prelude.o: libcfa-prelude.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-libcfa-prelude.o -MD -MP -MF $(DEPDIR)/libcfa_a-libcfa-prelude.Tpo -c -o libcfa_a-libcfa-prelude.o `test -f 'libcfa-prelude.c' || echo '$(srcdir)/'`libcfa-prelude.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-libcfa-prelude.Tpo $(DEPDIR)/libcfa_a-libcfa-prelude.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libcfa-prelude.c' object='libcfa_a-libcfa-prelude.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-libcfa-prelude.o `test -f 'libcfa-prelude.c' || echo '$(srcdir)/'`libcfa-prelude.c
-
-libcfa_a-libcfa-prelude.obj: libcfa-prelude.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-libcfa-prelude.obj -MD -MP -MF $(DEPDIR)/libcfa_a-libcfa-prelude.Tpo -c -o libcfa_a-libcfa-prelude.obj `if test -f 'libcfa-prelude.c'; then $(CYGPATH_W) 'libcfa-prelude.c'; else $(CYGPATH_W) '$(srcdir)/libcfa-prelude.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-libcfa-prelude.Tpo $(DEPDIR)/libcfa_a-libcfa-prelude.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libcfa-prelude.c' object='libcfa_a-libcfa-prelude.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-libcfa-prelude.obj `if test -f 'libcfa-prelude.c'; then $(CYGPATH_W) 'libcfa-prelude.c'; else $(CYGPATH_W) '$(srcdir)/libcfa-prelude.c'; fi`
-
-libcfa_a-startup.o: startup.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-startup.o -MD -MP -MF $(DEPDIR)/libcfa_a-startup.Tpo -c -o libcfa_a-startup.o `test -f 'startup.c' || echo '$(srcdir)/'`startup.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-startup.Tpo $(DEPDIR)/libcfa_a-startup.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='startup.c' object='libcfa_a-startup.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-startup.o `test -f 'startup.c' || echo '$(srcdir)/'`startup.c
-
-libcfa_a-startup.obj: startup.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-startup.obj -MD -MP -MF $(DEPDIR)/libcfa_a-startup.Tpo -c -o libcfa_a-startup.obj `if test -f 'startup.c'; then $(CYGPATH_W) 'startup.c'; else $(CYGPATH_W) '$(srcdir)/startup.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-startup.Tpo $(DEPDIR)/libcfa_a-startup.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='startup.c' object='libcfa_a-startup.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-startup.obj `if test -f 'startup.c'; then $(CYGPATH_W) 'startup.c'; else $(CYGPATH_W) '$(srcdir)/startup.c'; fi`
-
-libcfa_a-interpose.o: interpose.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-interpose.o -MD -MP -MF $(DEPDIR)/libcfa_a-interpose.Tpo -c -o libcfa_a-interpose.o `test -f 'interpose.c' || echo '$(srcdir)/'`interpose.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-interpose.Tpo $(DEPDIR)/libcfa_a-interpose.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='interpose.c' object='libcfa_a-interpose.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-interpose.o `test -f 'interpose.c' || echo '$(srcdir)/'`interpose.c
-
-libcfa_a-interpose.obj: interpose.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-interpose.obj -MD -MP -MF $(DEPDIR)/libcfa_a-interpose.Tpo -c -o libcfa_a-interpose.obj `if test -f 'interpose.c'; then $(CYGPATH_W) 'interpose.c'; else $(CYGPATH_W) '$(srcdir)/interpose.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-interpose.Tpo $(DEPDIR)/libcfa_a-interpose.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='interpose.c' object='libcfa_a-interpose.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-interpose.obj `if test -f 'interpose.c'; then $(CYGPATH_W) 'interpose.c'; else $(CYGPATH_W) '$(srcdir)/interpose.c'; fi`
-
-bits/libcfa_a-debug.o: bits/debug.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT bits/libcfa_a-debug.o -MD -MP -MF bits/$(DEPDIR)/libcfa_a-debug.Tpo -c -o bits/libcfa_a-debug.o `test -f 'bits/debug.c' || echo '$(srcdir)/'`bits/debug.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) bits/$(DEPDIR)/libcfa_a-debug.Tpo bits/$(DEPDIR)/libcfa_a-debug.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='bits/debug.c' object='bits/libcfa_a-debug.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o bits/libcfa_a-debug.o `test -f 'bits/debug.c' || echo '$(srcdir)/'`bits/debug.c
-
-bits/libcfa_a-debug.obj: bits/debug.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT bits/libcfa_a-debug.obj -MD -MP -MF bits/$(DEPDIR)/libcfa_a-debug.Tpo -c -o bits/libcfa_a-debug.obj `if test -f 'bits/debug.c'; then $(CYGPATH_W) 'bits/debug.c'; else $(CYGPATH_W) '$(srcdir)/bits/debug.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) bits/$(DEPDIR)/libcfa_a-debug.Tpo bits/$(DEPDIR)/libcfa_a-debug.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='bits/debug.c' object='bits/libcfa_a-debug.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o bits/libcfa_a-debug.obj `if test -f 'bits/debug.c'; then $(CYGPATH_W) 'bits/debug.c'; else $(CYGPATH_W) '$(srcdir)/bits/debug.c'; fi`
-
-libcfa_a-assert.o: assert.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-assert.o -MD -MP -MF $(DEPDIR)/libcfa_a-assert.Tpo -c -o libcfa_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-assert.Tpo $(DEPDIR)/libcfa_a-assert.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='assert.c' object='libcfa_a-assert.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
-
-libcfa_a-assert.obj: assert.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-assert.obj -MD -MP -MF $(DEPDIR)/libcfa_a-assert.Tpo -c -o libcfa_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-assert.Tpo $(DEPDIR)/libcfa_a-assert.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='assert.c' object='libcfa_a-assert.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
-
-libcfa_a-exception.o: exception.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-exception.o -MD -MP -MF $(DEPDIR)/libcfa_a-exception.Tpo -c -o libcfa_a-exception.o `test -f 'exception.c' || echo '$(srcdir)/'`exception.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-exception.Tpo $(DEPDIR)/libcfa_a-exception.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='exception.c' object='libcfa_a-exception.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-exception.o `test -f 'exception.c' || echo '$(srcdir)/'`exception.c
-
-libcfa_a-exception.obj: exception.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-exception.obj -MD -MP -MF $(DEPDIR)/libcfa_a-exception.Tpo -c -o libcfa_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-exception.Tpo $(DEPDIR)/libcfa_a-exception.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='exception.c' object='libcfa_a-exception.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi`
-
-libcfa_a-virtual.o: virtual.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-virtual.o -MD -MP -MF $(DEPDIR)/libcfa_a-virtual.Tpo -c -o libcfa_a-virtual.o `test -f 'virtual.c' || echo '$(srcdir)/'`virtual.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-virtual.Tpo $(DEPDIR)/libcfa_a-virtual.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='virtual.c' object='libcfa_a-virtual.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-virtual.o `test -f 'virtual.c' || echo '$(srcdir)/'`virtual.c
-
-libcfa_a-virtual.obj: virtual.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-virtual.obj -MD -MP -MF $(DEPDIR)/libcfa_a-virtual.Tpo -c -o libcfa_a-virtual.obj `if test -f 'virtual.c'; then $(CYGPATH_W) 'virtual.c'; else $(CYGPATH_W) '$(srcdir)/virtual.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-virtual.Tpo $(DEPDIR)/libcfa_a-virtual.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='virtual.c' object='libcfa_a-virtual.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-virtual.obj `if test -f 'virtual.c'; then $(CYGPATH_W) 'virtual.c'; else $(CYGPATH_W) '$(srcdir)/virtual.c'; fi`
-
-libcfa_a-heap.o: heap.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-heap.o -MD -MP -MF $(DEPDIR)/libcfa_a-heap.Tpo -c -o libcfa_a-heap.o `test -f 'heap.c' || echo '$(srcdir)/'`heap.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-heap.Tpo $(DEPDIR)/libcfa_a-heap.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='heap.c' object='libcfa_a-heap.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-heap.o `test -f 'heap.c' || echo '$(srcdir)/'`heap.c
-
-libcfa_a-heap.obj: heap.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-heap.obj -MD -MP -MF $(DEPDIR)/libcfa_a-heap.Tpo -c -o libcfa_a-heap.obj `if test -f 'heap.c'; then $(CYGPATH_W) 'heap.c'; else $(CYGPATH_W) '$(srcdir)/heap.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-heap.Tpo $(DEPDIR)/libcfa_a-heap.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='heap.c' object='libcfa_a-heap.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-heap.obj `if test -f 'heap.c'; then $(CYGPATH_W) 'heap.c'; else $(CYGPATH_W) '$(srcdir)/heap.c'; fi`
-
-libcfa_a-fstream.o: fstream.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-fstream.o -MD -MP -MF $(DEPDIR)/libcfa_a-fstream.Tpo -c -o libcfa_a-fstream.o `test -f 'fstream.c' || echo '$(srcdir)/'`fstream.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-fstream.Tpo $(DEPDIR)/libcfa_a-fstream.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='fstream.c' object='libcfa_a-fstream.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-fstream.o `test -f 'fstream.c' || echo '$(srcdir)/'`fstream.c
-
-libcfa_a-fstream.obj: fstream.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-fstream.obj -MD -MP -MF $(DEPDIR)/libcfa_a-fstream.Tpo -c -o libcfa_a-fstream.obj `if test -f 'fstream.c'; then $(CYGPATH_W) 'fstream.c'; else $(CYGPATH_W) '$(srcdir)/fstream.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-fstream.Tpo $(DEPDIR)/libcfa_a-fstream.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='fstream.c' object='libcfa_a-fstream.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-fstream.obj `if test -f 'fstream.c'; then $(CYGPATH_W) 'fstream.c'; else $(CYGPATH_W) '$(srcdir)/fstream.c'; fi`
-
-libcfa_a-iostream.o: iostream.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-iostream.o -MD -MP -MF $(DEPDIR)/libcfa_a-iostream.Tpo -c -o libcfa_a-iostream.o `test -f 'iostream.c' || echo '$(srcdir)/'`iostream.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-iostream.Tpo $(DEPDIR)/libcfa_a-iostream.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='iostream.c' object='libcfa_a-iostream.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-iostream.o `test -f 'iostream.c' || echo '$(srcdir)/'`iostream.c
-
-libcfa_a-iostream.obj: iostream.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-iostream.obj -MD -MP -MF $(DEPDIR)/libcfa_a-iostream.Tpo -c -o libcfa_a-iostream.obj `if test -f 'iostream.c'; then $(CYGPATH_W) 'iostream.c'; else $(CYGPATH_W) '$(srcdir)/iostream.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-iostream.Tpo $(DEPDIR)/libcfa_a-iostream.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='iostream.c' object='libcfa_a-iostream.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-iostream.obj `if test -f 'iostream.c'; then $(CYGPATH_W) 'iostream.c'; else $(CYGPATH_W) '$(srcdir)/iostream.c'; fi`
-
-libcfa_a-iterator.o: iterator.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-iterator.o -MD -MP -MF $(DEPDIR)/libcfa_a-iterator.Tpo -c -o libcfa_a-iterator.o `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-iterator.Tpo $(DEPDIR)/libcfa_a-iterator.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='iterator.c' object='libcfa_a-iterator.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-iterator.o `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c
-
-libcfa_a-iterator.obj: iterator.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-iterator.obj -MD -MP -MF $(DEPDIR)/libcfa_a-iterator.Tpo -c -o libcfa_a-iterator.obj `if test -f 'iterator.c'; then $(CYGPATH_W) 'iterator.c'; else $(CYGPATH_W) '$(srcdir)/iterator.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-iterator.Tpo $(DEPDIR)/libcfa_a-iterator.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='iterator.c' object='libcfa_a-iterator.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-iterator.obj `if test -f 'iterator.c'; then $(CYGPATH_W) 'iterator.c'; else $(CYGPATH_W) '$(srcdir)/iterator.c'; fi`
-
-libcfa_a-limits.o: limits.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-limits.o -MD -MP -MF $(DEPDIR)/libcfa_a-limits.Tpo -c -o libcfa_a-limits.o `test -f 'limits.c' || echo '$(srcdir)/'`limits.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-limits.Tpo $(DEPDIR)/libcfa_a-limits.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='limits.c' object='libcfa_a-limits.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-limits.o `test -f 'limits.c' || echo '$(srcdir)/'`limits.c
-
-libcfa_a-limits.obj: limits.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-limits.obj -MD -MP -MF $(DEPDIR)/libcfa_a-limits.Tpo -c -o libcfa_a-limits.obj `if test -f 'limits.c'; then $(CYGPATH_W) 'limits.c'; else $(CYGPATH_W) '$(srcdir)/limits.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-limits.Tpo $(DEPDIR)/libcfa_a-limits.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='limits.c' object='libcfa_a-limits.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-limits.obj `if test -f 'limits.c'; then $(CYGPATH_W) 'limits.c'; else $(CYGPATH_W) '$(srcdir)/limits.c'; fi`
-
-libcfa_a-rational.o: rational.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-rational.o -MD -MP -MF $(DEPDIR)/libcfa_a-rational.Tpo -c -o libcfa_a-rational.o `test -f 'rational.c' || echo '$(srcdir)/'`rational.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-rational.Tpo $(DEPDIR)/libcfa_a-rational.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='rational.c' object='libcfa_a-rational.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-rational.o `test -f 'rational.c' || echo '$(srcdir)/'`rational.c
-
-libcfa_a-rational.obj: rational.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-rational.obj -MD -MP -MF $(DEPDIR)/libcfa_a-rational.Tpo -c -o libcfa_a-rational.obj `if test -f 'rational.c'; then $(CYGPATH_W) 'rational.c'; else $(CYGPATH_W) '$(srcdir)/rational.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-rational.Tpo $(DEPDIR)/libcfa_a-rational.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='rational.c' object='libcfa_a-rational.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-rational.obj `if test -f 'rational.c'; then $(CYGPATH_W) 'rational.c'; else $(CYGPATH_W) '$(srcdir)/rational.c'; fi`
-
-libcfa_a-time.o: time.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-time.o -MD -MP -MF $(DEPDIR)/libcfa_a-time.Tpo -c -o libcfa_a-time.o `test -f 'time.c' || echo '$(srcdir)/'`time.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-time.Tpo $(DEPDIR)/libcfa_a-time.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='time.c' object='libcfa_a-time.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-time.o `test -f 'time.c' || echo '$(srcdir)/'`time.c
-
-libcfa_a-time.obj: time.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-time.obj -MD -MP -MF $(DEPDIR)/libcfa_a-time.Tpo -c -o libcfa_a-time.obj `if test -f 'time.c'; then $(CYGPATH_W) 'time.c'; else $(CYGPATH_W) '$(srcdir)/time.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-time.Tpo $(DEPDIR)/libcfa_a-time.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='time.c' object='libcfa_a-time.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-time.obj `if test -f 'time.c'; then $(CYGPATH_W) 'time.c'; else $(CYGPATH_W) '$(srcdir)/time.c'; fi`
-
-libcfa_a-stdlib.o: stdlib.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-stdlib.o -MD -MP -MF $(DEPDIR)/libcfa_a-stdlib.Tpo -c -o libcfa_a-stdlib.o `test -f 'stdlib.c' || echo '$(srcdir)/'`stdlib.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-stdlib.Tpo $(DEPDIR)/libcfa_a-stdlib.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stdlib.c' object='libcfa_a-stdlib.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-stdlib.o `test -f 'stdlib.c' || echo '$(srcdir)/'`stdlib.c
-
-libcfa_a-stdlib.obj: stdlib.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-stdlib.obj -MD -MP -MF $(DEPDIR)/libcfa_a-stdlib.Tpo -c -o libcfa_a-stdlib.obj `if test -f 'stdlib.c'; then $(CYGPATH_W) 'stdlib.c'; else $(CYGPATH_W) '$(srcdir)/stdlib.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-stdlib.Tpo $(DEPDIR)/libcfa_a-stdlib.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stdlib.c' object='libcfa_a-stdlib.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-stdlib.obj `if test -f 'stdlib.c'; then $(CYGPATH_W) 'stdlib.c'; else $(CYGPATH_W) '$(srcdir)/stdlib.c'; fi`
-
-libcfa_a-common.o: common.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-common.o -MD -MP -MF $(DEPDIR)/libcfa_a-common.Tpo -c -o libcfa_a-common.o `test -f 'common.c' || echo '$(srcdir)/'`common.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-common.Tpo $(DEPDIR)/libcfa_a-common.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='common.c' object='libcfa_a-common.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-common.o `test -f 'common.c' || echo '$(srcdir)/'`common.c
-
-libcfa_a-common.obj: common.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-common.obj -MD -MP -MF $(DEPDIR)/libcfa_a-common.Tpo -c -o libcfa_a-common.obj `if test -f 'common.c'; then $(CYGPATH_W) 'common.c'; else $(CYGPATH_W) '$(srcdir)/common.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-common.Tpo $(DEPDIR)/libcfa_a-common.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='common.c' object='libcfa_a-common.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-common.obj `if test -f 'common.c'; then $(CYGPATH_W) 'common.c'; else $(CYGPATH_W) '$(srcdir)/common.c'; fi`
-
-containers/libcfa_a-maybe.o: containers/maybe.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_a-maybe.o -MD -MP -MF containers/$(DEPDIR)/libcfa_a-maybe.Tpo -c -o containers/libcfa_a-maybe.o `test -f 'containers/maybe.c' || echo '$(srcdir)/'`containers/maybe.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_a-maybe.Tpo containers/$(DEPDIR)/libcfa_a-maybe.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='containers/maybe.c' object='containers/libcfa_a-maybe.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-maybe.o `test -f 'containers/maybe.c' || echo '$(srcdir)/'`containers/maybe.c
-
-containers/libcfa_a-maybe.obj: containers/maybe.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_a-maybe.obj -MD -MP -MF containers/$(DEPDIR)/libcfa_a-maybe.Tpo -c -o containers/libcfa_a-maybe.obj `if test -f 'containers/maybe.c'; then $(CYGPATH_W) 'containers/maybe.c'; else $(CYGPATH_W) '$(srcdir)/containers/maybe.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_a-maybe.Tpo containers/$(DEPDIR)/libcfa_a-maybe.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='containers/maybe.c' object='containers/libcfa_a-maybe.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-maybe.obj `if test -f 'containers/maybe.c'; then $(CYGPATH_W) 'containers/maybe.c'; else $(CYGPATH_W) '$(srcdir)/containers/maybe.c'; fi`
-
-containers/libcfa_a-pair.o: containers/pair.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_a-pair.o -MD -MP -MF containers/$(DEPDIR)/libcfa_a-pair.Tpo -c -o containers/libcfa_a-pair.o `test -f 'containers/pair.c' || echo '$(srcdir)/'`containers/pair.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_a-pair.Tpo containers/$(DEPDIR)/libcfa_a-pair.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='containers/pair.c' object='containers/libcfa_a-pair.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-pair.o `test -f 'containers/pair.c' || echo '$(srcdir)/'`containers/pair.c
-
-containers/libcfa_a-pair.obj: containers/pair.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_a-pair.obj -MD -MP -MF containers/$(DEPDIR)/libcfa_a-pair.Tpo -c -o containers/libcfa_a-pair.obj `if test -f 'containers/pair.c'; then $(CYGPATH_W) 'containers/pair.c'; else $(CYGPATH_W) '$(srcdir)/containers/pair.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_a-pair.Tpo containers/$(DEPDIR)/libcfa_a-pair.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='containers/pair.c' object='containers/libcfa_a-pair.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-pair.obj `if test -f 'containers/pair.c'; then $(CYGPATH_W) 'containers/pair.c'; else $(CYGPATH_W) '$(srcdir)/containers/pair.c'; fi`
-
-containers/libcfa_a-result.o: containers/result.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_a-result.o -MD -MP -MF containers/$(DEPDIR)/libcfa_a-result.Tpo -c -o containers/libcfa_a-result.o `test -f 'containers/result.c' || echo '$(srcdir)/'`containers/result.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_a-result.Tpo containers/$(DEPDIR)/libcfa_a-result.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='containers/result.c' object='containers/libcfa_a-result.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-result.o `test -f 'containers/result.c' || echo '$(srcdir)/'`containers/result.c
-
-containers/libcfa_a-result.obj: containers/result.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_a-result.obj -MD -MP -MF containers/$(DEPDIR)/libcfa_a-result.Tpo -c -o containers/libcfa_a-result.obj `if test -f 'containers/result.c'; then $(CYGPATH_W) 'containers/result.c'; else $(CYGPATH_W) '$(srcdir)/containers/result.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_a-result.Tpo containers/$(DEPDIR)/libcfa_a-result.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='containers/result.c' object='containers/libcfa_a-result.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-result.obj `if test -f 'containers/result.c'; then $(CYGPATH_W) 'containers/result.c'; else $(CYGPATH_W) '$(srcdir)/containers/result.c'; fi`
-
-containers/libcfa_a-vector.o: containers/vector.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_a-vector.o -MD -MP -MF containers/$(DEPDIR)/libcfa_a-vector.Tpo -c -o containers/libcfa_a-vector.o `test -f 'containers/vector.c' || echo '$(srcdir)/'`containers/vector.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_a-vector.Tpo containers/$(DEPDIR)/libcfa_a-vector.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='containers/vector.c' object='containers/libcfa_a-vector.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-vector.o `test -f 'containers/vector.c' || echo '$(srcdir)/'`containers/vector.c
-
-containers/libcfa_a-vector.obj: containers/vector.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_a-vector.obj -MD -MP -MF containers/$(DEPDIR)/libcfa_a-vector.Tpo -c -o containers/libcfa_a-vector.obj `if test -f 'containers/vector.c'; then $(CYGPATH_W) 'containers/vector.c'; else $(CYGPATH_W) '$(srcdir)/containers/vector.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) containers/$(DEPDIR)/libcfa_a-vector.Tpo containers/$(DEPDIR)/libcfa_a-vector.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='containers/vector.c' object='containers/libcfa_a-vector.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-vector.obj `if test -f 'containers/vector.c'; then $(CYGPATH_W) 'containers/vector.c'; else $(CYGPATH_W) '$(srcdir)/containers/vector.c'; fi`
-
-concurrency/libcfa_a-coroutine.o: concurrency/coroutine.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutine.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo -c -o concurrency/libcfa_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutine.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_a-coroutine.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c
-
-concurrency/libcfa_a-coroutine.obj: concurrency/coroutine.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutine.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo -c -o concurrency/libcfa_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutine.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_a-coroutine.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi`
-
-concurrency/libcfa_a-thread.o: concurrency/thread.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-thread.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-thread.Tpo -c -o concurrency/libcfa_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_a-thread.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_a-thread.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c
-
-concurrency/libcfa_a-thread.obj: concurrency/thread.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-thread.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-thread.Tpo -c -o concurrency/libcfa_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_a-thread.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_a-thread.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi`
-
-concurrency/libcfa_a-kernel.o: concurrency/kernel.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-kernel.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-kernel.Tpo -c -o concurrency/libcfa_a-kernel.o `test -f 'concurrency/kernel.c' || echo '$(srcdir)/'`concurrency/kernel.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-kernel.Tpo concurrency/$(DEPDIR)/libcfa_a-kernel.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/kernel.c' object='concurrency/libcfa_a-kernel.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-kernel.o `test -f 'concurrency/kernel.c' || echo '$(srcdir)/'`concurrency/kernel.c
-
-concurrency/libcfa_a-kernel.obj: concurrency/kernel.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-kernel.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-kernel.Tpo -c -o concurrency/libcfa_a-kernel.obj `if test -f 'concurrency/kernel.c'; then $(CYGPATH_W) 'concurrency/kernel.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/kernel.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-kernel.Tpo concurrency/$(DEPDIR)/libcfa_a-kernel.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/kernel.c' object='concurrency/libcfa_a-kernel.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-kernel.obj `if test -f 'concurrency/kernel.c'; then $(CYGPATH_W) 'concurrency/kernel.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/kernel.c'; fi`
-
-concurrency/libcfa_a-monitor.o: concurrency/monitor.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-monitor.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-monitor.Tpo -c -o concurrency/libcfa_a-monitor.o `test -f 'concurrency/monitor.c' || echo '$(srcdir)/'`concurrency/monitor.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-monitor.Tpo concurrency/$(DEPDIR)/libcfa_a-monitor.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/monitor.c' object='concurrency/libcfa_a-monitor.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-monitor.o `test -f 'concurrency/monitor.c' || echo '$(srcdir)/'`concurrency/monitor.c
-
-concurrency/libcfa_a-monitor.obj: concurrency/monitor.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-monitor.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-monitor.Tpo -c -o concurrency/libcfa_a-monitor.obj `if test -f 'concurrency/monitor.c'; then $(CYGPATH_W) 'concurrency/monitor.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/monitor.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-monitor.Tpo concurrency/$(DEPDIR)/libcfa_a-monitor.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/monitor.c' object='concurrency/libcfa_a-monitor.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-monitor.obj `if test -f 'concurrency/monitor.c'; then $(CYGPATH_W) 'concurrency/monitor.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/monitor.c'; fi`
-
-concurrency/libcfa_a-mutex.o: concurrency/mutex.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-mutex.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-mutex.Tpo -c -o concurrency/libcfa_a-mutex.o `test -f 'concurrency/mutex.c' || echo '$(srcdir)/'`concurrency/mutex.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-mutex.Tpo concurrency/$(DEPDIR)/libcfa_a-mutex.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/mutex.c' object='concurrency/libcfa_a-mutex.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-mutex.o `test -f 'concurrency/mutex.c' || echo '$(srcdir)/'`concurrency/mutex.c
-
-concurrency/libcfa_a-mutex.obj: concurrency/mutex.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-mutex.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-mutex.Tpo -c -o concurrency/libcfa_a-mutex.obj `if test -f 'concurrency/mutex.c'; then $(CYGPATH_W) 'concurrency/mutex.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/mutex.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-mutex.Tpo concurrency/$(DEPDIR)/libcfa_a-mutex.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/mutex.c' object='concurrency/libcfa_a-mutex.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-mutex.obj `if test -f 'concurrency/mutex.c'; then $(CYGPATH_W) 'concurrency/mutex.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/mutex.c'; fi`
-
-concurrency/libcfa_a-alarm.o: concurrency/alarm.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-alarm.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-alarm.Tpo -c -o concurrency/libcfa_a-alarm.o `test -f 'concurrency/alarm.c' || echo '$(srcdir)/'`concurrency/alarm.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-alarm.Tpo concurrency/$(DEPDIR)/libcfa_a-alarm.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/alarm.c' object='concurrency/libcfa_a-alarm.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-alarm.o `test -f 'concurrency/alarm.c' || echo '$(srcdir)/'`concurrency/alarm.c
-
-concurrency/libcfa_a-alarm.obj: concurrency/alarm.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-alarm.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-alarm.Tpo -c -o concurrency/libcfa_a-alarm.obj `if test -f 'concurrency/alarm.c'; then $(CYGPATH_W) 'concurrency/alarm.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/alarm.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-alarm.Tpo concurrency/$(DEPDIR)/libcfa_a-alarm.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/alarm.c' object='concurrency/libcfa_a-alarm.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-alarm.obj `if test -f 'concurrency/alarm.c'; then $(CYGPATH_W) 'concurrency/alarm.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/alarm.c'; fi`
-
-concurrency/libcfa_a-invoke.o: concurrency/invoke.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-invoke.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-invoke.Tpo -c -o concurrency/libcfa_a-invoke.o `test -f 'concurrency/invoke.c' || echo '$(srcdir)/'`concurrency/invoke.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-invoke.Tpo concurrency/$(DEPDIR)/libcfa_a-invoke.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/invoke.c' object='concurrency/libcfa_a-invoke.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-invoke.o `test -f 'concurrency/invoke.c' || echo '$(srcdir)/'`concurrency/invoke.c
-
-concurrency/libcfa_a-invoke.obj: concurrency/invoke.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-invoke.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-invoke.Tpo -c -o concurrency/libcfa_a-invoke.obj `if test -f 'concurrency/invoke.c'; then $(CYGPATH_W) 'concurrency/invoke.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/invoke.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-invoke.Tpo concurrency/$(DEPDIR)/libcfa_a-invoke.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/invoke.c' object='concurrency/libcfa_a-invoke.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-invoke.obj `if test -f 'concurrency/invoke.c'; then $(CYGPATH_W) 'concurrency/invoke.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/invoke.c'; fi`
-
-concurrency/libcfa_a-preemption.o: concurrency/preemption.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-preemption.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-preemption.Tpo -c -o concurrency/libcfa_a-preemption.o `test -f 'concurrency/preemption.c' || echo '$(srcdir)/'`concurrency/preemption.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-preemption.Tpo concurrency/$(DEPDIR)/libcfa_a-preemption.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/preemption.c' object='concurrency/libcfa_a-preemption.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-preemption.o `test -f 'concurrency/preemption.c' || echo '$(srcdir)/'`concurrency/preemption.c
-
-concurrency/libcfa_a-preemption.obj: concurrency/preemption.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-preemption.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-preemption.Tpo -c -o concurrency/libcfa_a-preemption.obj `if test -f 'concurrency/preemption.c'; then $(CYGPATH_W) 'concurrency/preemption.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/preemption.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-preemption.Tpo concurrency/$(DEPDIR)/libcfa_a-preemption.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='concurrency/preemption.c' object='concurrency/libcfa_a-preemption.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-preemption.obj `if test -f 'concurrency/preemption.c'; then $(CYGPATH_W) 'concurrency/preemption.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/preemption.c'; fi`
 install-nobase_cfa_includeHEADERS: $(nobase_cfa_include_HEADERS)
 	@$(NORMAL_INSTALL)
@@ -1119,5 +696,5 @@
 
 distclean: distclean-am
-	-rm -rf ./$(DEPDIR) bits/$(DEPDIR) concurrency/$(DEPDIR) containers/$(DEPDIR)
+	-rm -rf ./$(DEPDIR) concurrency/$(DEPDIR)
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
@@ -1165,5 +742,5 @@
 
 maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR) bits/$(DEPDIR) concurrency/$(DEPDIR) containers/$(DEPDIR)
+	-rm -rf ./$(DEPDIR) concurrency/$(DEPDIR)
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic \
@@ -1205,6 +782,8 @@
 
 
-libcfa-prelude.o : libcfa-prelude.c
-	 ${AM_V_GEN}gcc  -Wall -O2 -c -o $@ $<
+.cfa.o: $(CFACC) $(CFACPP)
+	$(AM_V_CFA)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+	$(CFACOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+	$(am__mv) $$depbase.Tpo $$depbase.Po
 
 # extensionless header files are overridden by -o flag in default makerule => explicitly override default rule to silently do nothing
@@ -1219,14 +798,5 @@
 	false
 
-concurrency/invoke.o : concurrency/invoke.c
-	${AM_V_CC}gcc -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
-
-exception.o : exception.c
-	${AM_V_CC}gcc -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
-
-virtual.o : virtual.c
-	${AM_V_CC}gcc -DHAVE_CONFIG_H -I. -I../.. -D__CFA_DEBUG__ -O0 ${EXTRA_FLAGS} -c -o $@ $<
-
-${libobjs} : @CFACPP@ ${cfalib_DATA} # add dependency to cfa-cpp so all libraries are rebuilt with new translator
+${libobjs} : ${cfalib_DATA} # add dependency to cfa-cpp so all libraries are rebuilt with new translator
 
 maintainer-clean-local:
Index: libcfa/src/assert.c
===================================================================
--- libcfa/src/assert.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,51 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// assert.c --
-//
-// Author           : Thierry Delisle
-// Created On       : Mon Nov 28 12:27:26 2016
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jul 20 15:10:26 2017
-// Update Count     : 2
-//
-
-#include <assert.h>
-#include <stdarg.h>								// varargs
-#include <stdio.h>								// fprintf
-#include "bits/debug.h"
-
-extern "C" {
-	extern const char * __progname;						// global name of running executable (argv[0])
-
-	#define CFA_ASSERT_FMT "Cforall Assertion error \"%s\" from program \"%s\" in \"%s\" at line %d in file \"%s\""
-
-	// called by macro assert in assert.h
-	void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
-		__cfaabi_dbg_bits_print_safe( CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
-		abort();
-	}
-
-	// called by macro assertf
-	void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
-		__cfaabi_dbg_bits_acquire();
-		__cfaabi_dbg_bits_print_nolock( CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
-
-		va_list args;
-		va_start( args, fmt );
-		__cfaabi_dbg_bits_print_vararg( fmt, args );
-		va_end( args );
-
-		__cfaabi_dbg_bits_print_nolock( "\n" );
-		__cfaabi_dbg_bits_release();
-		abort();
-	}
-}
-
-// Local Variables: //
-// mode: c //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/assert.cfa
===================================================================
--- libcfa/src/assert.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/assert.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,51 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// assert.c --
+//
+// Author           : Thierry Delisle
+// Created On       : Mon Nov 28 12:27:26 2016
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Thu Jul 20 15:10:26 2017
+// Update Count     : 2
+//
+
+#include <assert.h>
+#include <stdarg.h>								// varargs
+#include <stdio.h>								// fprintf
+#include "bits/debug.h"
+
+extern "C" {
+	extern const char * __progname;						// global name of running executable (argv[0])
+
+	#define CFA_ASSERT_FMT "Cforall Assertion error \"%s\" from program \"%s\" in \"%s\" at line %d in file \"%s\""
+
+	// called by macro assert in assert.h
+	void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
+		__cfaabi_dbg_bits_print_safe( CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
+		abort();
+	}
+
+	// called by macro assertf
+	void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
+		__cfaabi_dbg_bits_acquire();
+		__cfaabi_dbg_bits_print_nolock( CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
+
+		va_list args;
+		va_start( args, fmt );
+		__cfaabi_dbg_bits_print_vararg( fmt, args );
+		va_end( args );
+
+		__cfaabi_dbg_bits_print_nolock( "\n" );
+		__cfaabi_dbg_bits_release();
+		abort();
+	}
+}
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/bits/debug.c
===================================================================
--- libcfa/src/bits/debug.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,88 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// debug.c --
-//
-// Author           : Thierry Delisle
-// Created On       : Thu Mar 30 12:30:01 2017
-// Last Modified By :
-// Last Modified On :
-// Update Count     : 1
-//
-
-extern "C" {
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <unistd.h>
-}
-
-enum { buffer_size = 512 };
-static char buffer[ buffer_size ];
-
-extern "C" {
-
-	void __cfaabi_dbg_bits_write( const char *in_buffer, int len ) {
-		// ensure all data is written
-		for ( int count = 0, retcode; count < len; count += retcode ) {
-			in_buffer += count;
-
-			for ( ;; ) {
-				retcode = write( STDERR_FILENO, in_buffer, len - count );
-
-				// not a timer interrupt ?
-				if ( retcode != -1 || errno != EINTR ) break;
-			}
-
-			if ( retcode == -1 ) _exit( EXIT_FAILURE );
-		}
-	}
-
-	void __cfaabi_dbg_bits_acquire() __attribute__((__weak__)) {}
-	void __cfaabi_dbg_bits_release() __attribute__((__weak__)) {}
-
-	void __cfaabi_dbg_bits_print_safe  ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {
-		va_list args;
-
-		va_start( args, fmt );
-		__cfaabi_dbg_bits_acquire();
-
-		int len = vsnprintf( buffer, buffer_size, fmt, args );
-		__cfaabi_dbg_bits_write( buffer, len );
-
-		__cfaabi_dbg_bits_release();
-		va_end( args );
-	}
-
-	void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {
-		va_list args;
-
-		va_start( args, fmt );
-
-		int len = vsnprintf( buffer, buffer_size, fmt, args );
-		__cfaabi_dbg_bits_write( buffer, len );
-
-		va_end( args );
-	}
-
-	void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list args ) {
-		int len = vsnprintf( buffer, buffer_size, fmt, args );
-		__cfaabi_dbg_bits_write( buffer, len );
-	}
-
-	void __cfaabi_dbg_bits_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) )) {
-		va_list args;
-
-		va_start( args, fmt );
-
-		int len = vsnprintf( in_buffer, in_buffer_size, fmt, args );
-		__cfaabi_dbg_bits_write( in_buffer, len );
-
-		va_end( args );
-	}
-}
Index: libcfa/src/bits/debug.cfa
===================================================================
--- libcfa/src/bits/debug.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/bits/debug.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,88 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// debug.c --
+//
+// Author           : Thierry Delisle
+// Created On       : Thu Mar 30 12:30:01 2017
+// Last Modified By :
+// Last Modified On :
+// Update Count     : 1
+//
+
+extern "C" {
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <unistd.h>
+}
+
+enum { buffer_size = 512 };
+static char buffer[ buffer_size ];
+
+extern "C" {
+
+	void __cfaabi_dbg_bits_write( const char *in_buffer, int len ) {
+		// ensure all data is written
+		for ( int count = 0, retcode; count < len; count += retcode ) {
+			in_buffer += count;
+
+			for ( ;; ) {
+				retcode = write( STDERR_FILENO, in_buffer, len - count );
+
+				// not a timer interrupt ?
+				if ( retcode != -1 || errno != EINTR ) break;
+			}
+
+			if ( retcode == -1 ) _exit( EXIT_FAILURE );
+		}
+	}
+
+	void __cfaabi_dbg_bits_acquire() __attribute__((__weak__)) {}
+	void __cfaabi_dbg_bits_release() __attribute__((__weak__)) {}
+
+	void __cfaabi_dbg_bits_print_safe  ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {
+		va_list args;
+
+		va_start( args, fmt );
+		__cfaabi_dbg_bits_acquire();
+
+		int len = vsnprintf( buffer, buffer_size, fmt, args );
+		__cfaabi_dbg_bits_write( buffer, len );
+
+		__cfaabi_dbg_bits_release();
+		va_end( args );
+	}
+
+	void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {
+		va_list args;
+
+		va_start( args, fmt );
+
+		int len = vsnprintf( buffer, buffer_size, fmt, args );
+		__cfaabi_dbg_bits_write( buffer, len );
+
+		va_end( args );
+	}
+
+	void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list args ) {
+		int len = vsnprintf( buffer, buffer_size, fmt, args );
+		__cfaabi_dbg_bits_write( buffer, len );
+	}
+
+	void __cfaabi_dbg_bits_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) )) {
+		va_list args;
+
+		va_start( args, fmt );
+
+		int len = vsnprintf( in_buffer, in_buffer_size, fmt, args );
+		__cfaabi_dbg_bits_write( in_buffer, len );
+
+		va_end( args );
+	}
+}
Index: libcfa/src/common.c
===================================================================
--- libcfa/src/common.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,31 +1,0 @@
-//                               -*- Mode: C -*- 
-// 
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-// 
-// common.c -- 
-// 
-// Author           : Peter A. Buhr
-// Created On       : Thu Jul 12 08:02:29 2018
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jul 12 08:38:47 2018
-// Update Count     : 3
-// 
-
-#include "common"
-#include <stdlib.h>					// div_t, *div
-
-//---------------------------------------
-
-[ int, int ] div( int num, int denom ) { div_t qr = div( num, denom ); return [ qr.quot, qr.rem ]; }
-[ long int, long int ] div( long int num, long int denom ) { ldiv_t qr = ldiv( num, denom ); return [ qr.quot, qr.rem ]; }
-[ long long int, long long int ] div( long long int num, long long int denom ) { lldiv_t qr = lldiv( num, denom ); return [ qr.quot, qr.rem ]; }
-forall( otype T | { T ?/?( T, T ); T ?%?( T, T ); } )
-[ T, T ] div( T num, T denom ) { return [ num / denom, num % denom ]; }
-
-// Local Variables: //
-// mode: c //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/common.cfa
===================================================================
--- libcfa/src/common.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/common.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,31 @@
+//                               -*- Mode: C -*- 
+// 
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+// 
+// common.c -- 
+// 
+// Author           : Peter A. Buhr
+// Created On       : Thu Jul 12 08:02:29 2018
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Thu Jul 12 08:38:47 2018
+// Update Count     : 3
+// 
+
+#include "common"
+#include <stdlib.h>					// div_t, *div
+
+//---------------------------------------
+
+[ int, int ] div( int num, int denom ) { div_t qr = div( num, denom ); return [ qr.quot, qr.rem ]; }
+[ long int, long int ] div( long int num, long int denom ) { ldiv_t qr = ldiv( num, denom ); return [ qr.quot, qr.rem ]; }
+[ long long int, long long int ] div( long long int num, long long int denom ) { lldiv_t qr = lldiv( num, denom ); return [ qr.quot, qr.rem ]; }
+forall( otype T | { T ?/?( T, T ); T ?%?( T, T ); } )
+[ T, T ] div( T num, T denom ) { return [ num / denom, num % denom ]; }
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/concurrency/alarm.c
===================================================================
--- libcfa/src/concurrency/alarm.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,179 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// alarm.c --
-//
-// Author           : Thierry Delisle
-// Created On       : Fri Jun 2 11:31:25 2017
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Fri May 25 06:25:47 2018
-// Update Count     : 67
-//
-
-extern "C" {
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-}
-
-#include "alarm.h"
-#include "kernel_private.h"
-#include "preemption.h"
-
-//=============================================================================================
-// Clock logic
-//=============================================================================================
-
-Time __kernel_get_time() {
-	timespec curr;
-	clock_gettime( CLOCK_MONOTONIC_RAW, &curr );		// CLOCK_REALTIME
-	return (Time){ curr };
-}
-
-void __kernel_set_timer( Duration alarm ) {
-	verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm.tv);
-	setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL );
-}
-
-//=============================================================================================
-// Alarm logic
-//=============================================================================================
-
-void ?{}( alarm_node_t & this, thread_desc * thrd, Time alarm, Duration period ) with( this ) {
-	this.thrd = thrd;
-	this.alarm = alarm;
-	this.period = period;
-	next = 0;
-	set = false;
-	kernel_alarm = false;
-}
-
-void ?{}( alarm_node_t & this, processor   * proc, Time alarm, Duration period ) with( this ) {
-	this.proc = proc;
-	this.alarm = alarm;
-	this.period = period;
-	next = 0;
-	set = false;
-	kernel_alarm = true;
-}
-
-void ^?{}( alarm_node_t & this ) {
-	if( this.set ) {
-		unregister_self( &this );
-	}
-}
-
-#if !defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__))
-bool validate( alarm_list_t * this ) {
-	alarm_node_t ** it = &this->head;
-	while( (*it) ) {
-		it = &(*it)->next;
-	}
-
-	return it == this->tail;
-}
-#endif
-
-static inline void insert_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t p ) {
-	verify( !n->next );
-	if( p == this->tail ) {
-		this->tail = &n->next;
-	}
-	else {
-		n->next = *p;
-	}
-	*p = n;
-
-	verify( validate( this ) );
-}
-
-void insert( alarm_list_t * this, alarm_node_t * n ) {
-	alarm_node_t ** it = &this->head;
-	while( (*it) && (n->alarm > (*it)->alarm) ) {
-		it = &(*it)->next;
-	}
-
-	insert_at( this, n, it );
-
-	verify( validate( this ) );
-}
-
-alarm_node_t * pop( alarm_list_t * this ) {
-	alarm_node_t * head = this->head;
-	if( head ) {
-		this->head = head->next;
-		if( !head->next ) {
-			this->tail = &this->head;
-		}
-		head->next = NULL;
-	}
-	verify( validate( this ) );
-	return head;
-}
-
-static inline void remove_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t it ) {
-	verify( it );
-	verify( (*it) == n );
-
-	(*it) = n->next;
-	if( !n-> next ) {
-		this->tail = it;
-	}
-	n->next = NULL;
-
-	verify( validate( this ) );
-}
-
-static inline void remove( alarm_list_t * this, alarm_node_t * n ) {
-	alarm_node_t ** it = &this->head;
-	while( (*it) && (*it) != n ) {
-		it = &(*it)->next;
-	}
-
-	verify( validate( this ) );
-
-	if( *it ) { remove_at( this, n, it ); }
-
-	verify( validate( this ) );
-}
-
-void register_self( alarm_node_t * this ) {
-	alarm_list_t * alarms = &event_kernel->alarms;
-
-	disable_interrupts();
-	lock( event_kernel->lock __cfaabi_dbg_ctx2 );
-	{
-		verify( validate( alarms ) );
-		bool first = !alarms->head;
-
-		insert( alarms, this );
-		if( first ) {
-			__kernel_set_timer( alarms->head->alarm - __kernel_get_time() );
-		}
-	}
-	unlock( event_kernel->lock );
-	this->set = true;
-	enable_interrupts( __cfaabi_dbg_ctx );
-}
-
-void unregister_self( alarm_node_t * this ) {
-	disable_interrupts();
-	lock( event_kernel->lock __cfaabi_dbg_ctx2 );
-	{
-		verify( validate( &event_kernel->alarms ) );
-		remove( &event_kernel->alarms, this );
-	}
-	unlock( event_kernel->lock );
-	enable_interrupts( __cfaabi_dbg_ctx );
-	this->set = false;
-}
-
-// Local Variables: //
-// mode: c //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/concurrency/alarm.cfa
===================================================================
--- libcfa/src/concurrency/alarm.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/concurrency/alarm.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,179 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// alarm.c --
+//
+// Author           : Thierry Delisle
+// Created On       : Fri Jun 2 11:31:25 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Fri May 25 06:25:47 2018
+// Update Count     : 67
+//
+
+extern "C" {
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
+}
+
+#include "alarm.h"
+#include "kernel_private.h"
+#include "preemption.h"
+
+//=============================================================================================
+// Clock logic
+//=============================================================================================
+
+Time __kernel_get_time() {
+	timespec curr;
+	clock_gettime( CLOCK_MONOTONIC_RAW, &curr );		// CLOCK_REALTIME
+	return (Time){ curr };
+}
+
+void __kernel_set_timer( Duration alarm ) {
+	verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm.tv);
+	setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL );
+}
+
+//=============================================================================================
+// Alarm logic
+//=============================================================================================
+
+void ?{}( alarm_node_t & this, thread_desc * thrd, Time alarm, Duration period ) with( this ) {
+	this.thrd = thrd;
+	this.alarm = alarm;
+	this.period = period;
+	next = 0;
+	set = false;
+	kernel_alarm = false;
+}
+
+void ?{}( alarm_node_t & this, processor   * proc, Time alarm, Duration period ) with( this ) {
+	this.proc = proc;
+	this.alarm = alarm;
+	this.period = period;
+	next = 0;
+	set = false;
+	kernel_alarm = true;
+}
+
+void ^?{}( alarm_node_t & this ) {
+	if( this.set ) {
+		unregister_self( &this );
+	}
+}
+
+#if !defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__))
+bool validate( alarm_list_t * this ) {
+	alarm_node_t ** it = &this->head;
+	while( (*it) ) {
+		it = &(*it)->next;
+	}
+
+	return it == this->tail;
+}
+#endif
+
+static inline void insert_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t p ) {
+	verify( !n->next );
+	if( p == this->tail ) {
+		this->tail = &n->next;
+	}
+	else {
+		n->next = *p;
+	}
+	*p = n;
+
+	verify( validate( this ) );
+}
+
+void insert( alarm_list_t * this, alarm_node_t * n ) {
+	alarm_node_t ** it = &this->head;
+	while( (*it) && (n->alarm > (*it)->alarm) ) {
+		it = &(*it)->next;
+	}
+
+	insert_at( this, n, it );
+
+	verify( validate( this ) );
+}
+
+alarm_node_t * pop( alarm_list_t * this ) {
+	alarm_node_t * head = this->head;
+	if( head ) {
+		this->head = head->next;
+		if( !head->next ) {
+			this->tail = &this->head;
+		}
+		head->next = NULL;
+	}
+	verify( validate( this ) );
+	return head;
+}
+
+static inline void remove_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t it ) {
+	verify( it );
+	verify( (*it) == n );
+
+	(*it) = n->next;
+	if( !n-> next ) {
+		this->tail = it;
+	}
+	n->next = NULL;
+
+	verify( validate( this ) );
+}
+
+static inline void remove( alarm_list_t * this, alarm_node_t * n ) {
+	alarm_node_t ** it = &this->head;
+	while( (*it) && (*it) != n ) {
+		it = &(*it)->next;
+	}
+
+	verify( validate( this ) );
+
+	if( *it ) { remove_at( this, n, it ); }
+
+	verify( validate( this ) );
+}
+
+void register_self( alarm_node_t * this ) {
+	alarm_list_t * alarms = &event_kernel->alarms;
+
+	disable_interrupts();
+	lock( event_kernel->lock __cfaabi_dbg_ctx2 );
+	{
+		verify( validate( alarms ) );
+		bool first = !alarms->head;
+
+		insert( alarms, this );
+		if( first ) {
+			__kernel_set_timer( alarms->head->alarm - __kernel_get_time() );
+		}
+	}
+	unlock( event_kernel->lock );
+	this->set = true;
+	enable_interrupts( __cfaabi_dbg_ctx );
+}
+
+void unregister_self( alarm_node_t * this ) {
+	disable_interrupts();
+	lock( event_kernel->lock __cfaabi_dbg_ctx2 );
+	{
+		verify( validate( &event_kernel->alarms ) );
+		remove( &event_kernel->alarms, this );
+	}
+	unlock( event_kernel->lock );
+	enable_interrupts( __cfaabi_dbg_ctx );
+	this->set = false;
+}
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/concurrency/coroutine.c
===================================================================
--- libcfa/src/concurrency/coroutine.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,183 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// coroutine.c --
-//
-// Author           : Thierry Delisle
-// Created On       : Mon Nov 28 12:27:26 2016
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Mar 30 17:20:57 2018
-// Update Count     : 9
-//
-
-#include "coroutine"
-
-extern "C" {
-#include <stddef.h>
-#include <malloc.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-}
-
-#include "kernel_private.h"
-
-#define __CFA_INVOKE_PRIVATE__
-#include "invoke.h"
-
-//-----------------------------------------------------------------------------
-// Global state variables
-
-// minimum feasible stack size in bytes
-#define MinStackSize 1000
-static size_t pageSize = 0;				// architecture pagesize HACK, should go in proper runtime singleton
-
-//-----------------------------------------------------------------------------
-// Coroutine ctors and dtors
-void ?{}( coStack_t & this, void * storage, size_t storageSize ) with( this ) {
-      size		 = storageSize == 0 ? 65000 : storageSize; // size of stack
-      this.storage = storage;                                // pointer to stack
-      limit		 = NULL;                                   // stack grows towards stack limit
-      base		 = NULL;                                   // base of stack
-      context	 = NULL;                                   // address of cfa_context_t
-      top		 = NULL;                                   // address of top of storage
-      userStack	 = storage != NULL;
-}
-
-void ^?{}(coStack_t & this) {
-      if ( ! this.userStack && this.storage ) {
-            __cfaabi_dbg_debug_do(
-                  if ( mprotect( this.storage, pageSize, PROT_READ | PROT_WRITE ) == -1 ) {
-                        abort( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) );
-                  }
-            );
-            free( this.storage );
-      }
-}
-
-void ?{}( coroutine_desc & this, const char * name, void * storage, size_t storageSize ) with( this ) {
-      (this.stack){storage, storageSize};
-      this.name = name;
-      errno_ = 0;
-      state = Start;
-      starter = NULL;
-      last = NULL;
-}
-
-void ^?{}(coroutine_desc& this) {}
-
-// Part of the Public API
-// Not inline since only ever called once per coroutine
-forall(dtype T | is_coroutine(T))
-void prime(T& cor) {
-      coroutine_desc* this = get_coroutine(cor);
-      assert(this->state == Start);
-
-      this->state = Primed;
-      resume(cor);
-}
-
-// Wrapper for co
-void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
-      // Safety note : This could cause some false positives due to preemption
-      verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate );
-      disable_interrupts();
-
-      // set state of current coroutine to inactive
-      src->state = src->state == Halted ? Halted : Inactive;
-
-      // set new coroutine that task is executing
-      kernelTLS.this_coroutine = dst;
-
-      // context switch to specified coroutine
-      assert( src->stack.context );
-      CtxSwitch( src->stack.context, dst->stack.context );
-      // when CtxSwitch returns we are back in the src coroutine
-
-      // set state of new coroutine to active
-      src->state = Active;
-
-      enable_interrupts( __cfaabi_dbg_ctx );
-      // Safety note : This could cause some false positives due to preemption
-      verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate );
-} //ctxSwitchDirect
-
-void create_stack( coStack_t* this, unsigned int storageSize ) with( *this ) {
-      //TEMP HACK do this on proper kernel startup
-      if(pageSize == 0ul) pageSize = sysconf( _SC_PAGESIZE );
-
-      size_t cxtSize = libCeiling( sizeof(machine_context_t), 8 ); // minimum alignment
-
-      if ( !storage ) {
-            __cfaabi_dbg_print_safe("Kernel : Creating stack of size %zu for stack obj %p\n", cxtSize + size + 8, this);
-
-            userStack = false;
-            size = libCeiling( storageSize, 16 );
-            // use malloc/memalign because "new" raises an exception for out-of-memory
-
-            // assume malloc has 8 byte alignment so add 8 to allow rounding up to 16 byte alignment
-            __cfaabi_dbg_debug_do( storage = memalign( pageSize, cxtSize + size + pageSize ) );
-            __cfaabi_dbg_no_debug_do( storage = malloc( cxtSize + size + 8 ) );
-
-            __cfaabi_dbg_debug_do(
-                  if ( mprotect( storage, pageSize, PROT_NONE ) == -1 ) {
-                        abort( "(uMachContext &)%p.createContext() : internal error, mprotect failure, error(%d) %s.", this, (int)errno, strerror( (int)errno ) );
-                  } // if
-            );
-
-            if ( (intptr_t)storage == 0 ) {
-                  abort( "Attempt to allocate %zd bytes of storage for coroutine or task execution-state but insufficient memory available.", size );
-            } // if
-
-            __cfaabi_dbg_debug_do( limit = (char *)storage + pageSize );
-            __cfaabi_dbg_no_debug_do( limit = (char *)libCeiling( (unsigned long)storage, 16 ) ); // minimum alignment
-
-      } else {
-            __cfaabi_dbg_print_safe("Kernel : stack obj %p using user stack %p(%u bytes)\n", this, storage, storageSize);
-
-            assertf( ((size_t)storage & (libAlign() - 1)) == 0ul, "Stack storage %p for task/coroutine must be aligned on %d byte boundary.", storage, (int)libAlign() );
-            userStack = true;
-            size = storageSize - cxtSize;
-
-            if ( size % 16 != 0u ) size -= 8;
-
-            limit = (char *)libCeiling( (unsigned long)storage, 16 ); // minimum alignment
-      } // if
-      assertf( size >= MinStackSize, "Stack size %zd provides less than minimum of %d bytes for a stack.", size, MinStackSize );
-
-      base = (char *)limit + size;
-      context = base;
-      top = (char *)context + cxtSize;
-}
-
-// We need to call suspend from invoke.c, so we expose this wrapper that
-// is not inline (We can't inline Cforall in C)
-extern "C" {
-      void __suspend_internal(void) {
-            suspend();
-      }
-
-      void __leave_coroutine(void) {
-            coroutine_desc * src = TL_GET( this_coroutine ); // optimization
-
-            assertf( src->starter != 0,
-                  "Attempt to suspend/leave coroutine \"%.256s\" (%p) that has never been resumed.\n"
-                  "Possible cause is a suspend executed in a member called by a coroutine user rather than by the coroutine main.",
-                  src->name, src );
-            assertf( src->starter->state != Halted,
-                  "Attempt by coroutine \"%.256s\" (%p) to suspend/leave back to terminated coroutine \"%.256s\" (%p).\n"
-                  "Possible cause is terminated coroutine's main routine has already returned.",
-                  src->name, src, src->starter->name, src->starter );
-
-            CoroutineCtxSwitch( src, src->starter );
-      }
-}
-
-// Local Variables: //
-// mode: c //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/concurrency/coroutine.cfa
===================================================================
--- libcfa/src/concurrency/coroutine.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/concurrency/coroutine.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,183 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// coroutine.c --
+//
+// Author           : Thierry Delisle
+// Created On       : Mon Nov 28 12:27:26 2016
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Fri Mar 30 17:20:57 2018
+// Update Count     : 9
+//
+
+#include "coroutine"
+
+extern "C" {
+#include <stddef.h>
+#include <malloc.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+}
+
+#include "kernel_private.h"
+
+#define __CFA_INVOKE_PRIVATE__
+#include "invoke.h"
+
+//-----------------------------------------------------------------------------
+// Global state variables
+
+// minimum feasible stack size in bytes
+#define MinStackSize 1000
+static size_t pageSize = 0;				// architecture pagesize HACK, should go in proper runtime singleton
+
+//-----------------------------------------------------------------------------
+// Coroutine ctors and dtors
+void ?{}( coStack_t & this, void * storage, size_t storageSize ) with( this ) {
+      size		 = storageSize == 0 ? 65000 : storageSize; // size of stack
+      this.storage = storage;                                // pointer to stack
+      limit		 = NULL;                                   // stack grows towards stack limit
+      base		 = NULL;                                   // base of stack
+      context	 = NULL;                                   // address of cfa_context_t
+      top		 = NULL;                                   // address of top of storage
+      userStack	 = storage != NULL;
+}
+
+void ^?{}(coStack_t & this) {
+      if ( ! this.userStack && this.storage ) {
+            __cfaabi_dbg_debug_do(
+                  if ( mprotect( this.storage, pageSize, PROT_READ | PROT_WRITE ) == -1 ) {
+                        abort( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) );
+                  }
+            );
+            free( this.storage );
+      }
+}
+
+void ?{}( coroutine_desc & this, const char * name, void * storage, size_t storageSize ) with( this ) {
+      (this.stack){storage, storageSize};
+      this.name = name;
+      errno_ = 0;
+      state = Start;
+      starter = NULL;
+      last = NULL;
+}
+
+void ^?{}(coroutine_desc& this) {}
+
+// Part of the Public API
+// Not inline since only ever called once per coroutine
+forall(dtype T | is_coroutine(T))
+void prime(T& cor) {
+      coroutine_desc* this = get_coroutine(cor);
+      assert(this->state == Start);
+
+      this->state = Primed;
+      resume(cor);
+}
+
+// Wrapper for co
+void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
+      // Safety note : This could cause some false positives due to preemption
+      verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate );
+      disable_interrupts();
+
+      // set state of current coroutine to inactive
+      src->state = src->state == Halted ? Halted : Inactive;
+
+      // set new coroutine that task is executing
+      kernelTLS.this_coroutine = dst;
+
+      // context switch to specified coroutine
+      assert( src->stack.context );
+      CtxSwitch( src->stack.context, dst->stack.context );
+      // when CtxSwitch returns we are back in the src coroutine
+
+      // set state of new coroutine to active
+      src->state = Active;
+
+      enable_interrupts( __cfaabi_dbg_ctx );
+      // Safety note : This could cause some false positives due to preemption
+      verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate );
+} //ctxSwitchDirect
+
+void create_stack( coStack_t* this, unsigned int storageSize ) with( *this ) {
+      //TEMP HACK do this on proper kernel startup
+      if(pageSize == 0ul) pageSize = sysconf( _SC_PAGESIZE );
+
+      size_t cxtSize = libCeiling( sizeof(machine_context_t), 8 ); // minimum alignment
+
+      if ( !storage ) {
+            __cfaabi_dbg_print_safe("Kernel : Creating stack of size %zu for stack obj %p\n", cxtSize + size + 8, this);
+
+            userStack = false;
+            size = libCeiling( storageSize, 16 );
+            // use malloc/memalign because "new" raises an exception for out-of-memory
+
+            // assume malloc has 8 byte alignment so add 8 to allow rounding up to 16 byte alignment
+            __cfaabi_dbg_debug_do( storage = memalign( pageSize, cxtSize + size + pageSize ) );
+            __cfaabi_dbg_no_debug_do( storage = malloc( cxtSize + size + 8 ) );
+
+            __cfaabi_dbg_debug_do(
+                  if ( mprotect( storage, pageSize, PROT_NONE ) == -1 ) {
+                        abort( "(uMachContext &)%p.createContext() : internal error, mprotect failure, error(%d) %s.", this, (int)errno, strerror( (int)errno ) );
+                  } // if
+            );
+
+            if ( (intptr_t)storage == 0 ) {
+                  abort( "Attempt to allocate %zd bytes of storage for coroutine or task execution-state but insufficient memory available.", size );
+            } // if
+
+            __cfaabi_dbg_debug_do( limit = (char *)storage + pageSize );
+            __cfaabi_dbg_no_debug_do( limit = (char *)libCeiling( (unsigned long)storage, 16 ) ); // minimum alignment
+
+      } else {
+            __cfaabi_dbg_print_safe("Kernel : stack obj %p using user stack %p(%u bytes)\n", this, storage, storageSize);
+
+            assertf( ((size_t)storage & (libAlign() - 1)) == 0ul, "Stack storage %p for task/coroutine must be aligned on %d byte boundary.", storage, (int)libAlign() );
+            userStack = true;
+            size = storageSize - cxtSize;
+
+            if ( size % 16 != 0u ) size -= 8;
+
+            limit = (char *)libCeiling( (unsigned long)storage, 16 ); // minimum alignment
+      } // if
+      assertf( size >= MinStackSize, "Stack size %zd provides less than minimum of %d bytes for a stack.", size, MinStackSize );
+
+      base = (char *)limit + size;
+      context = base;
+      top = (char *)context + cxtSize;
+}
+
+// We need to call suspend from invoke.c, so we expose this wrapper that
+// is not inline (We can't inline Cforall in C)
+extern "C" {
+      void __suspend_internal(void) {
+            suspend();
+      }
+
+      void __leave_coroutine(void) {
+            coroutine_desc * src = TL_GET( this_coroutine ); // optimization
+
+            assertf( src->starter != 0,
+                  "Attempt to suspend/leave coroutine \"%.256s\" (%p) that has never been resumed.\n"
+                  "Possible cause is a suspend executed in a member called by a coroutine user rather than by the coroutine main.",
+                  src->name, src );
+            assertf( src->starter->state != Halted,
+                  "Attempt by coroutine \"%.256s\" (%p) to suspend/leave back to terminated coroutine \"%.256s\" (%p).\n"
+                  "Possible cause is terminated coroutine's main routine has already returned.",
+                  src->name, src, src->starter->name, src->starter );
+
+            CoroutineCtxSwitch( src, src->starter );
+      }
+}
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/concurrency/kernel.c
===================================================================
--- libcfa/src/concurrency/kernel.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,843 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// kernel.c --
-//
-// Author           : Thierry Delisle
-// Created On       : Tue Jan 17 12:27:26 2017
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Apr  9 16:11:46 2018
-// Update Count     : 24
-//
-
-//C Includes
-#include <stddef.h>
-#include <errno.h>
-#include <string.h>
-extern "C" {
-#include <stdio.h>
-#include <fenv.h>
-#include <sys/resource.h>
-#include <signal.h>
-#include <unistd.h>
-}
-
-//CFA Includes
-#include "time"
-#include "kernel_private.h"
-#include "preemption.h"
-#include "startup.h"
-
-//Private includes
-#define __CFA_INVOKE_PRIVATE__
-#include "invoke.h"
-
-//Start and stop routine for the kernel, declared first to make sure they run first
-static void kernel_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_KERNEL ) ));
-static void kernel_shutdown(void) __attribute__(( destructor ( STARTUP_PRIORITY_KERNEL ) ));
-
-//-----------------------------------------------------------------------------
-// Kernel storage
-KERNEL_STORAGE(cluster,           mainCluster);
-KERNEL_STORAGE(processor,         mainProcessor);
-KERNEL_STORAGE(thread_desc,       mainThread);
-KERNEL_STORAGE(machine_context_t, mainThreadCtx);
-
-cluster     * mainCluster;
-processor   * mainProcessor;
-thread_desc * mainThread;
-
-extern "C" {
-struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;
-}
-
-//-----------------------------------------------------------------------------
-// Global state
-thread_local struct KernelThreadData kernelTLS = {
-	NULL,
-	NULL,
-	NULL,
-	{ 1, false, false }
-};
-
-//-----------------------------------------------------------------------------
-// Struct to steal stack
-struct current_stack_info_t {
-	machine_context_t ctx;
-	unsigned int size;		// size of stack
-	void *base;				// base of stack
-	void *storage;			// pointer to stack
-	void *limit;			// stack grows towards stack limit
-	void *context;			// address of cfa_context_t
-	void *top;				// address of top of storage
-};
-
-void ?{}( current_stack_info_t & this ) {
-	CtxGet( this.ctx );
-	this.base = this.ctx.FP;
-	this.storage = this.ctx.SP;
-
-	rlimit r;
-	getrlimit( RLIMIT_STACK, &r);
-	this.size = r.rlim_cur;
-
-	this.limit = (void *)(((intptr_t)this.base) - this.size);
-	this.context = &storage_mainThreadCtx;
-	this.top = this.base;
-}
-
-//-----------------------------------------------------------------------------
-// Main thread construction
-void ?{}( coStack_t & this, current_stack_info_t * info) with( this ) {
-	size      = info->size;
-	storage   = info->storage;
-	limit     = info->limit;
-	base      = info->base;
-	context   = info->context;
-	top       = info->top;
-	userStack = true;
-}
-
-void ?{}( coroutine_desc & this, current_stack_info_t * info) with( this ) {
-	stack{ info };
-	name = "Main Thread";
-	errno_ = 0;
-	state = Start;
-	starter = NULL;
-}
-
-void ?{}( thread_desc & this, current_stack_info_t * info) with( this ) {
-	self_cor{ info };
-	curr_cor = &self_cor;
-	curr_cluster = mainCluster;
-	self_mon.owner = &this;
-	self_mon.recursion = 1;
-	self_mon_p = &self_mon;
-	next = NULL;
-
-	node.next = NULL;
-	node.prev = NULL;
-	doregister(curr_cluster, this);
-
-	monitors{ &self_mon_p, 1, (fptr_t)0 };
-}
-
-//-----------------------------------------------------------------------------
-// Processor coroutine
-void ?{}(processorCtx_t & this) {
-
-}
-
-// Construct the processor context of non-main processors
-static void ?{}(processorCtx_t & this, processor * proc, current_stack_info_t * info) {
-	(this.__cor){ info };
-	this.proc = proc;
-}
-
-static void start(processor * this);
-void ?{}(processor & this, const char * name, cluster & cltr) with( this ) {
-	this.name = name;
-	this.cltr = &cltr;
-	terminated{ 0 };
-	do_terminate = false;
-	preemption_alarm = NULL;
-	pending_preemption = false;
-	runner.proc = &this;
-
-	idleLock{};
-
-	start( &this );
-}
-
-void ^?{}(processor & this) with( this ){
-	if( ! __atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) ) {
-		__cfaabi_dbg_print_safe("Kernel : core %p signaling termination\n", &this);
-
-		__atomic_store_n(&do_terminate, true, __ATOMIC_RELAXED);
-		wake( &this );
-
-		P( terminated );
-		verify( kernelTLS.this_processor != &this);
-	}
-
-	pthread_join( kernel_thread, NULL );
-}
-
-void ?{}(cluster & this, const char * name, Duration preemption_rate) with( this ) {
-	this.name = name;
-	this.preemption_rate = preemption_rate;
-	ready_queue{};
-	ready_queue_lock{};
-
-	procs{ __get };
-	idles{ __get };
-	threads{ __get };
-
-	doregister(this);
-}
-
-void ^?{}(cluster & this) {
-	unregister(this);
-}
-
-//=============================================================================================
-// Kernel Scheduling logic
-//=============================================================================================
-static void runThread(processor * this, thread_desc * dst);
-static void finishRunning(processor * this);
-static void halt(processor * this);
-
-//Main of the processor contexts
-void main(processorCtx_t & runner) {
-	processor * this = runner.proc;
-	verify(this);
-
-	__cfaabi_dbg_print_safe("Kernel : core %p starting\n", this);
-
-	doregister(this->cltr, this);
-
-	{
-		// Setup preemption data
-		preemption_scope scope = { this };
-
-		__cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
-
-		thread_desc * readyThread = NULL;
-		for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ )
-		{
-			readyThread = nextThread( this->cltr );
-
-			if(readyThread)
-			{
-				verify( ! kernelTLS.preemption_state.enabled );
-
-				runThread(this, readyThread);
-
-				verify( ! kernelTLS.preemption_state.enabled );
-
-				//Some actions need to be taken from the kernel
-				finishRunning(this);
-
-				spin_count = 0;
-			}
-			else
-			{
-				// spin(this, &spin_count);
-				halt(this);
-			}
-		}
-
-		__cfaabi_dbg_print_safe("Kernel : core %p stopping\n", this);
-	}
-
-	unregister(this->cltr, this);
-
-	V( this->terminated );
-
-	__cfaabi_dbg_print_safe("Kernel : core %p terminated\n", this);
-}
-
-// KERNEL ONLY
-// runThread runs a thread by context switching
-// from the processor coroutine to the target thread
-static void runThread(processor * this, thread_desc * dst) {
-	assert(dst->curr_cor);
-	coroutine_desc * proc_cor = get_coroutine(this->runner);
-	coroutine_desc * thrd_cor = dst->curr_cor;
-
-	// Reset the terminating actions here
-	this->finish.action_code = No_Action;
-
-	// Update global state
-	kernelTLS.this_thread = dst;
-
-	// Context Switch to the thread
-	ThreadCtxSwitch(proc_cor, thrd_cor);
-	// when ThreadCtxSwitch returns we are back in the processor coroutine
-}
-
-// KERNEL_ONLY
-static void returnToKernel() {
-	coroutine_desc * proc_cor = get_coroutine(kernelTLS.this_processor->runner);
-	coroutine_desc * thrd_cor = kernelTLS.this_thread->curr_cor = kernelTLS.this_coroutine;
-	ThreadCtxSwitch(thrd_cor, proc_cor);
-}
-
-// KERNEL_ONLY
-// Once a thread has finished running, some of
-// its final actions must be executed from the kernel
-static void finishRunning(processor * this) with( this->finish ) {
-	verify( ! kernelTLS.preemption_state.enabled );
-	choose( action_code ) {
-	case No_Action:
-		break;
-	case Release:
-		unlock( *lock );
-	case Schedule:
-		ScheduleThread( thrd );
-	case Release_Schedule:
-		unlock( *lock );
-		ScheduleThread( thrd );
-	case Release_Multi:
-		for(int i = 0; i < lock_count; i++) {
-			unlock( *locks[i] );
-		}
-	case Release_Multi_Schedule:
-		for(int i = 0; i < lock_count; i++) {
-			unlock( *locks[i] );
-		}
-		for(int i = 0; i < thrd_count; i++) {
-			ScheduleThread( thrds[i] );
-		}
-	case Callback:
-		callback();
-	default:
-		abort("KERNEL ERROR: Unexpected action to run after thread");
-	}
-}
-
-// KERNEL_ONLY
-// Context invoker for processors
-// This is the entry point for processors (kernel threads)
-// It effectively constructs a coroutine by stealing the pthread stack
-static void * CtxInvokeProcessor(void * arg) {
-	processor * proc = (processor *) arg;
-	kernelTLS.this_processor = proc;
-	kernelTLS.this_coroutine = NULL;
-	kernelTLS.this_thread    = NULL;
-	kernelTLS.preemption_state.[enabled, disable_count] = [false, 1];
-	// SKULLDUGGERY: We want to create a context for the processor coroutine
-	// which is needed for the 2-step context switch. However, there is no reason
-	// to waste the perfectly valid stack create by pthread.
-	current_stack_info_t info;
-	machine_context_t ctx;
-	info.context = &ctx;
-	(proc->runner){ proc, &info };
-
-	__cfaabi_dbg_print_safe("Coroutine : created stack %p\n", get_coroutine(proc->runner)->stack.base);
-
-	//Set global state
-	kernelTLS.this_coroutine = get_coroutine(proc->runner);
-	kernelTLS.this_thread    = NULL;
-
-	//We now have a proper context from which to schedule threads
-	__cfaabi_dbg_print_safe("Kernel : core %p created (%p, %p)\n", proc, &proc->runner, &ctx);
-
-	// SKULLDUGGERY: Since the coroutine doesn't have its own stack, we can't
-	// resume it to start it like it normally would, it will just context switch
-	// back to here. Instead directly call the main since we already are on the
-	// appropriate stack.
-	get_coroutine(proc->runner)->state = Active;
-	main( proc->runner );
-	get_coroutine(proc->runner)->state = Halted;
-
-	// Main routine of the core returned, the core is now fully terminated
-	__cfaabi_dbg_print_safe("Kernel : core %p main ended (%p)\n", proc, &proc->runner);
-
-	return NULL;
-}
-
-static void start(processor * this) {
-	__cfaabi_dbg_print_safe("Kernel : Starting core %p\n", this);
-
-	pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this );
-
-	__cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
-}
-
-// KERNEL_ONLY
-void kernel_first_resume(processor * this) {
-	coroutine_desc * src = kernelTLS.this_coroutine;
-	coroutine_desc * dst = get_coroutine(this->runner);
-
-	verify( ! kernelTLS.preemption_state.enabled );
-
-	create_stack(&dst->stack, dst->stack.size);
-	CtxStart(&this->runner, CtxInvokeCoroutine);
-
-	verify( ! kernelTLS.preemption_state.enabled );
-
-	dst->last = src;
-	dst->starter = dst->starter ? dst->starter : src;
-
-	// set state of current coroutine to inactive
-	src->state = src->state == Halted ? Halted : Inactive;
-
-	// set new coroutine that task is executing
-	kernelTLS.this_coroutine = dst;
-
-	// SKULLDUGGERY normally interrupts are enable before leaving a coroutine ctxswitch.
-	// Therefore, when first creating a coroutine, interrupts are enable before calling the main.
-	// This is consistent with thread creation. However, when creating the main processor coroutine,
-	// we wan't interrupts to be disabled. Therefore, we double-disable interrupts here so they will
-	// stay disabled.
-	disable_interrupts();
-
-	// context switch to specified coroutine
-	assert( src->stack.context );
-	CtxSwitch( src->stack.context, dst->stack.context );
-	// when CtxSwitch returns we are back in the src coroutine
-
-	// set state of new coroutine to active
-	src->state = Active;
-
-	verify( ! kernelTLS.preemption_state.enabled );
-}
-
-//-----------------------------------------------------------------------------
-// Scheduler routines
-
-// KERNEL ONLY
-void ScheduleThread( thread_desc * thrd ) {
-	verify( thrd );
-	verify( thrd->self_cor.state != Halted );
-
-	verify( ! kernelTLS.preemption_state.enabled );
-
-	verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
-
-	with( *thrd->curr_cluster ) {
-		lock  ( ready_queue_lock __cfaabi_dbg_ctx2 );
-		bool was_empty = !(ready_queue != 0);
-		append( ready_queue, thrd );
-		unlock( ready_queue_lock );
-
-		if(was_empty) {
-			lock      (proc_list_lock __cfaabi_dbg_ctx2);
-			if(idles) {
-				wake_fast(idles.head);
-			}
-			unlock    (proc_list_lock);
-		}
-		else if( struct processor * idle = idles.head ) {
-			wake_fast(idle);
-		}
-
-	}
-
-	verify( ! kernelTLS.preemption_state.enabled );
-}
-
-// KERNEL ONLY
-thread_desc * nextThread(cluster * this) with( *this ) {
-	verify( ! kernelTLS.preemption_state.enabled );
-	lock( ready_queue_lock __cfaabi_dbg_ctx2 );
-	thread_desc * head = pop_head( ready_queue );
-	unlock( ready_queue_lock );
-	verify( ! kernelTLS.preemption_state.enabled );
-	return head;
-}
-
-void BlockInternal() {
-	disable_interrupts();
-	verify( ! kernelTLS.preemption_state.enabled );
-	returnToKernel();
-	verify( ! kernelTLS.preemption_state.enabled );
-	enable_interrupts( __cfaabi_dbg_ctx );
-}
-
-void BlockInternal( __spinlock_t * lock ) {
-	disable_interrupts();
-	with( *kernelTLS.this_processor ) {
-		finish.action_code = Release;
-		finish.lock        = lock;
-	}
-
-	verify( ! kernelTLS.preemption_state.enabled );
-	returnToKernel();
-	verify( ! kernelTLS.preemption_state.enabled );
-
-	enable_interrupts( __cfaabi_dbg_ctx );
-}
-
-void BlockInternal( thread_desc * thrd ) {
-	disable_interrupts();
-	with( * kernelTLS.this_processor ) {
-		finish.action_code = Schedule;
-		finish.thrd        = thrd;
-	}
-
-	verify( ! kernelTLS.preemption_state.enabled );
-	returnToKernel();
-	verify( ! kernelTLS.preemption_state.enabled );
-
-	enable_interrupts( __cfaabi_dbg_ctx );
-}
-
-void BlockInternal( __spinlock_t * lock, thread_desc * thrd ) {
-	assert(thrd);
-	disable_interrupts();
-	with( * kernelTLS.this_processor ) {
-		finish.action_code = Release_Schedule;
-		finish.lock        = lock;
-		finish.thrd        = thrd;
-	}
-
-	verify( ! kernelTLS.preemption_state.enabled );
-	returnToKernel();
-	verify( ! kernelTLS.preemption_state.enabled );
-
-	enable_interrupts( __cfaabi_dbg_ctx );
-}
-
-void BlockInternal(__spinlock_t * locks [], unsigned short count) {
-	disable_interrupts();
-	with( * kernelTLS.this_processor ) {
-		finish.action_code = Release_Multi;
-		finish.locks       = locks;
-		finish.lock_count  = count;
-	}
-
-	verify( ! kernelTLS.preemption_state.enabled );
-	returnToKernel();
-	verify( ! kernelTLS.preemption_state.enabled );
-
-	enable_interrupts( __cfaabi_dbg_ctx );
-}
-
-void BlockInternal(__spinlock_t * locks [], unsigned short lock_count, thread_desc * thrds [], unsigned short thrd_count) {
-	disable_interrupts();
-	with( *kernelTLS.this_processor ) {
-		finish.action_code = Release_Multi_Schedule;
-		finish.locks       = locks;
-		finish.lock_count  = lock_count;
-		finish.thrds       = thrds;
-		finish.thrd_count  = thrd_count;
-	}
-
-	verify( ! kernelTLS.preemption_state.enabled );
-	returnToKernel();
-	verify( ! kernelTLS.preemption_state.enabled );
-
-	enable_interrupts( __cfaabi_dbg_ctx );
-}
-
-void BlockInternal(__finish_callback_fptr_t callback) {
-	disable_interrupts();
-	with( *kernelTLS.this_processor ) {
-		finish.action_code = Callback;
-		finish.callback    = callback;
-	}
-
-	verify( ! kernelTLS.preemption_state.enabled );
-	returnToKernel();
-	verify( ! kernelTLS.preemption_state.enabled );
-
-	enable_interrupts( __cfaabi_dbg_ctx );
-}
-
-// KERNEL ONLY
-void LeaveThread(__spinlock_t * lock, thread_desc * thrd) {
-	verify( ! kernelTLS.preemption_state.enabled );
-	with( * kernelTLS.this_processor ) {
-		finish.action_code = thrd ? Release_Schedule : Release;
-		finish.lock        = lock;
-		finish.thrd        = thrd;
-	}
-
-	returnToKernel();
-}
-
-//=============================================================================================
-// Kernel Setup logic
-//=============================================================================================
-//-----------------------------------------------------------------------------
-// Kernel boot procedures
-static void kernel_startup(void) {
-	verify( ! kernelTLS.preemption_state.enabled );
-	__cfaabi_dbg_print_safe("Kernel : Starting\n");
-
-	__cfa_dbg_global_clusters.list{ __get };
-	__cfa_dbg_global_clusters.lock{};
-
-	// Initialize the main cluster
-	mainCluster = (cluster *)&storage_mainCluster;
-	(*mainCluster){"Main Cluster"};
-
-	__cfaabi_dbg_print_safe("Kernel : Main cluster ready\n");
-
-	// Start by initializing the main thread
-	// SKULLDUGGERY: the mainThread steals the process main thread
-	// which will then be scheduled by the mainProcessor normally
-	mainThread = (thread_desc *)&storage_mainThread;
-	current_stack_info_t info;
-	(*mainThread){ &info };
-
-	__cfaabi_dbg_print_safe("Kernel : Main thread ready\n");
-
-
-
-	// Construct the processor context of the main processor
-	void ?{}(processorCtx_t & this, processor * proc) {
-		(this.__cor){ "Processor" };
-		this.__cor.starter = NULL;
-		this.proc = proc;
-	}
-
-	void ?{}(processor & this) with( this ) {
-		name = "Main Processor";
-		cltr = mainCluster;
-		terminated{ 0 };
-		do_terminate = false;
-		preemption_alarm = NULL;
-		pending_preemption = false;
-		kernel_thread = pthread_self();
-
-		runner{ &this };
-		__cfaabi_dbg_print_safe("Kernel : constructed main processor context %p\n", &runner);
-	}
-
-	// Initialize the main processor and the main processor ctx
-	// (the coroutine that contains the processing control flow)
-	mainProcessor = (processor *)&storage_mainProcessor;
-	(*mainProcessor){};
-
-	//initialize the global state variables
-	kernelTLS.this_processor = mainProcessor;
-	kernelTLS.this_thread    = mainThread;
-	kernelTLS.this_coroutine = &mainThread->self_cor;
-
-	// Enable preemption
-	kernel_start_preemption();
-
-	// Add the main thread to the ready queue
-	// once resume is called on mainProcessor->runner the mainThread needs to be scheduled like any normal thread
-	ScheduleThread(mainThread);
-
-	// SKULLDUGGERY: Force a context switch to the main processor to set the main thread's context to the current UNIX
-	// context. Hence, the main thread does not begin through CtxInvokeThread, like all other threads. The trick here is that
-	// mainThread is on the ready queue when this call is made.
-	kernel_first_resume( kernelTLS.this_processor );
-
-
-
-	// THE SYSTEM IS NOW COMPLETELY RUNNING
-	__cfaabi_dbg_print_safe("Kernel : Started\n--------------------------------------------------\n\n");
-
-	verify( ! kernelTLS.preemption_state.enabled );
-	enable_interrupts( __cfaabi_dbg_ctx );
-	verify( TL_GET( preemption_state.enabled ) );
-}
-
-static void kernel_shutdown(void) {
-	__cfaabi_dbg_print_safe("\n--------------------------------------------------\nKernel : Shutting down\n");
-
-	verify( TL_GET( preemption_state.enabled ) );
-	disable_interrupts();
-	verify( ! kernelTLS.preemption_state.enabled );
-
-	// SKULLDUGGERY: Notify the mainProcessor it needs to terminates.
-	// When its coroutine terminates, it return control to the mainThread
-	// which is currently here
-	__atomic_store_n(&mainProcessor->do_terminate, true, __ATOMIC_RELEASE);
-	returnToKernel();
-	mainThread->self_cor.state = Halted;
-
-	// THE SYSTEM IS NOW COMPLETELY STOPPED
-
-	// Disable preemption
-	kernel_stop_preemption();
-
-	// Destroy the main processor and its context in reverse order of construction
-	// These were manually constructed so we need manually destroy them
-	^(mainProcessor->runner){};
-	^(mainProcessor){};
-
-	// Final step, destroy the main thread since it is no longer needed
-	// Since we provided a stack to this taxk it will not destroy anything
-	^(mainThread){};
-
-	^(__cfa_dbg_global_clusters.list){};
-	^(__cfa_dbg_global_clusters.lock){};
-
-	__cfaabi_dbg_print_safe("Kernel : Shutdown complete\n");
-}
-
-//=============================================================================================
-// Kernel Quiescing
-//=============================================================================================
-static void halt(processor * this) with( *this ) {
-	// verify( ! __atomic_load_n(&do_terminate, __ATOMIC_SEQ_CST) );
-
-	with( *cltr ) {
-		lock      (proc_list_lock __cfaabi_dbg_ctx2);
-		remove    (procs, *this);
-		push_front(idles, *this);
-		unlock    (proc_list_lock);
-	}
-
-	__cfaabi_dbg_print_safe("Kernel : Processor %p ready to sleep\n", this);
-
-	wait( idleLock );
-
-	__cfaabi_dbg_print_safe("Kernel : Processor %p woke up and ready to run\n", this);
-
-	with( *cltr ) {
-		lock      (proc_list_lock __cfaabi_dbg_ctx2);
-		remove    (idles, *this);
-		push_front(procs, *this);
-		unlock    (proc_list_lock);
-	}
-}
-
-//=============================================================================================
-// Unexpected Terminating logic
-//=============================================================================================
-static __spinlock_t kernel_abort_lock;
-static bool kernel_abort_called = false;
-
-void * kernel_abort(void) __attribute__ ((__nothrow__)) {
-	// abort cannot be recursively entered by the same or different processors because all signal handlers return when
-	// the globalAbort flag is true.
-	lock( kernel_abort_lock __cfaabi_dbg_ctx2 );
-
-	// first task to abort ?
-	if ( kernel_abort_called ) {			// not first task to abort ?
-		unlock( kernel_abort_lock );
-
-		sigset_t mask;
-		sigemptyset( &mask );
-		sigaddset( &mask, SIGALRM );		// block SIGALRM signals
-		sigsuspend( &mask );			// block the processor to prevent further damage during abort
-		_exit( EXIT_FAILURE );			// if processor unblocks before it is killed, terminate it
-	}
-	else {
-		kernel_abort_called = true;
-		unlock( kernel_abort_lock );
-	}
-
-	return kernelTLS.this_thread;
-}
-
-void kernel_abort_msg( void * kernel_data, char * abort_text, int abort_text_size ) {
-	thread_desc * thrd = kernel_data;
-
-	if(thrd) {
-		int len = snprintf( abort_text, abort_text_size, "Error occurred while executing thread %.256s (%p)", thrd->self_cor.name, thrd );
-		__cfaabi_dbg_bits_write( abort_text, len );
-
-		if ( get_coroutine(thrd) != kernelTLS.this_coroutine ) {
-			len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", kernelTLS.this_coroutine->name, kernelTLS.this_coroutine );
-			__cfaabi_dbg_bits_write( abort_text, len );
-		}
-		else {
-			__cfaabi_dbg_bits_write( ".\n", 2 );
-		}
-	}
-	else {
-		int len = snprintf( abort_text, abort_text_size, "Error occurred outside of any thread.\n" );
-		__cfaabi_dbg_bits_write( abort_text, len );
-	}
-}
-
-int kernel_abort_lastframe( void ) __attribute__ ((__nothrow__)) {
-	return get_coroutine(kernelTLS.this_thread) == get_coroutine(mainThread) ? 4 : 2;
-}
-
-static __spinlock_t kernel_debug_lock;
-
-extern "C" {
-	void __cfaabi_dbg_bits_acquire() {
-		lock( kernel_debug_lock __cfaabi_dbg_ctx2 );
-	}
-
-	void __cfaabi_dbg_bits_release() {
-		unlock( kernel_debug_lock );
-	}
-}
-
-//=============================================================================================
-// Kernel Utilities
-//=============================================================================================
-//-----------------------------------------------------------------------------
-// Locks
-void  ?{}( semaphore & this, int count = 1 ) {
-	(this.lock){};
-	this.count = count;
-	(this.waiting){};
-}
-void ^?{}(semaphore & this) {}
-
-void P(semaphore & this) with( this ){
-	lock( lock __cfaabi_dbg_ctx2 );
-	count -= 1;
-	if ( count < 0 ) {
-		// queue current task
-		append( waiting, kernelTLS.this_thread );
-
-		// atomically release spin lock and block
-		BlockInternal( &lock );
-	}
-	else {
-	    unlock( lock );
-	}
-}
-
-void V(semaphore & this) with( this ) {
-	thread_desc * thrd = NULL;
-	lock( lock __cfaabi_dbg_ctx2 );
-	count += 1;
-	if ( count <= 0 ) {
-		// remove task at head of waiting list
-		thrd = pop_head( waiting );
-	}
-
-	unlock( lock );
-
-	// make new owner
-	WakeThread( thrd );
-}
-
-//-----------------------------------------------------------------------------
-// Global Queues
-void doregister( cluster     & cltr ) {
-	lock      ( __cfa_dbg_global_clusters.lock __cfaabi_dbg_ctx2);
-	push_front( __cfa_dbg_global_clusters.list, cltr );
-	unlock    ( __cfa_dbg_global_clusters.lock );
-}
-
-void unregister( cluster     & cltr ) {
-	lock  ( __cfa_dbg_global_clusters.lock __cfaabi_dbg_ctx2);
-	remove( __cfa_dbg_global_clusters.list, cltr );
-	unlock( __cfa_dbg_global_clusters.lock );
-}
-
-void doregister( cluster * cltr, thread_desc & thrd ) {
-	lock      (cltr->thread_list_lock __cfaabi_dbg_ctx2);
-	push_front(cltr->threads, thrd);
-	unlock    (cltr->thread_list_lock);
-}
-
-void unregister( cluster * cltr, thread_desc & thrd ) {
-	lock  (cltr->thread_list_lock __cfaabi_dbg_ctx2);
-	remove(cltr->threads, thrd );
-	unlock(cltr->thread_list_lock);
-}
-
-void doregister( cluster * cltr, processor * proc ) {
-	lock      (cltr->proc_list_lock __cfaabi_dbg_ctx2);
-	push_front(cltr->procs, *proc);
-	unlock    (cltr->proc_list_lock);
-}
-
-void unregister( cluster * cltr, processor * proc ) {
-	lock  (cltr->proc_list_lock __cfaabi_dbg_ctx2);
-	remove(cltr->procs, *proc );
-	unlock(cltr->proc_list_lock);
-}
-
-//-----------------------------------------------------------------------------
-// Debug
-__cfaabi_dbg_debug_do(
-	void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name) {
-		this.prev_name = prev_name;
-		this.prev_thrd = kernelTLS.this_thread;
-	}
-)
-// Local Variables: //
-// mode: c //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/concurrency/kernel.cfa
===================================================================
--- libcfa/src/concurrency/kernel.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/concurrency/kernel.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,843 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// kernel.c --
+//
+// Author           : Thierry Delisle
+// Created On       : Tue Jan 17 12:27:26 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Mon Apr  9 16:11:46 2018
+// Update Count     : 24
+//
+
+//C Includes
+#include <stddef.h>
+#include <errno.h>
+#include <string.h>
+extern "C" {
+#include <stdio.h>
+#include <fenv.h>
+#include <sys/resource.h>
+#include <signal.h>
+#include <unistd.h>
+}
+
+//CFA Includes
+#include "time"
+#include "kernel_private.h"
+#include "preemption.h"
+#include "startup.h"
+
+//Private includes
+#define __CFA_INVOKE_PRIVATE__
+#include "invoke.h"
+
+//Start and stop routine for the kernel, declared first to make sure they run first
+static void kernel_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_KERNEL ) ));
+static void kernel_shutdown(void) __attribute__(( destructor ( STARTUP_PRIORITY_KERNEL ) ));
+
+//-----------------------------------------------------------------------------
+// Kernel storage
+KERNEL_STORAGE(cluster,           mainCluster);
+KERNEL_STORAGE(processor,         mainProcessor);
+KERNEL_STORAGE(thread_desc,       mainThread);
+KERNEL_STORAGE(machine_context_t, mainThreadCtx);
+
+cluster     * mainCluster;
+processor   * mainProcessor;
+thread_desc * mainThread;
+
+extern "C" {
+struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;
+}
+
+//-----------------------------------------------------------------------------
+// Global state
+thread_local struct KernelThreadData kernelTLS = {
+	NULL,
+	NULL,
+	NULL,
+	{ 1, false, false }
+};
+
+//-----------------------------------------------------------------------------
+// Struct to steal stack
+struct current_stack_info_t {
+	machine_context_t ctx;
+	unsigned int size;		// size of stack
+	void *base;				// base of stack
+	void *storage;			// pointer to stack
+	void *limit;			// stack grows towards stack limit
+	void *context;			// address of cfa_context_t
+	void *top;				// address of top of storage
+};
+
+void ?{}( current_stack_info_t & this ) {
+	CtxGet( this.ctx );
+	this.base = this.ctx.FP;
+	this.storage = this.ctx.SP;
+
+	rlimit r;
+	getrlimit( RLIMIT_STACK, &r);
+	this.size = r.rlim_cur;
+
+	this.limit = (void *)(((intptr_t)this.base) - this.size);
+	this.context = &storage_mainThreadCtx;
+	this.top = this.base;
+}
+
+//-----------------------------------------------------------------------------
+// Main thread construction
+void ?{}( coStack_t & this, current_stack_info_t * info) with( this ) {
+	size      = info->size;
+	storage   = info->storage;
+	limit     = info->limit;
+	base      = info->base;
+	context   = info->context;
+	top       = info->top;
+	userStack = true;
+}
+
+void ?{}( coroutine_desc & this, current_stack_info_t * info) with( this ) {
+	stack{ info };
+	name = "Main Thread";
+	errno_ = 0;
+	state = Start;
+	starter = NULL;
+}
+
+void ?{}( thread_desc & this, current_stack_info_t * info) with( this ) {
+	self_cor{ info };
+	curr_cor = &self_cor;
+	curr_cluster = mainCluster;
+	self_mon.owner = &this;
+	self_mon.recursion = 1;
+	self_mon_p = &self_mon;
+	next = NULL;
+
+	node.next = NULL;
+	node.prev = NULL;
+	doregister(curr_cluster, this);
+
+	monitors{ &self_mon_p, 1, (fptr_t)0 };
+}
+
+//-----------------------------------------------------------------------------
+// Processor coroutine
+void ?{}(processorCtx_t & this) {
+
+}
+
+// Construct the processor context of non-main processors
+static void ?{}(processorCtx_t & this, processor * proc, current_stack_info_t * info) {
+	(this.__cor){ info };
+	this.proc = proc;
+}
+
+static void start(processor * this);
+void ?{}(processor & this, const char * name, cluster & cltr) with( this ) {
+	this.name = name;
+	this.cltr = &cltr;
+	terminated{ 0 };
+	do_terminate = false;
+	preemption_alarm = NULL;
+	pending_preemption = false;
+	runner.proc = &this;
+
+	idleLock{};
+
+	start( &this );
+}
+
+void ^?{}(processor & this) with( this ){
+	if( ! __atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) ) {
+		__cfaabi_dbg_print_safe("Kernel : core %p signaling termination\n", &this);
+
+		__atomic_store_n(&do_terminate, true, __ATOMIC_RELAXED);
+		wake( &this );
+
+		P( terminated );
+		verify( kernelTLS.this_processor != &this);
+	}
+
+	pthread_join( kernel_thread, NULL );
+}
+
+void ?{}(cluster & this, const char * name, Duration preemption_rate) with( this ) {
+	this.name = name;
+	this.preemption_rate = preemption_rate;
+	ready_queue{};
+	ready_queue_lock{};
+
+	procs{ __get };
+	idles{ __get };
+	threads{ __get };
+
+	doregister(this);
+}
+
+void ^?{}(cluster & this) {
+	unregister(this);
+}
+
+//=============================================================================================
+// Kernel Scheduling logic
+//=============================================================================================
+static void runThread(processor * this, thread_desc * dst);
+static void finishRunning(processor * this);
+static void halt(processor * this);
+
+//Main of the processor contexts
+void main(processorCtx_t & runner) {
+	processor * this = runner.proc;
+	verify(this);
+
+	__cfaabi_dbg_print_safe("Kernel : core %p starting\n", this);
+
+	doregister(this->cltr, this);
+
+	{
+		// Setup preemption data
+		preemption_scope scope = { this };
+
+		__cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
+
+		thread_desc * readyThread = NULL;
+		for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ )
+		{
+			readyThread = nextThread( this->cltr );
+
+			if(readyThread)
+			{
+				verify( ! kernelTLS.preemption_state.enabled );
+
+				runThread(this, readyThread);
+
+				verify( ! kernelTLS.preemption_state.enabled );
+
+				//Some actions need to be taken from the kernel
+				finishRunning(this);
+
+				spin_count = 0;
+			}
+			else
+			{
+				// spin(this, &spin_count);
+				halt(this);
+			}
+		}
+
+		__cfaabi_dbg_print_safe("Kernel : core %p stopping\n", this);
+	}
+
+	unregister(this->cltr, this);
+
+	V( this->terminated );
+
+	__cfaabi_dbg_print_safe("Kernel : core %p terminated\n", this);
+}
+
+// KERNEL ONLY
+// runThread runs a thread by context switching
+// from the processor coroutine to the target thread
+static void runThread(processor * this, thread_desc * dst) {
+	assert(dst->curr_cor);
+	coroutine_desc * proc_cor = get_coroutine(this->runner);
+	coroutine_desc * thrd_cor = dst->curr_cor;
+
+	// Reset the terminating actions here
+	this->finish.action_code = No_Action;
+
+	// Update global state
+	kernelTLS.this_thread = dst;
+
+	// Context Switch to the thread
+	ThreadCtxSwitch(proc_cor, thrd_cor);
+	// when ThreadCtxSwitch returns we are back in the processor coroutine
+}
+
+// KERNEL_ONLY
+static void returnToKernel() {
+	coroutine_desc * proc_cor = get_coroutine(kernelTLS.this_processor->runner);
+	coroutine_desc * thrd_cor = kernelTLS.this_thread->curr_cor = kernelTLS.this_coroutine;
+	ThreadCtxSwitch(thrd_cor, proc_cor);
+}
+
+// KERNEL_ONLY
+// Once a thread has finished running, some of
+// its final actions must be executed from the kernel
+static void finishRunning(processor * this) with( this->finish ) {
+	verify( ! kernelTLS.preemption_state.enabled );
+	choose( action_code ) {
+	case No_Action:
+		break;
+	case Release:
+		unlock( *lock );
+	case Schedule:
+		ScheduleThread( thrd );
+	case Release_Schedule:
+		unlock( *lock );
+		ScheduleThread( thrd );
+	case Release_Multi:
+		for(int i = 0; i < lock_count; i++) {
+			unlock( *locks[i] );
+		}
+	case Release_Multi_Schedule:
+		for(int i = 0; i < lock_count; i++) {
+			unlock( *locks[i] );
+		}
+		for(int i = 0; i < thrd_count; i++) {
+			ScheduleThread( thrds[i] );
+		}
+	case Callback:
+		callback();
+	default:
+		abort("KERNEL ERROR: Unexpected action to run after thread");
+	}
+}
+
+// KERNEL_ONLY
+// Context invoker for processors
+// This is the entry point for processors (kernel threads)
+// It effectively constructs a coroutine by stealing the pthread stack
+static void * CtxInvokeProcessor(void * arg) {
+	processor * proc = (processor *) arg;
+	kernelTLS.this_processor = proc;
+	kernelTLS.this_coroutine = NULL;
+	kernelTLS.this_thread    = NULL;
+	kernelTLS.preemption_state.[enabled, disable_count] = [false, 1];
+	// SKULLDUGGERY: We want to create a context for the processor coroutine
+	// which is needed for the 2-step context switch. However, there is no reason
+	// to waste the perfectly valid stack create by pthread.
+	current_stack_info_t info;
+	machine_context_t ctx;
+	info.context = &ctx;
+	(proc->runner){ proc, &info };
+
+	__cfaabi_dbg_print_safe("Coroutine : created stack %p\n", get_coroutine(proc->runner)->stack.base);
+
+	//Set global state
+	kernelTLS.this_coroutine = get_coroutine(proc->runner);
+	kernelTLS.this_thread    = NULL;
+
+	//We now have a proper context from which to schedule threads
+	__cfaabi_dbg_print_safe("Kernel : core %p created (%p, %p)\n", proc, &proc->runner, &ctx);
+
+	// SKULLDUGGERY: Since the coroutine doesn't have its own stack, we can't
+	// resume it to start it like it normally would, it will just context switch
+	// back to here. Instead directly call the main since we already are on the
+	// appropriate stack.
+	get_coroutine(proc->runner)->state = Active;
+	main( proc->runner );
+	get_coroutine(proc->runner)->state = Halted;
+
+	// Main routine of the core returned, the core is now fully terminated
+	__cfaabi_dbg_print_safe("Kernel : core %p main ended (%p)\n", proc, &proc->runner);
+
+	return NULL;
+}
+
+static void start(processor * this) {
+	__cfaabi_dbg_print_safe("Kernel : Starting core %p\n", this);
+
+	pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this );
+
+	__cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
+}
+
+// KERNEL_ONLY
+void kernel_first_resume(processor * this) {
+	coroutine_desc * src = kernelTLS.this_coroutine;
+	coroutine_desc * dst = get_coroutine(this->runner);
+
+	verify( ! kernelTLS.preemption_state.enabled );
+
+	create_stack(&dst->stack, dst->stack.size);
+	CtxStart(&this->runner, CtxInvokeCoroutine);
+
+	verify( ! kernelTLS.preemption_state.enabled );
+
+	dst->last = src;
+	dst->starter = dst->starter ? dst->starter : src;
+
+	// set state of current coroutine to inactive
+	src->state = src->state == Halted ? Halted : Inactive;
+
+	// set new coroutine that task is executing
+	kernelTLS.this_coroutine = dst;
+
+	// SKULLDUGGERY normally interrupts are enable before leaving a coroutine ctxswitch.
+	// Therefore, when first creating a coroutine, interrupts are enable before calling the main.
+	// This is consistent with thread creation. However, when creating the main processor coroutine,
+	// we wan't interrupts to be disabled. Therefore, we double-disable interrupts here so they will
+	// stay disabled.
+	disable_interrupts();
+
+	// context switch to specified coroutine
+	assert( src->stack.context );
+	CtxSwitch( src->stack.context, dst->stack.context );
+	// when CtxSwitch returns we are back in the src coroutine
+
+	// set state of new coroutine to active
+	src->state = Active;
+
+	verify( ! kernelTLS.preemption_state.enabled );
+}
+
+//-----------------------------------------------------------------------------
+// Scheduler routines
+
+// KERNEL ONLY
+void ScheduleThread( thread_desc * thrd ) {
+	verify( thrd );
+	verify( thrd->self_cor.state != Halted );
+
+	verify( ! kernelTLS.preemption_state.enabled );
+
+	verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
+
+	with( *thrd->curr_cluster ) {
+		lock  ( ready_queue_lock __cfaabi_dbg_ctx2 );
+		bool was_empty = !(ready_queue != 0);
+		append( ready_queue, thrd );
+		unlock( ready_queue_lock );
+
+		if(was_empty) {
+			lock      (proc_list_lock __cfaabi_dbg_ctx2);
+			if(idles) {
+				wake_fast(idles.head);
+			}
+			unlock    (proc_list_lock);
+		}
+		else if( struct processor * idle = idles.head ) {
+			wake_fast(idle);
+		}
+
+	}
+
+	verify( ! kernelTLS.preemption_state.enabled );
+}
+
+// KERNEL ONLY
+thread_desc * nextThread(cluster * this) with( *this ) {
+	verify( ! kernelTLS.preemption_state.enabled );
+	lock( ready_queue_lock __cfaabi_dbg_ctx2 );
+	thread_desc * head = pop_head( ready_queue );
+	unlock( ready_queue_lock );
+	verify( ! kernelTLS.preemption_state.enabled );
+	return head;
+}
+
+void BlockInternal() {
+	disable_interrupts();
+	verify( ! kernelTLS.preemption_state.enabled );
+	returnToKernel();
+	verify( ! kernelTLS.preemption_state.enabled );
+	enable_interrupts( __cfaabi_dbg_ctx );
+}
+
+void BlockInternal( __spinlock_t * lock ) {
+	disable_interrupts();
+	with( *kernelTLS.this_processor ) {
+		finish.action_code = Release;
+		finish.lock        = lock;
+	}
+
+	verify( ! kernelTLS.preemption_state.enabled );
+	returnToKernel();
+	verify( ! kernelTLS.preemption_state.enabled );
+
+	enable_interrupts( __cfaabi_dbg_ctx );
+}
+
+void BlockInternal( thread_desc * thrd ) {
+	disable_interrupts();
+	with( * kernelTLS.this_processor ) {
+		finish.action_code = Schedule;
+		finish.thrd        = thrd;
+	}
+
+	verify( ! kernelTLS.preemption_state.enabled );
+	returnToKernel();
+	verify( ! kernelTLS.preemption_state.enabled );
+
+	enable_interrupts( __cfaabi_dbg_ctx );
+}
+
+void BlockInternal( __spinlock_t * lock, thread_desc * thrd ) {
+	assert(thrd);
+	disable_interrupts();
+	with( * kernelTLS.this_processor ) {
+		finish.action_code = Release_Schedule;
+		finish.lock        = lock;
+		finish.thrd        = thrd;
+	}
+
+	verify( ! kernelTLS.preemption_state.enabled );
+	returnToKernel();
+	verify( ! kernelTLS.preemption_state.enabled );
+
+	enable_interrupts( __cfaabi_dbg_ctx );
+}
+
+void BlockInternal(__spinlock_t * locks [], unsigned short count) {
+	disable_interrupts();
+	with( * kernelTLS.this_processor ) {
+		finish.action_code = Release_Multi;
+		finish.locks       = locks;
+		finish.lock_count  = count;
+	}
+
+	verify( ! kernelTLS.preemption_state.enabled );
+	returnToKernel();
+	verify( ! kernelTLS.preemption_state.enabled );
+
+	enable_interrupts( __cfaabi_dbg_ctx );
+}
+
+void BlockInternal(__spinlock_t * locks [], unsigned short lock_count, thread_desc * thrds [], unsigned short thrd_count) {
+	disable_interrupts();
+	with( *kernelTLS.this_processor ) {
+		finish.action_code = Release_Multi_Schedule;
+		finish.locks       = locks;
+		finish.lock_count  = lock_count;
+		finish.thrds       = thrds;
+		finish.thrd_count  = thrd_count;
+	}
+
+	verify( ! kernelTLS.preemption_state.enabled );
+	returnToKernel();
+	verify( ! kernelTLS.preemption_state.enabled );
+
+	enable_interrupts( __cfaabi_dbg_ctx );
+}
+
+void BlockInternal(__finish_callback_fptr_t callback) {
+	disable_interrupts();
+	with( *kernelTLS.this_processor ) {
+		finish.action_code = Callback;
+		finish.callback    = callback;
+	}
+
+	verify( ! kernelTLS.preemption_state.enabled );
+	returnToKernel();
+	verify( ! kernelTLS.preemption_state.enabled );
+
+	enable_interrupts( __cfaabi_dbg_ctx );
+}
+
+// KERNEL ONLY
+void LeaveThread(__spinlock_t * lock, thread_desc * thrd) {
+	verify( ! kernelTLS.preemption_state.enabled );
+	with( * kernelTLS.this_processor ) {
+		finish.action_code = thrd ? Release_Schedule : Release;
+		finish.lock        = lock;
+		finish.thrd        = thrd;
+	}
+
+	returnToKernel();
+}
+
+//=============================================================================================
+// Kernel Setup logic
+//=============================================================================================
+//-----------------------------------------------------------------------------
+// Kernel boot procedures
+static void kernel_startup(void) {
+	verify( ! kernelTLS.preemption_state.enabled );
+	__cfaabi_dbg_print_safe("Kernel : Starting\n");
+
+	__cfa_dbg_global_clusters.list{ __get };
+	__cfa_dbg_global_clusters.lock{};
+
+	// Initialize the main cluster
+	mainCluster = (cluster *)&storage_mainCluster;
+	(*mainCluster){"Main Cluster"};
+
+	__cfaabi_dbg_print_safe("Kernel : Main cluster ready\n");
+
+	// Start by initializing the main thread
+	// SKULLDUGGERY: the mainThread steals the process main thread
+	// which will then be scheduled by the mainProcessor normally
+	mainThread = (thread_desc *)&storage_mainThread;
+	current_stack_info_t info;
+	(*mainThread){ &info };
+
+	__cfaabi_dbg_print_safe("Kernel : Main thread ready\n");
+
+
+
+	// Construct the processor context of the main processor
+	void ?{}(processorCtx_t & this, processor * proc) {
+		(this.__cor){ "Processor" };
+		this.__cor.starter = NULL;
+		this.proc = proc;
+	}
+
+	void ?{}(processor & this) with( this ) {
+		name = "Main Processor";
+		cltr = mainCluster;
+		terminated{ 0 };
+		do_terminate = false;
+		preemption_alarm = NULL;
+		pending_preemption = false;
+		kernel_thread = pthread_self();
+
+		runner{ &this };
+		__cfaabi_dbg_print_safe("Kernel : constructed main processor context %p\n", &runner);
+	}
+
+	// Initialize the main processor and the main processor ctx
+	// (the coroutine that contains the processing control flow)
+	mainProcessor = (processor *)&storage_mainProcessor;
+	(*mainProcessor){};
+
+	//initialize the global state variables
+	kernelTLS.this_processor = mainProcessor;
+	kernelTLS.this_thread    = mainThread;
+	kernelTLS.this_coroutine = &mainThread->self_cor;
+
+	// Enable preemption
+	kernel_start_preemption();
+
+	// Add the main thread to the ready queue
+	// once resume is called on mainProcessor->runner the mainThread needs to be scheduled like any normal thread
+	ScheduleThread(mainThread);
+
+	// SKULLDUGGERY: Force a context switch to the main processor to set the main thread's context to the current UNIX
+	// context. Hence, the main thread does not begin through CtxInvokeThread, like all other threads. The trick here is that
+	// mainThread is on the ready queue when this call is made.
+	kernel_first_resume( kernelTLS.this_processor );
+
+
+
+	// THE SYSTEM IS NOW COMPLETELY RUNNING
+	__cfaabi_dbg_print_safe("Kernel : Started\n--------------------------------------------------\n\n");
+
+	verify( ! kernelTLS.preemption_state.enabled );
+	enable_interrupts( __cfaabi_dbg_ctx );
+	verify( TL_GET( preemption_state.enabled ) );
+}
+
+static void kernel_shutdown(void) {
+	__cfaabi_dbg_print_safe("\n--------------------------------------------------\nKernel : Shutting down\n");
+
+	verify( TL_GET( preemption_state.enabled ) );
+	disable_interrupts();
+	verify( ! kernelTLS.preemption_state.enabled );
+
+	// SKULLDUGGERY: Notify the mainProcessor it needs to terminates.
+	// When its coroutine terminates, it return control to the mainThread
+	// which is currently here
+	__atomic_store_n(&mainProcessor->do_terminate, true, __ATOMIC_RELEASE);
+	returnToKernel();
+	mainThread->self_cor.state = Halted;
+
+	// THE SYSTEM IS NOW COMPLETELY STOPPED
+
+	// Disable preemption
+	kernel_stop_preemption();
+
+	// Destroy the main processor and its context in reverse order of construction
+	// These were manually constructed so we need manually destroy them
+	^(mainProcessor->runner){};
+	^(mainProcessor){};
+
+	// Final step, destroy the main thread since it is no longer needed
+	// Since we provided a stack to this taxk it will not destroy anything
+	^(mainThread){};
+
+	^(__cfa_dbg_global_clusters.list){};
+	^(__cfa_dbg_global_clusters.lock){};
+
+	__cfaabi_dbg_print_safe("Kernel : Shutdown complete\n");
+}
+
+//=============================================================================================
+// Kernel Quiescing
+//=============================================================================================
+static void halt(processor * this) with( *this ) {
+	// verify( ! __atomic_load_n(&do_terminate, __ATOMIC_SEQ_CST) );
+
+	with( *cltr ) {
+		lock      (proc_list_lock __cfaabi_dbg_ctx2);
+		remove    (procs, *this);
+		push_front(idles, *this);
+		unlock    (proc_list_lock);
+	}
+
+	__cfaabi_dbg_print_safe("Kernel : Processor %p ready to sleep\n", this);
+
+	wait( idleLock );
+
+	__cfaabi_dbg_print_safe("Kernel : Processor %p woke up and ready to run\n", this);
+
+	with( *cltr ) {
+		lock      (proc_list_lock __cfaabi_dbg_ctx2);
+		remove    (idles, *this);
+		push_front(procs, *this);
+		unlock    (proc_list_lock);
+	}
+}
+
+//=============================================================================================
+// Unexpected Terminating logic
+//=============================================================================================
+static __spinlock_t kernel_abort_lock;
+static bool kernel_abort_called = false;
+
+void * kernel_abort(void) __attribute__ ((__nothrow__)) {
+	// abort cannot be recursively entered by the same or different processors because all signal handlers return when
+	// the globalAbort flag is true.
+	lock( kernel_abort_lock __cfaabi_dbg_ctx2 );
+
+	// first task to abort ?
+	if ( kernel_abort_called ) {			// not first task to abort ?
+		unlock( kernel_abort_lock );
+
+		sigset_t mask;
+		sigemptyset( &mask );
+		sigaddset( &mask, SIGALRM );		// block SIGALRM signals
+		sigsuspend( &mask );			// block the processor to prevent further damage during abort
+		_exit( EXIT_FAILURE );			// if processor unblocks before it is killed, terminate it
+	}
+	else {
+		kernel_abort_called = true;
+		unlock( kernel_abort_lock );
+	}
+
+	return kernelTLS.this_thread;
+}
+
+void kernel_abort_msg( void * kernel_data, char * abort_text, int abort_text_size ) {
+	thread_desc * thrd = kernel_data;
+
+	if(thrd) {
+		int len = snprintf( abort_text, abort_text_size, "Error occurred while executing thread %.256s (%p)", thrd->self_cor.name, thrd );
+		__cfaabi_dbg_bits_write( abort_text, len );
+
+		if ( get_coroutine(thrd) != kernelTLS.this_coroutine ) {
+			len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", kernelTLS.this_coroutine->name, kernelTLS.this_coroutine );
+			__cfaabi_dbg_bits_write( abort_text, len );
+		}
+		else {
+			__cfaabi_dbg_bits_write( ".\n", 2 );
+		}
+	}
+	else {
+		int len = snprintf( abort_text, abort_text_size, "Error occurred outside of any thread.\n" );
+		__cfaabi_dbg_bits_write( abort_text, len );
+	}
+}
+
+int kernel_abort_lastframe( void ) __attribute__ ((__nothrow__)) {
+	return get_coroutine(kernelTLS.this_thread) == get_coroutine(mainThread) ? 4 : 2;
+}
+
+static __spinlock_t kernel_debug_lock;
+
+extern "C" {
+	void __cfaabi_dbg_bits_acquire() {
+		lock( kernel_debug_lock __cfaabi_dbg_ctx2 );
+	}
+
+	void __cfaabi_dbg_bits_release() {
+		unlock( kernel_debug_lock );
+	}
+}
+
+//=============================================================================================
+// Kernel Utilities
+//=============================================================================================
+//-----------------------------------------------------------------------------
+// Locks
+void  ?{}( semaphore & this, int count = 1 ) {
+	(this.lock){};
+	this.count = count;
+	(this.waiting){};
+}
+void ^?{}(semaphore & this) {}
+
+void P(semaphore & this) with( this ){
+	lock( lock __cfaabi_dbg_ctx2 );
+	count -= 1;
+	if ( count < 0 ) {
+		// queue current task
+		append( waiting, kernelTLS.this_thread );
+
+		// atomically release spin lock and block
+		BlockInternal( &lock );
+	}
+	else {
+	    unlock( lock );
+	}
+}
+
+void V(semaphore & this) with( this ) {
+	thread_desc * thrd = NULL;
+	lock( lock __cfaabi_dbg_ctx2 );
+	count += 1;
+	if ( count <= 0 ) {
+		// remove task at head of waiting list
+		thrd = pop_head( waiting );
+	}
+
+	unlock( lock );
+
+	// make new owner
+	WakeThread( thrd );
+}
+
+//-----------------------------------------------------------------------------
+// Global Queues
+void doregister( cluster     & cltr ) {
+	lock      ( __cfa_dbg_global_clusters.lock __cfaabi_dbg_ctx2);
+	push_front( __cfa_dbg_global_clusters.list, cltr );
+	unlock    ( __cfa_dbg_global_clusters.lock );
+}
+
+void unregister( cluster     & cltr ) {
+	lock  ( __cfa_dbg_global_clusters.lock __cfaabi_dbg_ctx2);
+	remove( __cfa_dbg_global_clusters.list, cltr );
+	unlock( __cfa_dbg_global_clusters.lock );
+}
+
+void doregister( cluster * cltr, thread_desc & thrd ) {
+	lock      (cltr->thread_list_lock __cfaabi_dbg_ctx2);
+	push_front(cltr->threads, thrd);
+	unlock    (cltr->thread_list_lock);
+}
+
+void unregister( cluster * cltr, thread_desc & thrd ) {
+	lock  (cltr->thread_list_lock __cfaabi_dbg_ctx2);
+	remove(cltr->threads, thrd );
+	unlock(cltr->thread_list_lock);
+}
+
+void doregister( cluster * cltr, processor * proc ) {
+	lock      (cltr->proc_list_lock __cfaabi_dbg_ctx2);
+	push_front(cltr->procs, *proc);
+	unlock    (cltr->proc_list_lock);
+}
+
+void unregister( cluster * cltr, processor * proc ) {
+	lock  (cltr->proc_list_lock __cfaabi_dbg_ctx2);
+	remove(cltr->procs, *proc );
+	unlock(cltr->proc_list_lock);
+}
+
+//-----------------------------------------------------------------------------
+// Debug
+__cfaabi_dbg_debug_do(
+	void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name) {
+		this.prev_name = prev_name;
+		this.prev_thrd = kernelTLS.this_thread;
+	}
+)
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/concurrency/monitor.c
===================================================================
--- libcfa/src/concurrency/monitor.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,900 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// monitor_desc.c --
-//
-// Author           : Thierry Delisle
-// Created On       : Thd Feb 23 12:27:26 2017
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Mar 30 14:30:26 2018
-// Update Count     : 9
-//
-
-#include "monitor"
-
-#include <stdlib>
-#include <inttypes.h>
-
-#include "kernel_private.h"
-
-#include "bits/algorithms.h"
-
-//-----------------------------------------------------------------------------
-// Forward declarations
-static inline void set_owner ( monitor_desc * this, thread_desc * owner );
-static inline void set_owner ( monitor_desc * storage [], __lock_size_t count, thread_desc * owner );
-static inline void set_mask  ( monitor_desc * storage [], __lock_size_t count, const __waitfor_mask_t & mask );
-static inline void reset_mask( monitor_desc * this );
-
-static inline thread_desc * next_thread( monitor_desc * this );
-static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & monitors );
-
-static inline void lock_all  ( __spinlock_t * locks [], __lock_size_t count );
-static inline void lock_all  ( monitor_desc * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count );
-static inline void unlock_all( __spinlock_t * locks [], __lock_size_t count );
-static inline void unlock_all( monitor_desc * locks [], __lock_size_t count );
-
-static inline void save   ( monitor_desc * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*out*/ recursions [], __waitfor_mask_t /*out*/ masks [] );
-static inline void restore( monitor_desc * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*in */ recursions [], __waitfor_mask_t /*in */ masks [] );
-
-static inline void init     ( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
-static inline void init_push( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
-
-static inline thread_desc *        check_condition   ( __condition_criterion_t * );
-static inline void                 brand_condition   ( condition & );
-static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t &, monitor_desc * monitors [], __lock_size_t count );
-
-forall(dtype T | sized( T ))
-static inline __lock_size_t insert_unique( T * array [], __lock_size_t & size, T * val );
-static inline __lock_size_t count_max    ( const __waitfor_mask_t & mask );
-static inline __lock_size_t aggregate    ( monitor_desc * storage [], const __waitfor_mask_t & mask );
-
-//-----------------------------------------------------------------------------
-// Useful defines
-#define wait_ctx(thrd, user_info)                               /* Create the necessary information to use the signaller stack                         */ \
-	__condition_node_t waiter = { thrd, count, user_info };   /* Create the node specific to this wait operation                                     */ \
-	__condition_criterion_t criteria[count];                  /* Create the creteria this wait operation needs to wake up                            */ \
-	init( count, monitors, waiter, criteria );                /* Link everything together                                                            */ \
-
-#define wait_ctx_primed(thrd, user_info)                        /* Create the necessary information to use the signaller stack                         */ \
-	__condition_node_t waiter = { thrd, count, user_info };   /* Create the node specific to this wait operation                                     */ \
-	__condition_criterion_t criteria[count];                  /* Create the creteria this wait operation needs to wake up                            */ \
-	init_push( count, monitors, waiter, criteria );           /* Link everything together and push it to the AS-Stack                                */ \
-
-#define monitor_ctx( mons, cnt )                                /* Define that create the necessary struct for internal/external scheduling operations */ \
-	monitor_desc ** monitors = mons;                          /* Save the targeted monitors                                                          */ \
-	__lock_size_t count = cnt;                                /* Save the count to a local variable                                                  */ \
-	unsigned int recursions[ count ];                         /* Save the current recursion levels to restore them later                             */ \
-	__waitfor_mask_t masks [ count ];                         /* Save the current waitfor masks to restore them later                                */ \
-	__spinlock_t *   locks [ count ];                         /* We need to pass-in an array of locks to BlockInternal                               */ \
-
-#define monitor_save    save   ( monitors, count, locks, recursions, masks )
-#define monitor_restore restore( monitors, count, locks, recursions, masks )
-
-
-//-----------------------------------------------------------------------------
-// Enter/Leave routines
-
-
-extern "C" {
-	// Enter single monitor
-	static void __enter_monitor_desc( monitor_desc * this, const __monitor_group_t & group ) {
-		// Lock the monitor spinlock
-		lock( this->lock __cfaabi_dbg_ctx2 );
-		// Interrupts disable inside critical section
-		thread_desc * thrd = kernelTLS.this_thread;
-
-		__cfaabi_dbg_print_safe( "Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);
-
-		if( !this->owner ) {
-			// No one has the monitor, just take it
-			set_owner( this, thrd );
-
-			__cfaabi_dbg_print_safe( "Kernel :  mon is free \n" );
-		}
-		else if( this->owner == thrd) {
-			// We already have the monitor, just note how many times we took it
-			this->recursion += 1;
-
-			__cfaabi_dbg_print_safe( "Kernel :  mon already owned \n" );
-		}
-		else if( is_accepted( this, group) ) {
-			// Some one was waiting for us, enter
-			set_owner( this, thrd );
-
-			// Reset mask
-			reset_mask( this );
-
-			__cfaabi_dbg_print_safe( "Kernel :  mon accepts \n" );
-		}
-		else {
-			__cfaabi_dbg_print_safe( "Kernel :  blocking \n" );
-
-			// Some one else has the monitor, wait in line for it
-			append( this->entry_queue, thrd );
-
-			BlockInternal( &this->lock );
-
-			__cfaabi_dbg_print_safe( "Kernel : %10p Entered  mon %p\n", thrd, this);
-
-			// BlockInternal will unlock spinlock, no need to unlock ourselves
-			return;
-		}
-
-		__cfaabi_dbg_print_safe( "Kernel : %10p Entered  mon %p\n", thrd, this);
-
-		// Release the lock and leave
-		unlock( this->lock );
-		return;
-	}
-
-	static void __enter_monitor_dtor( monitor_desc * this, fptr_t func ) {
-		// Lock the monitor spinlock
-		lock( this->lock __cfaabi_dbg_ctx2 );
-		// Interrupts disable inside critical section
-		thread_desc * thrd = kernelTLS.this_thread;
-
-		__cfaabi_dbg_print_safe( "Kernel : %10p Entering dtor for mon %p (%p)\n", thrd, this, this->owner);
-
-
-		if( !this->owner ) {
-			__cfaabi_dbg_print_safe( "Kernel : Destroying free mon %p\n", this);
-
-			// No one has the monitor, just take it
-			set_owner( this, thrd );
-
-			unlock( this->lock );
-			return;
-		}
-		else if( this->owner == thrd) {
-			// We already have the monitor... but where about to destroy it so the nesting will fail
-			// Abort!
-			abort( "Attempt to destroy monitor %p by thread \"%.256s\" (%p) in nested mutex.", this, thrd->self_cor.name, thrd );
-		}
-
-		__lock_size_t count = 1;
-		monitor_desc ** monitors = &this;
-		__monitor_group_t group = { &this, 1, func };
-		if( is_accepted( this, group) ) {
-			__cfaabi_dbg_print_safe( "Kernel :  mon accepts dtor, block and signal it \n" );
-
-			// Wake the thread that is waiting for this
-			__condition_criterion_t * urgent = pop( this->signal_stack );
-			verify( urgent );
-
-			// Reset mask
-			reset_mask( this );
-
-			// Create the node specific to this wait operation
-			wait_ctx_primed( thrd, 0 )
-
-			// Some one else has the monitor, wait for him to finish and then run
-			BlockInternal( &this->lock, urgent->owner->waiting_thread );
-
-			// Some one was waiting for us, enter
-			set_owner( this, thrd );
-		}
-		else {
-			__cfaabi_dbg_print_safe( "Kernel :  blocking \n" );
-
-			wait_ctx( thrd, 0 )
-			this->dtor_node = &waiter;
-
-			// Some one else has the monitor, wait in line for it
-			append( this->entry_queue, thrd );
-			BlockInternal( &this->lock );
-
-			// BlockInternal will unlock spinlock, no need to unlock ourselves
-			return;
-		}
-
-		__cfaabi_dbg_print_safe( "Kernel : Destroying %p\n", this);
-
-	}
-
-	// Leave single monitor
-	void __leave_monitor_desc( monitor_desc * this ) {
-		// Lock the monitor spinlock
-		lock( this->lock __cfaabi_dbg_ctx2 );
-
-		__cfaabi_dbg_print_safe( "Kernel : %10p Leaving mon %p (%p)\n", kernelTLS.this_thread, this, this->owner);
-
-		verifyf( kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this );
-
-		// Leaving a recursion level, decrement the counter
-		this->recursion -= 1;
-
-		// If we haven't left the last level of recursion
-		// it means we don't need to do anything
-		if( this->recursion != 0) {
-			__cfaabi_dbg_print_safe( "Kernel :  recursion still %d\n", this->recursion);
-			unlock( this->lock );
-			return;
-		}
-
-		// Get the next thread, will be null on low contention monitor
-		thread_desc * new_owner = next_thread( this );
-
-		// We can now let other threads in safely
-		unlock( this->lock );
-
-		//We need to wake-up the thread
-		WakeThread( new_owner );
-	}
-
-	// Leave single monitor for the last time
-	void __leave_dtor_monitor_desc( monitor_desc * this ) {
-		__cfaabi_dbg_debug_do(
-			if( TL_GET( this_thread ) != this->owner ) {
-				abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, TL_GET( this_thread ), this->owner);
-			}
-			if( this->recursion != 1 ) {
-				abort( "Destroyed monitor %p has %d outstanding nested calls.\n", this, this->recursion - 1);
-			}
-		)
-	}
-
-	// Leave the thread monitor
-	// last routine called by a thread.
-	// Should never return
-	void __leave_thread_monitor( thread_desc * thrd ) {
-		monitor_desc * this = &thrd->self_mon;
-
-		// Lock the monitor now
-		lock( this->lock __cfaabi_dbg_ctx2 );
-
-		disable_interrupts();
-
-		thrd->self_cor.state = Halted;
-
-		verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", thrd, this->owner, this->recursion, this );
-
-		// Leaving a recursion level, decrement the counter
-		this->recursion -= 1;
-
-		// If we haven't left the last level of recursion
-		// it must mean there is an error
-		if( this->recursion != 0) { abort( "Thread internal monitor has unbalanced recursion" ); }
-
-		// Fetch the next thread, can be null
-		thread_desc * new_owner = next_thread( this );
-
-		// Leave the thread, this will unlock the spinlock
-		// Use leave thread instead of BlockInternal which is
-		// specialized for this case and supports null new_owner
-		LeaveThread( &this->lock, new_owner );
-
-		// Control flow should never reach here!
-	}
-}
-
-// Enter multiple monitor
-// relies on the monitor array being sorted
-static inline void enter( __monitor_group_t monitors ) {
-	for( __lock_size_t i = 0; i < monitors.size; i++) {
-		__enter_monitor_desc( monitors[i], monitors );
-	}
-}
-
-// Leave multiple monitor
-// relies on the monitor array being sorted
-static inline void leave(monitor_desc * monitors [], __lock_size_t count) {
-	for( __lock_size_t i = count - 1; i >= 0; i--) {
-		__leave_monitor_desc( monitors[i] );
-	}
-}
-
-// Ctor for monitor guard
-// Sorts monitors before entering
-void ?{}( monitor_guard_t & this, monitor_desc * m [], __lock_size_t count, fptr_t func ) {
-	thread_desc * thrd = TL_GET( this_thread );
-
-	// Store current array
-	this.m = m;
-	this.count = count;
-
-	// Sort monitors based on address
-	__libcfa_small_sort(this.m, count);
-
-	// Save previous thread context
-	this.prev = thrd->monitors;
-
-	// Update thread context (needed for conditions)
-	(thrd->monitors){m, count, func};
-
-	// __cfaabi_dbg_print_safe( "MGUARD : enter %d\n", count);
-
-	// Enter the monitors in order
-	__monitor_group_t group = {this.m, this.count, func};
-	enter( group );
-
-	// __cfaabi_dbg_print_safe( "MGUARD : entered\n" );
-}
-
-
-// Dtor for monitor guard
-void ^?{}( monitor_guard_t & this ) {
-	// __cfaabi_dbg_print_safe( "MGUARD : leaving %d\n", this.count);
-
-	// Leave the monitors in order
-	leave( this.m, this.count );
-
-	// __cfaabi_dbg_print_safe( "MGUARD : left\n" );
-
-	// Restore thread context
-	TL_GET( this_thread )->monitors = this.prev;
-}
-
-// Ctor for monitor guard
-// Sorts monitors before entering
-void ?{}( monitor_dtor_guard_t & this, monitor_desc * m [], fptr_t func ) {
-	// optimization
-	thread_desc * thrd = TL_GET( this_thread );
-
-	// Store current array
-	this.m = *m;
-
-	// Save previous thread context
-	this.prev = thrd->monitors;
-
-	// Update thread context (needed for conditions)
-	(thrd->monitors){m, 1, func};
-
-	__enter_monitor_dtor( this.m, func );
-}
-
-// Dtor for monitor guard
-void ^?{}( monitor_dtor_guard_t & this ) {
-	// Leave the monitors in order
-	__leave_dtor_monitor_desc( this.m );
-
-	// Restore thread context
-	TL_GET( this_thread )->monitors = this.prev;
-}
-
-//-----------------------------------------------------------------------------
-// Internal scheduling types
-void ?{}(__condition_node_t & this, thread_desc * waiting_thread, __lock_size_t count, uintptr_t user_info ) {
-	this.waiting_thread = waiting_thread;
-	this.count = count;
-	this.next = NULL;
-	this.user_info = user_info;
-}
-
-void ?{}(__condition_criterion_t & this ) with( this ) {
-	ready  = false;
-	target = NULL;
-	owner  = NULL;
-	next   = NULL;
-}
-
-void ?{}(__condition_criterion_t & this, monitor_desc * target, __condition_node_t & owner ) {
-	this.ready  = false;
-	this.target = target;
-	this.owner  = &owner;
-	this.next   = NULL;
-}
-
-//-----------------------------------------------------------------------------
-// Internal scheduling
-void wait( condition & this, uintptr_t user_info = 0 ) {
-	brand_condition( this );
-
-	// Check that everything is as expected
-	assertf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors );
-	verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count );
-	verifyf( this.monitor_count < 32u, "Excessive monitor count (%"PRIiFAST16")", this.monitor_count );
-
-	// Create storage for monitor context
-	monitor_ctx( this.monitors, this.monitor_count );
-
-	// Create the node specific to this wait operation
-	wait_ctx( TL_GET( this_thread ), user_info );
-
-	// Append the current wait operation to the ones already queued on the condition
-	// We don't need locks for that since conditions must always be waited on inside monitor mutual exclusion
-	append( this.blocked, &waiter );
-
-	// Lock all monitors (aggregates the locks as well)
-	lock_all( monitors, locks, count );
-
-	// Find the next thread(s) to run
-	__lock_size_t thread_count = 0;
-	thread_desc * threads[ count ];
-	__builtin_memset( threads, 0, sizeof( threads ) );
-
-	// Save monitor states
-	monitor_save;
-
-	// Remove any duplicate threads
-	for( __lock_size_t i = 0; i < count; i++) {
-		thread_desc * new_owner = next_thread( monitors[i] );
-		insert_unique( threads, thread_count, new_owner );
-	}
-
-	// Everything is ready to go to sleep
-	BlockInternal( locks, count, threads, thread_count );
-
-	// We are back, restore the owners and recursions
-	monitor_restore;
-}
-
-bool signal( condition & this ) {
-	if( is_empty( this ) ) { return false; }
-
-	//Check that everything is as expected
-	verify( this.monitors );
-	verify( this.monitor_count != 0 );
-
-	//Some more checking in debug
-	__cfaabi_dbg_debug_do(
-		thread_desc * this_thrd = TL_GET( this_thread );
-		if ( this.monitor_count != this_thrd->monitors.size ) {
-			abort( "Signal on condition %p made with different number of monitor(s), expected %zi got %zi", &this, this.monitor_count, this_thrd->monitors.size );
-		}
-
-		for(int i = 0; i < this.monitor_count; i++) {
-			if ( this.monitors[i] != this_thrd->monitors[i] ) {
-				abort( "Signal on condition %p made with different monitor, expected %p got %p", &this, this.monitors[i], this_thrd->monitors[i] );
-			}
-		}
-	);
-
-	__lock_size_t count = this.monitor_count;
-
-	// Lock all monitors
-	lock_all( this.monitors, NULL, count );
-
-	//Pop the head of the waiting queue
-	__condition_node_t * node = pop_head( this.blocked );
-
-	//Add the thread to the proper AS stack
-	for(int i = 0; i < count; i++) {
-		__condition_criterion_t * crit = &node->criteria[i];
-		assert( !crit->ready );
-		push( crit->target->signal_stack, crit );
-	}
-
-	//Release
-	unlock_all( this.monitors, count );
-
-	return true;
-}
-
-bool signal_block( condition & this ) {
-	if( !this.blocked.head ) { return false; }
-
-	//Check that everything is as expected
-	verifyf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors );
-	verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count );
-
-	// Create storage for monitor context
-	monitor_ctx( this.monitors, this.monitor_count );
-
-	// Lock all monitors (aggregates the locks them as well)
-	lock_all( monitors, locks, count );
-
-
-	// Create the node specific to this wait operation
-	wait_ctx_primed( kernelTLS.this_thread, 0 )
-
-	//save contexts
-	monitor_save;
-
-	//Find the thread to run
-	thread_desc * signallee = pop_head( this.blocked )->waiting_thread;
-	set_owner( monitors, count, signallee );
-
-	__cfaabi_dbg_print_buffer_decl( "Kernel : signal_block condition %p (s: %p)\n", &this, signallee );
-
-	//Everything is ready to go to sleep
-	BlockInternal( locks, count, &signallee, 1 );
-
-
-	// WE WOKE UP
-
-
-	__cfaabi_dbg_print_buffer_local( "Kernel :   signal_block returned\n" );
-
-	//We are back, restore the masks and recursions
-	monitor_restore;
-
-	return true;
-}
-
-// Access the user_info of the thread waiting at the front of the queue
-uintptr_t front( condition & this ) {
-	verifyf( !is_empty(this),
-		"Attempt to access user data on an empty condition.\n"
-		"Possible cause is not checking if the condition is empty before reading stored data."
-	);
-	return ((typeof(this.blocked.head))this.blocked.head)->user_info;
-}
-
-//-----------------------------------------------------------------------------
-// External scheduling
-// cases to handle :
-// 	- target already there :
-// 		block and wake
-// 	- dtor already there
-// 		put thread on signaller stack
-// 	- non-blocking
-// 		return else
-// 	- timeout
-// 		return timeout
-// 	- block
-// 		setup mask
-// 		block
-void __waitfor_internal( const __waitfor_mask_t & mask, int duration ) {
-	// This statment doesn't have a contiguous list of monitors...
-	// Create one!
-	__lock_size_t max = count_max( mask );
-	monitor_desc * mon_storage[max];
-	__builtin_memset( mon_storage, 0, sizeof( mon_storage ) );
-	__lock_size_t actual_count = aggregate( mon_storage, mask );
-
-	__cfaabi_dbg_print_buffer_decl( "Kernel : waitfor %"PRIdFAST16" (s: %"PRIdFAST16", m: %"PRIdFAST16")\n", actual_count, mask.size, (__lock_size_t)max);
-
-	if(actual_count == 0) return;
-
-	__cfaabi_dbg_print_buffer_local( "Kernel : waitfor internal proceeding\n" );
-
-	// Create storage for monitor context
-	monitor_ctx( mon_storage, actual_count );
-
-	// Lock all monitors (aggregates the locks as well)
-	lock_all( monitors, locks, count );
-
-	{
-		// Check if the entry queue
-		thread_desc * next; int index;
-		[next, index] = search_entry_queue( mask, monitors, count );
-
-		if( next ) {
-			*mask.accepted = index;
-			__acceptable_t& accepted = mask[index];
-			if( accepted.is_dtor ) {
-				__cfaabi_dbg_print_buffer_local( "Kernel : dtor already there\n" );
-				verifyf( accepted.size == 1,  "ERROR: Accepted dtor has more than 1 mutex parameter." );
-
-				monitor_desc * mon2dtor = accepted[0];
-				verifyf( mon2dtor->dtor_node, "ERROR: Accepted monitor has no dtor_node." );
-
-				__condition_criterion_t * dtor_crit = mon2dtor->dtor_node->criteria;
-				push( mon2dtor->signal_stack, dtor_crit );
-
-				unlock_all( locks, count );
-			}
-			else {
-				__cfaabi_dbg_print_buffer_local( "Kernel : thread present, baton-passing\n" );
-
-				// Create the node specific to this wait operation
-				wait_ctx_primed( kernelTLS.this_thread, 0 );
-
-				// Save monitor states
-				monitor_save;
-
-				__cfaabi_dbg_print_buffer_local( "Kernel :  baton of %"PRIdFAST16" monitors : ", count );
-				#ifdef __CFA_DEBUG_PRINT__
-					for( int i = 0; i < count; i++) {
-						__cfaabi_dbg_print_buffer_local( "%p %p ", monitors[i], monitors[i]->signal_stack.top );
-					}
-				#endif
-				__cfaabi_dbg_print_buffer_local( "\n" );
-
-				// Set the owners to be the next thread
-				set_owner( monitors, count, next );
-
-				// Everything is ready to go to sleep
-				BlockInternal( locks, count, &next, 1 );
-
-				// We are back, restore the owners and recursions
-				monitor_restore;
-
-				__cfaabi_dbg_print_buffer_local( "Kernel : thread present, returned\n" );
-			}
-
-			__cfaabi_dbg_print_buffer_local( "Kernel : accepted %d\n", *mask.accepted);
-			return;
-		}
-	}
-
-
-	if( duration == 0 ) {
-		__cfaabi_dbg_print_buffer_local( "Kernel : non-blocking, exiting\n" );
-
-		unlock_all( locks, count );
-
-		__cfaabi_dbg_print_buffer_local( "Kernel : accepted %d\n", *mask.accepted);
-		return;
-	}
-
-
-	verifyf( duration < 0, "Timeout on waitfor statments not supported yet." );
-
-	__cfaabi_dbg_print_buffer_local( "Kernel : blocking waitfor\n" );
-
-	// Create the node specific to this wait operation
-	wait_ctx_primed( kernelTLS.this_thread, 0 );
-
-	monitor_save;
-	set_mask( monitors, count, mask );
-
-	for( __lock_size_t i = 0; i < count; i++) {
-		verify( monitors[i]->owner == kernelTLS.this_thread );
-	}
-
-	//Everything is ready to go to sleep
-	BlockInternal( locks, count );
-
-
-	// WE WOKE UP
-
-
-	//We are back, restore the masks and recursions
-	monitor_restore;
-
-	__cfaabi_dbg_print_buffer_local( "Kernel : exiting\n" );
-
-	__cfaabi_dbg_print_buffer_local( "Kernel : accepted %d\n", *mask.accepted);
-}
-
-//-----------------------------------------------------------------------------
-// Utilities
-
-static inline void set_owner( monitor_desc * this, thread_desc * owner ) {
-	// __cfaabi_dbg_print_safe( "Kernal :   Setting owner of %p to %p ( was %p)\n", this, owner, this->owner );
-
-	//Pass the monitor appropriately
-	this->owner = owner;
-
-	//We are passing the monitor to someone else, which means recursion level is not 0
-	this->recursion = owner ? 1 : 0;
-}
-
-static inline void set_owner( monitor_desc * monitors [], __lock_size_t count, thread_desc * owner ) {
-	monitors[0]->owner     = owner;
-	monitors[0]->recursion = 1;
-	for( __lock_size_t i = 1; i < count; i++ ) {
-		monitors[i]->owner     = owner;
-		monitors[i]->recursion = 0;
-	}
-}
-
-static inline void set_mask( monitor_desc * storage [], __lock_size_t count, const __waitfor_mask_t & mask ) {
-	for( __lock_size_t i = 0; i < count; i++) {
-		storage[i]->mask = mask;
-	}
-}
-
-static inline void reset_mask( monitor_desc * this ) {
-	this->mask.accepted = NULL;
-	this->mask.data = NULL;
-	this->mask.size = 0;
-}
-
-static inline thread_desc * next_thread( monitor_desc * this ) {
-	//Check the signaller stack
-	__cfaabi_dbg_print_safe( "Kernel :  mon %p AS-stack top %p\n", this, this->signal_stack.top);
-	__condition_criterion_t * urgent = pop( this->signal_stack );
-	if( urgent ) {
-		//The signaller stack is not empty,
-		//regardless of if we are ready to baton pass,
-		//we need to set the monitor as in use
-		set_owner( this,  urgent->owner->waiting_thread );
-
-		return check_condition( urgent );
-	}
-
-	// No signaller thread
-	// Get the next thread in the entry_queue
-	thread_desc * new_owner = pop_head( this->entry_queue );
-	set_owner( this, new_owner );
-
-	return new_owner;
-}
-
-static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & group ) {
-	__acceptable_t * it = this->mask.data; // Optim
-	__lock_size_t count = this->mask.size;
-
-	// Check if there are any acceptable functions
-	if( !it ) return false;
-
-	// If this isn't the first monitor to test this, there is no reason to repeat the test.
-	if( this != group[0] ) return group[0]->mask.accepted >= 0;
-
-	// For all acceptable functions check if this is the current function.
-	for( __lock_size_t i = 0; i < count; i++, it++ ) {
-		if( *it == group ) {
-			*this->mask.accepted = i;
-			return true;
-		}
-	}
-
-	// No function matched
-	return false;
-}
-
-static inline void init( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {
-	for( __lock_size_t i = 0; i < count; i++) {
-		(criteria[i]){ monitors[i], waiter };
-	}
-
-	waiter.criteria = criteria;
-}
-
-static inline void init_push( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {
-	for( __lock_size_t i = 0; i < count; i++) {
-		(criteria[i]){ monitors[i], waiter };
-		__cfaabi_dbg_print_safe( "Kernel :  target %p = %p\n", criteria[i].target, &criteria[i] );
-		push( criteria[i].target->signal_stack, &criteria[i] );
-	}
-
-	waiter.criteria = criteria;
-}
-
-static inline void lock_all( __spinlock_t * locks [], __lock_size_t count ) {
-	for( __lock_size_t i = 0; i < count; i++ ) {
-		lock( *locks[i] __cfaabi_dbg_ctx2 );
-	}
-}
-
-static inline void lock_all( monitor_desc * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count ) {
-	for( __lock_size_t i = 0; i < count; i++ ) {
-		__spinlock_t * l = &source[i]->lock;
-		lock( *l __cfaabi_dbg_ctx2 );
-		if(locks) locks[i] = l;
-	}
-}
-
-static inline void unlock_all( __spinlock_t * locks [], __lock_size_t count ) {
-	for( __lock_size_t i = 0; i < count; i++ ) {
-		unlock( *locks[i] );
-	}
-}
-
-static inline void unlock_all( monitor_desc * locks [], __lock_size_t count ) {
-	for( __lock_size_t i = 0; i < count; i++ ) {
-		unlock( locks[i]->lock );
-	}
-}
-
-static inline void save(
-	monitor_desc * ctx [],
-	__lock_size_t count,
-	__attribute((unused)) __spinlock_t * locks [],
-	unsigned int /*out*/ recursions [],
-	__waitfor_mask_t /*out*/ masks []
-) {
-	for( __lock_size_t i = 0; i < count; i++ ) {
-		recursions[i] = ctx[i]->recursion;
-		masks[i]      = ctx[i]->mask;
-	}
-}
-
-static inline void restore(
-	monitor_desc * ctx [],
-	__lock_size_t count,
-	__spinlock_t * locks [],
-	unsigned int /*out*/ recursions [],
-	__waitfor_mask_t /*out*/ masks []
-) {
-	lock_all( locks, count );
-	for( __lock_size_t i = 0; i < count; i++ ) {
-		ctx[i]->recursion = recursions[i];
-		ctx[i]->mask      = masks[i];
-	}
-	unlock_all( locks, count );
-}
-
-// Function has 2 different behavior
-// 1 - Marks a monitors as being ready to run
-// 2 - Checks if all the monitors are ready to run
-//     if so return the thread to run
-static inline thread_desc * check_condition( __condition_criterion_t * target ) {
-	__condition_node_t * node = target->owner;
-	unsigned short count = node->count;
-	__condition_criterion_t * criteria = node->criteria;
-
-	bool ready2run = true;
-
-	for(	int i = 0; i < count; i++ ) {
-
-		// __cfaabi_dbg_print_safe( "Checking %p for %p\n", &criteria[i], target );
-		if( &criteria[i] == target ) {
-			criteria[i].ready = true;
-			// __cfaabi_dbg_print_safe( "True\n" );
-		}
-
-		ready2run = criteria[i].ready && ready2run;
-	}
-
-	__cfaabi_dbg_print_safe( "Kernel :  Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : NULL );
-	return ready2run ? node->waiting_thread : NULL;
-}
-
-static inline void brand_condition( condition & this ) {
-	thread_desc * thrd = TL_GET( this_thread );
-	if( !this.monitors ) {
-		// __cfaabi_dbg_print_safe( "Branding\n" );
-		assertf( thrd->monitors.data != NULL, "No current monitor to brand condition %p", thrd->monitors.data );
-		this.monitor_count = thrd->monitors.size;
-
-		this.monitors = (monitor_desc **)malloc( this.monitor_count * sizeof( *this.monitors ) );
-		for( int i = 0; i < this.monitor_count; i++ ) {
-			this.monitors[i] = thrd->monitors[i];
-		}
-	}
-}
-
-static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t & mask, monitor_desc * monitors [], __lock_size_t count ) {
-
-	__queue_t(thread_desc) & entry_queue = monitors[0]->entry_queue;
-
-	// For each thread in the entry-queue
-	for(	thread_desc ** thrd_it = &entry_queue.head;
-		*thrd_it;
-		thrd_it = &(*thrd_it)->next
-	) {
-		// For each acceptable check if it matches
-		int i = 0;
-		__acceptable_t * end   = end  (mask);
-		__acceptable_t * begin = begin(mask);
-		for( __acceptable_t * it = begin; it != end; it++, i++ ) {
-			// Check if we have a match
-			if( *it == (*thrd_it)->monitors ) {
-
-				// If we have a match return it
-				// after removeing it from the entry queue
-				return [remove( entry_queue, thrd_it ), i];
-			}
-		}
-	}
-
-	return [0, -1];
-}
-
-forall(dtype T | sized( T ))
-static inline __lock_size_t insert_unique( T * array [], __lock_size_t & size, T * val ) {
-	if( !val ) return size;
-
-	for( __lock_size_t i = 0; i <= size; i++) {
-		if( array[i] == val ) return size;
-	}
-
-	array[size] = val;
-	size = size + 1;
-	return size;
-}
-
-static inline __lock_size_t count_max( const __waitfor_mask_t & mask ) {
-	__lock_size_t max = 0;
-	for( __lock_size_t i = 0; i < mask.size; i++ ) {
-		__acceptable_t & accepted = mask[i];
-		max += accepted.size;
-	}
-	return max;
-}
-
-static inline __lock_size_t aggregate( monitor_desc * storage [], const __waitfor_mask_t & mask ) {
-	__lock_size_t size = 0;
-	for( __lock_size_t i = 0; i < mask.size; i++ ) {
-		__acceptable_t & accepted = mask[i];
-		__libcfa_small_sort( accepted.data, accepted.size );
-		for( __lock_size_t j = 0; j < accepted.size; j++) {
-			insert_unique( storage, size, accepted[j] );
-		}
-	}
-	// TODO insertion sort instead of this
-	__libcfa_small_sort( storage, size );
-	return size;
-}
-
-// Local Variables: //
-// mode: c //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/concurrency/monitor.cfa
===================================================================
--- libcfa/src/concurrency/monitor.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/concurrency/monitor.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,900 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// monitor_desc.c --
+//
+// Author           : Thierry Delisle
+// Created On       : Thd Feb 23 12:27:26 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Fri Mar 30 14:30:26 2018
+// Update Count     : 9
+//
+
+#include "monitor"
+
+#include <stdlib>
+#include <inttypes.h>
+
+#include "kernel_private.h"
+
+#include "bits/algorithms.h"
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+static inline void set_owner ( monitor_desc * this, thread_desc * owner );
+static inline void set_owner ( monitor_desc * storage [], __lock_size_t count, thread_desc * owner );
+static inline void set_mask  ( monitor_desc * storage [], __lock_size_t count, const __waitfor_mask_t & mask );
+static inline void reset_mask( monitor_desc * this );
+
+static inline thread_desc * next_thread( monitor_desc * this );
+static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & monitors );
+
+static inline void lock_all  ( __spinlock_t * locks [], __lock_size_t count );
+static inline void lock_all  ( monitor_desc * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count );
+static inline void unlock_all( __spinlock_t * locks [], __lock_size_t count );
+static inline void unlock_all( monitor_desc * locks [], __lock_size_t count );
+
+static inline void save   ( monitor_desc * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*out*/ recursions [], __waitfor_mask_t /*out*/ masks [] );
+static inline void restore( monitor_desc * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*in */ recursions [], __waitfor_mask_t /*in */ masks [] );
+
+static inline void init     ( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
+static inline void init_push( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
+
+static inline thread_desc *        check_condition   ( __condition_criterion_t * );
+static inline void                 brand_condition   ( condition & );
+static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t &, monitor_desc * monitors [], __lock_size_t count );
+
+forall(dtype T | sized( T ))
+static inline __lock_size_t insert_unique( T * array [], __lock_size_t & size, T * val );
+static inline __lock_size_t count_max    ( const __waitfor_mask_t & mask );
+static inline __lock_size_t aggregate    ( monitor_desc * storage [], const __waitfor_mask_t & mask );
+
+//-----------------------------------------------------------------------------
+// Useful defines
+#define wait_ctx(thrd, user_info)                               /* Create the necessary information to use the signaller stack                         */ \
+	__condition_node_t waiter = { thrd, count, user_info };   /* Create the node specific to this wait operation                                     */ \
+	__condition_criterion_t criteria[count];                  /* Create the creteria this wait operation needs to wake up                            */ \
+	init( count, monitors, waiter, criteria );                /* Link everything together                                                            */ \
+
+#define wait_ctx_primed(thrd, user_info)                        /* Create the necessary information to use the signaller stack                         */ \
+	__condition_node_t waiter = { thrd, count, user_info };   /* Create the node specific to this wait operation                                     */ \
+	__condition_criterion_t criteria[count];                  /* Create the creteria this wait operation needs to wake up                            */ \
+	init_push( count, monitors, waiter, criteria );           /* Link everything together and push it to the AS-Stack                                */ \
+
+#define monitor_ctx( mons, cnt )                                /* Define that create the necessary struct for internal/external scheduling operations */ \
+	monitor_desc ** monitors = mons;                          /* Save the targeted monitors                                                          */ \
+	__lock_size_t count = cnt;                                /* Save the count to a local variable                                                  */ \
+	unsigned int recursions[ count ];                         /* Save the current recursion levels to restore them later                             */ \
+	__waitfor_mask_t masks [ count ];                         /* Save the current waitfor masks to restore them later                                */ \
+	__spinlock_t *   locks [ count ];                         /* We need to pass-in an array of locks to BlockInternal                               */ \
+
+#define monitor_save    save   ( monitors, count, locks, recursions, masks )
+#define monitor_restore restore( monitors, count, locks, recursions, masks )
+
+
+//-----------------------------------------------------------------------------
+// Enter/Leave routines
+
+
+extern "C" {
+	// Enter single monitor
+	static void __enter_monitor_desc( monitor_desc * this, const __monitor_group_t & group ) {
+		// Lock the monitor spinlock
+		lock( this->lock __cfaabi_dbg_ctx2 );
+		// Interrupts disable inside critical section
+		thread_desc * thrd = kernelTLS.this_thread;
+
+		__cfaabi_dbg_print_safe( "Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);
+
+		if( !this->owner ) {
+			// No one has the monitor, just take it
+			set_owner( this, thrd );
+
+			__cfaabi_dbg_print_safe( "Kernel :  mon is free \n" );
+		}
+		else if( this->owner == thrd) {
+			// We already have the monitor, just note how many times we took it
+			this->recursion += 1;
+
+			__cfaabi_dbg_print_safe( "Kernel :  mon already owned \n" );
+		}
+		else if( is_accepted( this, group) ) {
+			// Some one was waiting for us, enter
+			set_owner( this, thrd );
+
+			// Reset mask
+			reset_mask( this );
+
+			__cfaabi_dbg_print_safe( "Kernel :  mon accepts \n" );
+		}
+		else {
+			__cfaabi_dbg_print_safe( "Kernel :  blocking \n" );
+
+			// Some one else has the monitor, wait in line for it
+			append( this->entry_queue, thrd );
+
+			BlockInternal( &this->lock );
+
+			__cfaabi_dbg_print_safe( "Kernel : %10p Entered  mon %p\n", thrd, this);
+
+			// BlockInternal will unlock spinlock, no need to unlock ourselves
+			return;
+		}
+
+		__cfaabi_dbg_print_safe( "Kernel : %10p Entered  mon %p\n", thrd, this);
+
+		// Release the lock and leave
+		unlock( this->lock );
+		return;
+	}
+
+	static void __enter_monitor_dtor( monitor_desc * this, fptr_t func ) {
+		// Lock the monitor spinlock
+		lock( this->lock __cfaabi_dbg_ctx2 );
+		// Interrupts disable inside critical section
+		thread_desc * thrd = kernelTLS.this_thread;
+
+		__cfaabi_dbg_print_safe( "Kernel : %10p Entering dtor for mon %p (%p)\n", thrd, this, this->owner);
+
+
+		if( !this->owner ) {
+			__cfaabi_dbg_print_safe( "Kernel : Destroying free mon %p\n", this);
+
+			// No one has the monitor, just take it
+			set_owner( this, thrd );
+
+			unlock( this->lock );
+			return;
+		}
+		else if( this->owner == thrd) {
+			// We already have the monitor... but where about to destroy it so the nesting will fail
+			// Abort!
+			abort( "Attempt to destroy monitor %p by thread \"%.256s\" (%p) in nested mutex.", this, thrd->self_cor.name, thrd );
+		}
+
+		__lock_size_t count = 1;
+		monitor_desc ** monitors = &this;
+		__monitor_group_t group = { &this, 1, func };
+		if( is_accepted( this, group) ) {
+			__cfaabi_dbg_print_safe( "Kernel :  mon accepts dtor, block and signal it \n" );
+
+			// Wake the thread that is waiting for this
+			__condition_criterion_t * urgent = pop( this->signal_stack );
+			verify( urgent );
+
+			// Reset mask
+			reset_mask( this );
+
+			// Create the node specific to this wait operation
+			wait_ctx_primed( thrd, 0 )
+
+			// Some one else has the monitor, wait for him to finish and then run
+			BlockInternal( &this->lock, urgent->owner->waiting_thread );
+
+			// Some one was waiting for us, enter
+			set_owner( this, thrd );
+		}
+		else {
+			__cfaabi_dbg_print_safe( "Kernel :  blocking \n" );
+
+			wait_ctx( thrd, 0 )
+			this->dtor_node = &waiter;
+
+			// Some one else has the monitor, wait in line for it
+			append( this->entry_queue, thrd );
+			BlockInternal( &this->lock );
+
+			// BlockInternal will unlock spinlock, no need to unlock ourselves
+			return;
+		}
+
+		__cfaabi_dbg_print_safe( "Kernel : Destroying %p\n", this);
+
+	}
+
+	// Leave single monitor
+	void __leave_monitor_desc( monitor_desc * this ) {
+		// Lock the monitor spinlock
+		lock( this->lock __cfaabi_dbg_ctx2 );
+
+		__cfaabi_dbg_print_safe( "Kernel : %10p Leaving mon %p (%p)\n", kernelTLS.this_thread, this, this->owner);
+
+		verifyf( kernelTLS.this_thread == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", kernelTLS.this_thread, this->owner, this->recursion, this );
+
+		// Leaving a recursion level, decrement the counter
+		this->recursion -= 1;
+
+		// If we haven't left the last level of recursion
+		// it means we don't need to do anything
+		if( this->recursion != 0) {
+			__cfaabi_dbg_print_safe( "Kernel :  recursion still %d\n", this->recursion);
+			unlock( this->lock );
+			return;
+		}
+
+		// Get the next thread, will be null on low contention monitor
+		thread_desc * new_owner = next_thread( this );
+
+		// We can now let other threads in safely
+		unlock( this->lock );
+
+		//We need to wake-up the thread
+		WakeThread( new_owner );
+	}
+
+	// Leave single monitor for the last time
+	void __leave_dtor_monitor_desc( monitor_desc * this ) {
+		__cfaabi_dbg_debug_do(
+			if( TL_GET( this_thread ) != this->owner ) {
+				abort( "Destroyed monitor %p has inconsistent owner, expected %p got %p.\n", this, TL_GET( this_thread ), this->owner);
+			}
+			if( this->recursion != 1 ) {
+				abort( "Destroyed monitor %p has %d outstanding nested calls.\n", this, this->recursion - 1);
+			}
+		)
+	}
+
+	// Leave the thread monitor
+	// last routine called by a thread.
+	// Should never return
+	void __leave_thread_monitor( thread_desc * thrd ) {
+		monitor_desc * this = &thrd->self_mon;
+
+		// Lock the monitor now
+		lock( this->lock __cfaabi_dbg_ctx2 );
+
+		disable_interrupts();
+
+		thrd->self_cor.state = Halted;
+
+		verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", thrd, this->owner, this->recursion, this );
+
+		// Leaving a recursion level, decrement the counter
+		this->recursion -= 1;
+
+		// If we haven't left the last level of recursion
+		// it must mean there is an error
+		if( this->recursion != 0) { abort( "Thread internal monitor has unbalanced recursion" ); }
+
+		// Fetch the next thread, can be null
+		thread_desc * new_owner = next_thread( this );
+
+		// Leave the thread, this will unlock the spinlock
+		// Use leave thread instead of BlockInternal which is
+		// specialized for this case and supports null new_owner
+		LeaveThread( &this->lock, new_owner );
+
+		// Control flow should never reach here!
+	}
+}
+
+// Enter multiple monitor
+// relies on the monitor array being sorted
+static inline void enter( __monitor_group_t monitors ) {
+	for( __lock_size_t i = 0; i < monitors.size; i++) {
+		__enter_monitor_desc( monitors[i], monitors );
+	}
+}
+
+// Leave multiple monitor
+// relies on the monitor array being sorted
+static inline void leave(monitor_desc * monitors [], __lock_size_t count) {
+	for( __lock_size_t i = count - 1; i >= 0; i--) {
+		__leave_monitor_desc( monitors[i] );
+	}
+}
+
+// Ctor for monitor guard
+// Sorts monitors before entering
+void ?{}( monitor_guard_t & this, monitor_desc * m [], __lock_size_t count, fptr_t func ) {
+	thread_desc * thrd = TL_GET( this_thread );
+
+	// Store current array
+	this.m = m;
+	this.count = count;
+
+	// Sort monitors based on address
+	__libcfa_small_sort(this.m, count);
+
+	// Save previous thread context
+	this.prev = thrd->monitors;
+
+	// Update thread context (needed for conditions)
+	(thrd->monitors){m, count, func};
+
+	// __cfaabi_dbg_print_safe( "MGUARD : enter %d\n", count);
+
+	// Enter the monitors in order
+	__monitor_group_t group = {this.m, this.count, func};
+	enter( group );
+
+	// __cfaabi_dbg_print_safe( "MGUARD : entered\n" );
+}
+
+
+// Dtor for monitor guard
+void ^?{}( monitor_guard_t & this ) {
+	// __cfaabi_dbg_print_safe( "MGUARD : leaving %d\n", this.count);
+
+	// Leave the monitors in order
+	leave( this.m, this.count );
+
+	// __cfaabi_dbg_print_safe( "MGUARD : left\n" );
+
+	// Restore thread context
+	TL_GET( this_thread )->monitors = this.prev;
+}
+
+// Ctor for monitor guard
+// Sorts monitors before entering
+void ?{}( monitor_dtor_guard_t & this, monitor_desc * m [], fptr_t func ) {
+	// optimization
+	thread_desc * thrd = TL_GET( this_thread );
+
+	// Store current array
+	this.m = *m;
+
+	// Save previous thread context
+	this.prev = thrd->monitors;
+
+	// Update thread context (needed for conditions)
+	(thrd->monitors){m, 1, func};
+
+	__enter_monitor_dtor( this.m, func );
+}
+
+// Dtor for monitor guard
+void ^?{}( monitor_dtor_guard_t & this ) {
+	// Leave the monitors in order
+	__leave_dtor_monitor_desc( this.m );
+
+	// Restore thread context
+	TL_GET( this_thread )->monitors = this.prev;
+}
+
+//-----------------------------------------------------------------------------
+// Internal scheduling types
+void ?{}(__condition_node_t & this, thread_desc * waiting_thread, __lock_size_t count, uintptr_t user_info ) {
+	this.waiting_thread = waiting_thread;
+	this.count = count;
+	this.next = NULL;
+	this.user_info = user_info;
+}
+
+void ?{}(__condition_criterion_t & this ) with( this ) {
+	ready  = false;
+	target = NULL;
+	owner  = NULL;
+	next   = NULL;
+}
+
+void ?{}(__condition_criterion_t & this, monitor_desc * target, __condition_node_t & owner ) {
+	this.ready  = false;
+	this.target = target;
+	this.owner  = &owner;
+	this.next   = NULL;
+}
+
+//-----------------------------------------------------------------------------
+// Internal scheduling
+void wait( condition & this, uintptr_t user_info = 0 ) {
+	brand_condition( this );
+
+	// Check that everything is as expected
+	assertf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors );
+	verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count );
+	verifyf( this.monitor_count < 32u, "Excessive monitor count (%"PRIiFAST16")", this.monitor_count );
+
+	// Create storage for monitor context
+	monitor_ctx( this.monitors, this.monitor_count );
+
+	// Create the node specific to this wait operation
+	wait_ctx( TL_GET( this_thread ), user_info );
+
+	// Append the current wait operation to the ones already queued on the condition
+	// We don't need locks for that since conditions must always be waited on inside monitor mutual exclusion
+	append( this.blocked, &waiter );
+
+	// Lock all monitors (aggregates the locks as well)
+	lock_all( monitors, locks, count );
+
+	// Find the next thread(s) to run
+	__lock_size_t thread_count = 0;
+	thread_desc * threads[ count ];
+	__builtin_memset( threads, 0, sizeof( threads ) );
+
+	// Save monitor states
+	monitor_save;
+
+	// Remove any duplicate threads
+	for( __lock_size_t i = 0; i < count; i++) {
+		thread_desc * new_owner = next_thread( monitors[i] );
+		insert_unique( threads, thread_count, new_owner );
+	}
+
+	// Everything is ready to go to sleep
+	BlockInternal( locks, count, threads, thread_count );
+
+	// We are back, restore the owners and recursions
+	monitor_restore;
+}
+
+bool signal( condition & this ) {
+	if( is_empty( this ) ) { return false; }
+
+	//Check that everything is as expected
+	verify( this.monitors );
+	verify( this.monitor_count != 0 );
+
+	//Some more checking in debug
+	__cfaabi_dbg_debug_do(
+		thread_desc * this_thrd = TL_GET( this_thread );
+		if ( this.monitor_count != this_thrd->monitors.size ) {
+			abort( "Signal on condition %p made with different number of monitor(s), expected %zi got %zi", &this, this.monitor_count, this_thrd->monitors.size );
+		}
+
+		for(int i = 0; i < this.monitor_count; i++) {
+			if ( this.monitors[i] != this_thrd->monitors[i] ) {
+				abort( "Signal on condition %p made with different monitor, expected %p got %p", &this, this.monitors[i], this_thrd->monitors[i] );
+			}
+		}
+	);
+
+	__lock_size_t count = this.monitor_count;
+
+	// Lock all monitors
+	lock_all( this.monitors, NULL, count );
+
+	//Pop the head of the waiting queue
+	__condition_node_t * node = pop_head( this.blocked );
+
+	//Add the thread to the proper AS stack
+	for(int i = 0; i < count; i++) {
+		__condition_criterion_t * crit = &node->criteria[i];
+		assert( !crit->ready );
+		push( crit->target->signal_stack, crit );
+	}
+
+	//Release
+	unlock_all( this.monitors, count );
+
+	return true;
+}
+
+bool signal_block( condition & this ) {
+	if( !this.blocked.head ) { return false; }
+
+	//Check that everything is as expected
+	verifyf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors );
+	verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count );
+
+	// Create storage for monitor context
+	monitor_ctx( this.monitors, this.monitor_count );
+
+	// Lock all monitors (aggregates the locks them as well)
+	lock_all( monitors, locks, count );
+
+
+	// Create the node specific to this wait operation
+	wait_ctx_primed( kernelTLS.this_thread, 0 )
+
+	//save contexts
+	monitor_save;
+
+	//Find the thread to run
+	thread_desc * signallee = pop_head( this.blocked )->waiting_thread;
+	set_owner( monitors, count, signallee );
+
+	__cfaabi_dbg_print_buffer_decl( "Kernel : signal_block condition %p (s: %p)\n", &this, signallee );
+
+	//Everything is ready to go to sleep
+	BlockInternal( locks, count, &signallee, 1 );
+
+
+	// WE WOKE UP
+
+
+	__cfaabi_dbg_print_buffer_local( "Kernel :   signal_block returned\n" );
+
+	//We are back, restore the masks and recursions
+	monitor_restore;
+
+	return true;
+}
+
+// Access the user_info of the thread waiting at the front of the queue
+uintptr_t front( condition & this ) {
+	verifyf( !is_empty(this),
+		"Attempt to access user data on an empty condition.\n"
+		"Possible cause is not checking if the condition is empty before reading stored data."
+	);
+	return ((typeof(this.blocked.head))this.blocked.head)->user_info;
+}
+
+//-----------------------------------------------------------------------------
+// External scheduling
+// cases to handle :
+// 	- target already there :
+// 		block and wake
+// 	- dtor already there
+// 		put thread on signaller stack
+// 	- non-blocking
+// 		return else
+// 	- timeout
+// 		return timeout
+// 	- block
+// 		setup mask
+// 		block
+void __waitfor_internal( const __waitfor_mask_t & mask, int duration ) {
+	// This statment doesn't have a contiguous list of monitors...
+	// Create one!
+	__lock_size_t max = count_max( mask );
+	monitor_desc * mon_storage[max];
+	__builtin_memset( mon_storage, 0, sizeof( mon_storage ) );
+	__lock_size_t actual_count = aggregate( mon_storage, mask );
+
+	__cfaabi_dbg_print_buffer_decl( "Kernel : waitfor %"PRIdFAST16" (s: %"PRIdFAST16", m: %"PRIdFAST16")\n", actual_count, mask.size, (__lock_size_t)max);
+
+	if(actual_count == 0) return;
+
+	__cfaabi_dbg_print_buffer_local( "Kernel : waitfor internal proceeding\n" );
+
+	// Create storage for monitor context
+	monitor_ctx( mon_storage, actual_count );
+
+	// Lock all monitors (aggregates the locks as well)
+	lock_all( monitors, locks, count );
+
+	{
+		// Check if the entry queue
+		thread_desc * next; int index;
+		[next, index] = search_entry_queue( mask, monitors, count );
+
+		if( next ) {
+			*mask.accepted = index;
+			__acceptable_t& accepted = mask[index];
+			if( accepted.is_dtor ) {
+				__cfaabi_dbg_print_buffer_local( "Kernel : dtor already there\n" );
+				verifyf( accepted.size == 1,  "ERROR: Accepted dtor has more than 1 mutex parameter." );
+
+				monitor_desc * mon2dtor = accepted[0];
+				verifyf( mon2dtor->dtor_node, "ERROR: Accepted monitor has no dtor_node." );
+
+				__condition_criterion_t * dtor_crit = mon2dtor->dtor_node->criteria;
+				push( mon2dtor->signal_stack, dtor_crit );
+
+				unlock_all( locks, count );
+			}
+			else {
+				__cfaabi_dbg_print_buffer_local( "Kernel : thread present, baton-passing\n" );
+
+				// Create the node specific to this wait operation
+				wait_ctx_primed( kernelTLS.this_thread, 0 );
+
+				// Save monitor states
+				monitor_save;
+
+				__cfaabi_dbg_print_buffer_local( "Kernel :  baton of %"PRIdFAST16" monitors : ", count );
+				#ifdef __CFA_DEBUG_PRINT__
+					for( int i = 0; i < count; i++) {
+						__cfaabi_dbg_print_buffer_local( "%p %p ", monitors[i], monitors[i]->signal_stack.top );
+					}
+				#endif
+				__cfaabi_dbg_print_buffer_local( "\n" );
+
+				// Set the owners to be the next thread
+				set_owner( monitors, count, next );
+
+				// Everything is ready to go to sleep
+				BlockInternal( locks, count, &next, 1 );
+
+				// We are back, restore the owners and recursions
+				monitor_restore;
+
+				__cfaabi_dbg_print_buffer_local( "Kernel : thread present, returned\n" );
+			}
+
+			__cfaabi_dbg_print_buffer_local( "Kernel : accepted %d\n", *mask.accepted);
+			return;
+		}
+	}
+
+
+	if( duration == 0 ) {
+		__cfaabi_dbg_print_buffer_local( "Kernel : non-blocking, exiting\n" );
+
+		unlock_all( locks, count );
+
+		__cfaabi_dbg_print_buffer_local( "Kernel : accepted %d\n", *mask.accepted);
+		return;
+	}
+
+
+	verifyf( duration < 0, "Timeout on waitfor statments not supported yet." );
+
+	__cfaabi_dbg_print_buffer_local( "Kernel : blocking waitfor\n" );
+
+	// Create the node specific to this wait operation
+	wait_ctx_primed( kernelTLS.this_thread, 0 );
+
+	monitor_save;
+	set_mask( monitors, count, mask );
+
+	for( __lock_size_t i = 0; i < count; i++) {
+		verify( monitors[i]->owner == kernelTLS.this_thread );
+	}
+
+	//Everything is ready to go to sleep
+	BlockInternal( locks, count );
+
+
+	// WE WOKE UP
+
+
+	//We are back, restore the masks and recursions
+	monitor_restore;
+
+	__cfaabi_dbg_print_buffer_local( "Kernel : exiting\n" );
+
+	__cfaabi_dbg_print_buffer_local( "Kernel : accepted %d\n", *mask.accepted);
+}
+
+//-----------------------------------------------------------------------------
+// Utilities
+
+static inline void set_owner( monitor_desc * this, thread_desc * owner ) {
+	// __cfaabi_dbg_print_safe( "Kernal :   Setting owner of %p to %p ( was %p)\n", this, owner, this->owner );
+
+	//Pass the monitor appropriately
+	this->owner = owner;
+
+	//We are passing the monitor to someone else, which means recursion level is not 0
+	this->recursion = owner ? 1 : 0;
+}
+
+static inline void set_owner( monitor_desc * monitors [], __lock_size_t count, thread_desc * owner ) {
+	monitors[0]->owner     = owner;
+	monitors[0]->recursion = 1;
+	for( __lock_size_t i = 1; i < count; i++ ) {
+		monitors[i]->owner     = owner;
+		monitors[i]->recursion = 0;
+	}
+}
+
+static inline void set_mask( monitor_desc * storage [], __lock_size_t count, const __waitfor_mask_t & mask ) {
+	for( __lock_size_t i = 0; i < count; i++) {
+		storage[i]->mask = mask;
+	}
+}
+
+static inline void reset_mask( monitor_desc * this ) {
+	this->mask.accepted = NULL;
+	this->mask.data = NULL;
+	this->mask.size = 0;
+}
+
+static inline thread_desc * next_thread( monitor_desc * this ) {
+	//Check the signaller stack
+	__cfaabi_dbg_print_safe( "Kernel :  mon %p AS-stack top %p\n", this, this->signal_stack.top);
+	__condition_criterion_t * urgent = pop( this->signal_stack );
+	if( urgent ) {
+		//The signaller stack is not empty,
+		//regardless of if we are ready to baton pass,
+		//we need to set the monitor as in use
+		set_owner( this,  urgent->owner->waiting_thread );
+
+		return check_condition( urgent );
+	}
+
+	// No signaller thread
+	// Get the next thread in the entry_queue
+	thread_desc * new_owner = pop_head( this->entry_queue );
+	set_owner( this, new_owner );
+
+	return new_owner;
+}
+
+static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & group ) {
+	__acceptable_t * it = this->mask.data; // Optim
+	__lock_size_t count = this->mask.size;
+
+	// Check if there are any acceptable functions
+	if( !it ) return false;
+
+	// If this isn't the first monitor to test this, there is no reason to repeat the test.
+	if( this != group[0] ) return group[0]->mask.accepted >= 0;
+
+	// For all acceptable functions check if this is the current function.
+	for( __lock_size_t i = 0; i < count; i++, it++ ) {
+		if( *it == group ) {
+			*this->mask.accepted = i;
+			return true;
+		}
+	}
+
+	// No function matched
+	return false;
+}
+
+static inline void init( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {
+	for( __lock_size_t i = 0; i < count; i++) {
+		(criteria[i]){ monitors[i], waiter };
+	}
+
+	waiter.criteria = criteria;
+}
+
+static inline void init_push( __lock_size_t count, monitor_desc * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] ) {
+	for( __lock_size_t i = 0; i < count; i++) {
+		(criteria[i]){ monitors[i], waiter };
+		__cfaabi_dbg_print_safe( "Kernel :  target %p = %p\n", criteria[i].target, &criteria[i] );
+		push( criteria[i].target->signal_stack, &criteria[i] );
+	}
+
+	waiter.criteria = criteria;
+}
+
+static inline void lock_all( __spinlock_t * locks [], __lock_size_t count ) {
+	for( __lock_size_t i = 0; i < count; i++ ) {
+		lock( *locks[i] __cfaabi_dbg_ctx2 );
+	}
+}
+
+static inline void lock_all( monitor_desc * source [], __spinlock_t * /*out*/ locks [], __lock_size_t count ) {
+	for( __lock_size_t i = 0; i < count; i++ ) {
+		__spinlock_t * l = &source[i]->lock;
+		lock( *l __cfaabi_dbg_ctx2 );
+		if(locks) locks[i] = l;
+	}
+}
+
+static inline void unlock_all( __spinlock_t * locks [], __lock_size_t count ) {
+	for( __lock_size_t i = 0; i < count; i++ ) {
+		unlock( *locks[i] );
+	}
+}
+
+static inline void unlock_all( monitor_desc * locks [], __lock_size_t count ) {
+	for( __lock_size_t i = 0; i < count; i++ ) {
+		unlock( locks[i]->lock );
+	}
+}
+
+static inline void save(
+	monitor_desc * ctx [],
+	__lock_size_t count,
+	__attribute((unused)) __spinlock_t * locks [],
+	unsigned int /*out*/ recursions [],
+	__waitfor_mask_t /*out*/ masks []
+) {
+	for( __lock_size_t i = 0; i < count; i++ ) {
+		recursions[i] = ctx[i]->recursion;
+		masks[i]      = ctx[i]->mask;
+	}
+}
+
+static inline void restore(
+	monitor_desc * ctx [],
+	__lock_size_t count,
+	__spinlock_t * locks [],
+	unsigned int /*out*/ recursions [],
+	__waitfor_mask_t /*out*/ masks []
+) {
+	lock_all( locks, count );
+	for( __lock_size_t i = 0; i < count; i++ ) {
+		ctx[i]->recursion = recursions[i];
+		ctx[i]->mask      = masks[i];
+	}
+	unlock_all( locks, count );
+}
+
+// Function has 2 different behavior
+// 1 - Marks a monitors as being ready to run
+// 2 - Checks if all the monitors are ready to run
+//     if so return the thread to run
+static inline thread_desc * check_condition( __condition_criterion_t * target ) {
+	__condition_node_t * node = target->owner;
+	unsigned short count = node->count;
+	__condition_criterion_t * criteria = node->criteria;
+
+	bool ready2run = true;
+
+	for(	int i = 0; i < count; i++ ) {
+
+		// __cfaabi_dbg_print_safe( "Checking %p for %p\n", &criteria[i], target );
+		if( &criteria[i] == target ) {
+			criteria[i].ready = true;
+			// __cfaabi_dbg_print_safe( "True\n" );
+		}
+
+		ready2run = criteria[i].ready && ready2run;
+	}
+
+	__cfaabi_dbg_print_safe( "Kernel :  Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : NULL );
+	return ready2run ? node->waiting_thread : NULL;
+}
+
+static inline void brand_condition( condition & this ) {
+	thread_desc * thrd = TL_GET( this_thread );
+	if( !this.monitors ) {
+		// __cfaabi_dbg_print_safe( "Branding\n" );
+		assertf( thrd->monitors.data != NULL, "No current monitor to brand condition %p", thrd->monitors.data );
+		this.monitor_count = thrd->monitors.size;
+
+		this.monitors = (monitor_desc **)malloc( this.monitor_count * sizeof( *this.monitors ) );
+		for( int i = 0; i < this.monitor_count; i++ ) {
+			this.monitors[i] = thrd->monitors[i];
+		}
+	}
+}
+
+static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t & mask, monitor_desc * monitors [], __lock_size_t count ) {
+
+	__queue_t(thread_desc) & entry_queue = monitors[0]->entry_queue;
+
+	// For each thread in the entry-queue
+	for(	thread_desc ** thrd_it = &entry_queue.head;
+		*thrd_it;
+		thrd_it = &(*thrd_it)->next
+	) {
+		// For each acceptable check if it matches
+		int i = 0;
+		__acceptable_t * end   = end  (mask);
+		__acceptable_t * begin = begin(mask);
+		for( __acceptable_t * it = begin; it != end; it++, i++ ) {
+			// Check if we have a match
+			if( *it == (*thrd_it)->monitors ) {
+
+				// If we have a match return it
+				// after removeing it from the entry queue
+				return [remove( entry_queue, thrd_it ), i];
+			}
+		}
+	}
+
+	return [0, -1];
+}
+
+forall(dtype T | sized( T ))
+static inline __lock_size_t insert_unique( T * array [], __lock_size_t & size, T * val ) {
+	if( !val ) return size;
+
+	for( __lock_size_t i = 0; i <= size; i++) {
+		if( array[i] == val ) return size;
+	}
+
+	array[size] = val;
+	size = size + 1;
+	return size;
+}
+
+static inline __lock_size_t count_max( const __waitfor_mask_t & mask ) {
+	__lock_size_t max = 0;
+	for( __lock_size_t i = 0; i < mask.size; i++ ) {
+		__acceptable_t & accepted = mask[i];
+		max += accepted.size;
+	}
+	return max;
+}
+
+static inline __lock_size_t aggregate( monitor_desc * storage [], const __waitfor_mask_t & mask ) {
+	__lock_size_t size = 0;
+	for( __lock_size_t i = 0; i < mask.size; i++ ) {
+		__acceptable_t & accepted = mask[i];
+		__libcfa_small_sort( accepted.data, accepted.size );
+		for( __lock_size_t j = 0; j < accepted.size; j++) {
+			insert_unique( storage, size, accepted[j] );
+		}
+	}
+	// TODO insertion sort instead of this
+	__libcfa_small_sort( storage, size );
+	return size;
+}
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/concurrency/mutex.c
===================================================================
--- libcfa/src/concurrency/mutex.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,193 +1,0 @@
-
-//                              -*- Mode: CFA -*-
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// mutex.c --
-//
-// Author           : Thierry Delisle
-// Created On       : Fri May 25 01:37:11 2018
-// Last Modified By : Thierry Delisle
-// Last Modified On : Fri May 25 01:37:51 2018
-// Update Count     : 0
-//
-
-#include "mutex"
-
-#include "kernel_private.h"
-
-//-----------------------------------------------------------------------------
-// Locks
-
-// Exclusive lock - non-recursive
-// ---
-void ?{}(mutex_lock & this) {
-	this.lock{};
-	this.blocked_threads{};
-}
-
-void ^?{}(mutex_lock & this) {
-	// default
-}
-
-void lock(mutex_lock & this) with(this) {
-	lock( lock __cfaabi_dbg_ctx2 );
-	if( is_locked ) {
-		append( blocked_threads, kernelTLS.this_thread );
-		BlockInternal( &lock );
-	}
-	else {
-		is_locked = true;
-		unlock( lock );
-	}
-}
-
-bool try_lock(mutex_lock & this) with(this) {
-	bool ret = false;
-	lock( lock __cfaabi_dbg_ctx2 );
-	if( !is_locked ) {
-		ret = true;
-		is_locked = true;
-	}
-	unlock( lock );
-	return ret;
-}
-
-void unlock(mutex_lock & this) {
-	lock( this.lock __cfaabi_dbg_ctx2 );
-	this.is_locked = (this.blocked_threads != 0);
-	WakeThread(
-		pop_head( this.blocked_threads )
-	);
-	unlock( this.lock );
-}
-
-// Exclusive lock - non-recursive
-// ---
-void ?{}(recursive_mutex_lock & this) {
-	this.lock{};
-	this.blocked_threads{};
-	this.owner = NULL;
-	this.recursion_count = 0;
-}
-
-void ^?{}(recursive_mutex_lock & this) {
-	// default
-}
-
-void lock(recursive_mutex_lock & this) with(this) {
-	lock( lock __cfaabi_dbg_ctx2 );
-	if( owner == NULL ) {
-		owner = kernelTLS.this_thread;
-		recursion_count = 1;
-		unlock( lock );
-	}
-	else if( owner == kernelTLS.this_thread ) {
-		recursion_count++;
-		unlock( lock );
-	}
-	else {
-		append( blocked_threads, kernelTLS.this_thread );
-		BlockInternal( &lock );
-	}
-}
-
-bool try_lock(recursive_mutex_lock & this) with(this) {
-	bool ret = false;
-	lock( lock __cfaabi_dbg_ctx2 );
-	if( owner == NULL ) {
-		owner = kernelTLS.this_thread;
-		recursion_count = 1;
-		ret = true;
-	}
-	else if( owner == kernelTLS.this_thread ) {
-		recursion_count++;
-		ret = true;
-	}
-	unlock( lock );
-	return ret;
-}
-
-void unlock(recursive_mutex_lock & this) with(this) {
-	lock( lock __cfaabi_dbg_ctx2 );
-	recursion_count--;
-	if( recursion_count == 0 ) {
-		thread_desc * thrd = pop_head( blocked_threads );
-		owner = thrd;
-		recursion_count = (thrd ? 1 : 0);
-		WakeThread( thrd );
-	}
-	unlock( lock );
-}
-
-//-----------------------------------------------------------------------------
-// Conditions
-void ?{}(condition_variable & this) {
-	this.blocked_threads{};
-}
-
-void ^?{}(condition_variable & this) {
-	// default
-}
-
-void notify_one(condition_variable & this) with(this) {
-	lock( lock __cfaabi_dbg_ctx2 );
-	WakeThread(
-		pop_head( this.blocked_threads )
-	);
-	unlock( lock );
-}
-
-void notify_all(condition_variable & this) with(this) {
-	lock( lock __cfaabi_dbg_ctx2 );
-	while(this.blocked_threads) {
-		WakeThread(
-			pop_head( this.blocked_threads )
-		);
-	}
-	unlock( lock );
-}
-
-void wait(condition_variable & this) {
-	lock( this.lock __cfaabi_dbg_ctx2 );
-	append( this.blocked_threads, kernelTLS.this_thread );
-	BlockInternal( &this.lock );
-}
-
-forall(dtype L | is_lock(L))
-void wait(condition_variable & this, L & l) {
-	lock( this.lock __cfaabi_dbg_ctx2 );
-	append( this.blocked_threads, kernelTLS.this_thread );
-	void __unlock(void) {
-		unlock(l);
-		unlock(this.lock);
-	}
-	BlockInternal( __unlock );
-	lock(l);
-}
-
-//-----------------------------------------------------------------------------
-// Scopes
-forall(dtype L | is_lock(L))
-void lock_all  ( L * locks[], size_t count) {
-	// Sort locks based on addresses
-	__libcfa_small_sort(locks, count);
-
-	// Lock all
-	for(size_t i = 0; i < count; i++) {
-		L * l = locks[i];
-		lock( *l );
-	}
-}
-
-forall(dtype L | is_lock(L))
-void unlock_all( L * locks[], size_t count) {
-	// Lock all
-	for(size_t i = 0; i < count; i++) {
-		L * l = locks[i];
-		unlock( *l );
-	}
-}
Index: libcfa/src/concurrency/mutex.cfa
===================================================================
--- libcfa/src/concurrency/mutex.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/concurrency/mutex.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,193 @@
+
+//                              -*- Mode: CFA -*-
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// mutex.c --
+//
+// Author           : Thierry Delisle
+// Created On       : Fri May 25 01:37:11 2018
+// Last Modified By : Thierry Delisle
+// Last Modified On : Fri May 25 01:37:51 2018
+// Update Count     : 0
+//
+
+#include "mutex"
+
+#include "kernel_private.h"
+
+//-----------------------------------------------------------------------------
+// Locks
+
+// Exclusive lock - non-recursive
+// ---
+void ?{}(mutex_lock & this) {
+	this.lock{};
+	this.blocked_threads{};
+}
+
+void ^?{}(mutex_lock & this) {
+	// default
+}
+
+void lock(mutex_lock & this) with(this) {
+	lock( lock __cfaabi_dbg_ctx2 );
+	if( is_locked ) {
+		append( blocked_threads, kernelTLS.this_thread );
+		BlockInternal( &lock );
+	}
+	else {
+		is_locked = true;
+		unlock( lock );
+	}
+}
+
+bool try_lock(mutex_lock & this) with(this) {
+	bool ret = false;
+	lock( lock __cfaabi_dbg_ctx2 );
+	if( !is_locked ) {
+		ret = true;
+		is_locked = true;
+	}
+	unlock( lock );
+	return ret;
+}
+
+void unlock(mutex_lock & this) {
+	lock( this.lock __cfaabi_dbg_ctx2 );
+	this.is_locked = (this.blocked_threads != 0);
+	WakeThread(
+		pop_head( this.blocked_threads )
+	);
+	unlock( this.lock );
+}
+
+// Exclusive lock - non-recursive
+// ---
+void ?{}(recursive_mutex_lock & this) {
+	this.lock{};
+	this.blocked_threads{};
+	this.owner = NULL;
+	this.recursion_count = 0;
+}
+
+void ^?{}(recursive_mutex_lock & this) {
+	// default
+}
+
+void lock(recursive_mutex_lock & this) with(this) {
+	lock( lock __cfaabi_dbg_ctx2 );
+	if( owner == NULL ) {
+		owner = kernelTLS.this_thread;
+		recursion_count = 1;
+		unlock( lock );
+	}
+	else if( owner == kernelTLS.this_thread ) {
+		recursion_count++;
+		unlock( lock );
+	}
+	else {
+		append( blocked_threads, kernelTLS.this_thread );
+		BlockInternal( &lock );
+	}
+}
+
+bool try_lock(recursive_mutex_lock & this) with(this) {
+	bool ret = false;
+	lock( lock __cfaabi_dbg_ctx2 );
+	if( owner == NULL ) {
+		owner = kernelTLS.this_thread;
+		recursion_count = 1;
+		ret = true;
+	}
+	else if( owner == kernelTLS.this_thread ) {
+		recursion_count++;
+		ret = true;
+	}
+	unlock( lock );
+	return ret;
+}
+
+void unlock(recursive_mutex_lock & this) with(this) {
+	lock( lock __cfaabi_dbg_ctx2 );
+	recursion_count--;
+	if( recursion_count == 0 ) {
+		thread_desc * thrd = pop_head( blocked_threads );
+		owner = thrd;
+		recursion_count = (thrd ? 1 : 0);
+		WakeThread( thrd );
+	}
+	unlock( lock );
+}
+
+//-----------------------------------------------------------------------------
+// Conditions
+void ?{}(condition_variable & this) {
+	this.blocked_threads{};
+}
+
+void ^?{}(condition_variable & this) {
+	// default
+}
+
+void notify_one(condition_variable & this) with(this) {
+	lock( lock __cfaabi_dbg_ctx2 );
+	WakeThread(
+		pop_head( this.blocked_threads )
+	);
+	unlock( lock );
+}
+
+void notify_all(condition_variable & this) with(this) {
+	lock( lock __cfaabi_dbg_ctx2 );
+	while(this.blocked_threads) {
+		WakeThread(
+			pop_head( this.blocked_threads )
+		);
+	}
+	unlock( lock );
+}
+
+void wait(condition_variable & this) {
+	lock( this.lock __cfaabi_dbg_ctx2 );
+	append( this.blocked_threads, kernelTLS.this_thread );
+	BlockInternal( &this.lock );
+}
+
+forall(dtype L | is_lock(L))
+void wait(condition_variable & this, L & l) {
+	lock( this.lock __cfaabi_dbg_ctx2 );
+	append( this.blocked_threads, kernelTLS.this_thread );
+	void __unlock(void) {
+		unlock(l);
+		unlock(this.lock);
+	}
+	BlockInternal( __unlock );
+	lock(l);
+}
+
+//-----------------------------------------------------------------------------
+// Scopes
+forall(dtype L | is_lock(L))
+void lock_all  ( L * locks[], size_t count) {
+	// Sort locks based on addresses
+	__libcfa_small_sort(locks, count);
+
+	// Lock all
+	for(size_t i = 0; i < count; i++) {
+		L * l = locks[i];
+		lock( *l );
+	}
+}
+
+forall(dtype L | is_lock(L))
+void unlock_all( L * locks[], size_t count) {
+	// Lock all
+	for(size_t i = 0; i < count; i++) {
+		L * l = locks[i];
+		unlock( *l );
+	}
+}
Index: libcfa/src/concurrency/preemption.c
===================================================================
--- libcfa/src/concurrency/preemption.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,491 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// signal.c --
-//
-// Author           : Thierry Delisle
-// Created On       : Mon Jun 5 14:20:42 2017
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Jun  5 17:35:49 2018
-// Update Count     : 37
-//
-
-#include "preemption.h"
-#include <assert.h>
-
-extern "C" {
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-}
-
-#include "bits/signal.h"
-
-#if !defined(__CFA_DEFAULT_PREEMPTION__)
-#define __CFA_DEFAULT_PREEMPTION__ 10`ms
-#endif
-
-Duration default_preemption() __attribute__((weak)) {
-	return __CFA_DEFAULT_PREEMPTION__;
-}
-
-// FwdDeclarations : timeout handlers
-static void preempt( processor   * this );
-static void timeout( thread_desc * this );
-
-// FwdDeclarations : Signal handlers
-static void sigHandler_ctxSwitch( __CFA_SIGPARMS__ );
-static void sigHandler_segv     ( __CFA_SIGPARMS__ );
-static void sigHandler_ill      ( __CFA_SIGPARMS__ );
-static void sigHandler_fpe      ( __CFA_SIGPARMS__ );
-static void sigHandler_abort    ( __CFA_SIGPARMS__ );
-
-// FwdDeclarations : alarm thread main
-static void * alarm_loop( __attribute__((unused)) void * args );
-
-// Machine specific register name
-#if   defined( __i386 )
-#define CFA_REG_IP gregs[REG_EIP]
-#elif defined( __x86_64 )
-#define CFA_REG_IP gregs[REG_RIP]
-#elif defined( __ARM_ARCH )
-#define CFA_REG_IP arm_pc
-#else
-#error unknown hardware architecture
-#endif
-
-KERNEL_STORAGE(event_kernel_t, event_kernel);         // private storage for event kernel
-event_kernel_t * event_kernel;                        // kernel public handle to even kernel
-static pthread_t alarm_thread;                        // pthread handle to alarm thread
-
-static void ?{}(event_kernel_t & this) with( this ) {
-	alarms{};
-	lock{};
-}
-
-enum {
-	PREEMPT_NORMAL    = 0,
-	PREEMPT_TERMINATE = 1,
-};
-
-//=============================================================================================
-// Kernel Preemption logic
-//=============================================================================================
-
-// Get next expired node
-static inline alarm_node_t * get_expired( alarm_list_t * alarms, Time currtime ) {
-	if( !alarms->head ) return NULL;                          // If no alarms return null
-	if( alarms->head->alarm >= currtime ) return NULL;        // If alarms head not expired return null
-	return pop(alarms);                                       // Otherwise just pop head
-}
-
-// Tick one frame of the Discrete Event Simulation for alarms
-static void tick_preemption() {
-	alarm_node_t * node = NULL;                     // Used in the while loop but cannot be declared in the while condition
-	alarm_list_t * alarms = &event_kernel->alarms;  // Local copy for ease of reading
-	Time currtime = __kernel_get_time();			// Check current time once so we everything "happens at once"
-
-	//Loop throught every thing expired
-	while( node = get_expired( alarms, currtime ) ) {
-		// __cfaabi_dbg_print_buffer_decl( " KERNEL: preemption tick.\n" );
-
-		// Check if this is a kernel
-		if( node->kernel_alarm ) {
-			preempt( node->proc );
-		}
-		else {
-			timeout( node->thrd );
-		}
-
-		// Check if this is a periodic alarm
-		Duration period = node->period;
-		if( period > 0 ) {
-			// __cfaabi_dbg_print_buffer_local( " KERNEL: alarm period is %lu.\n", period.tv );
-			node->alarm = currtime + period;    // Alarm is periodic, add currtime to it (used cached current time)
-			insert( alarms, node );             // Reinsert the node for the next time it triggers
-		}
-		else {
-			node->set = false;                  // Node is one-shot, just mark it as not pending
-		}
-	}
-
-	// If there are still alarms pending, reset the timer
-	if( alarms->head ) {
-		__cfaabi_dbg_print_buffer_decl( " KERNEL: @%ju(%ju) resetting alarm to %ju.\n", currtime.tv, __kernel_get_time().tv, (alarms->head->alarm - currtime).tv);
-		Duration delta = alarms->head->alarm - currtime;
-		Duration caped = max(delta, 50`us);
-		// itimerval tim  = { caped };
-		// __cfaabi_dbg_print_buffer_local( "    Values are %lu, %lu, %lu %lu.\n", delta.tv, caped.tv, tim.it_value.tv_sec, tim.it_value.tv_usec);
-
-		__kernel_set_timer( caped );
-	}
-}
-
-// Update the preemption of a processor and notify interested parties
-void update_preemption( processor * this, Duration duration ) {
-	alarm_node_t * alarm = this->preemption_alarm;
-
-	// Alarms need to be enabled
-	if ( duration > 0 && ! alarm->set ) {
-		alarm->alarm = __kernel_get_time() + duration;
-		alarm->period = duration;
-		register_self( alarm );
-	}
-	// Zero duration but alarm is set
-	else if ( duration == 0 && alarm->set ) {
-		unregister_self( alarm );
-		alarm->alarm = 0;
-		alarm->period = 0;
-	}
-	// If alarm is different from previous, change it
-	else if ( duration > 0 && alarm->period != duration ) {
-		unregister_self( alarm );
-		alarm->alarm = __kernel_get_time() + duration;
-		alarm->period = duration;
-		register_self( alarm );
-	}
-}
-
-//=============================================================================================
-// Kernel Signal Tools
-//=============================================================================================
-
-__cfaabi_dbg_debug_do( static thread_local void * last_interrupt = 0; )
-
-extern "C" {
-	// Disable interrupts by incrementing the counter
-	void disable_interrupts() {
-		with( kernelTLS.preemption_state ) {
-			#if GCC_VERSION > 50000
-			static_assert(__atomic_always_lock_free(sizeof(enabled), &enabled), "Must be lock-free");
-			#endif
-
-			// Set enabled flag to false
-			// should be atomic to avoid preemption in the middle of the operation.
-			// use memory order RELAXED since there is no inter-thread on this variable requirements
-			__atomic_store_n(&enabled, false, __ATOMIC_RELAXED);
-
-			// Signal the compiler that a fence is needed but only for signal handlers
-			__atomic_signal_fence(__ATOMIC_ACQUIRE);
-
-			__attribute__((unused)) unsigned short new_val = disable_count + 1;
-			disable_count = new_val;
-			verify( new_val < 65_000u );              // If this triggers someone is disabling interrupts without enabling them
-		}
-	}
-
-	// Enable interrupts by decrementing the counter
-	// If counter reaches 0, execute any pending CtxSwitch
-	void enable_interrupts( __cfaabi_dbg_ctx_param ) {
-		processor   * proc = kernelTLS.this_processor; // Cache the processor now since interrupts can start happening after the atomic store
-		thread_desc * thrd = kernelTLS.this_thread;	  // Cache the thread now since interrupts can start happening after the atomic store
-
-		with( kernelTLS.preemption_state ){
-			unsigned short prev = disable_count;
-			disable_count -= 1;
-			verify( prev != 0u );                     // If this triggers someone is enabled already enabled interruptsverify( prev != 0u );
-
-			// Check if we need to prempt the thread because an interrupt was missed
-			if( prev == 1 ) {
-				#if GCC_VERSION > 50000
-				static_assert(__atomic_always_lock_free(sizeof(enabled), &enabled), "Must be lock-free");
-				#endif
-
-				// Set enabled flag to true
-				// should be atomic to avoid preemption in the middle of the operation.
-				// use memory order RELAXED since there is no inter-thread on this variable requirements
-				__atomic_store_n(&enabled, true, __ATOMIC_RELAXED);
-
-				// Signal the compiler that a fence is needed but only for signal handlers
-				__atomic_signal_fence(__ATOMIC_RELEASE);
-				if( proc->pending_preemption ) {
-					proc->pending_preemption = false;
-					BlockInternal( thrd );
-				}
-			}
-		}
-
-		// For debugging purposes : keep track of the last person to enable the interrupts
-		__cfaabi_dbg_debug_do( proc->last_enable = caller; )
-	}
-
-	// Disable interrupts by incrementint the counter
-	// Don't execute any pending CtxSwitch even if counter reaches 0
-	void enable_interrupts_noPoll() {
-		unsigned short prev = kernelTLS.preemption_state.disable_count;
-		kernelTLS.preemption_state.disable_count -= 1;
-		verifyf( prev != 0u, "Incremented from %u\n", prev );                     // If this triggers someone is enabled already enabled interrupts
-		if( prev == 1 ) {
-			#if GCC_VERSION > 50000
-			static_assert(__atomic_always_lock_free(sizeof(kernelTLS.preemption_state.enabled), &kernelTLS.preemption_state.enabled), "Must be lock-free");
-			#endif
-			// Set enabled flag to true
-			// should be atomic to avoid preemption in the middle of the operation.
-			// use memory order RELAXED since there is no inter-thread on this variable requirements
-			__atomic_store_n(&kernelTLS.preemption_state.enabled, true, __ATOMIC_RELAXED);
-
-			// Signal the compiler that a fence is needed but only for signal handlers
-			__atomic_signal_fence(__ATOMIC_RELEASE);
-		}
-	}
-}
-
-// sigprocmask wrapper : unblock a single signal
-static inline void signal_unblock( int sig ) {
-	sigset_t mask;
-	sigemptyset( &mask );
-	sigaddset( &mask, sig );
-
-	if ( pthread_sigmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) {
-	    abort( "internal error, pthread_sigmask" );
-	}
-}
-
-// sigprocmask wrapper : block a single signal
-static inline void signal_block( int sig ) {
-	sigset_t mask;
-	sigemptyset( &mask );
-	sigaddset( &mask, sig );
-
-	if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
-	    abort( "internal error, pthread_sigmask" );
-	}
-}
-
-// kill wrapper : signal a processor
-static void preempt( processor * this ) {
-	sigval_t value = { PREEMPT_NORMAL };
-	pthread_sigqueue( this->kernel_thread, SIGUSR1, value );
-}
-
-// reserved for future use
-static void timeout( thread_desc * this ) {
-	//TODO : implement waking threads
-}
-
-// KERNEL ONLY
-// Check if a CtxSwitch signal handler shoud defer
-// If true  : preemption is safe
-// If false : preemption is unsafe and marked as pending
-static inline bool preemption_ready() {
-	// Check if preemption is safe
-	bool ready = kernelTLS.preemption_state.enabled && ! kernelTLS.preemption_state.in_progress;
-
-	// Adjust the pending flag accordingly
-	kernelTLS.this_processor->pending_preemption = !ready;
-	return ready;
-}
-
-//=============================================================================================
-// Kernel Signal Startup/Shutdown logic
-//=============================================================================================
-
-// Startup routine to activate preemption
-// Called from kernel_startup
-void kernel_start_preemption() {
-	__cfaabi_dbg_print_safe( "Kernel : Starting preemption\n" );
-
-	// Start with preemption disabled until ready
-	kernelTLS.preemption_state.enabled = false;
-	kernelTLS.preemption_state.disable_count = 1;
-
-	// Initialize the event kernel
-	event_kernel = (event_kernel_t *)&storage_event_kernel;
-	(*event_kernel){};
-
-	// Setup proper signal handlers
-	__cfaabi_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART );         // CtxSwitch handler
-
-	signal_block( SIGALRM );
-
-	pthread_create( &alarm_thread, NULL, alarm_loop, NULL );
-}
-
-// Shutdown routine to deactivate preemption
-// Called from kernel_shutdown
-void kernel_stop_preemption() {
-	__cfaabi_dbg_print_safe( "Kernel : Preemption stopping\n" );
-
-	// Block all signals since we are already shutting down
-	sigset_t mask;
-	sigfillset( &mask );
-	sigprocmask( SIG_BLOCK, &mask, NULL );
-
-	// Notify the alarm thread of the shutdown
-	sigval val = { 1 };
-	pthread_sigqueue( alarm_thread, SIGALRM, val );
-
-	// Wait for the preemption thread to finish
-	pthread_join( alarm_thread, NULL );
-
-	// Preemption is now fully stopped
-
-	__cfaabi_dbg_print_safe( "Kernel : Preemption stopped\n" );
-}
-
-// Raii ctor/dtor for the preemption_scope
-// Used by thread to control when they want to receive preemption signals
-void ?{}( preemption_scope & this, processor * proc ) {
-	(this.alarm){ proc, (Time){ 0 }, 0`s };
-	this.proc = proc;
-	this.proc->preemption_alarm = &this.alarm;
-
-	update_preemption( this.proc, this.proc->cltr->preemption_rate );
-}
-
-void ^?{}( preemption_scope & this ) {
-	disable_interrupts();
-
-	update_preemption( this.proc, 0`s );
-}
-
-//=============================================================================================
-// Kernel Signal Handlers
-//=============================================================================================
-
-// Context switch signal handler
-// Receives SIGUSR1 signal and causes the current thread to yield
-static void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) {
-	__cfaabi_dbg_debug_do( last_interrupt = (void *)(cxt->uc_mcontext.CFA_REG_IP); )
-
-	// SKULLDUGGERY: if a thread creates a processor and the immediately deletes it,
-	// the interrupt that is supposed to force the kernel thread to preempt might arrive
-	// before the kernel thread has even started running. When that happens an iterrupt
-	// we a null 'this_processor' will be caught, just ignore it.
-	if(! kernelTLS.this_processor ) return;
-
-	choose(sfp->si_value.sival_int) {
-		case PREEMPT_NORMAL   : ;// Normal case, nothing to do here
-		case PREEMPT_TERMINATE: verify( __atomic_load_n( &kernelTLS.this_processor->do_terminate, __ATOMIC_SEQ_CST ) );
-		default:
-			abort( "internal error, signal value is %d", sfp->si_value.sival_int );
-	}
-
-	// Check if it is safe to preempt here
-	if( !preemption_ready() ) { return; }
-
-	__cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p @ %p).\n", kernelTLS.this_processor, kernelTLS.this_thread, (void *)(cxt->uc_mcontext.CFA_REG_IP) );
-
-	// Sync flag : prevent recursive calls to the signal handler
-	kernelTLS.preemption_state.in_progress = true;
-
-	// Clear sighandler mask before context switching.
-	#if GCC_VERSION > 50000
-	static_assert( sizeof( sigset_t ) == sizeof( cxt->uc_sigmask ), "Expected cxt->uc_sigmask to be of sigset_t" );
-	#endif
-	if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), NULL ) == -1 ) {
-		abort( "internal error, sigprocmask" );
-	}
-
-	// TODO: this should go in finish action
-	// Clear the in progress flag
-	kernelTLS.preemption_state.in_progress = false;
-
-	// Preemption can occur here
-
-	BlockInternal( kernelTLS.this_thread ); // Do the actual CtxSwitch
-}
-
-// Main of the alarm thread
-// Waits on SIGALRM and send SIGUSR1 to whom ever needs it
-static void * alarm_loop( __attribute__((unused)) void * args ) {
-	// Block sigalrms to control when they arrive
-	sigset_t mask;
-	sigfillset(&mask);
-	if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
-	    abort( "internal error, pthread_sigmask" );
-	}
-
-	sigemptyset( &mask );
-	sigaddset( &mask, SIGALRM );
-
-	// Main loop
-	while( true ) {
-		// Wait for a sigalrm
-		siginfo_t info;
-		int sig = sigwaitinfo( &mask, &info );
-
-		if( sig < 0 ) {
-			//Error!
-			int err = errno;
-			switch( err ) {
-				case EAGAIN :
-				case EINTR :
-					{__cfaabi_dbg_print_buffer_decl( " KERNEL: Spurious wakeup %d.\n", err );}
-					continue;
-       			case EINVAL :
-				 	abort( "Timeout was invalid." );
-				default:
-				 	abort( "Unhandled error %d", err);
-			}
-		}
-
-		// If another signal arrived something went wrong
-		assertf(sig == SIGALRM, "Kernel Internal Error, sigwait: Unexpected signal %d (%d : %d)\n", sig, info.si_code, info.si_value.sival_int);
-
-		// __cfaabi_dbg_print_safe( "Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int );
-		// Switch on the code (a.k.a. the sender) to
-		switch( info.si_code )
-		{
-		// Timers can apparently be marked as sent for the kernel
-		// In either case, tick preemption
-		case SI_TIMER:
-		case SI_KERNEL:
-			// __cfaabi_dbg_print_safe( "Kernel : Preemption thread tick\n" );
-			lock( event_kernel->lock __cfaabi_dbg_ctx2 );
-			tick_preemption();
-			unlock( event_kernel->lock );
-			break;
-		// Signal was not sent by the kernel but by an other thread
-		case SI_QUEUE:
-			// For now, other thread only signal the alarm thread to shut it down
-			// If this needs to change use info.si_value and handle the case here
-			goto EXIT;
-		}
-	}
-
-EXIT:
-	__cfaabi_dbg_print_safe( "Kernel : Preemption thread stopping\n" );
-	return NULL;
-}
-
-//=============================================================================================
-// Kernel Signal Debug
-//=============================================================================================
-
-void __cfaabi_check_preemption() {
-	bool ready = kernelTLS.preemption_state.enabled;
-	if(!ready) { abort("Preemption should be ready"); }
-
-	sigset_t oldset;
-	int ret;
-	ret = pthread_sigmask(0, NULL, &oldset);
-	if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); }
-
-	ret = sigismember(&oldset, SIGUSR1);
-	if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
-	if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); }
-
-	ret = sigismember(&oldset, SIGALRM);
-	if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
-	if(ret == 0) { abort("ERROR SIGALRM is enabled"); }
-
-	ret = sigismember(&oldset, SIGTERM);
-	if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
-	if(ret == 1) { abort("ERROR SIGTERM is disabled"); }
-}
-
-#ifdef __CFA_WITH_VERIFY__
-bool __cfaabi_dbg_in_kernel() {
-	return !kernelTLS.preemption_state.enabled;
-}
-#endif
-
-// Local Variables: //
-// mode: c //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/concurrency/preemption.cfa
===================================================================
--- libcfa/src/concurrency/preemption.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/concurrency/preemption.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,491 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// signal.c --
+//
+// Author           : Thierry Delisle
+// Created On       : Mon Jun 5 14:20:42 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Tue Jun  5 17:35:49 2018
+// Update Count     : 37
+//
+
+#include "preemption.h"
+#include <assert.h>
+
+extern "C" {
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+}
+
+#include "bits/signal.h"
+
+#if !defined(__CFA_DEFAULT_PREEMPTION__)
+#define __CFA_DEFAULT_PREEMPTION__ 10`ms
+#endif
+
+Duration default_preemption() __attribute__((weak)) {
+	return __CFA_DEFAULT_PREEMPTION__;
+}
+
+// FwdDeclarations : timeout handlers
+static void preempt( processor   * this );
+static void timeout( thread_desc * this );
+
+// FwdDeclarations : Signal handlers
+static void sigHandler_ctxSwitch( __CFA_SIGPARMS__ );
+static void sigHandler_segv     ( __CFA_SIGPARMS__ );
+static void sigHandler_ill      ( __CFA_SIGPARMS__ );
+static void sigHandler_fpe      ( __CFA_SIGPARMS__ );
+static void sigHandler_abort    ( __CFA_SIGPARMS__ );
+
+// FwdDeclarations : alarm thread main
+static void * alarm_loop( __attribute__((unused)) void * args );
+
+// Machine specific register name
+#if   defined( __i386 )
+#define CFA_REG_IP gregs[REG_EIP]
+#elif defined( __x86_64 )
+#define CFA_REG_IP gregs[REG_RIP]
+#elif defined( __ARM_ARCH )
+#define CFA_REG_IP arm_pc
+#else
+#error unknown hardware architecture
+#endif
+
+KERNEL_STORAGE(event_kernel_t, event_kernel);         // private storage for event kernel
+event_kernel_t * event_kernel;                        // kernel public handle to even kernel
+static pthread_t alarm_thread;                        // pthread handle to alarm thread
+
+static void ?{}(event_kernel_t & this) with( this ) {
+	alarms{};
+	lock{};
+}
+
+enum {
+	PREEMPT_NORMAL    = 0,
+	PREEMPT_TERMINATE = 1,
+};
+
+//=============================================================================================
+// Kernel Preemption logic
+//=============================================================================================
+
+// Get next expired node
+static inline alarm_node_t * get_expired( alarm_list_t * alarms, Time currtime ) {
+	if( !alarms->head ) return NULL;                          // If no alarms return null
+	if( alarms->head->alarm >= currtime ) return NULL;        // If alarms head not expired return null
+	return pop(alarms);                                       // Otherwise just pop head
+}
+
+// Tick one frame of the Discrete Event Simulation for alarms
+static void tick_preemption() {
+	alarm_node_t * node = NULL;                     // Used in the while loop but cannot be declared in the while condition
+	alarm_list_t * alarms = &event_kernel->alarms;  // Local copy for ease of reading
+	Time currtime = __kernel_get_time();			// Check current time once so we everything "happens at once"
+
+	//Loop throught every thing expired
+	while( node = get_expired( alarms, currtime ) ) {
+		// __cfaabi_dbg_print_buffer_decl( " KERNEL: preemption tick.\n" );
+
+		// Check if this is a kernel
+		if( node->kernel_alarm ) {
+			preempt( node->proc );
+		}
+		else {
+			timeout( node->thrd );
+		}
+
+		// Check if this is a periodic alarm
+		Duration period = node->period;
+		if( period > 0 ) {
+			// __cfaabi_dbg_print_buffer_local( " KERNEL: alarm period is %lu.\n", period.tv );
+			node->alarm = currtime + period;    // Alarm is periodic, add currtime to it (used cached current time)
+			insert( alarms, node );             // Reinsert the node for the next time it triggers
+		}
+		else {
+			node->set = false;                  // Node is one-shot, just mark it as not pending
+		}
+	}
+
+	// If there are still alarms pending, reset the timer
+	if( alarms->head ) {
+		__cfaabi_dbg_print_buffer_decl( " KERNEL: @%ju(%ju) resetting alarm to %ju.\n", currtime.tv, __kernel_get_time().tv, (alarms->head->alarm - currtime).tv);
+		Duration delta = alarms->head->alarm - currtime;
+		Duration caped = max(delta, 50`us);
+		// itimerval tim  = { caped };
+		// __cfaabi_dbg_print_buffer_local( "    Values are %lu, %lu, %lu %lu.\n", delta.tv, caped.tv, tim.it_value.tv_sec, tim.it_value.tv_usec);
+
+		__kernel_set_timer( caped );
+	}
+}
+
+// Update the preemption of a processor and notify interested parties
+void update_preemption( processor * this, Duration duration ) {
+	alarm_node_t * alarm = this->preemption_alarm;
+
+	// Alarms need to be enabled
+	if ( duration > 0 && ! alarm->set ) {
+		alarm->alarm = __kernel_get_time() + duration;
+		alarm->period = duration;
+		register_self( alarm );
+	}
+	// Zero duration but alarm is set
+	else if ( duration == 0 && alarm->set ) {
+		unregister_self( alarm );
+		alarm->alarm = 0;
+		alarm->period = 0;
+	}
+	// If alarm is different from previous, change it
+	else if ( duration > 0 && alarm->period != duration ) {
+		unregister_self( alarm );
+		alarm->alarm = __kernel_get_time() + duration;
+		alarm->period = duration;
+		register_self( alarm );
+	}
+}
+
+//=============================================================================================
+// Kernel Signal Tools
+//=============================================================================================
+
+__cfaabi_dbg_debug_do( static thread_local void * last_interrupt = 0; )
+
+extern "C" {
+	// Disable interrupts by incrementing the counter
+	void disable_interrupts() {
+		with( kernelTLS.preemption_state ) {
+			#if GCC_VERSION > 50000
+			static_assert(__atomic_always_lock_free(sizeof(enabled), &enabled), "Must be lock-free");
+			#endif
+
+			// Set enabled flag to false
+			// should be atomic to avoid preemption in the middle of the operation.
+			// use memory order RELAXED since there is no inter-thread on this variable requirements
+			__atomic_store_n(&enabled, false, __ATOMIC_RELAXED);
+
+			// Signal the compiler that a fence is needed but only for signal handlers
+			__atomic_signal_fence(__ATOMIC_ACQUIRE);
+
+			__attribute__((unused)) unsigned short new_val = disable_count + 1;
+			disable_count = new_val;
+			verify( new_val < 65_000u );              // If this triggers someone is disabling interrupts without enabling them
+		}
+	}
+
+	// Enable interrupts by decrementing the counter
+	// If counter reaches 0, execute any pending CtxSwitch
+	void enable_interrupts( __cfaabi_dbg_ctx_param ) {
+		processor   * proc = kernelTLS.this_processor; // Cache the processor now since interrupts can start happening after the atomic store
+		thread_desc * thrd = kernelTLS.this_thread;	  // Cache the thread now since interrupts can start happening after the atomic store
+
+		with( kernelTLS.preemption_state ){
+			unsigned short prev = disable_count;
+			disable_count -= 1;
+			verify( prev != 0u );                     // If this triggers someone is enabled already enabled interruptsverify( prev != 0u );
+
+			// Check if we need to prempt the thread because an interrupt was missed
+			if( prev == 1 ) {
+				#if GCC_VERSION > 50000
+				static_assert(__atomic_always_lock_free(sizeof(enabled), &enabled), "Must be lock-free");
+				#endif
+
+				// Set enabled flag to true
+				// should be atomic to avoid preemption in the middle of the operation.
+				// use memory order RELAXED since there is no inter-thread on this variable requirements
+				__atomic_store_n(&enabled, true, __ATOMIC_RELAXED);
+
+				// Signal the compiler that a fence is needed but only for signal handlers
+				__atomic_signal_fence(__ATOMIC_RELEASE);
+				if( proc->pending_preemption ) {
+					proc->pending_preemption = false;
+					BlockInternal( thrd );
+				}
+			}
+		}
+
+		// For debugging purposes : keep track of the last person to enable the interrupts
+		__cfaabi_dbg_debug_do( proc->last_enable = caller; )
+	}
+
+	// Disable interrupts by incrementint the counter
+	// Don't execute any pending CtxSwitch even if counter reaches 0
+	void enable_interrupts_noPoll() {
+		unsigned short prev = kernelTLS.preemption_state.disable_count;
+		kernelTLS.preemption_state.disable_count -= 1;
+		verifyf( prev != 0u, "Incremented from %u\n", prev );                     // If this triggers someone is enabled already enabled interrupts
+		if( prev == 1 ) {
+			#if GCC_VERSION > 50000
+			static_assert(__atomic_always_lock_free(sizeof(kernelTLS.preemption_state.enabled), &kernelTLS.preemption_state.enabled), "Must be lock-free");
+			#endif
+			// Set enabled flag to true
+			// should be atomic to avoid preemption in the middle of the operation.
+			// use memory order RELAXED since there is no inter-thread on this variable requirements
+			__atomic_store_n(&kernelTLS.preemption_state.enabled, true, __ATOMIC_RELAXED);
+
+			// Signal the compiler that a fence is needed but only for signal handlers
+			__atomic_signal_fence(__ATOMIC_RELEASE);
+		}
+	}
+}
+
+// sigprocmask wrapper : unblock a single signal
+static inline void signal_unblock( int sig ) {
+	sigset_t mask;
+	sigemptyset( &mask );
+	sigaddset( &mask, sig );
+
+	if ( pthread_sigmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) {
+	    abort( "internal error, pthread_sigmask" );
+	}
+}
+
+// sigprocmask wrapper : block a single signal
+static inline void signal_block( int sig ) {
+	sigset_t mask;
+	sigemptyset( &mask );
+	sigaddset( &mask, sig );
+
+	if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
+	    abort( "internal error, pthread_sigmask" );
+	}
+}
+
+// kill wrapper : signal a processor
+static void preempt( processor * this ) {
+	sigval_t value = { PREEMPT_NORMAL };
+	pthread_sigqueue( this->kernel_thread, SIGUSR1, value );
+}
+
+// reserved for future use
+static void timeout( thread_desc * this ) {
+	//TODO : implement waking threads
+}
+
+// KERNEL ONLY
+// Check if a CtxSwitch signal handler shoud defer
+// If true  : preemption is safe
+// If false : preemption is unsafe and marked as pending
+static inline bool preemption_ready() {
+	// Check if preemption is safe
+	bool ready = kernelTLS.preemption_state.enabled && ! kernelTLS.preemption_state.in_progress;
+
+	// Adjust the pending flag accordingly
+	kernelTLS.this_processor->pending_preemption = !ready;
+	return ready;
+}
+
+//=============================================================================================
+// Kernel Signal Startup/Shutdown logic
+//=============================================================================================
+
+// Startup routine to activate preemption
+// Called from kernel_startup
+void kernel_start_preemption() {
+	__cfaabi_dbg_print_safe( "Kernel : Starting preemption\n" );
+
+	// Start with preemption disabled until ready
+	kernelTLS.preemption_state.enabled = false;
+	kernelTLS.preemption_state.disable_count = 1;
+
+	// Initialize the event kernel
+	event_kernel = (event_kernel_t *)&storage_event_kernel;
+	(*event_kernel){};
+
+	// Setup proper signal handlers
+	__cfaabi_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART );         // CtxSwitch handler
+
+	signal_block( SIGALRM );
+
+	pthread_create( &alarm_thread, NULL, alarm_loop, NULL );
+}
+
+// Shutdown routine to deactivate preemption
+// Called from kernel_shutdown
+void kernel_stop_preemption() {
+	__cfaabi_dbg_print_safe( "Kernel : Preemption stopping\n" );
+
+	// Block all signals since we are already shutting down
+	sigset_t mask;
+	sigfillset( &mask );
+	sigprocmask( SIG_BLOCK, &mask, NULL );
+
+	// Notify the alarm thread of the shutdown
+	sigval val = { 1 };
+	pthread_sigqueue( alarm_thread, SIGALRM, val );
+
+	// Wait for the preemption thread to finish
+	pthread_join( alarm_thread, NULL );
+
+	// Preemption is now fully stopped
+
+	__cfaabi_dbg_print_safe( "Kernel : Preemption stopped\n" );
+}
+
+// Raii ctor/dtor for the preemption_scope
+// Used by thread to control when they want to receive preemption signals
+void ?{}( preemption_scope & this, processor * proc ) {
+	(this.alarm){ proc, (Time){ 0 }, 0`s };
+	this.proc = proc;
+	this.proc->preemption_alarm = &this.alarm;
+
+	update_preemption( this.proc, this.proc->cltr->preemption_rate );
+}
+
+void ^?{}( preemption_scope & this ) {
+	disable_interrupts();
+
+	update_preemption( this.proc, 0`s );
+}
+
+//=============================================================================================
+// Kernel Signal Handlers
+//=============================================================================================
+
+// Context switch signal handler
+// Receives SIGUSR1 signal and causes the current thread to yield
+static void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) {
+	__cfaabi_dbg_debug_do( last_interrupt = (void *)(cxt->uc_mcontext.CFA_REG_IP); )
+
+	// SKULLDUGGERY: if a thread creates a processor and the immediately deletes it,
+	// the interrupt that is supposed to force the kernel thread to preempt might arrive
+	// before the kernel thread has even started running. When that happens an iterrupt
+	// we a null 'this_processor' will be caught, just ignore it.
+	if(! kernelTLS.this_processor ) return;
+
+	choose(sfp->si_value.sival_int) {
+		case PREEMPT_NORMAL   : ;// Normal case, nothing to do here
+		case PREEMPT_TERMINATE: verify( __atomic_load_n( &kernelTLS.this_processor->do_terminate, __ATOMIC_SEQ_CST ) );
+		default:
+			abort( "internal error, signal value is %d", sfp->si_value.sival_int );
+	}
+
+	// Check if it is safe to preempt here
+	if( !preemption_ready() ) { return; }
+
+	__cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p @ %p).\n", kernelTLS.this_processor, kernelTLS.this_thread, (void *)(cxt->uc_mcontext.CFA_REG_IP) );
+
+	// Sync flag : prevent recursive calls to the signal handler
+	kernelTLS.preemption_state.in_progress = true;
+
+	// Clear sighandler mask before context switching.
+	#if GCC_VERSION > 50000
+	static_assert( sizeof( sigset_t ) == sizeof( cxt->uc_sigmask ), "Expected cxt->uc_sigmask to be of sigset_t" );
+	#endif
+	if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), NULL ) == -1 ) {
+		abort( "internal error, sigprocmask" );
+	}
+
+	// TODO: this should go in finish action
+	// Clear the in progress flag
+	kernelTLS.preemption_state.in_progress = false;
+
+	// Preemption can occur here
+
+	BlockInternal( kernelTLS.this_thread ); // Do the actual CtxSwitch
+}
+
+// Main of the alarm thread
+// Waits on SIGALRM and send SIGUSR1 to whom ever needs it
+static void * alarm_loop( __attribute__((unused)) void * args ) {
+	// Block sigalrms to control when they arrive
+	sigset_t mask;
+	sigfillset(&mask);
+	if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
+	    abort( "internal error, pthread_sigmask" );
+	}
+
+	sigemptyset( &mask );
+	sigaddset( &mask, SIGALRM );
+
+	// Main loop
+	while( true ) {
+		// Wait for a sigalrm
+		siginfo_t info;
+		int sig = sigwaitinfo( &mask, &info );
+
+		if( sig < 0 ) {
+			//Error!
+			int err = errno;
+			switch( err ) {
+				case EAGAIN :
+				case EINTR :
+					{__cfaabi_dbg_print_buffer_decl( " KERNEL: Spurious wakeup %d.\n", err );}
+					continue;
+       			case EINVAL :
+				 	abort( "Timeout was invalid." );
+				default:
+				 	abort( "Unhandled error %d", err);
+			}
+		}
+
+		// If another signal arrived something went wrong
+		assertf(sig == SIGALRM, "Kernel Internal Error, sigwait: Unexpected signal %d (%d : %d)\n", sig, info.si_code, info.si_value.sival_int);
+
+		// __cfaabi_dbg_print_safe( "Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int );
+		// Switch on the code (a.k.a. the sender) to
+		switch( info.si_code )
+		{
+		// Timers can apparently be marked as sent for the kernel
+		// In either case, tick preemption
+		case SI_TIMER:
+		case SI_KERNEL:
+			// __cfaabi_dbg_print_safe( "Kernel : Preemption thread tick\n" );
+			lock( event_kernel->lock __cfaabi_dbg_ctx2 );
+			tick_preemption();
+			unlock( event_kernel->lock );
+			break;
+		// Signal was not sent by the kernel but by an other thread
+		case SI_QUEUE:
+			// For now, other thread only signal the alarm thread to shut it down
+			// If this needs to change use info.si_value and handle the case here
+			goto EXIT;
+		}
+	}
+
+EXIT:
+	__cfaabi_dbg_print_safe( "Kernel : Preemption thread stopping\n" );
+	return NULL;
+}
+
+//=============================================================================================
+// Kernel Signal Debug
+//=============================================================================================
+
+void __cfaabi_check_preemption() {
+	bool ready = kernelTLS.preemption_state.enabled;
+	if(!ready) { abort("Preemption should be ready"); }
+
+	sigset_t oldset;
+	int ret;
+	ret = pthread_sigmask(0, NULL, &oldset);
+	if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); }
+
+	ret = sigismember(&oldset, SIGUSR1);
+	if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
+	if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); }
+
+	ret = sigismember(&oldset, SIGALRM);
+	if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
+	if(ret == 0) { abort("ERROR SIGALRM is enabled"); }
+
+	ret = sigismember(&oldset, SIGTERM);
+	if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
+	if(ret == 1) { abort("ERROR SIGTERM is disabled"); }
+}
+
+#ifdef __CFA_WITH_VERIFY__
+bool __cfaabi_dbg_in_kernel() {
+	return !kernelTLS.preemption_state.enabled;
+}
+#endif
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/concurrency/thread.c
===================================================================
--- libcfa/src/concurrency/thread.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,135 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// thread.c --
-//
-// Author           : Thierry Delisle
-// Created On       : Tue Jan 17 12:27:26 2017
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Mar 30 17:19:52 2018
-// Update Count     : 8
-//
-
-#include "thread"
-
-#include "kernel_private.h"
-
-#define __CFA_INVOKE_PRIVATE__
-#include "invoke.h"
-
-extern "C" {
-	#include <fenv.h>
-	#include <stddef.h>
-}
-
-//extern volatile thread_local processor * this_processor;
-
-//-----------------------------------------------------------------------------
-// Thread ctors and dtors
-void ?{}(thread_desc & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
-	self_cor{ name, storage, storageSize };
-	verify(&self_cor);
-	curr_cor = &self_cor;
-	self_mon.owner = &this;
-	self_mon.recursion = 1;
-	self_mon_p = &self_mon;
-	curr_cluster = &cl;
-	next = NULL;
-
-	node.next = NULL;
-	node.prev = NULL;
-	doregister(curr_cluster, this);
-
-	monitors{ &self_mon_p, 1, (fptr_t)0 };
-}
-
-void ^?{}(thread_desc& this) with( this ) {
-	unregister(curr_cluster, this);
-	^self_cor{};
-}
-
-forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T&); } )
-void ?{}( scoped(T)& this ) with( this ) {
-	handle{};
-	__thrd_start(handle);
-}
-
-forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T&, P); } )
-void ?{}( scoped(T)& this, P params ) with( this ) {
-	handle{ params };
-	__thrd_start(handle);
-}
-
-forall( dtype T | sized(T) | is_thread(T) )
-void ^?{}( scoped(T)& this ) with( this ) {
-	^handle{};
-}
-
-//-----------------------------------------------------------------------------
-// Starting and stopping threads
-forall( dtype T | is_thread(T) )
-void __thrd_start( T& this ) {
-	coroutine_desc* thrd_c = get_coroutine(this);
-	thread_desc   * thrd_h = get_thread   (this);
-	thrd_c->last = TL_GET( this_coroutine );
-
-	// __cfaabi_dbg_print_safe("Thread start : %p (t %p, c %p)\n", this, thrd_c, thrd_h);
-
-	disable_interrupts();
-	create_stack(&thrd_c->stack, thrd_c->stack.size);
-	kernelTLS.this_coroutine = thrd_c;
-	CtxStart(&this, CtxInvokeThread);
-	assert( thrd_c->last->stack.context );
-	CtxSwitch( thrd_c->last->stack.context, thrd_c->stack.context );
-
-	ScheduleThread(thrd_h);
-	enable_interrupts( __cfaabi_dbg_ctx );
-}
-
-extern "C" {
-	// KERNEL ONLY
-	void __finish_creation(void) {
-		coroutine_desc* thrd_c = kernelTLS.this_coroutine;
-		ThreadCtxSwitch( thrd_c, thrd_c->last );
-	}
-}
-
-void yield( void ) {
-	// Safety note : This could cause some false positives due to preemption
-      verify( TL_GET( preemption_state.enabled ) );
-	BlockInternal( TL_GET( this_thread ) );
-	// Safety note : This could cause some false positives due to preemption
-      verify( TL_GET( preemption_state.enabled ) );
-}
-
-void yield( unsigned times ) {
-	for( unsigned i = 0; i < times; i++ ) {
-		yield();
-	}
-}
-
-// KERNEL ONLY
-void ThreadCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
-	// set state of current coroutine to inactive
-	src->state = src->state == Halted ? Halted : Inactive;
-	dst->state = Active;
-
-	// set new coroutine that the processor is executing
-	// and context switch to it
-	kernelTLS.this_coroutine = dst;
-	assert( src->stack.context );
-	CtxSwitch( src->stack.context, dst->stack.context );
-	kernelTLS.this_coroutine = src;
-
-	// set state of new coroutine to active
-	dst->state = dst->state == Halted ? Halted : Inactive;
-	src->state = Active;
-}
-
-// Local Variables: //
-// mode: c //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/concurrency/thread.cfa
===================================================================
--- libcfa/src/concurrency/thread.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/concurrency/thread.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,135 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// thread.c --
+//
+// Author           : Thierry Delisle
+// Created On       : Tue Jan 17 12:27:26 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Fri Mar 30 17:19:52 2018
+// Update Count     : 8
+//
+
+#include "thread"
+
+#include "kernel_private.h"
+
+#define __CFA_INVOKE_PRIVATE__
+#include "invoke.h"
+
+extern "C" {
+	#include <fenv.h>
+	#include <stddef.h>
+}
+
+//extern volatile thread_local processor * this_processor;
+
+//-----------------------------------------------------------------------------
+// Thread ctors and dtors
+void ?{}(thread_desc & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
+	self_cor{ name, storage, storageSize };
+	verify(&self_cor);
+	curr_cor = &self_cor;
+	self_mon.owner = &this;
+	self_mon.recursion = 1;
+	self_mon_p = &self_mon;
+	curr_cluster = &cl;
+	next = NULL;
+
+	node.next = NULL;
+	node.prev = NULL;
+	doregister(curr_cluster, this);
+
+	monitors{ &self_mon_p, 1, (fptr_t)0 };
+}
+
+void ^?{}(thread_desc& this) with( this ) {
+	unregister(curr_cluster, this);
+	^self_cor{};
+}
+
+forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T&); } )
+void ?{}( scoped(T)& this ) with( this ) {
+	handle{};
+	__thrd_start(handle);
+}
+
+forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T&, P); } )
+void ?{}( scoped(T)& this, P params ) with( this ) {
+	handle{ params };
+	__thrd_start(handle);
+}
+
+forall( dtype T | sized(T) | is_thread(T) )
+void ^?{}( scoped(T)& this ) with( this ) {
+	^handle{};
+}
+
+//-----------------------------------------------------------------------------
+// Starting and stopping threads
+forall( dtype T | is_thread(T) )
+void __thrd_start( T& this ) {
+	coroutine_desc* thrd_c = get_coroutine(this);
+	thread_desc   * thrd_h = get_thread   (this);
+	thrd_c->last = TL_GET( this_coroutine );
+
+	// __cfaabi_dbg_print_safe("Thread start : %p (t %p, c %p)\n", this, thrd_c, thrd_h);
+
+	disable_interrupts();
+	create_stack(&thrd_c->stack, thrd_c->stack.size);
+	kernelTLS.this_coroutine = thrd_c;
+	CtxStart(&this, CtxInvokeThread);
+	assert( thrd_c->last->stack.context );
+	CtxSwitch( thrd_c->last->stack.context, thrd_c->stack.context );
+
+	ScheduleThread(thrd_h);
+	enable_interrupts( __cfaabi_dbg_ctx );
+}
+
+extern "C" {
+	// KERNEL ONLY
+	void __finish_creation(void) {
+		coroutine_desc* thrd_c = kernelTLS.this_coroutine;
+		ThreadCtxSwitch( thrd_c, thrd_c->last );
+	}
+}
+
+void yield( void ) {
+	// Safety note : This could cause some false positives due to preemption
+      verify( TL_GET( preemption_state.enabled ) );
+	BlockInternal( TL_GET( this_thread ) );
+	// Safety note : This could cause some false positives due to preemption
+      verify( TL_GET( preemption_state.enabled ) );
+}
+
+void yield( unsigned times ) {
+	for( unsigned i = 0; i < times; i++ ) {
+		yield();
+	}
+}
+
+// KERNEL ONLY
+void ThreadCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
+	// set state of current coroutine to inactive
+	src->state = src->state == Halted ? Halted : Inactive;
+	dst->state = Active;
+
+	// set new coroutine that the processor is executing
+	// and context switch to it
+	kernelTLS.this_coroutine = dst;
+	assert( src->stack.context );
+	CtxSwitch( src->stack.context, dst->stack.context );
+	kernelTLS.this_coroutine = src;
+
+	// set state of new coroutine to active
+	dst->state = dst->state == Halted ? Halted : Inactive;
+	src->state = Active;
+}
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/containers/maybe.c
===================================================================
--- libcfa/src/containers/maybe.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,102 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// maybe.c -- May contain a value.
-//
-// Author           : Andrew Beach
-// Created On       : Wed May 24 15:40:00 2017
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jul 20 15:23:50 2017
-// Update Count     : 2
-//
-
-#include <containers/maybe>
-#include <assert.h>
-
-
-forall(otype T)
-void ?{}(maybe(T) & this) {
-	this.has_value = false;
-}
-
-forall(otype T)
-void ?{}(maybe(T) & this, T value) {
-	this.has_value = true;
-	(this.value){value};
-}
-
-forall(otype T)
-void ?{}(maybe(T) & this, maybe(T) other) {
-	this.has_value = other.has_value;
-	if (other.has_value) {
-		(this.value){other.value};
-	}
-}
-
-forall(otype T)
-maybe(T) ?=?(maybe(T) & this, maybe(T) that) {
-	if (this.has_value & that.has_value) {
-		this.value = that.value;
-	} else if (this.has_value) {
-		^(this.value){};
-		this.has_value = false;
-	} else if (that.has_value) {
-		this.has_value = true;
-		(this.value){that.value};
-	}
-	return this;
-}
-
-forall(otype T)
-void ^?{}(maybe(T) & this) {
-	if (this.has_value) {
-		^(this.value){};
-	}
-}
-
-forall(otype T)
-bool ?!=?(maybe(T) this, zero_t) {
-	return this.has_value;
-}
-
-forall(otype T)
-maybe(T) maybe_value(T value) {
-	return (maybe(T)){value};
-}
-
-forall(otype T)
-maybe(T) maybe_none() {
-	return (maybe(T)){};
-}
-
-forall(otype T)
-bool has_value(maybe(T) * this) {
-	return this->has_value;
-}
-
-forall(otype T)
-T get(maybe(T) * this) {
-	assertf(this->has_value, "attempt to get from maybe without value");
-	return this->value;
-}
-
-forall(otype T)
-void set(maybe(T) * this, T value) {
-	if (this->has_value) {
-		this->value = value;
-	} else {
-		this->has_value = true;
-		(this->value){value};
-	}
-}
-
-forall(otype T)
-void set_none(maybe(T) * this) {
-	if (this->has_value) {
-		this->has_value = false;
-		^(this->value){};
-	}
-}
Index: libcfa/src/containers/maybe.cfa
===================================================================
--- libcfa/src/containers/maybe.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/containers/maybe.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,102 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// maybe.c -- May contain a value.
+//
+// Author           : Andrew Beach
+// Created On       : Wed May 24 15:40:00 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Thu Jul 20 15:23:50 2017
+// Update Count     : 2
+//
+
+#include <containers/maybe>
+#include <assert.h>
+
+
+forall(otype T)
+void ?{}(maybe(T) & this) {
+	this.has_value = false;
+}
+
+forall(otype T)
+void ?{}(maybe(T) & this, T value) {
+	this.has_value = true;
+	(this.value){value};
+}
+
+forall(otype T)
+void ?{}(maybe(T) & this, maybe(T) other) {
+	this.has_value = other.has_value;
+	if (other.has_value) {
+		(this.value){other.value};
+	}
+}
+
+forall(otype T)
+maybe(T) ?=?(maybe(T) & this, maybe(T) that) {
+	if (this.has_value & that.has_value) {
+		this.value = that.value;
+	} else if (this.has_value) {
+		^(this.value){};
+		this.has_value = false;
+	} else if (that.has_value) {
+		this.has_value = true;
+		(this.value){that.value};
+	}
+	return this;
+}
+
+forall(otype T)
+void ^?{}(maybe(T) & this) {
+	if (this.has_value) {
+		^(this.value){};
+	}
+}
+
+forall(otype T)
+bool ?!=?(maybe(T) this, zero_t) {
+	return this.has_value;
+}
+
+forall(otype T)
+maybe(T) maybe_value(T value) {
+	return (maybe(T)){value};
+}
+
+forall(otype T)
+maybe(T) maybe_none() {
+	return (maybe(T)){};
+}
+
+forall(otype T)
+bool has_value(maybe(T) * this) {
+	return this->has_value;
+}
+
+forall(otype T)
+T get(maybe(T) * this) {
+	assertf(this->has_value, "attempt to get from maybe without value");
+	return this->value;
+}
+
+forall(otype T)
+void set(maybe(T) * this, T value) {
+	if (this->has_value) {
+		this->value = value;
+	} else {
+		this->has_value = true;
+		(this->value){value};
+	}
+}
+
+forall(otype T)
+void set_none(maybe(T) * this) {
+	if (this->has_value) {
+		this->has_value = false;
+		^(this->value){};
+	}
+}
Index: libcfa/src/containers/pair.c
===================================================================
--- libcfa/src/containers/pair.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,47 +1,0 @@
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// pair.c --
-//
-// Author           : Aaron Moss
-// Created On       : Wed Apr 12 15:32:00 2017
-// Last Modified By : Aaron Moss
-// Last Modified On : Wed Apr 12 15:32:00 2017
-// Update Count     : 1
-//
-
-#include <containers/pair>
-
-forall(otype R, otype S 
-	| { int ?==?(R, R); int ?<?(R, R); int ?<?(S, S); })
-int ?<?(pair(R, S) p, pair(R, S) q) {
-	return p.first < q.first || ( p.first == q.first && p.second < q.second );
-}
-
-forall(otype R, otype S 
-	| { int ?==?(R, R); int ?<?(R, R); int ?<=?(S, S); })
-int ?<=?(pair(R, S) p, pair(R, S) q) {
-	return p.first < q.first || ( p.first == q.first && p.second <= q.second );
-}
-
-forall(otype R, otype S | { int ?==?(R, R); int ?==?(S, S); })
-int ?==?(pair(R, S) p, pair(R, S) q) {
-	return p.first == q.first && p.second == q.second;
-}
-
-forall(otype R, otype S | { int ?!=?(R, R); int ?!=?(S, S); })
-int ?!=?(pair(R, S) p, pair(R, S) q) {
-	return p.first != q.first || p.second != q.second;
-}
-
-forall(otype R, otype S 
-	| { int ?==?(R, R); int ?>?(R, R); int ?>?(S, S); })
-int ?>?(pair(R, S) p, pair(R, S) q) {
-	return p.first > q.first || ( p.first == q.first && p.second > q.second );
-}
-
-forall(otype R, otype S 
-	| { int ?==?(R, R); int ?>?(R, R); int ?>=?(S, S); })
-int ?>=?(pair(R, S) p, pair(R, S) q) {
-	return p.first > q.first || ( p.first == q.first && p.second >= q.second );
-}
Index: libcfa/src/containers/pair.cfa
===================================================================
--- libcfa/src/containers/pair.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/containers/pair.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,47 @@
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// pair.c --
+//
+// Author           : Aaron Moss
+// Created On       : Wed Apr 12 15:32:00 2017
+// Last Modified By : Aaron Moss
+// Last Modified On : Wed Apr 12 15:32:00 2017
+// Update Count     : 1
+//
+
+#include <containers/pair>
+
+forall(otype R, otype S 
+	| { int ?==?(R, R); int ?<?(R, R); int ?<?(S, S); })
+int ?<?(pair(R, S) p, pair(R, S) q) {
+	return p.first < q.first || ( p.first == q.first && p.second < q.second );
+}
+
+forall(otype R, otype S 
+	| { int ?==?(R, R); int ?<?(R, R); int ?<=?(S, S); })
+int ?<=?(pair(R, S) p, pair(R, S) q) {
+	return p.first < q.first || ( p.first == q.first && p.second <= q.second );
+}
+
+forall(otype R, otype S | { int ?==?(R, R); int ?==?(S, S); })
+int ?==?(pair(R, S) p, pair(R, S) q) {
+	return p.first == q.first && p.second == q.second;
+}
+
+forall(otype R, otype S | { int ?!=?(R, R); int ?!=?(S, S); })
+int ?!=?(pair(R, S) p, pair(R, S) q) {
+	return p.first != q.first || p.second != q.second;
+}
+
+forall(otype R, otype S 
+	| { int ?==?(R, R); int ?>?(R, R); int ?>?(S, S); })
+int ?>?(pair(R, S) p, pair(R, S) q) {
+	return p.first > q.first || ( p.first == q.first && p.second > q.second );
+}
+
+forall(otype R, otype S 
+	| { int ?==?(R, R); int ?>?(R, R); int ?>=?(S, S); })
+int ?>=?(pair(R, S) p, pair(R, S) q) {
+	return p.first > q.first || ( p.first == q.first && p.second >= q.second );
+}
Index: libcfa/src/containers/result.c
===================================================================
--- libcfa/src/containers/result.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,126 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// result.c -- Contains the expected value or an error value.
-//
-// Author           : Andrew Beach
-// Created On       : Wed May 24 15:40:00 2017
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jul 20 15:23:58 2017
-// Update Count     : 2
-//
-
-#include <containers/result>
-#include <assert.h>
-
-
-forall(otype T, otype E)
-void ?{}(result(T, E) & this) {
-	this.has_value = false;
-	(this.error){};
-}
-
-forall(otype T, otype E)
-void ?{}(result(T, E) & this, one_t, T value) {
-	this.has_value = true;
-	(this.value){value};
-}
-
-forall(otype T, otype E)
-void ?{}(result(T, E) & this, zero_t, E error) {
-	this.has_value = false;
-	(this.error){error};
-}
-
-forall(otype T, otype E)
-void ?{}(result(T, E) & this, result(T, E) other) {
-	this.has_value = other.has_value;
-	if (other.has_value) {
-		(this.value){other.value};
-	} else {
-		(this.error){other.error};
-	}
-}
-
-forall(otype T, otype E)
-result(T, E) ?=?(result(T, E) & this, result(T, E) that) {
-	if (this.has_value & that.has_value) {
-		this.value = that.value;
-	} else if (this.has_value) {
-		^(this.value){};
-		this.has_value = false;
-		(this.error){that.error};
-	} else if (that.has_value) {
-		^(this.error){};
-		this.has_value = true;
-		(this.value){that.value};
-	} else {
-		this.error = that.error;
-	}
-}
-
-forall(otype T, otype E)
-void ^?{}(result(T, E) & this) {
-	if (this.has_value) {
-		^(this.value){};
-	} else {
-		^(this.error){};
-	}
-}
-
-forall(otype T, otype E)
-bool ?!=?(result(T, E) this, zero_t) {
-	return this.has_value;
-}
-
-forall(otype T, otype E)
-result(T, E) result_value(T value) {
-	return (result(T, E)){1, value};
-}
-
-forall(otype T, otype E)
-result(T, E) result_error(E error) {
-	return (result(T, E)){0, error};
-}
-
-forall(otype T, otype E)
-bool has_value(result(T, E) * this) {
-	return this->has_value;
-}
-
-forall(otype T, otype E)
-T get(result(T, E) * this) {
-	assertf(this->has_value, "attempt to get from result without value");
-	return this->value;
-}
-
-forall(otype T, otype E)
-E get_error(result(T, E) * this) {
-	assertf(!this->has_value, "attempt to get from result without error");
-	return this->error;
-}
-
-forall(otype T, otype E)
-void set(result(T, E) * this, T value) {
-	if (this->has_value) {
-		this->value = value;
-	} else {
-		^(this->error){};
-		this->has_value = true;
-		(this->value){value};
-	}
-}
-
-forall(otype T, otype E)
-void set_error(result(T, E) * this, E error) {
-	if (this->has_value) {
-		^(this->value){};
-		this->has_value = false;
-		(this->error){error};
-	} else {
-		this->error = error;
-	}
-}
Index: libcfa/src/containers/result.cfa
===================================================================
--- libcfa/src/containers/result.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/containers/result.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,126 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// result.c -- Contains the expected value or an error value.
+//
+// Author           : Andrew Beach
+// Created On       : Wed May 24 15:40:00 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Thu Jul 20 15:23:58 2017
+// Update Count     : 2
+//
+
+#include <containers/result>
+#include <assert.h>
+
+
+forall(otype T, otype E)
+void ?{}(result(T, E) & this) {
+	this.has_value = false;
+	(this.error){};
+}
+
+forall(otype T, otype E)
+void ?{}(result(T, E) & this, one_t, T value) {
+	this.has_value = true;
+	(this.value){value};
+}
+
+forall(otype T, otype E)
+void ?{}(result(T, E) & this, zero_t, E error) {
+	this.has_value = false;
+	(this.error){error};
+}
+
+forall(otype T, otype E)
+void ?{}(result(T, E) & this, result(T, E) other) {
+	this.has_value = other.has_value;
+	if (other.has_value) {
+		(this.value){other.value};
+	} else {
+		(this.error){other.error};
+	}
+}
+
+forall(otype T, otype E)
+result(T, E) ?=?(result(T, E) & this, result(T, E) that) {
+	if (this.has_value & that.has_value) {
+		this.value = that.value;
+	} else if (this.has_value) {
+		^(this.value){};
+		this.has_value = false;
+		(this.error){that.error};
+	} else if (that.has_value) {
+		^(this.error){};
+		this.has_value = true;
+		(this.value){that.value};
+	} else {
+		this.error = that.error;
+	}
+}
+
+forall(otype T, otype E)
+void ^?{}(result(T, E) & this) {
+	if (this.has_value) {
+		^(this.value){};
+	} else {
+		^(this.error){};
+	}
+}
+
+forall(otype T, otype E)
+bool ?!=?(result(T, E) this, zero_t) {
+	return this.has_value;
+}
+
+forall(otype T, otype E)
+result(T, E) result_value(T value) {
+	return (result(T, E)){1, value};
+}
+
+forall(otype T, otype E)
+result(T, E) result_error(E error) {
+	return (result(T, E)){0, error};
+}
+
+forall(otype T, otype E)
+bool has_value(result(T, E) * this) {
+	return this->has_value;
+}
+
+forall(otype T, otype E)
+T get(result(T, E) * this) {
+	assertf(this->has_value, "attempt to get from result without value");
+	return this->value;
+}
+
+forall(otype T, otype E)
+E get_error(result(T, E) * this) {
+	assertf(!this->has_value, "attempt to get from result without error");
+	return this->error;
+}
+
+forall(otype T, otype E)
+void set(result(T, E) * this, T value) {
+	if (this->has_value) {
+		this->value = value;
+	} else {
+		^(this->error){};
+		this->has_value = true;
+		(this->value){value};
+	}
+}
+
+forall(otype T, otype E)
+void set_error(result(T, E) * this, E error) {
+	if (this->has_value) {
+		^(this->value){};
+		this->has_value = false;
+		(this->error){error};
+	} else {
+		this->error = error;
+	}
+}
Index: libcfa/src/containers/vector.c
===================================================================
--- libcfa/src/containers/vector.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,137 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// vector.c --
-//
-// Author           : Thierry Delisle
-// Created On       : Tue Jul  5 18:07:52 2016
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Jul  5 18:08:31 2016
-// Update Count     : 2
-//
-
-#include <containers/vector>
-
-#include <stdlib>
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void copy_internal(vector(T, allocator_t)* this, vector(T, allocator_t)* other);
-
-//------------------------------------------------------------------------------
-//Initialization
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void ?{}(vector(T, allocator_t)& this)
-{
-	(this.storage){};
-	this.size = 0;
-}
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void ?{}(vector(T, allocator_t)& this, vector(T, allocator_t) rhs)
-{
-	(this.storage){ rhs.storage };
-	copy_internal(&this, &rhs);
-}
-
-// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-// vector(T, allocator_t) ?=?(vector(T, allocator_t)* this, vector(T, allocator_t) rhs)
-// {
-// 	(&this->storage){};
-// 	copy_internal(this, &rhs);
-// 	return *this;
-// }
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void ^?{}(vector(T, allocator_t)& this)
-{
-	clear(&this);
-	^(this.storage){};
-}
-
-//------------------------------------------------------------------------------
-//Modifiers
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void push_back(vector(T, allocator_t)* this, T value)
-{
-	realloc_storage(&this->storage, this->size+1);
-	data(&this->storage)[this->size] = value;
-	this->size++;
-}
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void pop_back(vector(T, allocator_t)* this)
-{
-	this->size--;
-	^(data(&this->storage)[this->size]){};
-}
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void clear(vector(T, allocator_t)* this)
-{
-	for(size_t i = 0; i < this->size; i++)
-	{
-		^(data(&this->storage)[this->size]){};
-	}
-	this->size = 0;
-}
-
-//------------------------------------------------------------------------------
-//Internal Helpers
-
-forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
-void copy_internal(vector(T, allocator_t)* this, vector(T, allocator_t)* other)
-{
-	this->size = other->size;
-	for(size_t i = 0; i < this->size; i++) {
-		(data(&this->storage)[this->size]){ data(&other->storage)[other->size] };
-	}
-}
-
-//------------------------------------------------------------------------------
-//Allocator
-forall(otype T)
-void ?{}(heap_allocator(T)& this)
-{
-	this.storage = 0;
-	this.capacity = 0;
-}
-
-forall(otype T)
-void ?{}(heap_allocator(T)& this, heap_allocator(T) rhs)
-{
-	this.capacity = rhs.capacity;
-	this.storage = (T*)realloc((void*)this.storage, this.capacity * sizeof(T));
-}
-
-forall(otype T)
-heap_allocator(T) ?=?(heap_allocator(T)& this, heap_allocator(T) rhs)
-{
-	this.capacity = rhs.capacity;
-	this.storage = (T*)realloc((void*)this.storage, this.capacity * sizeof(T));
-	return this;
-}
-
-forall(otype T)
-void ^?{}(heap_allocator(T)& this)
-{
-	free(this.storage);
-}
-
-forall(otype T)
-inline void realloc_storage(heap_allocator(T)* this, size_t size)
-{
-	enum { GROWTH_RATE = 2 };
-	if(size > this->capacity)
-	{
-		this->capacity = GROWTH_RATE * size;
-		this->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T));
-	}
-}
-
-// Local Variables: //
-// mode: c //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/containers/vector.cfa
===================================================================
--- libcfa/src/containers/vector.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/containers/vector.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,137 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// vector.c --
+//
+// Author           : Thierry Delisle
+// Created On       : Tue Jul  5 18:07:52 2016
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Tue Jul  5 18:08:31 2016
+// Update Count     : 2
+//
+
+#include <containers/vector>
+
+#include <stdlib>
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void copy_internal(vector(T, allocator_t)* this, vector(T, allocator_t)* other);
+
+//------------------------------------------------------------------------------
+//Initialization
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void ?{}(vector(T, allocator_t)& this)
+{
+	(this.storage){};
+	this.size = 0;
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void ?{}(vector(T, allocator_t)& this, vector(T, allocator_t) rhs)
+{
+	(this.storage){ rhs.storage };
+	copy_internal(&this, &rhs);
+}
+
+// forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+// vector(T, allocator_t) ?=?(vector(T, allocator_t)* this, vector(T, allocator_t) rhs)
+// {
+// 	(&this->storage){};
+// 	copy_internal(this, &rhs);
+// 	return *this;
+// }
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void ^?{}(vector(T, allocator_t)& this)
+{
+	clear(&this);
+	^(this.storage){};
+}
+
+//------------------------------------------------------------------------------
+//Modifiers
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void push_back(vector(T, allocator_t)* this, T value)
+{
+	realloc_storage(&this->storage, this->size+1);
+	data(&this->storage)[this->size] = value;
+	this->size++;
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void pop_back(vector(T, allocator_t)* this)
+{
+	this->size--;
+	^(data(&this->storage)[this->size]){};
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void clear(vector(T, allocator_t)* this)
+{
+	for(size_t i = 0; i < this->size; i++)
+	{
+		^(data(&this->storage)[this->size]){};
+	}
+	this->size = 0;
+}
+
+//------------------------------------------------------------------------------
+//Internal Helpers
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void copy_internal(vector(T, allocator_t)* this, vector(T, allocator_t)* other)
+{
+	this->size = other->size;
+	for(size_t i = 0; i < this->size; i++) {
+		(data(&this->storage)[this->size]){ data(&other->storage)[other->size] };
+	}
+}
+
+//------------------------------------------------------------------------------
+//Allocator
+forall(otype T)
+void ?{}(heap_allocator(T)& this)
+{
+	this.storage = 0;
+	this.capacity = 0;
+}
+
+forall(otype T)
+void ?{}(heap_allocator(T)& this, heap_allocator(T) rhs)
+{
+	this.capacity = rhs.capacity;
+	this.storage = (T*)realloc((void*)this.storage, this.capacity * sizeof(T));
+}
+
+forall(otype T)
+heap_allocator(T) ?=?(heap_allocator(T)& this, heap_allocator(T) rhs)
+{
+	this.capacity = rhs.capacity;
+	this.storage = (T*)realloc((void*)this.storage, this.capacity * sizeof(T));
+	return this;
+}
+
+forall(otype T)
+void ^?{}(heap_allocator(T)& this)
+{
+	free(this.storage);
+}
+
+forall(otype T)
+inline void realloc_storage(heap_allocator(T)* this, size_t size)
+{
+	enum { GROWTH_RATE = 2 };
+	if(size > this->capacity)
+	{
+		this->capacity = GROWTH_RATE * size;
+		this->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T));
+	}
+}
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/fstream.c
===================================================================
--- libcfa/src/fstream.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,247 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// fstream.c --
-//
-// Author           : Peter A. Buhr
-// Created On       : Wed May 27 17:56:53 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Jun  5 17:02:56 2018
-// Update Count     : 281
-//
-
-#include "fstream"
-
-#include <stdio.h>										// vfprintf, vfscanf
-#include <stdlib.h>										// exit
-#include <stdarg.h>										// varargs
-#include <string.h>										// strlen
-#include <stdbool.h>									// true/false
-#include <float.h>										// DBL_DIG, LDBL_DIG
-#include <complex.h>									// creal, cimag
-#include <assert.h>
-
-#define IO_MSG "I/O error: "
-
-void ?{}( ofstream & os, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) {
-	os.file = file;
-	os.sepDefault = sepDefault;
-	os.sepOnOff = sepOnOff;
-	sepSet( os, separator );
-	sepSetCur( os, sepGet( os ) );
-	sepSetTuple( os, tupleSeparator );
-}
-
-// private
-_Bool sepPrt( ofstream & os ) { setNL( os, false ); return os.sepOnOff; }
-void sepReset( ofstream & os ) { os.sepOnOff = os.sepDefault; }
-void sepReset( ofstream & os, _Bool reset ) { os.sepDefault = reset; os.sepOnOff = os.sepDefault; }
-const char * sepGetCur( ofstream & os ) { return os.sepCur; }
-void sepSetCur( ofstream & os, const char * sepCur ) { os.sepCur = sepCur; }
-_Bool getNL( ofstream & os ) { return os.sawNL; }
-void setNL( ofstream & os, _Bool state ) { os.sawNL = state; }
-
-// public
-void ?{}( ofstream & os ) { os.file = 0; }
-
-void ?{}( ofstream & os, const char * name, const char * mode ) {
-	open( os, name, mode );
-}
-void ?{}( ofstream & os, const char * name ) {
-	open( os, name, "w" );
-}
-
-void sepOn( ofstream & os ) { os.sepOnOff = ! getNL( os ); }
-void sepOff( ofstream & os ) { os.sepOnOff = false; }
-
-_Bool sepDisable( ofstream & os ) {
-	_Bool temp = os.sepDefault;
-	os.sepDefault = false;
-	sepReset( os );
-	return temp;
-} // sepDisable
-
-_Bool sepEnable( ofstream & os ) {
-	_Bool temp = os.sepDefault;
-	os.sepDefault = true;
-	if ( os.sepOnOff ) sepReset( os );					// start of line ?
-	return temp;
-} // sepEnable
-
-const char * sepGet( ofstream & os ) { return os.separator; }
-void sepSet( ofstream & os, const char * s ) {
-	assert( s );
-	strncpy( os.separator, s, sepSize - 1 );
-	os.separator[sepSize - 1] = '\0';
-} // sepSet
-
-const char * sepGetTuple( ofstream & os ) { return os.tupleSeparator; }
-void sepSetTuple( ofstream & os, const char * s ) {
-	assert( s );
-	strncpy( os.tupleSeparator, s, sepSize - 1 );
-	os.tupleSeparator[sepSize - 1] = '\0';
-} // sepSet
-
-int fail( ofstream & os ) {
-	return os.file == 0 || ferror( (FILE *)(os.file) );
-} // fail
-
-int flush( ofstream & os ) {
-	return fflush( (FILE *)(os.file) );
-} // flush
-
-void open( ofstream & os, const char * name, const char * mode ) {
-	FILE *file = fopen( name, mode );
-	// if ( file == 0 ) {									// do not change unless successful
-	// 	fprintf( stderr, IO_MSG "open output file \"%s\", ", name );
-	// 	perror( 0 );
-	// 	exit( EXIT_FAILURE );
-	// } // if
-	(os){ file, true, false, " ", ", " };
-} // open
-
-void open( ofstream & os, const char * name ) {
-	open( os, name, "w" );
-} // open
-
-void close( ofstream & os ) {
-	if ( (FILE *)(os.file) == stdout || (FILE *)(os.file) == stderr ) return;
-
-	if ( fclose( (FILE *)(os.file) ) == EOF ) {
-		perror( IO_MSG "close output" );
-	} // if
-} // close
-
-ofstream & write( ofstream & os, const char * data, size_t size ) {
-	if ( fail( os ) ) {
-		fprintf( stderr, "attempt write I/O on failed stream\n" );
-		exit( EXIT_FAILURE );
-	} // if
-
-	if ( fwrite( data, 1, size, (FILE *)(os.file) ) != size ) {
-		perror( IO_MSG "write" );
-		exit( EXIT_FAILURE );
-	} // if
-	return os;
-} // write
-
-int fmt( ofstream & os, const char format[], ... ) {
-	va_list args;
-	va_start( args, format );
-	int len = vfprintf( (FILE *)(os.file), format, args );
-	if ( len == EOF ) {
-		if ( ferror( (FILE *)(os.file) ) ) {
-			fprintf( stderr, "invalid write\n" );
-			exit( EXIT_FAILURE );
-		} // if
-	} // if
-	va_end( args );
-
-	sepReset( os );										// reset separator
-	return len;
-} // fmt
-
-static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, " ", ", " };
-ofstream & sout = soutFile;
-static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, " ", ", " };
-ofstream & serr = serrFile;
-
-
-//---------------------------------------
-
-// private
-void ?{}( ifstream & is, void * file ) {
-	is.file = file;
-}
-
-// public
-void ?{}( ifstream & is ) {	is.file = 0; }
-
-void ?{}( ifstream & is, const char * name, const char * mode ) {
-	open( is, name, mode );
-}
-void ?{}( ifstream & is, const char * name ) {
-	open( is, name, "r" );
-}
-
-int fail( ifstream & is ) {
-	return is.file == 0 || ferror( (FILE *)(is.file) );
-} // fail
-
-int eof( ifstream & is ) {
-	return feof( (FILE *)(is.file) );
-} // eof
-
-void open( ifstream & is, const char * name, const char * mode ) {
-	FILE *file = fopen( name, mode );
-	// if ( file == 0 ) {									// do not change unless successful
-	// 	fprintf( stderr, IO_MSG "open input file \"%s\", ", name );
-	// 	perror( 0 );
-	// 	exit( EXIT_FAILURE );
-	// } // if
-	is.file = file;
-} // open
-
-void open( ifstream & is, const char * name ) {
-	open( is, name, "r" );
-} // open
-
-void close( ifstream & is ) {
-	if ( (FILE *)(is.file) == stdin ) return;
-
-	if ( fclose( (FILE *)(is.file) ) == EOF ) {
-		perror( IO_MSG "close input" );
-	} // if
-} // close
-
-ifstream & read( ifstream & is, char * data, size_t size ) {
-	if ( fail( is ) ) {
-		fprintf( stderr, "attempt read I/O on failed stream\n" );
-		exit( EXIT_FAILURE );
-	} // if
-
-	if ( fread( data, size, 1, (FILE *)(is.file) ) == 0 ) {
-		perror( IO_MSG "read" );
-		exit( EXIT_FAILURE );
-	} // if
-	return is;
-} // read
-
-ifstream &ungetc( ifstream & is, char c ) {
-	if ( fail( is ) ) {
-		fprintf( stderr, "attempt ungetc I/O on failed stream\n" );
-		exit( EXIT_FAILURE );
-	} // if
-
-	if ( ungetc( c, (FILE *)(is.file) ) == EOF ) {
-		perror( IO_MSG "ungetc" );
-		exit( EXIT_FAILURE );
-	} // if
-	return is;
-} // ungetc
-
-int fmt( ifstream & is, const char format[], ... ) {
-	va_list args;
-
-	va_start( args, format );
-	int len = vfscanf( (FILE *)(is.file), format, args );
-	if ( len == EOF ) {
-		if ( ferror( (FILE *)(is.file) ) ) {
-			fprintf( stderr, "invalid read\n" );
-			exit( EXIT_FAILURE );
-		} // if
-	} // if
-	va_end( args );
-	return len;
-} // fmt
-
-
-static ifstream sinFile = { (FILE *)(&_IO_2_1_stdin_) };
-ifstream & sin = sinFile;
-
-// Local Variables: //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/fstream.cfa
===================================================================
--- libcfa/src/fstream.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/fstream.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,247 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// fstream.c --
+//
+// Author           : Peter A. Buhr
+// Created On       : Wed May 27 17:56:53 2015
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Tue Jun  5 17:02:56 2018
+// Update Count     : 281
+//
+
+#include "fstream"
+
+#include <stdio.h>										// vfprintf, vfscanf
+#include <stdlib.h>										// exit
+#include <stdarg.h>										// varargs
+#include <string.h>										// strlen
+#include <stdbool.h>									// true/false
+#include <float.h>										// DBL_DIG, LDBL_DIG
+#include <complex.h>									// creal, cimag
+#include <assert.h>
+
+#define IO_MSG "I/O error: "
+
+void ?{}( ofstream & os, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) {
+	os.file = file;
+	os.sepDefault = sepDefault;
+	os.sepOnOff = sepOnOff;
+	sepSet( os, separator );
+	sepSetCur( os, sepGet( os ) );
+	sepSetTuple( os, tupleSeparator );
+}
+
+// private
+_Bool sepPrt( ofstream & os ) { setNL( os, false ); return os.sepOnOff; }
+void sepReset( ofstream & os ) { os.sepOnOff = os.sepDefault; }
+void sepReset( ofstream & os, _Bool reset ) { os.sepDefault = reset; os.sepOnOff = os.sepDefault; }
+const char * sepGetCur( ofstream & os ) { return os.sepCur; }
+void sepSetCur( ofstream & os, const char * sepCur ) { os.sepCur = sepCur; }
+_Bool getNL( ofstream & os ) { return os.sawNL; }
+void setNL( ofstream & os, _Bool state ) { os.sawNL = state; }
+
+// public
+void ?{}( ofstream & os ) { os.file = 0; }
+
+void ?{}( ofstream & os, const char * name, const char * mode ) {
+	open( os, name, mode );
+}
+void ?{}( ofstream & os, const char * name ) {
+	open( os, name, "w" );
+}
+
+void sepOn( ofstream & os ) { os.sepOnOff = ! getNL( os ); }
+void sepOff( ofstream & os ) { os.sepOnOff = false; }
+
+_Bool sepDisable( ofstream & os ) {
+	_Bool temp = os.sepDefault;
+	os.sepDefault = false;
+	sepReset( os );
+	return temp;
+} // sepDisable
+
+_Bool sepEnable( ofstream & os ) {
+	_Bool temp = os.sepDefault;
+	os.sepDefault = true;
+	if ( os.sepOnOff ) sepReset( os );					// start of line ?
+	return temp;
+} // sepEnable
+
+const char * sepGet( ofstream & os ) { return os.separator; }
+void sepSet( ofstream & os, const char * s ) {
+	assert( s );
+	strncpy( os.separator, s, sepSize - 1 );
+	os.separator[sepSize - 1] = '\0';
+} // sepSet
+
+const char * sepGetTuple( ofstream & os ) { return os.tupleSeparator; }
+void sepSetTuple( ofstream & os, const char * s ) {
+	assert( s );
+	strncpy( os.tupleSeparator, s, sepSize - 1 );
+	os.tupleSeparator[sepSize - 1] = '\0';
+} // sepSet
+
+int fail( ofstream & os ) {
+	return os.file == 0 || ferror( (FILE *)(os.file) );
+} // fail
+
+int flush( ofstream & os ) {
+	return fflush( (FILE *)(os.file) );
+} // flush
+
+void open( ofstream & os, const char * name, const char * mode ) {
+	FILE *file = fopen( name, mode );
+	// if ( file == 0 ) {									// do not change unless successful
+	// 	fprintf( stderr, IO_MSG "open output file \"%s\", ", name );
+	// 	perror( 0 );
+	// 	exit( EXIT_FAILURE );
+	// } // if
+	(os){ file, true, false, " ", ", " };
+} // open
+
+void open( ofstream & os, const char * name ) {
+	open( os, name, "w" );
+} // open
+
+void close( ofstream & os ) {
+	if ( (FILE *)(os.file) == stdout || (FILE *)(os.file) == stderr ) return;
+
+	if ( fclose( (FILE *)(os.file) ) == EOF ) {
+		perror( IO_MSG "close output" );
+	} // if
+} // close
+
+ofstream & write( ofstream & os, const char * data, size_t size ) {
+	if ( fail( os ) ) {
+		fprintf( stderr, "attempt write I/O on failed stream\n" );
+		exit( EXIT_FAILURE );
+	} // if
+
+	if ( fwrite( data, 1, size, (FILE *)(os.file) ) != size ) {
+		perror( IO_MSG "write" );
+		exit( EXIT_FAILURE );
+	} // if
+	return os;
+} // write
+
+int fmt( ofstream & os, const char format[], ... ) {
+	va_list args;
+	va_start( args, format );
+	int len = vfprintf( (FILE *)(os.file), format, args );
+	if ( len == EOF ) {
+		if ( ferror( (FILE *)(os.file) ) ) {
+			fprintf( stderr, "invalid write\n" );
+			exit( EXIT_FAILURE );
+		} // if
+	} // if
+	va_end( args );
+
+	sepReset( os );										// reset separator
+	return len;
+} // fmt
+
+static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, " ", ", " };
+ofstream & sout = soutFile;
+static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, " ", ", " };
+ofstream & serr = serrFile;
+
+
+//---------------------------------------
+
+// private
+void ?{}( ifstream & is, void * file ) {
+	is.file = file;
+}
+
+// public
+void ?{}( ifstream & is ) {	is.file = 0; }
+
+void ?{}( ifstream & is, const char * name, const char * mode ) {
+	open( is, name, mode );
+}
+void ?{}( ifstream & is, const char * name ) {
+	open( is, name, "r" );
+}
+
+int fail( ifstream & is ) {
+	return is.file == 0 || ferror( (FILE *)(is.file) );
+} // fail
+
+int eof( ifstream & is ) {
+	return feof( (FILE *)(is.file) );
+} // eof
+
+void open( ifstream & is, const char * name, const char * mode ) {
+	FILE *file = fopen( name, mode );
+	// if ( file == 0 ) {									// do not change unless successful
+	// 	fprintf( stderr, IO_MSG "open input file \"%s\", ", name );
+	// 	perror( 0 );
+	// 	exit( EXIT_FAILURE );
+	// } // if
+	is.file = file;
+} // open
+
+void open( ifstream & is, const char * name ) {
+	open( is, name, "r" );
+} // open
+
+void close( ifstream & is ) {
+	if ( (FILE *)(is.file) == stdin ) return;
+
+	if ( fclose( (FILE *)(is.file) ) == EOF ) {
+		perror( IO_MSG "close input" );
+	} // if
+} // close
+
+ifstream & read( ifstream & is, char * data, size_t size ) {
+	if ( fail( is ) ) {
+		fprintf( stderr, "attempt read I/O on failed stream\n" );
+		exit( EXIT_FAILURE );
+	} // if
+
+	if ( fread( data, size, 1, (FILE *)(is.file) ) == 0 ) {
+		perror( IO_MSG "read" );
+		exit( EXIT_FAILURE );
+	} // if
+	return is;
+} // read
+
+ifstream &ungetc( ifstream & is, char c ) {
+	if ( fail( is ) ) {
+		fprintf( stderr, "attempt ungetc I/O on failed stream\n" );
+		exit( EXIT_FAILURE );
+	} // if
+
+	if ( ungetc( c, (FILE *)(is.file) ) == EOF ) {
+		perror( IO_MSG "ungetc" );
+		exit( EXIT_FAILURE );
+	} // if
+	return is;
+} // ungetc
+
+int fmt( ifstream & is, const char format[], ... ) {
+	va_list args;
+
+	va_start( args, format );
+	int len = vfscanf( (FILE *)(is.file), format, args );
+	if ( len == EOF ) {
+		if ( ferror( (FILE *)(is.file) ) ) {
+			fprintf( stderr, "invalid read\n" );
+			exit( EXIT_FAILURE );
+		} // if
+	} // if
+	va_end( args );
+	return len;
+} // fmt
+
+
+static ifstream sinFile = { (FILE *)(&_IO_2_1_stdin_) };
+ifstream & sin = sinFile;
+
+// Local Variables: //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/heap.c
===================================================================
--- libcfa/src/heap.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,979 +1,0 @@
-// 
-// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-// 
-// heap.c -- 
-// 
-// Author           : Peter A. Buhr
-// Created On       : Tue Dec 19 21:58:35 2017
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Jul 31 18:08:50 2018
-// Update Count     : 470
-// 
-
-#include <unistd.h>										// sbrk, sysconf
-#include <stdbool.h>									// true, false
-#include <stdio.h>										// snprintf, fileno
-#include <errno.h>										// errno
-extern "C" {
-#include <sys/mman.h>									// mmap, munmap
-} // extern "C"
-
-#include "bits/align.h"									// libPow2
-#include "bits/defs.h"									// likely, unlikely
-#include "bits/locks.h"									// __spinlock_t
-#include "startup.h"									// STARTUP_PRIORITY_MEMORY
-#include "stdlib"										// bsearchl
-#include "malloc.h"
-
-
-enum {
-	__CFA_DEFAULT_MMAP_START__ = (512 * 1024 + 1),
-	__CFA_DEFAULT_HEAP_EXPANSION__ = (1 * 1024 * 1024),
-};
-
-size_t default_mmap_start() __attribute__(( weak )) {
-    return __CFA_DEFAULT_MMAP_START__;
-} // default_mmap_start
-
-size_t default_heap_expansion() __attribute__(( weak )) {
-    return __CFA_DEFAULT_HEAP_EXPANSION__;
-} // default_heap_expansion
-
-
-// supported mallopt options
-#ifndef M_MMAP_THRESHOLD
-#define M_MMAP_THRESHOLD (-1)
-#endif // M_TOP_PAD
-#ifndef M_TOP_PAD
-#define M_TOP_PAD (-2)
-#endif // M_TOP_PAD
-
-#define FASTLOOKUP
-#define __STATISTICS__
-
-#define SPINLOCK 0
-#define LOCKFREE 1
-#define BUCKETLOCK SPINLOCK
-#if BUCKETLOCK == LOCKFREE
-#include <uStackLF.h>
-#endif // LOCKFREE
-
-#define ALIGN 16
-
-// enum { NoBucketSizes = 93,								// number of buckets sizes
-// #ifdef FASTLOOKUP
-// 	   LookupSizes = 65536,								// number of fast lookup sizes
-// #endif // FASTLOOKUP
-// };
-#define NoBucketSizes 93								// number of buckets sizes
-#ifdef FASTLOOKUP
-#define LookupSizes 65536								// number of fast lookup sizes
-#endif // FASTLOOKUP
-
-
-static _Bool traceHeap = false;
-
-inline _Bool traceHeap() {
-	return traceHeap;
-} // traceHeap
-
-_Bool traceHeapOn() {
-	_Bool temp = traceHeap;
-	traceHeap = true;
-	return temp;
-} // traceHeapOn
-
-_Bool traceHeapOff() {
-	_Bool temp = traceHeap;
-	traceHeap = false;
-	return temp;
-} // traceHeapOff
-
-
-static _Bool checkFree = false;
-
-inline _Bool checkFree() {
-	return checkFree;
-} // checkFree
-
-_Bool checkFreeOn() {
-	_Bool temp = checkFree;
-	checkFree = true;
-	return temp;
-} // checkFreeOn
-
-_Bool checkFreeOff() {
-	_Bool temp = checkFree;
-	checkFree = false;
-	return temp;
-} // checkFreeOff
-
-
-// static _Bool traceHeapTerm = false;
-
-// inline _Bool traceHeapTerm() {
-// 	return traceHeapTerm;
-// } // traceHeapTerm
-
-// _Bool traceHeapTermOn() {
-// 	_Bool temp = traceHeapTerm;
-// 	traceHeapTerm = true;
-// 	return temp;
-// } // traceHeapTermOn
-
-// _Bool traceHeapTermOff() {
-// 	_Bool temp = traceHeapTerm;
-// 	traceHeapTerm = false;
-// 	return temp;
-// } // traceHeapTermOff
-
-
-#ifdef __CFA_DEBUG__
-static unsigned int allocfree;							// running total of allocations minus frees
-static unsigned int appStart;							// storage allocation when application starts
-
-static void checkUnfreed() {
-	unsigned int total = allocfree - appStart;
-    if ( total != 0 ) {
-		// DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
-		// char helpText[512];
-		// int len = snprintf( helpText, 512, "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"
-		// 					"Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n",
-		// 					(long int)getpid(), total, total ); // always print the UNIX pid
-		// __cfaabi_dbg_bits_write( helpText, len );
-    } // if
-} // checkUnfreed
-
-extern "C" {
-void heapAppStart() {									// called by __cfaabi_appready_startup
-	appStart = allocfree;
-} // heapAppStart
-
-void heapAppStop() {									// called by __cfaabi_appready_startdown
-	checkUnfreed();
-} // heapAppStop
-} // extern "C"
-#endif // __CFA_DEBUG__
-
-
-struct HeapManager {
-//	struct FreeHeader;									// forward declaration
-
-	struct Storage {
-	    struct Header {									// header
-			union Kind {
-				struct RealHeader {
-					union {
-						struct {						// 32-bit word => 64-bit header, 64-bit word => 128-bit header
-							#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ && __SIZEOF_POINTER__ == 4
-							uint32_t padding;			// unused, force home/blocksize to overlay alignment in fake header
-							#endif // __ORDER_BIG_ENDIAN__ && __U_WORDSIZE__ == 32
-
-							union {
-//								FreeHeader * home;		// allocated block points back to home locations (must overlay alignment)
-								void * home;			// allocated block points back to home locations (must overlay alignment)
-								size_t blockSize;		// size for munmap (must overlay alignment)
-								#if BUCKLOCK == SPINLOCK
-								Storage * next;			// freed block points next freed block of same size
-								#endif // SPINLOCK
-							};
-
-							#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && __SIZEOF_POINTER__ == 4
-							uint32_t padding;			// unused, force home/blocksize to overlay alignment in fake header
-							#endif // __ORDER_LITTLE_ENDIAN__ && __U_WORDSIZE__ == 32
-
-						};
-						#if BUCKLOCK == LOCKFREE
-						Stack<Storage>::Link next;		// freed block points next freed block of same size (double-wide)
-						#endif // LOCKFREE
-					};
-				} real;
-				struct FakeHeader {
-					#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-					uint32_t alignment;					// low-order bits of home/blockSize used for tricks
-					#endif // __ORDER_LITTLE_ENDIAN__
-
-					uint32_t offset;
-
-					#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-					uint32_t alignment;					// low-order bits of home/blockSize used for tricks
-					#endif // __ORDER_BIG_ENDIAN__
-				} fake;
-			} kind;
-	    } header; // Header
-	    char pad[ALIGN - sizeof( Header )];
-	    char data[0];									// storage
-	}; // Storage
-
-	static_assert( ALIGN >= sizeof( Storage ), "ALIGN < sizeof( Storage )" );
-
-	struct FreeHeader {
-		#if BUCKLOCK == SPINLOCK
-	    __spinlock_t lock;								// must be first field for alignment
-	    Storage * freeList;
-		#elif BUCKLOCK == LOCKFREE
-	    StackLF<Storage> freeList;
-		#else
-			#error undefined lock type for bucket lock
-		#endif // SPINLOCK
-	    size_t blockSize;								// size of allocations on this list
-	}; // FreeHeader
-
-	// must be first fields for alignment
-	__spinlock_t extlock;								// protects allocation-buffer extension
-	FreeHeader freeLists[NoBucketSizes];				// buckets for different allocation sizes
-
-	void * heapBegin;									// start of heap
-	void * heapEnd;										// logical end of heap
-	size_t heapRemaining;								// amount of storage not allocated in the current chunk
-}; // HeapManager
-
-static inline size_t getKey( const HeapManager.FreeHeader & freeheader ) { return freeheader.blockSize; }
-// statically allocated variables => zero filled.
-
-
-static size_t pageSize;									// architecture pagesize
-static size_t heapExpand;								// sbrk advance
-static size_t mmapStart;								// cross over point for mmap
-static unsigned int maxBucketsUsed;						// maximum number of buckets in use
-
-// Powers of 2 are common allocation sizes, so make powers of 2 generate the minimum required size.
-static unsigned int bucketSizes[NoBucketSizes] @= {		// different bucket sizes
-    16, 32, 48, 64,
-    64 + sizeof(HeapManager.Storage), 96, 112, 128, 128 + sizeof(HeapManager.Storage), 160, 192, 224,
-    256 + sizeof(HeapManager.Storage), 320, 384, 448, 512 + sizeof(HeapManager.Storage), 640, 768, 896,
-    1_024 + sizeof(HeapManager.Storage), 1_536, 2_048 + sizeof(HeapManager.Storage), 2_560, 3_072, 3_584, 4_096 + sizeof(HeapManager.Storage), 6_144,
-    8_192 + sizeof(HeapManager.Storage), 9_216, 10_240, 11_264, 12_288, 13_312, 14_336, 15_360,
-    16_384 + sizeof(HeapManager.Storage), 18_432, 20_480, 22_528, 24_576, 26_624, 28_672, 30_720,
-    32_768 + sizeof(HeapManager.Storage), 36_864, 40_960, 45_056, 49_152, 53_248, 57_344, 61_440,
-    65_536 + sizeof(HeapManager.Storage), 73_728, 81_920, 90_112, 98_304, 106_496, 114_688, 122_880,
-    131_072 + sizeof(HeapManager.Storage), 147_456, 163_840, 180_224, 196_608, 212_992, 229_376, 245_760,
-    262_144 + sizeof(HeapManager.Storage), 294_912, 327_680, 360_448, 393_216, 425_984, 458_752, 491_520,
-    524_288 + sizeof(HeapManager.Storage), 655_360, 786_432, 917_504, 1_048_576 + sizeof(HeapManager.Storage), 1_179_648, 1_310_720, 1_441_792,
-    1_572_864, 1_703_936, 1_835_008, 1_966_080, 2_097_152 + sizeof(HeapManager.Storage), 2_621_440, 3_145_728, 3_670_016,
-    4_194_304 + sizeof(HeapManager.Storage)
-};
-#ifdef FASTLOOKUP
-static unsigned char lookup[LookupSizes];				// O(1) lookup for small sizes
-#endif // FASTLOOKUP
-static int mmapFd = -1;									// fake or actual fd for anonymous file
-
-
-#ifdef __CFA_DEBUG__
-static _Bool heapBoot = 0;								// detect recursion during boot
-#endif // __CFA_DEBUG__
-static HeapManager heapManager __attribute__(( aligned (128) )) @= {}; // size of cache line to prevent false sharing
-
-
-static inline _Bool setMmapStart( size_t value ) {
-    if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return true;
-    mmapStart = value;									// set global
-
-    // find the closest bucket size less than or equal to the mmapStart size
-    maxBucketsUsed = bsearchl( (unsigned int)mmapStart, bucketSizes, NoBucketSizes ); // binary search
-    assert( maxBucketsUsed < NoBucketSizes );			// subscript failure ?
-    assert( mmapStart <= bucketSizes[maxBucketsUsed] ); // search failure ?
-    return false;
-} // setMmapStart
-
-
-static void ?{}( HeapManager & manager ) with ( manager ) {
-    pageSize = sysconf( _SC_PAGESIZE );
-    
-    for ( unsigned int i = 0; i < NoBucketSizes; i += 1 ) { // initialize the free lists
-		freeLists[i].blockSize = bucketSizes[i];
-    } // for
-
-	#ifdef FASTLOOKUP
-    unsigned int idx = 0;
-    for ( unsigned int i = 0; i < LookupSizes; i += 1 ) {
-		if ( i > bucketSizes[idx] ) idx += 1;
-		lookup[i] = idx;
-    } // for
-	#endif // FASTLOOKUP
-
-    if ( setMmapStart( default_mmap_start() ) ) {
-		abort( "HeapManager : internal error, mmap start initialization failure." );
-    } // if
-    heapExpand = default_heap_expansion();
-
-    char * End = (char *)sbrk( 0 );
-    sbrk( (char *)libCeiling( (long unsigned int)End, libAlign() ) - End ); // move start of heap to multiple of alignment
-    heapBegin = heapEnd = sbrk( 0 );					// get new start point
-} // HeapManager
-
-
-static void ^?{}( HeapManager & ) {
-	#ifdef __STATISTICS__
-	// if ( traceHeapTerm() ) {
-	// 	printStats();
-	// 	if ( checkfree() ) checkFree( heapManager, true );
-	// } // if
-	#endif // __STATISTICS__
-} // ~HeapManager
-
-
-static void memory_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_MEMORY ) ));
-void memory_startup( void ) {
-	#ifdef __CFA_DEBUG__
-	if ( unlikely( heapBoot ) ) {					// check for recursion during system boot
-		// DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
-		abort( "boot() : internal error, recursively invoked during system boot." );
-	} // if
-	heapBoot = true;
-	#endif // __CFA_DEBUG__
-
-	assert( heapManager.heapBegin == 0 );
-	heapManager{};
-} // memory_startup
-
-static void memory_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_MEMORY ) ));
-void memory_shutdown( void ) {
-	^heapManager{};
-} // memory_shutdown
-
-
-#ifdef __STATISTICS__
-static unsigned long long int mmap_storage;				// heap statistics counters
-static unsigned int mmap_calls;
-static unsigned long long int munmap_storage;
-static unsigned int munmap_calls;
-static unsigned long long int sbrk_storage;
-static unsigned int sbrk_calls;
-static unsigned long long int malloc_storage;
-static unsigned int malloc_calls;
-static unsigned long long int free_storage;
-static unsigned int free_calls;
-static unsigned long long int calloc_storage;
-static unsigned int calloc_calls;
-static unsigned long long int memalign_storage;
-static unsigned int memalign_calls;
-static unsigned long long int cmemalign_storage;
-static unsigned int cmemalign_calls;
-static unsigned long long int realloc_storage;
-static unsigned int realloc_calls;
-
-static int statfd;										// statistics file descriptor (changed by malloc_stats_fd)
-
-
-// Use "write" because streams may be shutdown when calls are made.
-static void printStats() {
-    char helpText[512];
-	__cfaabi_dbg_bits_print_buffer( helpText, 512,
-			"\nHeap statistics:\n"
-			"  malloc: calls %u / storage %llu\n"
-			"  calloc: calls %u / storage %llu\n"
-			"  memalign: calls %u / storage %llu\n"
-			"  cmemalign: calls %u / storage %llu\n"
-			"  realloc: calls %u / storage %llu\n"
-			"  free: calls %u / storage %llu\n"
-			"  mmap: calls %u / storage %llu\n"
-			"  munmap: calls %u / storage %llu\n"
-			"  sbrk: calls %u / storage %llu\n",
-			malloc_calls, malloc_storage,
-			calloc_calls, calloc_storage,
-			memalign_calls, memalign_storage,
-			cmemalign_calls, cmemalign_storage,
-			realloc_calls, realloc_storage,
-			free_calls, free_storage,
-			mmap_calls, mmap_storage,
-			munmap_calls, munmap_storage,
-			sbrk_calls, sbrk_storage
-		);
-} // printStats
-
-
-static int printStatsXML( FILE * stream ) {
-    char helpText[512];
-    int len = snprintf( helpText, 512,
-						"<malloc version=\"1\">\n"
-						"<heap nr=\"0\">\n"
-						"<sizes>\n"
-						"</sizes>\n"
-						"<total type=\"malloc\" count=\"%u\" size=\"%llu\"/>\n"
-						"<total type=\"calloc\" count=\"%u\" size=\"%llu\"/>\n"
-						"<total type=\"memalign\" count=\"%u\" size=\"%llu\"/>\n"
-						"<total type=\"cmemalign\" count=\"%u\" size=\"%llu\"/>\n"
-						"<total type=\"realloc\" count=\"%u\" size=\"%llu\"/>\n"
-						"<total type=\"free\" count=\"%u\" size=\"%llu\"/>\n"
-						"<total type=\"mmap\" count=\"%u\" size=\"%llu\"/>\n"
-						"<total type=\"munmap\" count=\"%u\" size=\"%llu\"/>\n"
-						"<total type=\"sbrk\" count=\"%u\" size=\"%llu\"/>\n"
-						"</malloc>",
-						malloc_calls, malloc_storage,
-						calloc_calls, calloc_storage,
-						memalign_calls, memalign_storage,
-						cmemalign_calls, cmemalign_storage,
-						realloc_calls, realloc_storage,
-						free_calls, free_storage,
-						mmap_calls, mmap_storage,
-						munmap_calls, munmap_storage,
-						sbrk_calls, sbrk_storage
-		);
-    return write( fileno( stream ), helpText, len );	// -1 => error
-} // printStatsXML
-#endif // __STATISTICS__
-
-
-static inline void noMemory() {
-    abort( "Heap memory exhausted at %zu bytes.\n"
-			"Possible cause is very large memory allocation and/or large amount of unfreed storage allocated by the program or system/library routines.",
-			((char *)(sbrk( 0 )) - (char *)(heapManager.heapBegin)) );
-} // noMemory
-
-
-static inline void checkAlign( size_t alignment ) {
-    if ( alignment < sizeof(void *) || ! libPow2( alignment ) ) {
-		abort( "Alignment %zu for memory allocation is less than sizeof(void *) and/or not a power of 2.", alignment );
-    } // if
-} // checkAlign
-
-
-static inline _Bool setHeapExpand( size_t value ) {
-    if ( heapExpand < pageSize ) return true;
-    heapExpand = value;
-    return false;
-} // setHeapExpand
-
-
-static inline void checkHeader( _Bool check, const char * name, void * addr ) {
-    if ( unlikely( check ) ) {							// bad address ?
-		abort( "Attempt to %s storage %p with address outside the heap.\n"
-				"Possible cause is duplicate free on same block or overwriting of memory.",
-				name, addr );
-    } // if
-} // checkHeader
-
-
-static inline void fakeHeader( HeapManager.Storage.Header *& header, size_t & size, size_t & alignment ) {
-    if ( unlikely( (header->kind.fake.alignment & 1) == 1 ) ) { // fake header ?
-		size_t offset = header->kind.fake.offset;
-		alignment = header->kind.fake.alignment & -2;	// remove flag from value
-		#ifdef __CFA_DEBUG__
-		checkAlign( alignment );						// check alignment
-		#endif // __CFA_DEBUG__
-		header = (HeapManager.Storage.Header *)((char *)header - offset);
-    } // if
-} // fakeHeader
-
-
-#define headerAddr( addr ) ((HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) ))
-
-static inline _Bool headers( const char * name, void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) {
-    header = headerAddr( addr );
-
-    if ( unlikely( heapEnd < addr ) ) {					// mmapped ?
-		fakeHeader( header, size, alignment );
-		size = header->kind.real.blockSize & -3;		// mmap size
-		return true;
-    } // if
-
-	#ifdef __CFA_DEBUG__
-    checkHeader( addr < heapBegin || header < (HeapManager.Storage.Header *)heapBegin, name, addr ); // bad low address ?
-	#endif // __CFA_DEBUG__
-    // header may be safe to dereference
-    fakeHeader( header, size, alignment );
-	#ifdef __CFA_DEBUG__
-    checkHeader( header < (HeapManager.Storage.Header *)heapBegin || (HeapManager.Storage.Header *)heapEnd < header, name, addr ); // bad address ? (offset could be + or -)
-	#endif // __CFA_DEBUG__
-
-    freeElem = (HeapManager.FreeHeader *)((size_t)header->kind.real.home & -3);
-	#ifdef __CFA_DEBUG__
-    if ( freeElem < &freeLists[0] || &freeLists[NoBucketSizes] <= freeElem ) {
-		abort( "Attempt to %s storage %p with corrupted header.\n"
-			   "Possible cause is duplicate free on same block or overwriting of header information.",
-			   name, addr );
-    } // if
-	#endif // __CFA_DEBUG__
-    size = freeElem->blockSize;
-    return false;
-} // headers
-
-
-static inline void * extend( size_t size ) with ( heapManager ) {
-    lock( extlock __cfaabi_dbg_ctx2 );
-    ptrdiff_t rem = heapRemaining - size;
-    if ( rem < 0 ) {
-		// If the size requested is bigger than the current remaining storage, increase the size of the heap.
-
-		size_t increase = libCeiling( size > heapExpand ? size : heapExpand, libAlign() );
-		if ( sbrk( increase ) == (void *)-1 ) {
-			unlock( extlock );
-			errno = ENOMEM;
-			return 0;
-		} // if
-#ifdef __STATISTICS__
-		sbrk_calls += 1;
-		sbrk_storage += increase;
-#endif // __STATISTICS__
-#ifdef __CFA_DEBUG__
-		// Set new memory to garbage so subsequent uninitialized usages might fail.
-		memset( (char *)heapEnd + heapRemaining, '\377', increase );
-#endif // __CFA_DEBUG__
-		rem = heapRemaining + increase - size;
-    } // if
-
-    HeapManager.Storage * block = (HeapManager.Storage *)heapEnd;
-    heapRemaining = rem;
-    heapEnd = (char *)heapEnd + size;
-    unlock( extlock );
-    return block;
-} // extend
-
-
-static inline void * doMalloc( size_t size ) with ( heapManager ) {
-    HeapManager.Storage * block;
-
-    // Look up size in the size list.  Make sure the user request includes space for the header that must be allocated
-    // along with the block and is a multiple of the alignment size.
-
-    size_t tsize = size + sizeof(HeapManager.Storage);
-    if ( likely( tsize < mmapStart ) ) {				// small size => sbrk
-		HeapManager.FreeHeader * freeElem =
-			#ifdef FASTLOOKUP
-			tsize < LookupSizes ? &freeLists[lookup[tsize]] :
-			#endif // FASTLOOKUP
-			bsearchl( tsize, freeLists, (size_t)maxBucketsUsed ); // binary search
-		assert( freeElem <= &freeLists[maxBucketsUsed] ); // subscripting error ?
-		assert( tsize <= freeElem->blockSize );			// search failure ?
-		tsize = freeElem->blockSize;					// total space needed for request
-
-		// Spin until the lock is acquired for this particular size of block.
-
-		#if defined( SPINLOCK )
-		lock( freeElem->lock __cfaabi_dbg_ctx2 );
-		block = freeElem->freeList;						// remove node from stack
-		#else
-		block = freeElem->freeList.pop();
-		#endif // SPINLOCK
-		if ( unlikely( block == 0 ) ) {					// no free block ?
-			#if defined( SPINLOCK )
-			unlock( freeElem->lock );
-			#endif // SPINLOCK
-			// Freelist for that size was empty, so carve it out of the heap if there's enough left, or get some more
-			// and then carve it off.
-
-			block = (HeapManager.Storage *)extend( tsize );	// mutual exclusion on call
-			if ( unlikely( block == 0 ) ) return 0;
-			#if defined( SPINLOCK )
-		} else {
-			freeElem->freeList = block->header.kind.real.next;
-			unlock( freeElem->lock );
-			#endif // SPINLOCK
-		} // if
-
-		block->header.kind.real.home = freeElem;		// pointer back to free list of apropriate size
-    } else {											// large size => mmap
-		tsize = libCeiling( tsize, pageSize );			// must be multiple of page size
-		#ifdef __STATISTICS__
-		__atomic_add_fetch( &mmap_calls, 1, __ATOMIC_SEQ_CST );
-		__atomic_add_fetch( &mmap_storage, tsize, __ATOMIC_SEQ_CST );
-		#endif // __STATISTICS__
-		block = (HeapManager.Storage *)mmap( 0, tsize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, mmapFd, 0 );
-		if ( block == (HeapManager.Storage *)MAP_FAILED ) {
-			// Do not call strerror( errno ) as it may call malloc.
-			abort( "(HeapManager &)0x%p.doMalloc() : internal error, mmap failure, size:%zu error:%d.", &heapManager, tsize, errno );
-		} // if
-#ifdef __CFA_DEBUG__
-		// Set new memory to garbage so subsequent uninitialized usages might fail.
-		memset( block, '\377', tsize );
-#endif // __CFA_DEBUG__
-		block->header.kind.real.blockSize = tsize;		// storage size for munmap
-    } // if
-
-    void * area = &(block->data);						// adjust off header to user bytes
-
-	#ifdef __CFA_DEBUG__
-    assert( ((uintptr_t)area & (libAlign() - 1)) == 0 ); // minimum alignment ?
-    __atomic_add_fetch( &allocfree, tsize, __ATOMIC_SEQ_CST );
-	if ( traceHeap() ) {
-		enum { BufferSize = 64 };
-		char helpText[BufferSize];
-		int len = snprintf( helpText, BufferSize, "%p = Malloc( %zu ) (allocated %zu)\n", area, size, tsize );
-		// int len = snprintf( helpText, BufferSize, "Malloc %p %zu\n", area, size );
-		__cfaabi_dbg_bits_write( helpText, len );
-	} // if
-	#endif // __CFA_DEBUG__
-
-    return area;
-} // doMalloc
-
-
-static inline void doFree( void * addr ) with ( heapManager ) {
-	#ifdef __CFA_DEBUG__
-    if ( unlikely( heapManager.heapBegin == 0 ) ) {
-		abort( "doFree( %p ) : internal error, called before heap is initialized.", addr );
-    } // if
-	#endif // __CFA_DEBUG__
-
-    HeapManager.Storage.Header * header;
-    HeapManager.FreeHeader * freeElem;
-    size_t size, alignment;								// not used (see realloc)
-
-    if ( headers( "free", addr, header, freeElem, size, alignment ) ) { // mmapped ?
-		#ifdef __STATISTICS__
-		__atomic_add_fetch( &munmap_calls, 1, __ATOMIC_SEQ_CST );
-		__atomic_add_fetch( &munmap_storage, size, __ATOMIC_SEQ_CST );
-		#endif // __STATISTICS__
-		if ( munmap( header, size ) == -1 ) {
-			#ifdef __CFA_DEBUG__
-			abort( "Attempt to deallocate storage %p not allocated or with corrupt header.\n"
-					"Possible cause is invalid pointer.",
-					addr );
-			#endif // __CFA_DEBUG__
-		} // if
-    } else {
-		#ifdef __CFA_DEBUG__
-		// Set free memory to garbage so subsequent usages might fail.
-		memset( ((HeapManager.Storage *)header)->data, '\377', freeElem->blockSize - sizeof( HeapManager.Storage ) );
-		#endif // __CFA_DEBUG__
-
-		#ifdef __STATISTICS__
-		free_storage += size;
-		#endif // __STATISTICS__
-		#if defined( SPINLOCK )
-		lock( freeElem->lock __cfaabi_dbg_ctx2 );		// acquire spin lock
-		header->kind.real.next = freeElem->freeList;	// push on stack
-		freeElem->freeList = (HeapManager.Storage *)header;
-		unlock( freeElem->lock );						// release spin lock
-		#else
-		freeElem->freeList.push( *(HeapManager.Storage *)header );
-		#endif // SPINLOCK
-    } // if
-
-	#ifdef __CFA_DEBUG__
-    __atomic_add_fetch( &allocfree, -size, __ATOMIC_SEQ_CST );
-    if ( traceHeap() ) {
-		enum { BufferSize = 64 };
-		char helpText[BufferSize];
-		int len = snprintf( helpText, BufferSize, "Free( %p ) size:%zu\n", addr, size );
-		__cfaabi_dbg_bits_write( helpText, len );
-    } // if
-	#endif // __CFA_DEBUG__
-} // doFree
-
-
-size_t checkFree( HeapManager & manager ) with ( manager ) {
-    size_t total = 0;
-	#ifdef __STATISTICS__
-    __cfaabi_dbg_bits_acquire();
-    __cfaabi_dbg_bits_print_nolock( "\nBin lists (bin size : free blocks on list)\n" );
-	#endif // __STATISTICS__
-    for ( unsigned int i = 0; i < maxBucketsUsed; i += 1 ) {
-		size_t size = freeLists[i].blockSize;
-		#ifdef __STATISTICS__
-		unsigned int N = 0;
-		#endif // __STATISTICS__
-		#if defined( SPINLOCK )
-		for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0; p = p->header.kind.real.next ) {
-		#else
-		for ( HeapManager.Storage * p = freeLists[i].freeList.top(); p != 0; p = p->header.kind.real.next.top ) {
-		#endif // SPINLOCK
-			total += size;
-			#ifdef __STATISTICS__
-			N += 1;
-			#endif // __STATISTICS__
-	    } // for
-		#ifdef __STATISTICS__
-	    __cfaabi_dbg_bits_print_nolock( "%7zu, %-7u  ", size, N );
-	    if ( (i + 1) % 8 == 0 ) __cfaabi_dbg_bits_print_nolock( "\n" );
-		#endif // __STATISTICS__
-	} // for
-	#ifdef __STATISTICS__
-	__cfaabi_dbg_bits_print_nolock( "\ntotal free blocks:%zu\n", total );
-	__cfaabi_dbg_bits_release();
-	#endif // __STATISTICS__
-	return (char *)heapEnd - (char *)heapBegin - total;
-} // checkFree
-
-
-static inline void * malloc2( size_t size ) {			// necessary for malloc statistics
-	assert( heapManager.heapBegin != 0 );
-    void * area = doMalloc( size );
-    if ( unlikely( area == 0 ) ) errno = ENOMEM;		// POSIX
-    return area;
-} // malloc2
-
-
-static inline void * memalign2( size_t alignment, size_t size ) { // necessary for malloc statistics
-#ifdef __CFA_DEBUG__
-    checkAlign( alignment );							// check alignment
-#endif // __CFA_DEBUG__
-
-    // if alignment <= default alignment, do normal malloc as two headers are unnecessary
-    if ( unlikely( alignment <= libAlign() ) ) return malloc2( size );
-
-    // Allocate enough storage to guarantee an address on the alignment boundary, and sufficient space before it for
-    // administrative storage. NOTE, WHILE THERE ARE 2 HEADERS, THE FIRST ONE IS IMPLICITLY CREATED BY DOMALLOC.
-    //      .-------------v-----------------v----------------v----------,
-    //      | Real Header | ... padding ... |   Fake Header  | data ... |
-    //      `-------------^-----------------^-+--------------^----------'
-    //      |<--------------------------------' offset/align |<-- alignment boundary
-
-    // subtract libAlign() because it is already the minimum alignment
-    // add sizeof(Storage) for fake header
-    char * area = (char *)doMalloc( size + alignment - libAlign() + sizeof(HeapManager.Storage) );
-    if ( unlikely( area == 0 ) ) return area;
-
-    // address in the block of the "next" alignment address
-    char * user = (char *)libCeiling( (uintptr_t)(area + sizeof(HeapManager.Storage)), alignment );
-
-    // address of header from malloc
-    HeapManager.Storage.Header * realHeader = headerAddr( area );
-    // address of fake header * before* the alignment location
-    HeapManager.Storage.Header * fakeHeader = headerAddr( user );
-    // SKULLDUGGERY: insert the offset to the start of the actual storage block and remember alignment
-    fakeHeader->kind.fake.offset = (char *)fakeHeader - (char *)realHeader;
-    // SKULLDUGGERY: odd alignment imples fake header
-    fakeHeader->kind.fake.alignment = alignment | 1;
-
-    return user;
-} // memalign2
-
-
-extern "C" {
-    void * malloc( size_t size ) {
-		#ifdef __STATISTICS__
-		__atomic_add_fetch( &malloc_calls, 1, __ATOMIC_SEQ_CST );
-		__atomic_add_fetch( &malloc_storage, size, __ATOMIC_SEQ_CST );
-		#endif // __STATISTICS__
-
-		return malloc2( size );
-    } // malloc
-
-
-    void * calloc( size_t noOfElems, size_t elemSize ) {
-		size_t size = noOfElems * elemSize;
-		#ifdef __STATISTICS__
-		__atomic_add_fetch( &calloc_calls, 1, __ATOMIC_SEQ_CST );
-		__atomic_add_fetch( &calloc_storage, size, __ATOMIC_SEQ_CST );
-		#endif // __STATISTICS__
-
-		char * area = (char *)malloc2( size );
-		if ( unlikely( area == 0 ) ) return 0;
-		HeapManager.Storage.Header * header;
-		HeapManager.FreeHeader * freeElem;
-		size_t asize, alignment;
-		_Bool mapped __attribute__(( unused )) = headers( "calloc", area, header, freeElem, asize, alignment );
-		#ifndef __CFA_DEBUG__
-		// Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 
-		if ( ! mapped )
-		#endif // __CFA_DEBUG__
-			memset( area, '\0', asize - sizeof(HeapManager.Storage) ); // set to zeros
-		header->kind.real.blockSize |= 2;		// mark as zero filled
-		return area;
-    } // calloc
-
-
-    void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ) {
-		size_t size = noOfElems * elemSize;
-		#ifdef __STATISTICS__
-		__atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST );
-		__atomic_add_fetch( &cmemalign_storage, size, __ATOMIC_SEQ_CST );
-		#endif // __STATISTICS__
-
-		char * area = (char *)memalign2( alignment, size );
-		if ( unlikely( area == 0 ) ) return 0;
-		HeapManager.Storage.Header * header;
-		HeapManager.FreeHeader * freeElem;
-		size_t asize;
-		_Bool mapped __attribute__(( unused )) = headers( "cmemalign", area, header, freeElem, asize, alignment );
-		#ifndef __CFA_DEBUG__
-		// Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 
-		if ( ! mapped )
-		#endif // __CFA_DEBUG__
-			memset( area, '\0', asize - ( (char *)area - (char *)header ) ); // set to zeros
-		header->kind.real.blockSize |= 2;				// mark as zero filled
-
-		return area;
-    } // cmemalign
-
-
-    void * realloc( void * addr, size_t size ) {
-		#ifdef __STATISTICS__
-		__atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST );
-		#endif // __STATISTICS__
-
-		if ( unlikely( addr == 0 ) ) return malloc2( size ); // special cases
-		if ( unlikely( size == 0 ) ) { free( addr ); return 0; }
-
-		HeapManager.Storage.Header * header;
-		HeapManager.FreeHeader * freeElem;
-		size_t asize, alignment = 0;
-		headers( "realloc", addr, header, freeElem, asize, alignment );
-
-		size_t usize = asize - ( (char *)addr - (char *)header ); // compute the amount of user storage in the block
-		if ( usize >= size ) {							// already sufficient storage
-			// This case does not result in a new profiler entry because the previous one still exists and it must match with
-			// the free for this memory.  Hence, this realloc does not appear in the profiler output.
-			return addr;
-		} // if
-
-		#ifdef __STATISTICS__
-		__atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST );
-		#endif // __STATISTICS__
-
-		void * area;
-		if ( unlikely( alignment != 0 ) ) {				// previous request memalign?
-			area = memalign( alignment, size );			// create new area
-		} else {
-			area = malloc2( size );	// create new area
-		} // if
-		if ( unlikely( area == 0 ) ) return 0;
-		if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill (calloc/cmemalign) ?
-			assert( (header->kind.real.blockSize & 1) == 0 );
-			_Bool mapped __attribute__(( unused )) = headers( "realloc", area, header, freeElem, asize, alignment );
-			#ifndef __CFA_DEBUG__
-			// Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 
-			if ( ! mapped )
-			#endif // __CFA_DEBUG__
-				memset( (char *)area + usize, '\0', asize - ( (char *)area - (char *)header ) - usize ); // zero-fill back part
-			header->kind.real.blockSize |= 2;			// mark new request as zero fill
-		} // if
-		memcpy( area, addr, usize );					// copy bytes
-		free( addr );
-		return area;
-    } // realloc
-
-
-    void * memalign( size_t alignment, size_t size ) {
-		#ifdef __STATISTICS__
-		__atomic_add_fetch( &memalign_calls, 1, __ATOMIC_SEQ_CST );
-		__atomic_add_fetch( &memalign_storage, size, __ATOMIC_SEQ_CST );
-		#endif // __STATISTICS__
-
-		void * area = memalign2( alignment, size );
-
-		return area;
-    } // memalign
-
-
-    void * aligned_alloc( size_t alignment, size_t size ) {
-		return memalign( alignment, size );
-    } // aligned_alloc
-
-
-    int posix_memalign( void ** memptr, size_t alignment, size_t size ) {
-		if ( alignment < sizeof(void *) || ! libPow2( alignment ) ) return EINVAL; // check alignment
-		* memptr = memalign( alignment, size );
-		if ( unlikely( * memptr == 0 ) ) return ENOMEM;
-		return 0;
-    } // posix_memalign
-
-
-    void * valloc( size_t size ) {
-		return memalign( pageSize, size );
-    } // valloc
-
-
-    void free( void * addr ) {
-		#ifdef __STATISTICS__
-		__atomic_add_fetch( &free_calls, 1, __ATOMIC_SEQ_CST );
-		#endif // __STATISTICS__
-
-		if ( unlikely( addr == 0 ) ) {					// special case
-			#ifdef __CFA_DEBUG__
-			if ( traceHeap() ) {
-				#define nullmsg "Free( 0x0 ) size:0\n"
-				// Do not debug print free( 0 ), as it can cause recursive entry from sprintf.
-				__cfaabi_dbg_bits_write( nullmsg, sizeof(nullmsg) - 1 );
-			} // if
-			#endif // __CFA_DEBUG__
-			return;
-		} // exit
-
-		doFree( addr );
-    } // free
-
-    int mallopt( int option, int value ) {
-		choose( option ) {
-		  case M_TOP_PAD:
-			if ( setHeapExpand( value ) ) fallthru default;
-		  case M_MMAP_THRESHOLD:
-			if ( setMmapStart( value ) ) fallthru default;
-		  default:
-			return 1;									// success, or unsupported
-		} // switch
-		return 0;										// error
-    } // mallopt
-
-
-	int malloc_trim( size_t ) {
-		return 0;										// => impossible to release memory
-	} // malloc_trim
-
-    size_t malloc_usable_size( void * addr ) {
-		if ( unlikely( addr == 0 ) ) return 0;			// null allocation has 0 size
-		HeapManager.Storage.Header * header;
-		HeapManager.FreeHeader * freeElem;
-		size_t size, alignment;
-
-		headers( "malloc_usable_size", addr, header, freeElem, size, alignment );
-		size_t usize = size - ( (char *)addr - (char *)header ); // compute the amount of user storage in the block
-		return usize;
-    } // malloc_usable_size
-
-
-    size_t malloc_alignment( void * addr ) {
-		if ( unlikely( addr == 0 ) ) return libAlign();	// minimum alignment
-		HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) );
-		if ( (header->kind.fake.alignment & 1) == 1 ) {	// fake header ?
-			return header->kind.fake.alignment & -2;	// remove flag from value
-		} else {
-			return libAlign ();							// minimum alignment
-		} // if
-    } // malloc_alignment
-
-
-    _Bool malloc_zero_fill( void * addr ) {
-		if ( unlikely( addr == 0 ) ) return false;		// null allocation is not zero fill
-		HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) );
-		if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ?
-			header = (HeapManager.Storage.Header *)((char *)header - header->kind.fake.offset);
-		} // if
-		return (header->kind.real.blockSize & 2) != 0;	// zero filled (calloc/cmemalign) ?
-    } // malloc_zero_fill
-
-
-    void malloc_stats( void ) {
-		#ifdef __STATISTICS__
-		printStats();
-		if ( checkFree() ) checkFree( heapManager );
-		#endif // __STATISTICS__
-    } // malloc_stats
-
-
-    int malloc_stats_fd( int fd ) {
-		#ifdef __STATISTICS__
-		int temp = statfd;
-		statfd = fd;
-		return temp;
-		#else
-		return -1;
-		#endif // __STATISTICS__
-    } // malloc_stats_fd
-
-
-	int malloc_info( int options, FILE * stream ) {
-		return printStatsXML( stream );
-	} // malloc_info
-
-
-	void * malloc_get_state( void ) {
-		return 0;
-	} // malloc_get_state
-
-
-	int malloc_set_state( void * ptr ) {
-		return 0;
-	} // malloc_set_state
-} // extern "C"
-
-
-// Local Variables: //
-// tab-width: 4 //
-// compile-command: "cfa -nodebug -O2 heap.c" //
-// End: //
Index: libcfa/src/heap.cfa
===================================================================
--- libcfa/src/heap.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/heap.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,979 @@
+// 
+// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+// 
+// heap.c -- 
+// 
+// Author           : Peter A. Buhr
+// Created On       : Tue Dec 19 21:58:35 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Tue Jul 31 18:08:50 2018
+// Update Count     : 470
+// 
+
+#include <unistd.h>										// sbrk, sysconf
+#include <stdbool.h>									// true, false
+#include <stdio.h>										// snprintf, fileno
+#include <errno.h>										// errno
+extern "C" {
+#include <sys/mman.h>									// mmap, munmap
+} // extern "C"
+
+#include "bits/align.h"									// libPow2
+#include "bits/defs.h"									// likely, unlikely
+#include "bits/locks.h"									// __spinlock_t
+#include "startup.h"									// STARTUP_PRIORITY_MEMORY
+#include "stdlib"										// bsearchl
+#include "malloc.h"
+
+
+enum {
+	__CFA_DEFAULT_MMAP_START__ = (512 * 1024 + 1),
+	__CFA_DEFAULT_HEAP_EXPANSION__ = (1 * 1024 * 1024),
+};
+
+size_t default_mmap_start() __attribute__(( weak )) {
+    return __CFA_DEFAULT_MMAP_START__;
+} // default_mmap_start
+
+size_t default_heap_expansion() __attribute__(( weak )) {
+    return __CFA_DEFAULT_HEAP_EXPANSION__;
+} // default_heap_expansion
+
+
+// supported mallopt options
+#ifndef M_MMAP_THRESHOLD
+#define M_MMAP_THRESHOLD (-1)
+#endif // M_TOP_PAD
+#ifndef M_TOP_PAD
+#define M_TOP_PAD (-2)
+#endif // M_TOP_PAD
+
+#define FASTLOOKUP
+#define __STATISTICS__
+
+#define SPINLOCK 0
+#define LOCKFREE 1
+#define BUCKETLOCK SPINLOCK
+#if BUCKETLOCK == LOCKFREE
+#include <uStackLF.h>
+#endif // LOCKFREE
+
+#define ALIGN 16
+
+// enum { NoBucketSizes = 93,								// number of buckets sizes
+// #ifdef FASTLOOKUP
+// 	   LookupSizes = 65536,								// number of fast lookup sizes
+// #endif // FASTLOOKUP
+// };
+#define NoBucketSizes 93								// number of buckets sizes
+#ifdef FASTLOOKUP
+#define LookupSizes 65536								// number of fast lookup sizes
+#endif // FASTLOOKUP
+
+
+static _Bool traceHeap = false;
+
+inline _Bool traceHeap() {
+	return traceHeap;
+} // traceHeap
+
+_Bool traceHeapOn() {
+	_Bool temp = traceHeap;
+	traceHeap = true;
+	return temp;
+} // traceHeapOn
+
+_Bool traceHeapOff() {
+	_Bool temp = traceHeap;
+	traceHeap = false;
+	return temp;
+} // traceHeapOff
+
+
+static _Bool checkFree = false;
+
+inline _Bool checkFree() {
+	return checkFree;
+} // checkFree
+
+_Bool checkFreeOn() {
+	_Bool temp = checkFree;
+	checkFree = true;
+	return temp;
+} // checkFreeOn
+
+_Bool checkFreeOff() {
+	_Bool temp = checkFree;
+	checkFree = false;
+	return temp;
+} // checkFreeOff
+
+
+// static _Bool traceHeapTerm = false;
+
+// inline _Bool traceHeapTerm() {
+// 	return traceHeapTerm;
+// } // traceHeapTerm
+
+// _Bool traceHeapTermOn() {
+// 	_Bool temp = traceHeapTerm;
+// 	traceHeapTerm = true;
+// 	return temp;
+// } // traceHeapTermOn
+
+// _Bool traceHeapTermOff() {
+// 	_Bool temp = traceHeapTerm;
+// 	traceHeapTerm = false;
+// 	return temp;
+// } // traceHeapTermOff
+
+
+#ifdef __CFA_DEBUG__
+static unsigned int allocfree;							// running total of allocations minus frees
+static unsigned int appStart;							// storage allocation when application starts
+
+static void checkUnfreed() {
+	unsigned int total = allocfree - appStart;
+    if ( total != 0 ) {
+		// DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
+		// char helpText[512];
+		// int len = snprintf( helpText, 512, "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"
+		// 					"Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n",
+		// 					(long int)getpid(), total, total ); // always print the UNIX pid
+		// __cfaabi_dbg_bits_write( helpText, len );
+    } // if
+} // checkUnfreed
+
+extern "C" {
+void heapAppStart() {									// called by __cfaabi_appready_startup
+	appStart = allocfree;
+} // heapAppStart
+
+void heapAppStop() {									// called by __cfaabi_appready_startdown
+	checkUnfreed();
+} // heapAppStop
+} // extern "C"
+#endif // __CFA_DEBUG__
+
+
+struct HeapManager {
+//	struct FreeHeader;									// forward declaration
+
+	struct Storage {
+	    struct Header {									// header
+			union Kind {
+				struct RealHeader {
+					union {
+						struct {						// 32-bit word => 64-bit header, 64-bit word => 128-bit header
+							#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ && __SIZEOF_POINTER__ == 4
+							uint32_t padding;			// unused, force home/blocksize to overlay alignment in fake header
+							#endif // __ORDER_BIG_ENDIAN__ && __U_WORDSIZE__ == 32
+
+							union {
+//								FreeHeader * home;		// allocated block points back to home locations (must overlay alignment)
+								void * home;			// allocated block points back to home locations (must overlay alignment)
+								size_t blockSize;		// size for munmap (must overlay alignment)
+								#if BUCKLOCK == SPINLOCK
+								Storage * next;			// freed block points next freed block of same size
+								#endif // SPINLOCK
+							};
+
+							#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && __SIZEOF_POINTER__ == 4
+							uint32_t padding;			// unused, force home/blocksize to overlay alignment in fake header
+							#endif // __ORDER_LITTLE_ENDIAN__ && __U_WORDSIZE__ == 32
+
+						};
+						#if BUCKLOCK == LOCKFREE
+						Stack<Storage>::Link next;		// freed block points next freed block of same size (double-wide)
+						#endif // LOCKFREE
+					};
+				} real;
+				struct FakeHeader {
+					#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+					uint32_t alignment;					// low-order bits of home/blockSize used for tricks
+					#endif // __ORDER_LITTLE_ENDIAN__
+
+					uint32_t offset;
+
+					#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+					uint32_t alignment;					// low-order bits of home/blockSize used for tricks
+					#endif // __ORDER_BIG_ENDIAN__
+				} fake;
+			} kind;
+	    } header; // Header
+	    char pad[ALIGN - sizeof( Header )];
+	    char data[0];									// storage
+	}; // Storage
+
+	static_assert( ALIGN >= sizeof( Storage ), "ALIGN < sizeof( Storage )" );
+
+	struct FreeHeader {
+		#if BUCKLOCK == SPINLOCK
+	    __spinlock_t lock;								// must be first field for alignment
+	    Storage * freeList;
+		#elif BUCKLOCK == LOCKFREE
+	    StackLF<Storage> freeList;
+		#else
+			#error undefined lock type for bucket lock
+		#endif // SPINLOCK
+	    size_t blockSize;								// size of allocations on this list
+	}; // FreeHeader
+
+	// must be first fields for alignment
+	__spinlock_t extlock;								// protects allocation-buffer extension
+	FreeHeader freeLists[NoBucketSizes];				// buckets for different allocation sizes
+
+	void * heapBegin;									// start of heap
+	void * heapEnd;										// logical end of heap
+	size_t heapRemaining;								// amount of storage not allocated in the current chunk
+}; // HeapManager
+
+static inline size_t getKey( const HeapManager.FreeHeader & freeheader ) { return freeheader.blockSize; }
+// statically allocated variables => zero filled.
+
+
+static size_t pageSize;									// architecture pagesize
+static size_t heapExpand;								// sbrk advance
+static size_t mmapStart;								// cross over point for mmap
+static unsigned int maxBucketsUsed;						// maximum number of buckets in use
+
+// Powers of 2 are common allocation sizes, so make powers of 2 generate the minimum required size.
+static unsigned int bucketSizes[NoBucketSizes] @= {		// different bucket sizes
+    16, 32, 48, 64,
+    64 + sizeof(HeapManager.Storage), 96, 112, 128, 128 + sizeof(HeapManager.Storage), 160, 192, 224,
+    256 + sizeof(HeapManager.Storage), 320, 384, 448, 512 + sizeof(HeapManager.Storage), 640, 768, 896,
+    1_024 + sizeof(HeapManager.Storage), 1_536, 2_048 + sizeof(HeapManager.Storage), 2_560, 3_072, 3_584, 4_096 + sizeof(HeapManager.Storage), 6_144,
+    8_192 + sizeof(HeapManager.Storage), 9_216, 10_240, 11_264, 12_288, 13_312, 14_336, 15_360,
+    16_384 + sizeof(HeapManager.Storage), 18_432, 20_480, 22_528, 24_576, 26_624, 28_672, 30_720,
+    32_768 + sizeof(HeapManager.Storage), 36_864, 40_960, 45_056, 49_152, 53_248, 57_344, 61_440,
+    65_536 + sizeof(HeapManager.Storage), 73_728, 81_920, 90_112, 98_304, 106_496, 114_688, 122_880,
+    131_072 + sizeof(HeapManager.Storage), 147_456, 163_840, 180_224, 196_608, 212_992, 229_376, 245_760,
+    262_144 + sizeof(HeapManager.Storage), 294_912, 327_680, 360_448, 393_216, 425_984, 458_752, 491_520,
+    524_288 + sizeof(HeapManager.Storage), 655_360, 786_432, 917_504, 1_048_576 + sizeof(HeapManager.Storage), 1_179_648, 1_310_720, 1_441_792,
+    1_572_864, 1_703_936, 1_835_008, 1_966_080, 2_097_152 + sizeof(HeapManager.Storage), 2_621_440, 3_145_728, 3_670_016,
+    4_194_304 + sizeof(HeapManager.Storage)
+};
+#ifdef FASTLOOKUP
+static unsigned char lookup[LookupSizes];				// O(1) lookup for small sizes
+#endif // FASTLOOKUP
+static int mmapFd = -1;									// fake or actual fd for anonymous file
+
+
+#ifdef __CFA_DEBUG__
+static _Bool heapBoot = 0;								// detect recursion during boot
+#endif // __CFA_DEBUG__
+static HeapManager heapManager __attribute__(( aligned (128) )) @= {}; // size of cache line to prevent false sharing
+
+
+static inline _Bool setMmapStart( size_t value ) {
+    if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return true;
+    mmapStart = value;									// set global
+
+    // find the closest bucket size less than or equal to the mmapStart size
+    maxBucketsUsed = bsearchl( (unsigned int)mmapStart, bucketSizes, NoBucketSizes ); // binary search
+    assert( maxBucketsUsed < NoBucketSizes );			// subscript failure ?
+    assert( mmapStart <= bucketSizes[maxBucketsUsed] ); // search failure ?
+    return false;
+} // setMmapStart
+
+
+static void ?{}( HeapManager & manager ) with ( manager ) {
+    pageSize = sysconf( _SC_PAGESIZE );
+    
+    for ( unsigned int i = 0; i < NoBucketSizes; i += 1 ) { // initialize the free lists
+		freeLists[i].blockSize = bucketSizes[i];
+    } // for
+
+	#ifdef FASTLOOKUP
+    unsigned int idx = 0;
+    for ( unsigned int i = 0; i < LookupSizes; i += 1 ) {
+		if ( i > bucketSizes[idx] ) idx += 1;
+		lookup[i] = idx;
+    } // for
+	#endif // FASTLOOKUP
+
+    if ( setMmapStart( default_mmap_start() ) ) {
+		abort( "HeapManager : internal error, mmap start initialization failure." );
+    } // if
+    heapExpand = default_heap_expansion();
+
+    char * End = (char *)sbrk( 0 );
+    sbrk( (char *)libCeiling( (long unsigned int)End, libAlign() ) - End ); // move start of heap to multiple of alignment
+    heapBegin = heapEnd = sbrk( 0 );					// get new start point
+} // HeapManager
+
+
+static void ^?{}( HeapManager & ) {
+	#ifdef __STATISTICS__
+	// if ( traceHeapTerm() ) {
+	// 	printStats();
+	// 	if ( checkfree() ) checkFree( heapManager, true );
+	// } // if
+	#endif // __STATISTICS__
+} // ~HeapManager
+
+
+static void memory_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_MEMORY ) ));
+void memory_startup( void ) {
+	#ifdef __CFA_DEBUG__
+	if ( unlikely( heapBoot ) ) {					// check for recursion during system boot
+		// DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
+		abort( "boot() : internal error, recursively invoked during system boot." );
+	} // if
+	heapBoot = true;
+	#endif // __CFA_DEBUG__
+
+	assert( heapManager.heapBegin == 0 );
+	heapManager{};
+} // memory_startup
+
+static void memory_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_MEMORY ) ));
+void memory_shutdown( void ) {
+	^heapManager{};
+} // memory_shutdown
+
+
+#ifdef __STATISTICS__
+static unsigned long long int mmap_storage;				// heap statistics counters
+static unsigned int mmap_calls;
+static unsigned long long int munmap_storage;
+static unsigned int munmap_calls;
+static unsigned long long int sbrk_storage;
+static unsigned int sbrk_calls;
+static unsigned long long int malloc_storage;
+static unsigned int malloc_calls;
+static unsigned long long int free_storage;
+static unsigned int free_calls;
+static unsigned long long int calloc_storage;
+static unsigned int calloc_calls;
+static unsigned long long int memalign_storage;
+static unsigned int memalign_calls;
+static unsigned long long int cmemalign_storage;
+static unsigned int cmemalign_calls;
+static unsigned long long int realloc_storage;
+static unsigned int realloc_calls;
+
+static int statfd;										// statistics file descriptor (changed by malloc_stats_fd)
+
+
+// Use "write" because streams may be shutdown when calls are made.
+static void printStats() {
+    char helpText[512];
+	__cfaabi_dbg_bits_print_buffer( helpText, 512,
+			"\nHeap statistics:\n"
+			"  malloc: calls %u / storage %llu\n"
+			"  calloc: calls %u / storage %llu\n"
+			"  memalign: calls %u / storage %llu\n"
+			"  cmemalign: calls %u / storage %llu\n"
+			"  realloc: calls %u / storage %llu\n"
+			"  free: calls %u / storage %llu\n"
+			"  mmap: calls %u / storage %llu\n"
+			"  munmap: calls %u / storage %llu\n"
+			"  sbrk: calls %u / storage %llu\n",
+			malloc_calls, malloc_storage,
+			calloc_calls, calloc_storage,
+			memalign_calls, memalign_storage,
+			cmemalign_calls, cmemalign_storage,
+			realloc_calls, realloc_storage,
+			free_calls, free_storage,
+			mmap_calls, mmap_storage,
+			munmap_calls, munmap_storage,
+			sbrk_calls, sbrk_storage
+		);
+} // printStats
+
+
+static int printStatsXML( FILE * stream ) {
+    char helpText[512];
+    int len = snprintf( helpText, 512,
+						"<malloc version=\"1\">\n"
+						"<heap nr=\"0\">\n"
+						"<sizes>\n"
+						"</sizes>\n"
+						"<total type=\"malloc\" count=\"%u\" size=\"%llu\"/>\n"
+						"<total type=\"calloc\" count=\"%u\" size=\"%llu\"/>\n"
+						"<total type=\"memalign\" count=\"%u\" size=\"%llu\"/>\n"
+						"<total type=\"cmemalign\" count=\"%u\" size=\"%llu\"/>\n"
+						"<total type=\"realloc\" count=\"%u\" size=\"%llu\"/>\n"
+						"<total type=\"free\" count=\"%u\" size=\"%llu\"/>\n"
+						"<total type=\"mmap\" count=\"%u\" size=\"%llu\"/>\n"
+						"<total type=\"munmap\" count=\"%u\" size=\"%llu\"/>\n"
+						"<total type=\"sbrk\" count=\"%u\" size=\"%llu\"/>\n"
+						"</malloc>",
+						malloc_calls, malloc_storage,
+						calloc_calls, calloc_storage,
+						memalign_calls, memalign_storage,
+						cmemalign_calls, cmemalign_storage,
+						realloc_calls, realloc_storage,
+						free_calls, free_storage,
+						mmap_calls, mmap_storage,
+						munmap_calls, munmap_storage,
+						sbrk_calls, sbrk_storage
+		);
+    return write( fileno( stream ), helpText, len );	// -1 => error
+} // printStatsXML
+#endif // __STATISTICS__
+
+
+static inline void noMemory() {
+    abort( "Heap memory exhausted at %zu bytes.\n"
+			"Possible cause is very large memory allocation and/or large amount of unfreed storage allocated by the program or system/library routines.",
+			((char *)(sbrk( 0 )) - (char *)(heapManager.heapBegin)) );
+} // noMemory
+
+
+static inline void checkAlign( size_t alignment ) {
+    if ( alignment < sizeof(void *) || ! libPow2( alignment ) ) {
+		abort( "Alignment %zu for memory allocation is less than sizeof(void *) and/or not a power of 2.", alignment );
+    } // if
+} // checkAlign
+
+
+static inline _Bool setHeapExpand( size_t value ) {
+    if ( heapExpand < pageSize ) return true;
+    heapExpand = value;
+    return false;
+} // setHeapExpand
+
+
+static inline void checkHeader( _Bool check, const char * name, void * addr ) {
+    if ( unlikely( check ) ) {							// bad address ?
+		abort( "Attempt to %s storage %p with address outside the heap.\n"
+				"Possible cause is duplicate free on same block or overwriting of memory.",
+				name, addr );
+    } // if
+} // checkHeader
+
+
+static inline void fakeHeader( HeapManager.Storage.Header *& header, size_t & size, size_t & alignment ) {
+    if ( unlikely( (header->kind.fake.alignment & 1) == 1 ) ) { // fake header ?
+		size_t offset = header->kind.fake.offset;
+		alignment = header->kind.fake.alignment & -2;	// remove flag from value
+		#ifdef __CFA_DEBUG__
+		checkAlign( alignment );						// check alignment
+		#endif // __CFA_DEBUG__
+		header = (HeapManager.Storage.Header *)((char *)header - offset);
+    } // if
+} // fakeHeader
+
+
+#define headerAddr( addr ) ((HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) ))
+
+static inline _Bool headers( const char * name, void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) {
+    header = headerAddr( addr );
+
+    if ( unlikely( heapEnd < addr ) ) {					// mmapped ?
+		fakeHeader( header, size, alignment );
+		size = header->kind.real.blockSize & -3;		// mmap size
+		return true;
+    } // if
+
+	#ifdef __CFA_DEBUG__
+    checkHeader( addr < heapBegin || header < (HeapManager.Storage.Header *)heapBegin, name, addr ); // bad low address ?
+	#endif // __CFA_DEBUG__
+    // header may be safe to dereference
+    fakeHeader( header, size, alignment );
+	#ifdef __CFA_DEBUG__
+    checkHeader( header < (HeapManager.Storage.Header *)heapBegin || (HeapManager.Storage.Header *)heapEnd < header, name, addr ); // bad address ? (offset could be + or -)
+	#endif // __CFA_DEBUG__
+
+    freeElem = (HeapManager.FreeHeader *)((size_t)header->kind.real.home & -3);
+	#ifdef __CFA_DEBUG__
+    if ( freeElem < &freeLists[0] || &freeLists[NoBucketSizes] <= freeElem ) {
+		abort( "Attempt to %s storage %p with corrupted header.\n"
+			   "Possible cause is duplicate free on same block or overwriting of header information.",
+			   name, addr );
+    } // if
+	#endif // __CFA_DEBUG__
+    size = freeElem->blockSize;
+    return false;
+} // headers
+
+
+static inline void * extend( size_t size ) with ( heapManager ) {
+    lock( extlock __cfaabi_dbg_ctx2 );
+    ptrdiff_t rem = heapRemaining - size;
+    if ( rem < 0 ) {
+		// If the size requested is bigger than the current remaining storage, increase the size of the heap.
+
+		size_t increase = libCeiling( size > heapExpand ? size : heapExpand, libAlign() );
+		if ( sbrk( increase ) == (void *)-1 ) {
+			unlock( extlock );
+			errno = ENOMEM;
+			return 0;
+		} // if
+#ifdef __STATISTICS__
+		sbrk_calls += 1;
+		sbrk_storage += increase;
+#endif // __STATISTICS__
+#ifdef __CFA_DEBUG__
+		// Set new memory to garbage so subsequent uninitialized usages might fail.
+		memset( (char *)heapEnd + heapRemaining, '\377', increase );
+#endif // __CFA_DEBUG__
+		rem = heapRemaining + increase - size;
+    } // if
+
+    HeapManager.Storage * block = (HeapManager.Storage *)heapEnd;
+    heapRemaining = rem;
+    heapEnd = (char *)heapEnd + size;
+    unlock( extlock );
+    return block;
+} // extend
+
+
+static inline void * doMalloc( size_t size ) with ( heapManager ) {
+    HeapManager.Storage * block;
+
+    // Look up size in the size list.  Make sure the user request includes space for the header that must be allocated
+    // along with the block and is a multiple of the alignment size.
+
+    size_t tsize = size + sizeof(HeapManager.Storage);
+    if ( likely( tsize < mmapStart ) ) {				// small size => sbrk
+		HeapManager.FreeHeader * freeElem =
+			#ifdef FASTLOOKUP
+			tsize < LookupSizes ? &freeLists[lookup[tsize]] :
+			#endif // FASTLOOKUP
+			bsearchl( tsize, freeLists, (size_t)maxBucketsUsed ); // binary search
+		assert( freeElem <= &freeLists[maxBucketsUsed] ); // subscripting error ?
+		assert( tsize <= freeElem->blockSize );			// search failure ?
+		tsize = freeElem->blockSize;					// total space needed for request
+
+		// Spin until the lock is acquired for this particular size of block.
+
+		#if defined( SPINLOCK )
+		lock( freeElem->lock __cfaabi_dbg_ctx2 );
+		block = freeElem->freeList;						// remove node from stack
+		#else
+		block = freeElem->freeList.pop();
+		#endif // SPINLOCK
+		if ( unlikely( block == 0 ) ) {					// no free block ?
+			#if defined( SPINLOCK )
+			unlock( freeElem->lock );
+			#endif // SPINLOCK
+			// Freelist for that size was empty, so carve it out of the heap if there's enough left, or get some more
+			// and then carve it off.
+
+			block = (HeapManager.Storage *)extend( tsize );	// mutual exclusion on call
+			if ( unlikely( block == 0 ) ) return 0;
+			#if defined( SPINLOCK )
+		} else {
+			freeElem->freeList = block->header.kind.real.next;
+			unlock( freeElem->lock );
+			#endif // SPINLOCK
+		} // if
+
+		block->header.kind.real.home = freeElem;		// pointer back to free list of apropriate size
+    } else {											// large size => mmap
+		tsize = libCeiling( tsize, pageSize );			// must be multiple of page size
+		#ifdef __STATISTICS__
+		__atomic_add_fetch( &mmap_calls, 1, __ATOMIC_SEQ_CST );
+		__atomic_add_fetch( &mmap_storage, tsize, __ATOMIC_SEQ_CST );
+		#endif // __STATISTICS__
+		block = (HeapManager.Storage *)mmap( 0, tsize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, mmapFd, 0 );
+		if ( block == (HeapManager.Storage *)MAP_FAILED ) {
+			// Do not call strerror( errno ) as it may call malloc.
+			abort( "(HeapManager &)0x%p.doMalloc() : internal error, mmap failure, size:%zu error:%d.", &heapManager, tsize, errno );
+		} // if
+#ifdef __CFA_DEBUG__
+		// Set new memory to garbage so subsequent uninitialized usages might fail.
+		memset( block, '\377', tsize );
+#endif // __CFA_DEBUG__
+		block->header.kind.real.blockSize = tsize;		// storage size for munmap
+    } // if
+
+    void * area = &(block->data);						// adjust off header to user bytes
+
+	#ifdef __CFA_DEBUG__
+    assert( ((uintptr_t)area & (libAlign() - 1)) == 0 ); // minimum alignment ?
+    __atomic_add_fetch( &allocfree, tsize, __ATOMIC_SEQ_CST );
+	if ( traceHeap() ) {
+		enum { BufferSize = 64 };
+		char helpText[BufferSize];
+		int len = snprintf( helpText, BufferSize, "%p = Malloc( %zu ) (allocated %zu)\n", area, size, tsize );
+		// int len = snprintf( helpText, BufferSize, "Malloc %p %zu\n", area, size );
+		__cfaabi_dbg_bits_write( helpText, len );
+	} // if
+	#endif // __CFA_DEBUG__
+
+    return area;
+} // doMalloc
+
+
+static inline void doFree( void * addr ) with ( heapManager ) {
+	#ifdef __CFA_DEBUG__
+    if ( unlikely( heapManager.heapBegin == 0 ) ) {
+		abort( "doFree( %p ) : internal error, called before heap is initialized.", addr );
+    } // if
+	#endif // __CFA_DEBUG__
+
+    HeapManager.Storage.Header * header;
+    HeapManager.FreeHeader * freeElem;
+    size_t size, alignment;								// not used (see realloc)
+
+    if ( headers( "free", addr, header, freeElem, size, alignment ) ) { // mmapped ?
+		#ifdef __STATISTICS__
+		__atomic_add_fetch( &munmap_calls, 1, __ATOMIC_SEQ_CST );
+		__atomic_add_fetch( &munmap_storage, size, __ATOMIC_SEQ_CST );
+		#endif // __STATISTICS__
+		if ( munmap( header, size ) == -1 ) {
+			#ifdef __CFA_DEBUG__
+			abort( "Attempt to deallocate storage %p not allocated or with corrupt header.\n"
+					"Possible cause is invalid pointer.",
+					addr );
+			#endif // __CFA_DEBUG__
+		} // if
+    } else {
+		#ifdef __CFA_DEBUG__
+		// Set free memory to garbage so subsequent usages might fail.
+		memset( ((HeapManager.Storage *)header)->data, '\377', freeElem->blockSize - sizeof( HeapManager.Storage ) );
+		#endif // __CFA_DEBUG__
+
+		#ifdef __STATISTICS__
+		free_storage += size;
+		#endif // __STATISTICS__
+		#if defined( SPINLOCK )
+		lock( freeElem->lock __cfaabi_dbg_ctx2 );		// acquire spin lock
+		header->kind.real.next = freeElem->freeList;	// push on stack
+		freeElem->freeList = (HeapManager.Storage *)header;
+		unlock( freeElem->lock );						// release spin lock
+		#else
+		freeElem->freeList.push( *(HeapManager.Storage *)header );
+		#endif // SPINLOCK
+    } // if
+
+	#ifdef __CFA_DEBUG__
+    __atomic_add_fetch( &allocfree, -size, __ATOMIC_SEQ_CST );
+    if ( traceHeap() ) {
+		enum { BufferSize = 64 };
+		char helpText[BufferSize];
+		int len = snprintf( helpText, BufferSize, "Free( %p ) size:%zu\n", addr, size );
+		__cfaabi_dbg_bits_write( helpText, len );
+    } // if
+	#endif // __CFA_DEBUG__
+} // doFree
+
+
+size_t checkFree( HeapManager & manager ) with ( manager ) {
+    size_t total = 0;
+	#ifdef __STATISTICS__
+    __cfaabi_dbg_bits_acquire();
+    __cfaabi_dbg_bits_print_nolock( "\nBin lists (bin size : free blocks on list)\n" );
+	#endif // __STATISTICS__
+    for ( unsigned int i = 0; i < maxBucketsUsed; i += 1 ) {
+		size_t size = freeLists[i].blockSize;
+		#ifdef __STATISTICS__
+		unsigned int N = 0;
+		#endif // __STATISTICS__
+		#if defined( SPINLOCK )
+		for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0; p = p->header.kind.real.next ) {
+		#else
+		for ( HeapManager.Storage * p = freeLists[i].freeList.top(); p != 0; p = p->header.kind.real.next.top ) {
+		#endif // SPINLOCK
+			total += size;
+			#ifdef __STATISTICS__
+			N += 1;
+			#endif // __STATISTICS__
+	    } // for
+		#ifdef __STATISTICS__
+	    __cfaabi_dbg_bits_print_nolock( "%7zu, %-7u  ", size, N );
+	    if ( (i + 1) % 8 == 0 ) __cfaabi_dbg_bits_print_nolock( "\n" );
+		#endif // __STATISTICS__
+	} // for
+	#ifdef __STATISTICS__
+	__cfaabi_dbg_bits_print_nolock( "\ntotal free blocks:%zu\n", total );
+	__cfaabi_dbg_bits_release();
+	#endif // __STATISTICS__
+	return (char *)heapEnd - (char *)heapBegin - total;
+} // checkFree
+
+
+static inline void * malloc2( size_t size ) {			// necessary for malloc statistics
+	assert( heapManager.heapBegin != 0 );
+    void * area = doMalloc( size );
+    if ( unlikely( area == 0 ) ) errno = ENOMEM;		// POSIX
+    return area;
+} // malloc2
+
+
+static inline void * memalign2( size_t alignment, size_t size ) { // necessary for malloc statistics
+#ifdef __CFA_DEBUG__
+    checkAlign( alignment );							// check alignment
+#endif // __CFA_DEBUG__
+
+    // if alignment <= default alignment, do normal malloc as two headers are unnecessary
+    if ( unlikely( alignment <= libAlign() ) ) return malloc2( size );
+
+    // Allocate enough storage to guarantee an address on the alignment boundary, and sufficient space before it for
+    // administrative storage. NOTE, WHILE THERE ARE 2 HEADERS, THE FIRST ONE IS IMPLICITLY CREATED BY DOMALLOC.
+    //      .-------------v-----------------v----------------v----------,
+    //      | Real Header | ... padding ... |   Fake Header  | data ... |
+    //      `-------------^-----------------^-+--------------^----------'
+    //      |<--------------------------------' offset/align |<-- alignment boundary
+
+    // subtract libAlign() because it is already the minimum alignment
+    // add sizeof(Storage) for fake header
+    char * area = (char *)doMalloc( size + alignment - libAlign() + sizeof(HeapManager.Storage) );
+    if ( unlikely( area == 0 ) ) return area;
+
+    // address in the block of the "next" alignment address
+    char * user = (char *)libCeiling( (uintptr_t)(area + sizeof(HeapManager.Storage)), alignment );
+
+    // address of header from malloc
+    HeapManager.Storage.Header * realHeader = headerAddr( area );
+    // address of fake header * before* the alignment location
+    HeapManager.Storage.Header * fakeHeader = headerAddr( user );
+    // SKULLDUGGERY: insert the offset to the start of the actual storage block and remember alignment
+    fakeHeader->kind.fake.offset = (char *)fakeHeader - (char *)realHeader;
+    // SKULLDUGGERY: odd alignment imples fake header
+    fakeHeader->kind.fake.alignment = alignment | 1;
+
+    return user;
+} // memalign2
+
+
+extern "C" {
+    void * malloc( size_t size ) {
+		#ifdef __STATISTICS__
+		__atomic_add_fetch( &malloc_calls, 1, __ATOMIC_SEQ_CST );
+		__atomic_add_fetch( &malloc_storage, size, __ATOMIC_SEQ_CST );
+		#endif // __STATISTICS__
+
+		return malloc2( size );
+    } // malloc
+
+
+    void * calloc( size_t noOfElems, size_t elemSize ) {
+		size_t size = noOfElems * elemSize;
+		#ifdef __STATISTICS__
+		__atomic_add_fetch( &calloc_calls, 1, __ATOMIC_SEQ_CST );
+		__atomic_add_fetch( &calloc_storage, size, __ATOMIC_SEQ_CST );
+		#endif // __STATISTICS__
+
+		char * area = (char *)malloc2( size );
+		if ( unlikely( area == 0 ) ) return 0;
+		HeapManager.Storage.Header * header;
+		HeapManager.FreeHeader * freeElem;
+		size_t asize, alignment;
+		_Bool mapped __attribute__(( unused )) = headers( "calloc", area, header, freeElem, asize, alignment );
+		#ifndef __CFA_DEBUG__
+		// Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 
+		if ( ! mapped )
+		#endif // __CFA_DEBUG__
+			memset( area, '\0', asize - sizeof(HeapManager.Storage) ); // set to zeros
+		header->kind.real.blockSize |= 2;		// mark as zero filled
+		return area;
+    } // calloc
+
+
+    void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ) {
+		size_t size = noOfElems * elemSize;
+		#ifdef __STATISTICS__
+		__atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST );
+		__atomic_add_fetch( &cmemalign_storage, size, __ATOMIC_SEQ_CST );
+		#endif // __STATISTICS__
+
+		char * area = (char *)memalign2( alignment, size );
+		if ( unlikely( area == 0 ) ) return 0;
+		HeapManager.Storage.Header * header;
+		HeapManager.FreeHeader * freeElem;
+		size_t asize;
+		_Bool mapped __attribute__(( unused )) = headers( "cmemalign", area, header, freeElem, asize, alignment );
+		#ifndef __CFA_DEBUG__
+		// Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 
+		if ( ! mapped )
+		#endif // __CFA_DEBUG__
+			memset( area, '\0', asize - ( (char *)area - (char *)header ) ); // set to zeros
+		header->kind.real.blockSize |= 2;				// mark as zero filled
+
+		return area;
+    } // cmemalign
+
+
+    void * realloc( void * addr, size_t size ) {
+		#ifdef __STATISTICS__
+		__atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST );
+		#endif // __STATISTICS__
+
+		if ( unlikely( addr == 0 ) ) return malloc2( size ); // special cases
+		if ( unlikely( size == 0 ) ) { free( addr ); return 0; }
+
+		HeapManager.Storage.Header * header;
+		HeapManager.FreeHeader * freeElem;
+		size_t asize, alignment = 0;
+		headers( "realloc", addr, header, freeElem, asize, alignment );
+
+		size_t usize = asize - ( (char *)addr - (char *)header ); // compute the amount of user storage in the block
+		if ( usize >= size ) {							// already sufficient storage
+			// This case does not result in a new profiler entry because the previous one still exists and it must match with
+			// the free for this memory.  Hence, this realloc does not appear in the profiler output.
+			return addr;
+		} // if
+
+		#ifdef __STATISTICS__
+		__atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST );
+		#endif // __STATISTICS__
+
+		void * area;
+		if ( unlikely( alignment != 0 ) ) {				// previous request memalign?
+			area = memalign( alignment, size );			// create new area
+		} else {
+			area = malloc2( size );	// create new area
+		} // if
+		if ( unlikely( area == 0 ) ) return 0;
+		if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill (calloc/cmemalign) ?
+			assert( (header->kind.real.blockSize & 1) == 0 );
+			_Bool mapped __attribute__(( unused )) = headers( "realloc", area, header, freeElem, asize, alignment );
+			#ifndef __CFA_DEBUG__
+			// Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 
+			if ( ! mapped )
+			#endif // __CFA_DEBUG__
+				memset( (char *)area + usize, '\0', asize - ( (char *)area - (char *)header ) - usize ); // zero-fill back part
+			header->kind.real.blockSize |= 2;			// mark new request as zero fill
+		} // if
+		memcpy( area, addr, usize );					// copy bytes
+		free( addr );
+		return area;
+    } // realloc
+
+
+    void * memalign( size_t alignment, size_t size ) {
+		#ifdef __STATISTICS__
+		__atomic_add_fetch( &memalign_calls, 1, __ATOMIC_SEQ_CST );
+		__atomic_add_fetch( &memalign_storage, size, __ATOMIC_SEQ_CST );
+		#endif // __STATISTICS__
+
+		void * area = memalign2( alignment, size );
+
+		return area;
+    } // memalign
+
+
+    void * aligned_alloc( size_t alignment, size_t size ) {
+		return memalign( alignment, size );
+    } // aligned_alloc
+
+
+    int posix_memalign( void ** memptr, size_t alignment, size_t size ) {
+		if ( alignment < sizeof(void *) || ! libPow2( alignment ) ) return EINVAL; // check alignment
+		* memptr = memalign( alignment, size );
+		if ( unlikely( * memptr == 0 ) ) return ENOMEM;
+		return 0;
+    } // posix_memalign
+
+
+    void * valloc( size_t size ) {
+		return memalign( pageSize, size );
+    } // valloc
+
+
+    void free( void * addr ) {
+		#ifdef __STATISTICS__
+		__atomic_add_fetch( &free_calls, 1, __ATOMIC_SEQ_CST );
+		#endif // __STATISTICS__
+
+		if ( unlikely( addr == 0 ) ) {					// special case
+			#ifdef __CFA_DEBUG__
+			if ( traceHeap() ) {
+				#define nullmsg "Free( 0x0 ) size:0\n"
+				// Do not debug print free( 0 ), as it can cause recursive entry from sprintf.
+				__cfaabi_dbg_bits_write( nullmsg, sizeof(nullmsg) - 1 );
+			} // if
+			#endif // __CFA_DEBUG__
+			return;
+		} // exit
+
+		doFree( addr );
+    } // free
+
+    int mallopt( int option, int value ) {
+		choose( option ) {
+		  case M_TOP_PAD:
+			if ( setHeapExpand( value ) ) fallthru default;
+		  case M_MMAP_THRESHOLD:
+			if ( setMmapStart( value ) ) fallthru default;
+		  default:
+			return 1;									// success, or unsupported
+		} // switch
+		return 0;										// error
+    } // mallopt
+
+
+	int malloc_trim( size_t ) {
+		return 0;										// => impossible to release memory
+	} // malloc_trim
+
+    size_t malloc_usable_size( void * addr ) {
+		if ( unlikely( addr == 0 ) ) return 0;			// null allocation has 0 size
+		HeapManager.Storage.Header * header;
+		HeapManager.FreeHeader * freeElem;
+		size_t size, alignment;
+
+		headers( "malloc_usable_size", addr, header, freeElem, size, alignment );
+		size_t usize = size - ( (char *)addr - (char *)header ); // compute the amount of user storage in the block
+		return usize;
+    } // malloc_usable_size
+
+
+    size_t malloc_alignment( void * addr ) {
+		if ( unlikely( addr == 0 ) ) return libAlign();	// minimum alignment
+		HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) );
+		if ( (header->kind.fake.alignment & 1) == 1 ) {	// fake header ?
+			return header->kind.fake.alignment & -2;	// remove flag from value
+		} else {
+			return libAlign ();							// minimum alignment
+		} // if
+    } // malloc_alignment
+
+
+    _Bool malloc_zero_fill( void * addr ) {
+		if ( unlikely( addr == 0 ) ) return false;		// null allocation is not zero fill
+		HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) );
+		if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ?
+			header = (HeapManager.Storage.Header *)((char *)header - header->kind.fake.offset);
+		} // if
+		return (header->kind.real.blockSize & 2) != 0;	// zero filled (calloc/cmemalign) ?
+    } // malloc_zero_fill
+
+
+    void malloc_stats( void ) {
+		#ifdef __STATISTICS__
+		printStats();
+		if ( checkFree() ) checkFree( heapManager );
+		#endif // __STATISTICS__
+    } // malloc_stats
+
+
+    int malloc_stats_fd( int fd ) {
+		#ifdef __STATISTICS__
+		int temp = statfd;
+		statfd = fd;
+		return temp;
+		#else
+		return -1;
+		#endif // __STATISTICS__
+    } // malloc_stats_fd
+
+
+	int malloc_info( int options, FILE * stream ) {
+		return printStatsXML( stream );
+	} // malloc_info
+
+
+	void * malloc_get_state( void ) {
+		return 0;
+	} // malloc_get_state
+
+
+	int malloc_set_state( void * ptr ) {
+		return 0;
+	} // malloc_set_state
+} // extern "C"
+
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa -nodebug -O2 heap.c" //
+// End: //
Index: libcfa/src/interpose.c
===================================================================
--- libcfa/src/interpose.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,276 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// interpose.c --
-//
-// Author           : Thierry Delisle
-// Created On       : Wed Mar 29 16:10:31 2017
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sat May  5 11:37:35 2018
-// Update Count     : 111
-//
-
-#include <stdarg.h>										// va_start, va_end
-#include <string.h>										// strlen
-#include <unistd.h>										// _exit, getpid
-#define __USE_GNU
-#include <signal.h>
-#undef __USE_GNU
-extern "C" {
-#include <dlfcn.h>										// dlopen, dlsym
-#include <execinfo.h>									// backtrace, messages
-}
-
-#include "bits/debug.h"
-#include "bits/defs.h"
-#include "bits/signal.h"								// sigHandler_?
-#include "startup.h"									// STARTUP_PRIORITY_CORE
-
-//=============================================================================================
-// Interposing helpers
-//=============================================================================================
-
-void preload_libgcc(void) {
-	dlopen( "libgcc_s.so.1", RTLD_NOW );
-	if ( const char * error = dlerror() ) abort( "interpose_symbol : internal error pre-loading libgcc, %s\n", error );
-}
-
-typedef void (* generic_fptr_t)(void);
-generic_fptr_t interpose_symbol( const char * symbol, const char * version ) {
-	const char * error;
-
-	static void * library;
-	if ( ! library ) {
-		#if defined( RTLD_NEXT )
-			library = RTLD_NEXT;
-		#else
-			// missing RTLD_NEXT => must hard-code library name, assuming libstdc++
-			library = dlopen( "libc.so.6", RTLD_LAZY );
-			error = dlerror();
-			if ( error ) {
-				abort( "interpose_symbol : failed to open libc, %s\n", error );
-			}
-		#endif
-	} // if
-
-	union { generic_fptr_t fptr; void * ptr; } originalFunc;
-
-	#if defined( _GNU_SOURCE )
-		if ( version ) {
-			originalFunc.ptr = dlvsym( library, symbol, version );
-		} else {
-			originalFunc.ptr = dlsym( library, symbol );
-		}
-	#else
-		originalFunc.ptr = dlsym( library, symbol );
-	#endif // _GNU_SOURCE
-
-	error = dlerror();
-	if ( error ) abort( "interpose_symbol : internal error, %s\n", error );
-
-	return originalFunc.fptr;
-}
-
-#define INTERPOSE_LIBC( x, ver ) __cabi_libc.x = (typeof(__cabi_libc.x))interpose_symbol( #x, ver )
-
-//=============================================================================================
-// Interposition Startup logic
-//=============================================================================================
-
-void sigHandler_segv ( __CFA_SIGPARMS__ );
-void sigHandler_ill  ( __CFA_SIGPARMS__ );
-void sigHandler_fpe  ( __CFA_SIGPARMS__ );
-void sigHandler_abort( __CFA_SIGPARMS__ );
-void sigHandler_term ( __CFA_SIGPARMS__ );
-
-struct {
-	void (* exit)( int ) __attribute__(( __noreturn__ ));
-	void (* abort)( void ) __attribute__(( __noreturn__ ));
-} __cabi_libc;
-
-extern "C" {
-	void __cfaabi_interpose_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_CORE ) ));
-	void __cfaabi_interpose_startup( void ) {
-		const char *version = NULL;
-
-		preload_libgcc();
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
-		INTERPOSE_LIBC( abort, version );
-		INTERPOSE_LIBC( exit , version );
-#pragma GCC diagnostic pop
-
-		// Failure handler
-		__cfaabi_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO );
-		__cfaabi_sigaction( SIGBUS , sigHandler_segv , SA_SIGINFO );
-		__cfaabi_sigaction( SIGILL , sigHandler_ill  , SA_SIGINFO );
-		__cfaabi_sigaction( SIGFPE , sigHandler_fpe  , SA_SIGINFO );
-		__cfaabi_sigaction( SIGABRT, sigHandler_abort, SA_SIGINFO | SA_RESETHAND);
-		__cfaabi_sigaction( SIGTERM, sigHandler_term , SA_SIGINFO );
-		__cfaabi_sigaction( SIGINT , sigHandler_term , SA_SIGINFO );
-	}
-}
-
-//=============================================================================================
-// Terminating Signals logic
-//=============================================================================================
-
-// Forward declare abort after the __typeof__ call to avoid ambiguities
-void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
-void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
-
-extern "C" {
-	void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) {
-		abort( NULL );
-	}
-
-	void __cabi_abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) {
-		va_list argp;
-		va_start( argp, fmt );
-		abort( fmt, argp );
-		va_end( argp );
-	}
-
-	void exit( int status ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) {
-		__cabi_libc.exit( status );
-	}
-}
-
-void * kernel_abort    ( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return NULL; }
-void   kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}
-int kernel_abort_lastframe( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 4; }
-
-enum { abort_text_size = 1024 };
-static char abort_text[ abort_text_size ];
-static int abort_lastframe;
-
-void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )) {
-    va_list args;
-    va_start( args, fmt );
-    vfprintf( stderr, fmt, args );
-    va_end( args );
-	__cabi_libc.exit( status );
-}
-
-void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) {
-	void * kernel_data = kernel_abort();			// must be done here to lock down kernel
-	int len;
-
-	abort_lastframe = kernel_abort_lastframe();
-	len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
-	__cfaabi_dbg_bits_write( abort_text, len );
-
-	if ( fmt ) {
-		va_list args;
-		va_start( args, fmt );
-
-		len = vsnprintf( abort_text, abort_text_size, fmt, args );
-		va_end( args );
-		__cfaabi_dbg_bits_write( abort_text, len );
-
-		if ( fmt[strlen( fmt ) - 1] != '\n' ) {		// add optional newline if missing at the end of the format text
-			__cfaabi_dbg_bits_write( "\n", 1 );
-		}
-	}
-
-	kernel_abort_msg( kernel_data, abort_text, abort_text_size );
-	__cabi_libc.abort();
-}
-
-static void __cfaabi_backtrace() {
-	enum {
-		Frames = 50,									// maximum number of stack frames
-		Start = 8,										// skip first N stack frames
-	};
-
-	void * array[Frames];
-	size_t size = backtrace( array, Frames );
-	char ** messages = backtrace_symbols( array, size );
-
-	// find executable name
-	*index( messages[0], '(' ) = '\0';
-	__cfaabi_dbg_bits_print_nolock( "Stack back trace for: %s\n", messages[0]);
-
-	for ( int i = Start; i < size - abort_lastframe && messages != NULL; i += 1 ) {
-		char * name = NULL, * offset_begin = NULL, * offset_end = NULL;
-
-		for ( char * p = messages[i]; *p; ++p ) {
-			//__cfaabi_dbg_bits_print_nolock( "X %s\n", p);
-			// find parantheses and +offset
-			if ( *p == '(' ) {
-				name = p;
-			}
-			else if ( *p == '+' ) {
-				offset_begin = p;
-			}
-			else if ( *p == ')' ) {
-				offset_end = p;
-				break;
-			}
-		}
-
-		// if line contains symbol print it
-		int frameNo = i - Start;
-		if ( name && offset_begin && offset_end && name < offset_begin ) {
-			// delimit strings
-			*name++ = '\0';
-			*offset_begin++ = '\0';
-			*offset_end++ = '\0';
-
-			__cfaabi_dbg_bits_print_nolock( "(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end);
-		}
-		// otherwise, print the whole line
-		else {
-			__cfaabi_dbg_bits_print_nolock( "(%i) %s\n", frameNo, messages[i] );
-		}
-	}
-	free( messages );
-}
-
-void sigHandler_segv( __CFA_SIGPARMS__ ) {
-	abort( "Addressing invalid memory at location %p\n"
-			"Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript.\n",
-			sfp->si_addr );
-}
-
-void sigHandler_ill( __CFA_SIGPARMS__ ) {
-	abort( "Executing illegal instruction at location %p.\n"
-			"Possible cause is stack corruption.\n",
-			sfp->si_addr );
-}
-
-void sigHandler_fpe( __CFA_SIGPARMS__ ) {
-	const char * msg;
-
-	choose( sfp->si_code ) {
-	  case FPE_INTDIV, FPE_FLTDIV: msg = "divide by zero";
-	  case FPE_FLTOVF: msg = "overflow";
-	  case FPE_FLTUND: msg = "underflow";
-	  case FPE_FLTRES: msg = "inexact result";
-	  case FPE_FLTINV: msg = "invalid operation";
-	  default: msg = "unknown";
-	} // choose
-	abort( "Computation error %s at location %p.\n", msg, sfp->si_addr );
-}
-
-void sigHandler_abort( __CFA_SIGPARMS__ ) {
-	__cfaabi_backtrace();
-
-	// reset default signal handler
-	__cfaabi_sigdefault( SIGABRT );
-
-	raise( SIGABRT );
-}
-
-void sigHandler_term( __CFA_SIGPARMS__ ) {
-	abort( "Application stopped by %s signal.", sig == SIGINT ? "an interrupt (SIGINT)" : "a terminate (SIGTERM)" );
-}
-
-// Local Variables: //
-// mode: c //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/interpose.cfa
===================================================================
--- libcfa/src/interpose.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/interpose.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,276 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// interpose.c --
+//
+// Author           : Thierry Delisle
+// Created On       : Wed Mar 29 16:10:31 2017
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Sat May  5 11:37:35 2018
+// Update Count     : 111
+//
+
+#include <stdarg.h>										// va_start, va_end
+#include <string.h>										// strlen
+#include <unistd.h>										// _exit, getpid
+#define __USE_GNU
+#include <signal.h>
+#undef __USE_GNU
+extern "C" {
+#include <dlfcn.h>										// dlopen, dlsym
+#include <execinfo.h>									// backtrace, messages
+}
+
+#include "bits/debug.h"
+#include "bits/defs.h"
+#include "bits/signal.h"								// sigHandler_?
+#include "startup.h"									// STARTUP_PRIORITY_CORE
+
+//=============================================================================================
+// Interposing helpers
+//=============================================================================================
+
+void preload_libgcc(void) {
+	dlopen( "libgcc_s.so.1", RTLD_NOW );
+	if ( const char * error = dlerror() ) abort( "interpose_symbol : internal error pre-loading libgcc, %s\n", error );
+}
+
+typedef void (* generic_fptr_t)(void);
+generic_fptr_t interpose_symbol( const char * symbol, const char * version ) {
+	const char * error;
+
+	static void * library;
+	if ( ! library ) {
+		#if defined( RTLD_NEXT )
+			library = RTLD_NEXT;
+		#else
+			// missing RTLD_NEXT => must hard-code library name, assuming libstdc++
+			library = dlopen( "libc.so.6", RTLD_LAZY );
+			error = dlerror();
+			if ( error ) {
+				abort( "interpose_symbol : failed to open libc, %s\n", error );
+			}
+		#endif
+	} // if
+
+	union { generic_fptr_t fptr; void * ptr; } originalFunc;
+
+	#if defined( _GNU_SOURCE )
+		if ( version ) {
+			originalFunc.ptr = dlvsym( library, symbol, version );
+		} else {
+			originalFunc.ptr = dlsym( library, symbol );
+		}
+	#else
+		originalFunc.ptr = dlsym( library, symbol );
+	#endif // _GNU_SOURCE
+
+	error = dlerror();
+	if ( error ) abort( "interpose_symbol : internal error, %s\n", error );
+
+	return originalFunc.fptr;
+}
+
+#define INTERPOSE_LIBC( x, ver ) __cabi_libc.x = (typeof(__cabi_libc.x))interpose_symbol( #x, ver )
+
+//=============================================================================================
+// Interposition Startup logic
+//=============================================================================================
+
+void sigHandler_segv ( __CFA_SIGPARMS__ );
+void sigHandler_ill  ( __CFA_SIGPARMS__ );
+void sigHandler_fpe  ( __CFA_SIGPARMS__ );
+void sigHandler_abort( __CFA_SIGPARMS__ );
+void sigHandler_term ( __CFA_SIGPARMS__ );
+
+struct {
+	void (* exit)( int ) __attribute__(( __noreturn__ ));
+	void (* abort)( void ) __attribute__(( __noreturn__ ));
+} __cabi_libc;
+
+extern "C" {
+	void __cfaabi_interpose_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_CORE ) ));
+	void __cfaabi_interpose_startup( void ) {
+		const char *version = NULL;
+
+		preload_libgcc();
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
+		INTERPOSE_LIBC( abort, version );
+		INTERPOSE_LIBC( exit , version );
+#pragma GCC diagnostic pop
+
+		// Failure handler
+		__cfaabi_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO );
+		__cfaabi_sigaction( SIGBUS , sigHandler_segv , SA_SIGINFO );
+		__cfaabi_sigaction( SIGILL , sigHandler_ill  , SA_SIGINFO );
+		__cfaabi_sigaction( SIGFPE , sigHandler_fpe  , SA_SIGINFO );
+		__cfaabi_sigaction( SIGABRT, sigHandler_abort, SA_SIGINFO | SA_RESETHAND);
+		__cfaabi_sigaction( SIGTERM, sigHandler_term , SA_SIGINFO );
+		__cfaabi_sigaction( SIGINT , sigHandler_term , SA_SIGINFO );
+	}
+}
+
+//=============================================================================================
+// Terminating Signals logic
+//=============================================================================================
+
+// Forward declare abort after the __typeof__ call to avoid ambiguities
+void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
+void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
+
+extern "C" {
+	void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) {
+		abort( NULL );
+	}
+
+	void __cabi_abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) {
+		va_list argp;
+		va_start( argp, fmt );
+		abort( fmt, argp );
+		va_end( argp );
+	}
+
+	void exit( int status ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) {
+		__cabi_libc.exit( status );
+	}
+}
+
+void * kernel_abort    ( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return NULL; }
+void   kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}
+int kernel_abort_lastframe( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 4; }
+
+enum { abort_text_size = 1024 };
+static char abort_text[ abort_text_size ];
+static int abort_lastframe;
+
+void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )) {
+    va_list args;
+    va_start( args, fmt );
+    vfprintf( stderr, fmt, args );
+    va_end( args );
+	__cabi_libc.exit( status );
+}
+
+void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) {
+	void * kernel_data = kernel_abort();			// must be done here to lock down kernel
+	int len;
+
+	abort_lastframe = kernel_abort_lastframe();
+	len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
+	__cfaabi_dbg_bits_write( abort_text, len );
+
+	if ( fmt ) {
+		va_list args;
+		va_start( args, fmt );
+
+		len = vsnprintf( abort_text, abort_text_size, fmt, args );
+		va_end( args );
+		__cfaabi_dbg_bits_write( abort_text, len );
+
+		if ( fmt[strlen( fmt ) - 1] != '\n' ) {		// add optional newline if missing at the end of the format text
+			__cfaabi_dbg_bits_write( "\n", 1 );
+		}
+	}
+
+	kernel_abort_msg( kernel_data, abort_text, abort_text_size );
+	__cabi_libc.abort();
+}
+
+static void __cfaabi_backtrace() {
+	enum {
+		Frames = 50,									// maximum number of stack frames
+		Start = 8,										// skip first N stack frames
+	};
+
+	void * array[Frames];
+	size_t size = backtrace( array, Frames );
+	char ** messages = backtrace_symbols( array, size );
+
+	// find executable name
+	*index( messages[0], '(' ) = '\0';
+	__cfaabi_dbg_bits_print_nolock( "Stack back trace for: %s\n", messages[0]);
+
+	for ( int i = Start; i < size - abort_lastframe && messages != NULL; i += 1 ) {
+		char * name = NULL, * offset_begin = NULL, * offset_end = NULL;
+
+		for ( char * p = messages[i]; *p; ++p ) {
+			//__cfaabi_dbg_bits_print_nolock( "X %s\n", p);
+			// find parantheses and +offset
+			if ( *p == '(' ) {
+				name = p;
+			}
+			else if ( *p == '+' ) {
+				offset_begin = p;
+			}
+			else if ( *p == ')' ) {
+				offset_end = p;
+				break;
+			}
+		}
+
+		// if line contains symbol print it
+		int frameNo = i - Start;
+		if ( name && offset_begin && offset_end && name < offset_begin ) {
+			// delimit strings
+			*name++ = '\0';
+			*offset_begin++ = '\0';
+			*offset_end++ = '\0';
+
+			__cfaabi_dbg_bits_print_nolock( "(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end);
+		}
+		// otherwise, print the whole line
+		else {
+			__cfaabi_dbg_bits_print_nolock( "(%i) %s\n", frameNo, messages[i] );
+		}
+	}
+	free( messages );
+}
+
+void sigHandler_segv( __CFA_SIGPARMS__ ) {
+	abort( "Addressing invalid memory at location %p\n"
+			"Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript.\n",
+			sfp->si_addr );
+}
+
+void sigHandler_ill( __CFA_SIGPARMS__ ) {
+	abort( "Executing illegal instruction at location %p.\n"
+			"Possible cause is stack corruption.\n",
+			sfp->si_addr );
+}
+
+void sigHandler_fpe( __CFA_SIGPARMS__ ) {
+	const char * msg;
+
+	choose( sfp->si_code ) {
+	  case FPE_INTDIV, FPE_FLTDIV: msg = "divide by zero";
+	  case FPE_FLTOVF: msg = "overflow";
+	  case FPE_FLTUND: msg = "underflow";
+	  case FPE_FLTRES: msg = "inexact result";
+	  case FPE_FLTINV: msg = "invalid operation";
+	  default: msg = "unknown";
+	} // choose
+	abort( "Computation error %s at location %p.\n", msg, sfp->si_addr );
+}
+
+void sigHandler_abort( __CFA_SIGPARMS__ ) {
+	__cfaabi_backtrace();
+
+	// reset default signal handler
+	__cfaabi_sigdefault( SIGABRT );
+
+	raise( SIGABRT );
+}
+
+void sigHandler_term( __CFA_SIGPARMS__ ) {
+	abort( "Application stopped by %s signal.", sig == SIGINT ? "an interrupt (SIGINT)" : "a terminate (SIGTERM)" );
+}
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/iostream.c
===================================================================
--- libcfa/src/iostream.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,413 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// iostream.c --
-//
-// Author           : Peter A. Buhr
-// Created On       : Wed May 27 17:56:53 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Jun  2 08:24:56 2018
-// Update Count     : 471
-//
-
-#include "iostream"
-
-extern "C" {
-#include <stdio.h>
-#include <stdbool.h>									// true/false
-//#include <string.h>										// strlen, strcmp
-extern int strcmp (const char *__s1, const char *__s2) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
-extern size_t strlen (const char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
-#include <float.h>										// DBL_DIG, LDBL_DIG
-#include <complex.h>									// creal, cimag
-}
-
-forall( dtype ostype | ostream( ostype ) ) {
-	ostype & ?|?( ostype & os, _Bool b ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%s", b ? "true" : "false" );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, char ch ) {
-		fmt( os, "%c", ch );
-		if ( ch == '\n' ) setNL( os, true );
-		sepOff( os );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, signed char c ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%hhd", c );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, unsigned char c ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%hhu", c );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, short int si ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%hd", si );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, unsigned short int usi ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%hu", usi );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, int i ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%d", i );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, unsigned int ui ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%u", ui );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, long int li ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%ld", li );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, unsigned long int uli ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%lu", uli );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, long long int lli ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%lld", lli );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, unsigned long long int ulli ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%llu", ulli );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, float f ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%g", f );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, double d ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%.*lg", DBL_DIG, d );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, long double ld ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%.*Lg", LDBL_DIG, ld );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, float _Complex fc ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%g%+gi", crealf( fc ), cimagf( fc ) );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, double _Complex dc ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%.*lg%+.*lgi", DBL_DIG, creal( dc ), DBL_DIG, cimag( dc ) );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, long double _Complex ldc ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%.*Lg%+.*Lgi", LDBL_DIG, creall( ldc ), LDBL_DIG, cimagl( ldc ) );
-		return os;
-	} // ?|?
-
-	ostype & ?|?( ostype & os, const char * str ) {
-		enum { Open = 1, Close, OpenClose };
-		static const unsigned char mask[256] @= {
-			// opening delimiters, no space after
-			['('] : Open, ['['] : Open, ['{'] : Open,
-			['='] : Open, ['$'] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open,
-			[(unsigned char)'¡'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open,
-			// closing delimiters, no space before
-			[','] : Close, ['.'] : Close, [';'] : Close, ['!'] : Close, ['?'] : Close,
-			['%'] : Close, [(unsigned char)'¢'] : Close, [(unsigned char)'»'] : Close,
-			[')'] : Close, [']'] : Close, ['}'] : Close,
-			// opening-closing delimiters, no space before or after
-			['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose, [':'] : OpenClose,
-			[' '] : OpenClose, ['\f'] : OpenClose, ['\n'] : OpenClose, ['\r'] : OpenClose, ['\t'] : OpenClose, ['\v'] : OpenClose, // isspace
-		}; // mask
-
-	  if ( str[0] == '\0' ) { sepOff( os ); return os; } // null string => no separator
-
-		// first character IS NOT spacing or closing punctuation => add left separator
-		unsigned char ch = str[0];						// must make unsigned
-		if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {
-			fmt( os, "%s", sepGetCur( os ) );
-		} // if
-
-		// if string starts line, must reset to determine open state because separator is off
-		sepReset( os );									// reset separator
-
-		// last character IS spacing or opening punctuation => turn off separator for next item
-		size_t len = strlen( str );
-		ch = str[len - 1];								// must make unsigned
-		if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
-			sepOn( os );
-		} else {
-			sepOff( os );
-		} // if
-		if ( ch == '\n' ) setNL( os, true );			// check *AFTER* sepPrt call above as it resets NL flag
-		return write( os, str, len );
-	} // ?|?
-
-// 	ostype & ?|?( ostype & os, const char16_t * str ) {
-// 		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-// 		fmt( os, "%ls", str );
-// 		return os;
-// 	} // ?|?
-
-// #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
-// 	ostype & ?|?( ostype & os, const char32_t * str ) {
-// 		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-// 		fmt( os, "%ls", str );
-// 		return os;
-// 	} // ?|?
-// #endif // ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 )
-
-// 	ostype & ?|?( ostype & os, const wchar_t * str ) {
-// 		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-// 		fmt( os, "%ls", str );
-// 		return os;
-// 	} // ?|?
-
-	ostype & ?|?( ostype & os, const void * p ) {
-		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
-		fmt( os, "%p", p );
-		return os;
-	} // ?|?
-
-
-	// manipulators
-	ostype & ?|?( ostype & os, ostype & (* manip)( ostype & ) ) {
-		return manip( os );
-	} // ?|?
-
-	ostype & sep( ostype & os ) {
-		os | sepGet( os );
-		return os;
-	} // sep
-
-	ostype & sepTuple( ostype & os ) {
-		os | sepGetTuple( os );
-		return os;
-	} // sepTuple
-
-	ostype & endl( ostype & os ) {
-		os | '\n';
-		setNL( os, true );
-		flush( os );
-		sepOff( os );									// prepare for next line
-		return os;
-	} // endl
-
-	ostype & sepOn( ostype & os ) {
-		sepOn( os );
-		return os;
-	} // sepOn
-
-	ostype & sepOff( ostype & os ) {
-		sepOff( os );
-		return os;
-	} // sepOff
-
-	ostype & sepEnable( ostype & os ) {
-		sepEnable( os );
-		return os;
-	} // sepEnable
-
-	ostype & sepDisable( ostype & os ) {
-		sepDisable( os );
-		return os;
-	} // sepDisable
-} // distribution
-
-
-// tuples
-forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } )
-ostype & ?|?( ostype & os, T arg, Params rest ) {
-	os | arg;											// print first argument
-	sepSetCur( os, sepGetTuple( os ) );					// switch to tuple separator
-	os | rest;											// print remaining arguments
-	sepSetCur( os, sepGet( os ) );						// switch to regular separator
-	return os;
-} // ?|?
-
-//---------------------------------------
-
-// writes the range [begin, end) to the given stream
-forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
-void write( iterator_type begin, iterator_type end, ostype & os ) {
-	void print( elt_type i ) { os | i; }
-	for_each( begin, end, print );
-} // ?|?
-
-forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
-void write_reverse( iterator_type begin, iterator_type end, ostype & os ) {
-	void print( elt_type i ) { os | i; }
-	for_each_reverse( begin, end, print );
-} // ?|?
-
-//---------------------------------------
-
-forall( dtype istype | istream( istype ) ) {
-	istype & ?|?( istype & is, _Bool & b ) {
-		char val[6];
-		fmt( is, "%5s", val );
-		if ( strcmp( val, "true" ) == 0 ) b = true;
-		else if ( strcmp( val, "false" ) == 0 ) b = false;
-		else {
-			fprintf( stderr, "invalid _Bool constant\n" );
-			abort();
-		} // if
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, char & c ) {
-		fmt( is, "%c", &c );							// must pass pointer through varg to fmt
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, signed char & sc ) {
-		fmt( is, "%hhd", &sc );
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, unsigned char & usc ) {
-		fmt( is, "%hhu", &usc );
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, short int & si ) {
-		fmt( is, "%hd", &si );
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, unsigned short int & usi ) {
-		fmt( is, "%hu", &usi );
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, int & i ) {
-		fmt( is, "%d", &i );
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, unsigned int & ui ) {
-		fmt( is, "%u", &ui );
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, long int & li ) {
-		fmt( is, "%ld", &li );
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, unsigned long int & ulli ) {
-		fmt( is, "%lu", &ulli );
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, long long int & lli ) {
-		fmt( is, "%lld", &lli );
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, unsigned long long int & ulli ) {
-		fmt( is, "%llu", &ulli );
-		return is;
-	} // ?|?
-
-
-	istype & ?|?( istype & is, float & f ) {
-		fmt( is, "%f", &f );
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, double & d ) {
-		fmt( is, "%lf", &d );
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, long double & ld ) {
-		fmt( is, "%Lf", &ld );
-		return is;
-	} // ?|?
-
-
-	istype & ?|?( istype & is, float _Complex & fc ) {
-		float re, im;
-		fmt( is, "%g%gi", &re, &im );
-		fc = re + im * _Complex_I;
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, double _Complex & dc ) {
-		double re, im;
-		fmt( is, "%lf%lfi", &re, &im );
-		dc = re + im * _Complex_I;
-		return is;
-	} // ?|?
-
-	istype & ?|?( istype & is, long double _Complex & ldc ) {
-		long double re, im;
-		fmt( is, "%Lf%Lfi", &re, &im );
-		ldc = re + im * _Complex_I;
-		return is;
-	} // ?|?
-
-
-	// manipulators
-	istype & ?|?( istype & is, istype & (* manip)( istype & ) ) {
-		return manip( is );
-	} // ?|?
-
-	istype & endl( istype & is ) {
-		fmt( is, "%*[ \t\f\n\r\v]" );					// ignore whitespace
-		return is;
-	} // endl
-} // distribution
-
-_Istream_cstrUC cstr( char * str ) { return (_Istream_cstrUC){ str }; }
-forall( dtype istype | istream( istype ) )
-istype & ?|?( istype & is, _Istream_cstrUC cstr ) {
-	fmt( is, "%s", cstr.s );
-	return is;
-} // cstr
-
-_Istream_cstrC cstr( char * str, int size ) { return (_Istream_cstrC){ str, size }; }
-forall( dtype istype | istream( istype ) )
-istype & ?|?( istype & is, _Istream_cstrC cstr ) {
-	char buf[16];
-	sprintf( buf, "%%%ds", cstr.size );
-	fmt( is, buf, cstr.s );
-	return is;
-} // cstr
-
-// Local Variables: //
-// tab-width: 4 //
-// compile-command: "cfa iostream.c" //
-// End: //
Index: libcfa/src/iostream.cfa
===================================================================
--- libcfa/src/iostream.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/iostream.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,413 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// iostream.c --
+//
+// Author           : Peter A. Buhr
+// Created On       : Wed May 27 17:56:53 2015
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Sat Jun  2 08:24:56 2018
+// Update Count     : 471
+//
+
+#include "iostream"
+
+extern "C" {
+#include <stdio.h>
+#include <stdbool.h>									// true/false
+//#include <string.h>										// strlen, strcmp
+extern int strcmp (const char *__s1, const char *__s2) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
+extern size_t strlen (const char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
+#include <float.h>										// DBL_DIG, LDBL_DIG
+#include <complex.h>									// creal, cimag
+}
+
+forall( dtype ostype | ostream( ostype ) ) {
+	ostype & ?|?( ostype & os, _Bool b ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%s", b ? "true" : "false" );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, char ch ) {
+		fmt( os, "%c", ch );
+		if ( ch == '\n' ) setNL( os, true );
+		sepOff( os );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, signed char c ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%hhd", c );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, unsigned char c ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%hhu", c );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, short int si ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%hd", si );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, unsigned short int usi ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%hu", usi );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, int i ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%d", i );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, unsigned int ui ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%u", ui );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, long int li ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%ld", li );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, unsigned long int uli ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%lu", uli );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, long long int lli ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%lld", lli );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, unsigned long long int ulli ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%llu", ulli );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, float f ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%g", f );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, double d ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%.*lg", DBL_DIG, d );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, long double ld ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%.*Lg", LDBL_DIG, ld );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, float _Complex fc ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%g%+gi", crealf( fc ), cimagf( fc ) );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, double _Complex dc ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%.*lg%+.*lgi", DBL_DIG, creal( dc ), DBL_DIG, cimag( dc ) );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, long double _Complex ldc ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%.*Lg%+.*Lgi", LDBL_DIG, creall( ldc ), LDBL_DIG, cimagl( ldc ) );
+		return os;
+	} // ?|?
+
+	ostype & ?|?( ostype & os, const char * str ) {
+		enum { Open = 1, Close, OpenClose };
+		static const unsigned char mask[256] @= {
+			// opening delimiters, no space after
+			['('] : Open, ['['] : Open, ['{'] : Open,
+			['='] : Open, ['$'] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open,
+			[(unsigned char)'¡'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open,
+			// closing delimiters, no space before
+			[','] : Close, ['.'] : Close, [';'] : Close, ['!'] : Close, ['?'] : Close,
+			['%'] : Close, [(unsigned char)'¢'] : Close, [(unsigned char)'»'] : Close,
+			[')'] : Close, [']'] : Close, ['}'] : Close,
+			// opening-closing delimiters, no space before or after
+			['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose, [':'] : OpenClose,
+			[' '] : OpenClose, ['\f'] : OpenClose, ['\n'] : OpenClose, ['\r'] : OpenClose, ['\t'] : OpenClose, ['\v'] : OpenClose, // isspace
+		}; // mask
+
+	  if ( str[0] == '\0' ) { sepOff( os ); return os; } // null string => no separator
+
+		// first character IS NOT spacing or closing punctuation => add left separator
+		unsigned char ch = str[0];						// must make unsigned
+		if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {
+			fmt( os, "%s", sepGetCur( os ) );
+		} // if
+
+		// if string starts line, must reset to determine open state because separator is off
+		sepReset( os );									// reset separator
+
+		// last character IS spacing or opening punctuation => turn off separator for next item
+		size_t len = strlen( str );
+		ch = str[len - 1];								// must make unsigned
+		if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
+			sepOn( os );
+		} else {
+			sepOff( os );
+		} // if
+		if ( ch == '\n' ) setNL( os, true );			// check *AFTER* sepPrt call above as it resets NL flag
+		return write( os, str, len );
+	} // ?|?
+
+// 	ostype & ?|?( ostype & os, const char16_t * str ) {
+// 		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+// 		fmt( os, "%ls", str );
+// 		return os;
+// 	} // ?|?
+
+// #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
+// 	ostype & ?|?( ostype & os, const char32_t * str ) {
+// 		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+// 		fmt( os, "%ls", str );
+// 		return os;
+// 	} // ?|?
+// #endif // ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 )
+
+// 	ostype & ?|?( ostype & os, const wchar_t * str ) {
+// 		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+// 		fmt( os, "%ls", str );
+// 		return os;
+// 	} // ?|?
+
+	ostype & ?|?( ostype & os, const void * p ) {
+		if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
+		fmt( os, "%p", p );
+		return os;
+	} // ?|?
+
+
+	// manipulators
+	ostype & ?|?( ostype & os, ostype & (* manip)( ostype & ) ) {
+		return manip( os );
+	} // ?|?
+
+	ostype & sep( ostype & os ) {
+		os | sepGet( os );
+		return os;
+	} // sep
+
+	ostype & sepTuple( ostype & os ) {
+		os | sepGetTuple( os );
+		return os;
+	} // sepTuple
+
+	ostype & endl( ostype & os ) {
+		os | '\n';
+		setNL( os, true );
+		flush( os );
+		sepOff( os );									// prepare for next line
+		return os;
+	} // endl
+
+	ostype & sepOn( ostype & os ) {
+		sepOn( os );
+		return os;
+	} // sepOn
+
+	ostype & sepOff( ostype & os ) {
+		sepOff( os );
+		return os;
+	} // sepOff
+
+	ostype & sepEnable( ostype & os ) {
+		sepEnable( os );
+		return os;
+	} // sepEnable
+
+	ostype & sepDisable( ostype & os ) {
+		sepDisable( os );
+		return os;
+	} // sepDisable
+} // distribution
+
+
+// tuples
+forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } )
+ostype & ?|?( ostype & os, T arg, Params rest ) {
+	os | arg;											// print first argument
+	sepSetCur( os, sepGetTuple( os ) );					// switch to tuple separator
+	os | rest;											// print remaining arguments
+	sepSetCur( os, sepGet( os ) );						// switch to regular separator
+	return os;
+} // ?|?
+
+//---------------------------------------
+
+// writes the range [begin, end) to the given stream
+forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
+void write( iterator_type begin, iterator_type end, ostype & os ) {
+	void print( elt_type i ) { os | i; }
+	for_each( begin, end, print );
+} // ?|?
+
+forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
+void write_reverse( iterator_type begin, iterator_type end, ostype & os ) {
+	void print( elt_type i ) { os | i; }
+	for_each_reverse( begin, end, print );
+} // ?|?
+
+//---------------------------------------
+
+forall( dtype istype | istream( istype ) ) {
+	istype & ?|?( istype & is, _Bool & b ) {
+		char val[6];
+		fmt( is, "%5s", val );
+		if ( strcmp( val, "true" ) == 0 ) b = true;
+		else if ( strcmp( val, "false" ) == 0 ) b = false;
+		else {
+			fprintf( stderr, "invalid _Bool constant\n" );
+			abort();
+		} // if
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, char & c ) {
+		fmt( is, "%c", &c );							// must pass pointer through varg to fmt
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, signed char & sc ) {
+		fmt( is, "%hhd", &sc );
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, unsigned char & usc ) {
+		fmt( is, "%hhu", &usc );
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, short int & si ) {
+		fmt( is, "%hd", &si );
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, unsigned short int & usi ) {
+		fmt( is, "%hu", &usi );
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, int & i ) {
+		fmt( is, "%d", &i );
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, unsigned int & ui ) {
+		fmt( is, "%u", &ui );
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, long int & li ) {
+		fmt( is, "%ld", &li );
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, unsigned long int & ulli ) {
+		fmt( is, "%lu", &ulli );
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, long long int & lli ) {
+		fmt( is, "%lld", &lli );
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, unsigned long long int & ulli ) {
+		fmt( is, "%llu", &ulli );
+		return is;
+	} // ?|?
+
+
+	istype & ?|?( istype & is, float & f ) {
+		fmt( is, "%f", &f );
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, double & d ) {
+		fmt( is, "%lf", &d );
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, long double & ld ) {
+		fmt( is, "%Lf", &ld );
+		return is;
+	} // ?|?
+
+
+	istype & ?|?( istype & is, float _Complex & fc ) {
+		float re, im;
+		fmt( is, "%g%gi", &re, &im );
+		fc = re + im * _Complex_I;
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, double _Complex & dc ) {
+		double re, im;
+		fmt( is, "%lf%lfi", &re, &im );
+		dc = re + im * _Complex_I;
+		return is;
+	} // ?|?
+
+	istype & ?|?( istype & is, long double _Complex & ldc ) {
+		long double re, im;
+		fmt( is, "%Lf%Lfi", &re, &im );
+		ldc = re + im * _Complex_I;
+		return is;
+	} // ?|?
+
+
+	// manipulators
+	istype & ?|?( istype & is, istype & (* manip)( istype & ) ) {
+		return manip( is );
+	} // ?|?
+
+	istype & endl( istype & is ) {
+		fmt( is, "%*[ \t\f\n\r\v]" );					// ignore whitespace
+		return is;
+	} // endl
+} // distribution
+
+_Istream_cstrUC cstr( char * str ) { return (_Istream_cstrUC){ str }; }
+forall( dtype istype | istream( istype ) )
+istype & ?|?( istype & is, _Istream_cstrUC cstr ) {
+	fmt( is, "%s", cstr.s );
+	return is;
+} // cstr
+
+_Istream_cstrC cstr( char * str, int size ) { return (_Istream_cstrC){ str, size }; }
+forall( dtype istype | istream( istype ) )
+istype & ?|?( istype & is, _Istream_cstrC cstr ) {
+	char buf[16];
+	sprintf( buf, "%%%ds", cstr.size );
+	fmt( is, buf, cstr.s );
+	return is;
+} // cstr
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa iostream.c" //
+// End: //
Index: libcfa/src/iterator.c
===================================================================
--- libcfa/src/iterator.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,36 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// iterator.c -- 
-//
-// Author           : Richard C. Bilson
-// Created On       : Wed May 27 17:56:53 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Jul  7 08:38:23 2017
-// Update Count     : 28
-//
-
-#include "iterator"
-
-forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
-void for_each( iterator_type begin, iterator_type end, void (* func)( elt_type ) ) {
-	for ( iterator_type i = begin; i != end; ++i ) {
-		func( *i );
-	} // for
-} // for_each
-
-forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
-void for_each_reverse( iterator_type begin, iterator_type end, void (* func)( elt_type ) ) {
-	for ( iterator_type i = end; i != begin; ) {
-		--i;
-		func( *i );
-	} // for
-} // for_each_reverse
-
-// Local Variables: //
-// tab-width: 4 //
-// compile-command: "cfa iterator.c" //
-// End: //
Index: libcfa/src/iterator.cfa
===================================================================
--- libcfa/src/iterator.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/iterator.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,36 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// iterator.c -- 
+//
+// Author           : Richard C. Bilson
+// Created On       : Wed May 27 17:56:53 2015
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Fri Jul  7 08:38:23 2017
+// Update Count     : 28
+//
+
+#include "iterator"
+
+forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
+void for_each( iterator_type begin, iterator_type end, void (* func)( elt_type ) ) {
+	for ( iterator_type i = begin; i != end; ++i ) {
+		func( *i );
+	} // for
+} // for_each
+
+forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
+void for_each_reverse( iterator_type begin, iterator_type end, void (* func)( elt_type ) ) {
+	for ( iterator_type i = end; i != begin; ) {
+		--i;
+		func( *i );
+	} // for
+} // for_each_reverse
+
+// Local Variables: //
+// tab-width: 4 //
+// compile-command: "cfa iterator.c" //
+// End: //
Index: libcfa/src/limits.c
===================================================================
--- libcfa/src/limits.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,156 +1,0 @@
-// 
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-// 
-// limits.c -- 
-// 
-// Author           : Peter A. Buhr
-// Created On       : Wed Apr  6 18:06:52 2016
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Mar  1 16:22:51 2018
-// Update Count     : 74
-// 
-
-#include <limits.h>
-#include <float.h>
-#define __USE_GNU										// get M_* constants
-#include <math.h>
-#include <complex.h>
-#include "limits"
-
-// Integral Constants
-
-const signed char MIN = SCHAR_MIN;
-const unsigned char MIN = 0;
-const short int MIN = SHRT_MIN;
-const unsigned short int MIN = 0;
-const int MIN = INT_MIN;
-const unsigned int MIN = 0;
-const long int MIN = LONG_MIN;
-const unsigned long int MIN = 0;
-const long long int MIN = LLONG_MIN;
-const unsigned long long int MIN = 0;
-
-const signed char MAX = SCHAR_MAX;
-const unsigned char MAX = UCHAR_MAX;
-const short int MAX = SHRT_MAX;
-const unsigned short int MAX = USHRT_MAX;
-const int MAX = INT_MAX;
-const unsigned int MAX = UINT_MAX;
-const long int MAX = LONG_MAX;
-const unsigned long int MAX = ULONG_MAX;
-const long long int MAX = LLONG_MAX;
-const unsigned long long int MAX = ULLONG_MAX;
-
-// Floating-Point Constants
-
-const float MIN = FLT_MIN;
-const double MIN = DBL_MIN;
-const long double MIN = LDBL_MIN;
-const float _Complex MIN = __FLT_MIN__ + __FLT_MIN__ * I;
-const double _Complex MIN = DBL_MIN +  DBL_MIN * I;
-const long double _Complex MIN = LDBL_MIN + LDBL_MIN * I;
-
-const float MAX = FLT_MAX;
-const double MAX = DBL_MAX;
-const long double MAX = LDBL_MAX;
-const float _Complex MAX = FLT_MAX + FLT_MAX * I;
-const double _Complex MAX = DBL_MAX + DBL_MAX * I;
-const long double _Complex MAX = LDBL_MAX + LDBL_MAX * I;
-
-const float PI = (float)M_PI;							// pi
-const float PI_2 = (float)M_PI_2;						// pi / 2
-const float PI_4 = (float)M_PI_4;						// pi / 4
-const float _1_PI = (float)M_1_PI;						// 1 / pi
-const float _2_PI = (float)M_2_PI;						// 2 / pi
-const float _2_SQRT_PI = (float)M_2_SQRTPI;				// 2 / sqrt(pi)
-
-const double PI = M_PI;									// pi
-const double PI_2 = M_PI_2;								// pi / 2
-const double PI_4 = M_PI_4;								// pi / 4
-const double _1_PI = M_1_PI;							// 1 / pi
-const double _2_PI = M_2_PI;							// 2 / pi
-const double _2_SQRT_PI = M_2_SQRTPI;					// 2 / sqrt(pi)
-
-const long double PI = M_PIl;							// pi
-const long double PI_2 = M_PI_2l;						// pi / 2
-const long double PI_4 = M_PI_4l;						// pi / 4
-const long double _1_PI = M_1_PIl;						// 1 / pi
-const long double _2_PI = M_2_PIl;						// 2 / pi
-const long double _2_SQRT_PI = M_2_SQRTPIl;				// 2 / sqrt(pi)
-
-const float _Complex PI = (float)M_PI + 0.0_iF;			// pi
-const float _Complex PI_2 = (float)M_PI_2 + 0.0_iF;		// pi / 2
-const float _Complex PI_4 = (float)M_PI_4 + 0.0_iF;		// pi / 4
-const float _Complex _1_PI = (float)M_1_PI + 0.0_iF;	// 1 / pi
-const float _Complex _2_PI = (float)M_2_PI + 0.0_iF;	// 2 / pi
-const float _Complex _2_SQRT_PI = (float)M_2_SQRTPI + 0.0_iF; // 2 / sqrt(pi)
-
-const double _Complex PI = M_PI + 0.0_iD;				// pi
-const double _Complex PI_2 = M_PI_2 + 0.0_iD;			// pi / 2
-const double _Complex PI_4 = M_PI_4 + 0.0_iD;			// pi / 4
-const double _Complex _1_PI = M_1_PI + 0.0_iD;			// 1 / pi
-const double _Complex _2_PI = M_2_PI + 0.0_iD;			// 2 / pi
-const double _Complex _2_SQRT_PI = M_2_SQRTPI + 0.0_iD;	// 2 / sqrt(pi)
-
-const long double _Complex PI = M_PIl + 0.0_iL;			// pi
-const long double _Complex PI_2 = M_PI_2l + 0.0_iL;		// pi / 2
-const long double _Complex PI_4 = M_PI_4l + 0.0_iL;		// pi / 4
-const long double _Complex _1_PI = M_1_PIl + 0.0_iL;	// 1 / pi
-const long double _Complex _2_PI = M_2_PIl + 0.0_iL;	// 2 / pi
-const long double _Complex _2_SQRT_PI = M_2_SQRTPIl + 0.0_iL; // 2 / sqrt(pi)
-
-const float E = (float)M_E;								// e
-const float LOG2_E = (float)M_LOG2E;					// log_2(e)
-const float LOG10_E = (float)M_LOG10E;					// log_10(e)
-const float LN_2 = (float)M_LN2;						// log_e(2)
-const float LN_10 = (float)M_LN10;						// log_e(10)
-const float SQRT_2 = (float)M_SQRT2;					// sqrt(2)
-const float _1_SQRT_2 = (float)M_SQRT1_2;				// 1 / sqrt(2)
-
-const double E = M_E;									// e
-const double LOG2_E = M_LOG2E;							// log_2(e)
-const double LOG10_E = M_LOG10E;						// log_10(e)
-const double LN_2 = M_LN2;								// log_e(2)
-const double LN_10 = M_LN10;							// log_e(10)
-const double SQRT_2 = M_SQRT2;							// sqrt(2)
-const double _1_SQRT_2 = M_SQRT1_2;						// 1 / sqrt(2)
-
-const long double E = M_El;								// e
-const long double LOG2_E = M_LOG2El;					// log_2(e)
-const long double LOG10_E = M_LOG10El;					// log_10(e)
-const long double LN_2 = M_LN2l;						// log_e(2)
-const long double LN_10 = M_LN10l;						// log_e(10)
-const long double SQRT_2 = M_SQRT2l;					// sqrt(2)
-const long double _1_SQRT_2 = M_SQRT1_2l;				// 1 / sqrt(2)
-
-const float _Complex E = M_E + 0.0_iF;					// e
-const float _Complex LOG2_E = M_LOG2E + 0.0_iF;			// log_2(e)
-const float _Complex LOG10_E = M_LOG10E + 0.0_iF;		// log_10(e)
-const float _Complex LN_2 = M_LN2 + 0.0_iF;				// log_e(2)
-const float _Complex LN_10 = M_LN10 + 0.0_iF;			// log_e(10)
-const float _Complex SQRT_2 = M_SQRT2 + 0.0_iF;			// sqrt(2)
-const float _Complex _1_SQRT_2 = M_SQRT1_2 + 0.0_iF;	// 1 / sqrt(2)
-
-const double _Complex E = M_E + 0.0_iD;					// e
-const double _Complex LOG2_E = M_LOG2E + 0.0_iD;		// log_2(e)
-const double _Complex LOG10_E = M_LOG10E + 0.0_iD;		// log_10(e)
-const double _Complex LN_2 = M_LN2 + 0.0_iD;			// log_e(2)
-const double _Complex LN_10 = M_LN10 + 0.0_iD;			// log_e(10)
-const double _Complex SQRT_2 = M_SQRT2 + 0.0_iD;		// sqrt(2)
-const double _Complex _1_SQRT_2 = M_SQRT1_2 + 0.0_iD;	// 1 / sqrt(2)
-
-const long double _Complex E = M_El + 0.0_iL;			// e
-const long double _Complex LOG2_E = M_LOG2El + 0.0_iL;	// log_2(e)
-const long double _Complex LOG10_E = M_LOG10El + 0.0_iL; // log_10(e)
-const long double _Complex LN_2 = M_LN2l + 0.0_iL;		// log_e(2)
-const long double _Complex LN_10 = M_LN10l + 0.0_iL;	// log_e(10)
-const long double _Complex SQRT_2 = M_SQRT2l + 0.0_iL;	// sqrt(2)
-const long double _Complex _1_SQRT_2 = M_SQRT1_2l + 0.0_iL; // 1 / sqrt(2)
-
-// Local Variables: //
-// mode: c //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/limits.cfa
===================================================================
--- libcfa/src/limits.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/limits.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,156 @@
+// 
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+// 
+// limits.c -- 
+// 
+// Author           : Peter A. Buhr
+// Created On       : Wed Apr  6 18:06:52 2016
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Thu Mar  1 16:22:51 2018
+// Update Count     : 74
+// 
+
+#include <limits.h>
+#include <float.h>
+#define __USE_GNU										// get M_* constants
+#include <math.h>
+#include <complex.h>
+#include "limits"
+
+// Integral Constants
+
+const signed char MIN = SCHAR_MIN;
+const unsigned char MIN = 0;
+const short int MIN = SHRT_MIN;
+const unsigned short int MIN = 0;
+const int MIN = INT_MIN;
+const unsigned int MIN = 0;
+const long int MIN = LONG_MIN;
+const unsigned long int MIN = 0;
+const long long int MIN = LLONG_MIN;
+const unsigned long long int MIN = 0;
+
+const signed char MAX = SCHAR_MAX;
+const unsigned char MAX = UCHAR_MAX;
+const short int MAX = SHRT_MAX;
+const unsigned short int MAX = USHRT_MAX;
+const int MAX = INT_MAX;
+const unsigned int MAX = UINT_MAX;
+const long int MAX = LONG_MAX;
+const unsigned long int MAX = ULONG_MAX;
+const long long int MAX = LLONG_MAX;
+const unsigned long long int MAX = ULLONG_MAX;
+
+// Floating-Point Constants
+
+const float MIN = FLT_MIN;
+const double MIN = DBL_MIN;
+const long double MIN = LDBL_MIN;
+const float _Complex MIN = __FLT_MIN__ + __FLT_MIN__ * I;
+const double _Complex MIN = DBL_MIN +  DBL_MIN * I;
+const long double _Complex MIN = LDBL_MIN + LDBL_MIN * I;
+
+const float MAX = FLT_MAX;
+const double MAX = DBL_MAX;
+const long double MAX = LDBL_MAX;
+const float _Complex MAX = FLT_MAX + FLT_MAX * I;
+const double _Complex MAX = DBL_MAX + DBL_MAX * I;
+const long double _Complex MAX = LDBL_MAX + LDBL_MAX * I;
+
+const float PI = (float)M_PI;							// pi
+const float PI_2 = (float)M_PI_2;						// pi / 2
+const float PI_4 = (float)M_PI_4;						// pi / 4
+const float _1_PI = (float)M_1_PI;						// 1 / pi
+const float _2_PI = (float)M_2_PI;						// 2 / pi
+const float _2_SQRT_PI = (float)M_2_SQRTPI;				// 2 / sqrt(pi)
+
+const double PI = M_PI;									// pi
+const double PI_2 = M_PI_2;								// pi / 2
+const double PI_4 = M_PI_4;								// pi / 4
+const double _1_PI = M_1_PI;							// 1 / pi
+const double _2_PI = M_2_PI;							// 2 / pi
+const double _2_SQRT_PI = M_2_SQRTPI;					// 2 / sqrt(pi)
+
+const long double PI = M_PIl;							// pi
+const long double PI_2 = M_PI_2l;						// pi / 2
+const long double PI_4 = M_PI_4l;						// pi / 4
+const long double _1_PI = M_1_PIl;						// 1 / pi
+const long double _2_PI = M_2_PIl;						// 2 / pi
+const long double _2_SQRT_PI = M_2_SQRTPIl;				// 2 / sqrt(pi)
+
+const float _Complex PI = (float)M_PI + 0.0_iF;			// pi
+const float _Complex PI_2 = (float)M_PI_2 + 0.0_iF;		// pi / 2
+const float _Complex PI_4 = (float)M_PI_4 + 0.0_iF;		// pi / 4
+const float _Complex _1_PI = (float)M_1_PI + 0.0_iF;	// 1 / pi
+const float _Complex _2_PI = (float)M_2_PI + 0.0_iF;	// 2 / pi
+const float _Complex _2_SQRT_PI = (float)M_2_SQRTPI + 0.0_iF; // 2 / sqrt(pi)
+
+const double _Complex PI = M_PI + 0.0_iD;				// pi
+const double _Complex PI_2 = M_PI_2 + 0.0_iD;			// pi / 2
+const double _Complex PI_4 = M_PI_4 + 0.0_iD;			// pi / 4
+const double _Complex _1_PI = M_1_PI + 0.0_iD;			// 1 / pi
+const double _Complex _2_PI = M_2_PI + 0.0_iD;			// 2 / pi
+const double _Complex _2_SQRT_PI = M_2_SQRTPI + 0.0_iD;	// 2 / sqrt(pi)
+
+const long double _Complex PI = M_PIl + 0.0_iL;			// pi
+const long double _Complex PI_2 = M_PI_2l + 0.0_iL;		// pi / 2
+const long double _Complex PI_4 = M_PI_4l + 0.0_iL;		// pi / 4
+const long double _Complex _1_PI = M_1_PIl + 0.0_iL;	// 1 / pi
+const long double _Complex _2_PI = M_2_PIl + 0.0_iL;	// 2 / pi
+const long double _Complex _2_SQRT_PI = M_2_SQRTPIl + 0.0_iL; // 2 / sqrt(pi)
+
+const float E = (float)M_E;								// e
+const float LOG2_E = (float)M_LOG2E;					// log_2(e)
+const float LOG10_E = (float)M_LOG10E;					// log_10(e)
+const float LN_2 = (float)M_LN2;						// log_e(2)
+const float LN_10 = (float)M_LN10;						// log_e(10)
+const float SQRT_2 = (float)M_SQRT2;					// sqrt(2)
+const float _1_SQRT_2 = (float)M_SQRT1_2;				// 1 / sqrt(2)
+
+const double E = M_E;									// e
+const double LOG2_E = M_LOG2E;							// log_2(e)
+const double LOG10_E = M_LOG10E;						// log_10(e)
+const double LN_2 = M_LN2;								// log_e(2)
+const double LN_10 = M_LN10;							// log_e(10)
+const double SQRT_2 = M_SQRT2;							// sqrt(2)
+const double _1_SQRT_2 = M_SQRT1_2;						// 1 / sqrt(2)
+
+const long double E = M_El;								// e
+const long double LOG2_E = M_LOG2El;					// log_2(e)
+const long double LOG10_E = M_LOG10El;					// log_10(e)
+const long double LN_2 = M_LN2l;						// log_e(2)
+const long double LN_10 = M_LN10l;						// log_e(10)
+const long double SQRT_2 = M_SQRT2l;					// sqrt(2)
+const long double _1_SQRT_2 = M_SQRT1_2l;				// 1 / sqrt(2)
+
+const float _Complex E = M_E + 0.0_iF;					// e
+const float _Complex LOG2_E = M_LOG2E + 0.0_iF;			// log_2(e)
+const float _Complex LOG10_E = M_LOG10E + 0.0_iF;		// log_10(e)
+const float _Complex LN_2 = M_LN2 + 0.0_iF;				// log_e(2)
+const float _Complex LN_10 = M_LN10 + 0.0_iF;			// log_e(10)
+const float _Complex SQRT_2 = M_SQRT2 + 0.0_iF;			// sqrt(2)
+const float _Complex _1_SQRT_2 = M_SQRT1_2 + 0.0_iF;	// 1 / sqrt(2)
+
+const double _Complex E = M_E + 0.0_iD;					// e
+const double _Complex LOG2_E = M_LOG2E + 0.0_iD;		// log_2(e)
+const double _Complex LOG10_E = M_LOG10E + 0.0_iD;		// log_10(e)
+const double _Complex LN_2 = M_LN2 + 0.0_iD;			// log_e(2)
+const double _Complex LN_10 = M_LN10 + 0.0_iD;			// log_e(10)
+const double _Complex SQRT_2 = M_SQRT2 + 0.0_iD;		// sqrt(2)
+const double _Complex _1_SQRT_2 = M_SQRT1_2 + 0.0_iD;	// 1 / sqrt(2)
+
+const long double _Complex E = M_El + 0.0_iL;			// e
+const long double _Complex LOG2_E = M_LOG2El + 0.0_iL;	// log_2(e)
+const long double _Complex LOG10_E = M_LOG10El + 0.0_iL; // log_10(e)
+const long double _Complex LN_2 = M_LN2l + 0.0_iL;		// log_e(2)
+const long double _Complex LN_10 = M_LN10l + 0.0_iL;	// log_e(10)
+const long double _Complex SQRT_2 = M_SQRT2l + 0.0_iL;	// sqrt(2)
+const long double _Complex _1_SQRT_2 = M_SQRT1_2l + 0.0_iL; // 1 / sqrt(2)
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/rational.c
===================================================================
--- libcfa/src/rational.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,221 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// rational.c --
-//
-// Author           : Peter A. Buhr
-// Created On       : Wed Apr  6 17:54:28 2016
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Jun  2 09:24:33 2018
-// Update Count     : 162
-//
-
-#include "rational"
-#include "fstream"
-#include "stdlib"
-
-forall( otype RationalImpl | arithmetic( RationalImpl ) ) {
-	// helper routines
-
-	// Calculate greatest common denominator of two numbers, the first of which may be negative. Used to reduce
-	// rationals.  alternative: https://en.wikipedia.org/wiki/Binary_GCD_algorithm
-	static RationalImpl gcd( RationalImpl a, RationalImpl b ) {
-		for ( ;; ) {									// Euclid's algorithm
-			RationalImpl r = a % b;
-		  if ( r == (RationalImpl){0} ) break;
-			a = b;
-			b = r;
-		} // for
-		return b;
-	} // gcd
-
-	static RationalImpl simplify( RationalImpl & n, RationalImpl & d ) {
-		if ( d == (RationalImpl){0} ) {
-			serr | "Invalid rational number construction: denominator cannot be equal to 0." | endl;
-			exit( EXIT_FAILURE );
-		} // exit
-		if ( d < (RationalImpl){0} ) { d = -d; n = -n; } // move sign to numerator
-		return gcd( abs( n ), d );						// simplify
-	} // Rationalnumber::simplify
-
-	// constructors
-
-	void ?{}( Rational(RationalImpl) & r ) {
-		r{ (RationalImpl){0}, (RationalImpl){1} };
-	} // rational
-
-	void ?{}( Rational(RationalImpl) & r, RationalImpl n ) {
-		r{ n, (RationalImpl){1} };
-	} // rational
-
-	void ?{}( Rational(RationalImpl) & r, RationalImpl n, RationalImpl d ) {
-		RationalImpl t = simplify( n, d );				// simplify
-		r.numerator = n / t;
-		r.denominator = d / t;
-	} // rational
-
-
-	// getter for numerator/denominator
-
-	RationalImpl numerator( Rational(RationalImpl) r ) {
-		return r.numerator;
-	} // numerator
-
-	RationalImpl denominator( Rational(RationalImpl) r ) {
-		return r.denominator;
-	} // denominator
-
-	[ RationalImpl, RationalImpl ] ?=?( & [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) {
-		return dest = src.[ numerator, denominator ];
-	} // ?=?
-
-	// setter for numerator/denominator
-
-	RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n ) {
-		RationalImpl prev = r.numerator;
-		RationalImpl t = gcd( abs( n ), r.denominator ); // simplify
-		r.numerator = n / t;
-		r.denominator = r.denominator / t;
-		return prev;
-	} // numerator
-
-	RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d ) {
-		RationalImpl prev = r.denominator;
-		RationalImpl t = simplify( r.numerator, d );	// simplify
-		r.numerator = r.numerator / t;
-		r.denominator = d / t;
-		return prev;
-	} // denominator
-
-	// comparison
-
-	int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
-		return l.numerator * r.denominator == l.denominator * r.numerator;
-	} // ?==?
-
-	int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
-		return ! ( l == r );
-	} // ?!=?
-
-	int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
-		return l.numerator * r.denominator < l.denominator * r.numerator;
-	} // ?<?
-
-	int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
-		return l.numerator * r.denominator <= l.denominator * r.numerator;
-	} // ?<=?
-
-	int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
-		return ! ( l <= r );
-	} // ?>?
-
-	int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
-		return ! ( l < r );
-	} // ?>=?
-
-	// arithmetic
-
-	Rational(RationalImpl) +?( Rational(RationalImpl) r ) {
-		Rational(RationalImpl) t = { r.numerator, r.denominator };
-		return t;
-	} // +?
-
-	Rational(RationalImpl) -?( Rational(RationalImpl) r ) {
-		Rational(RationalImpl) t = { -r.numerator, r.denominator };
-		return t;
-	} // -?
-
-	Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
-		if ( l.denominator == r.denominator ) {			// special case
-			Rational(RationalImpl) t = { l.numerator + r.numerator, l.denominator };
-			return t;
-		} else {
-			Rational(RationalImpl) t = { l.numerator * r.denominator + l.denominator * r.numerator, l.denominator * r.denominator };
-			return t;
-		} // if
-	} // ?+?
-
-	Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
-		if ( l.denominator == r.denominator ) {			// special case
-			Rational(RationalImpl) t = { l.numerator - r.numerator, l.denominator };
-			return t;
-		} else {
-			Rational(RationalImpl) t = { l.numerator * r.denominator - l.denominator * r.numerator, l.denominator * r.denominator };
-			return t;
-		} // if
-	} // ?-?
-
-	Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
-		Rational(RationalImpl) t = { l.numerator * r.numerator, l.denominator * r.denominator };
-		return t;
-	} // ?*?
-
-	Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
-		if ( r.numerator < (RationalImpl){0} ) {
-			r.numerator = -r.numerator;
-			r.denominator = -r.denominator;
-		} // if
-		Rational(RationalImpl) t = { l.numerator * r.denominator, l.denominator * r.numerator };
-		return t;
-	} // ?/?
-
-	// I/O
-
-	forall( dtype istype | istream( istype ) | { istype & ?|?( istype &, RationalImpl & ); } )
-	istype & ?|?( istype & is, Rational(RationalImpl) & r ) {
-		RationalImpl t;
-		is | r.numerator | r.denominator;
-		t = simplify( r.numerator, r.denominator );
-		r.numerator /= t;
-		r.denominator /= t;
-		return is;
-	} // ?|?
-
-	forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } )
-	ostype & ?|?( ostype & os, Rational(RationalImpl ) r ) {
-		return os | r.numerator | '/' | r.denominator;
-	} // ?|?
-} // distribution
-
-// conversion
-
-forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
-double widen( Rational(RationalImpl) r ) {
- 	return convert( r.numerator ) / convert( r.denominator );
-} // widen
-
-forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double ); } )
-Rational(RationalImpl) narrow( double f, RationalImpl md ) {
-	// http://www.ics.uci.edu/~eppstein/numth/frap.c
-	if ( md <= (RationalImpl){1} ) {					// maximum fractional digits too small?
-		return (Rational(RationalImpl)){ convert( f ), (RationalImpl){1}}; // truncate fraction
-	} // if
-
-	// continued fraction coefficients
-	RationalImpl m00 = {1}, m11 = { 1 }, m01 = { 0 }, m10 = { 0 };
-	RationalImpl ai, t;
-
-	// find terms until denom gets too big
-	for ( ;; ) {
-		ai = convert( f );
-	  if ( ! (m10 * ai + m11 <= md) ) break;
-		t = m00 * ai + m01;
-		m01 = m00;
-		m00 = t;
-		t = m10 * ai + m11;
-		m11 = m10;
-		m10 = t;
-		double temp = convert( ai );
-	  if ( f == temp ) break;							// prevent division by zero
-		f = 1 / (f - temp);
-	  if ( f > (double)0x7FFFFFFF ) break;				// representation failure
-	} // for
-	return (Rational(RationalImpl)){ m00, m10 };
-} // narrow
-
-// Local Variables: //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/rational.cfa
===================================================================
--- libcfa/src/rational.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/rational.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,221 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// rational.c --
+//
+// Author           : Peter A. Buhr
+// Created On       : Wed Apr  6 17:54:28 2016
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Sat Jun  2 09:24:33 2018
+// Update Count     : 162
+//
+
+#include "rational"
+#include "fstream"
+#include "stdlib"
+
+forall( otype RationalImpl | arithmetic( RationalImpl ) ) {
+	// helper routines
+
+	// Calculate greatest common denominator of two numbers, the first of which may be negative. Used to reduce
+	// rationals.  alternative: https://en.wikipedia.org/wiki/Binary_GCD_algorithm
+	static RationalImpl gcd( RationalImpl a, RationalImpl b ) {
+		for ( ;; ) {									// Euclid's algorithm
+			RationalImpl r = a % b;
+		  if ( r == (RationalImpl){0} ) break;
+			a = b;
+			b = r;
+		} // for
+		return b;
+	} // gcd
+
+	static RationalImpl simplify( RationalImpl & n, RationalImpl & d ) {
+		if ( d == (RationalImpl){0} ) {
+			serr | "Invalid rational number construction: denominator cannot be equal to 0." | endl;
+			exit( EXIT_FAILURE );
+		} // exit
+		if ( d < (RationalImpl){0} ) { d = -d; n = -n; } // move sign to numerator
+		return gcd( abs( n ), d );						// simplify
+	} // Rationalnumber::simplify
+
+	// constructors
+
+	void ?{}( Rational(RationalImpl) & r ) {
+		r{ (RationalImpl){0}, (RationalImpl){1} };
+	} // rational
+
+	void ?{}( Rational(RationalImpl) & r, RationalImpl n ) {
+		r{ n, (RationalImpl){1} };
+	} // rational
+
+	void ?{}( Rational(RationalImpl) & r, RationalImpl n, RationalImpl d ) {
+		RationalImpl t = simplify( n, d );				// simplify
+		r.numerator = n / t;
+		r.denominator = d / t;
+	} // rational
+
+
+	// getter for numerator/denominator
+
+	RationalImpl numerator( Rational(RationalImpl) r ) {
+		return r.numerator;
+	} // numerator
+
+	RationalImpl denominator( Rational(RationalImpl) r ) {
+		return r.denominator;
+	} // denominator
+
+	[ RationalImpl, RationalImpl ] ?=?( & [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) {
+		return dest = src.[ numerator, denominator ];
+	} // ?=?
+
+	// setter for numerator/denominator
+
+	RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n ) {
+		RationalImpl prev = r.numerator;
+		RationalImpl t = gcd( abs( n ), r.denominator ); // simplify
+		r.numerator = n / t;
+		r.denominator = r.denominator / t;
+		return prev;
+	} // numerator
+
+	RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d ) {
+		RationalImpl prev = r.denominator;
+		RationalImpl t = simplify( r.numerator, d );	// simplify
+		r.numerator = r.numerator / t;
+		r.denominator = d / t;
+		return prev;
+	} // denominator
+
+	// comparison
+
+	int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
+		return l.numerator * r.denominator == l.denominator * r.numerator;
+	} // ?==?
+
+	int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
+		return ! ( l == r );
+	} // ?!=?
+
+	int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
+		return l.numerator * r.denominator < l.denominator * r.numerator;
+	} // ?<?
+
+	int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
+		return l.numerator * r.denominator <= l.denominator * r.numerator;
+	} // ?<=?
+
+	int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
+		return ! ( l <= r );
+	} // ?>?
+
+	int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
+		return ! ( l < r );
+	} // ?>=?
+
+	// arithmetic
+
+	Rational(RationalImpl) +?( Rational(RationalImpl) r ) {
+		Rational(RationalImpl) t = { r.numerator, r.denominator };
+		return t;
+	} // +?
+
+	Rational(RationalImpl) -?( Rational(RationalImpl) r ) {
+		Rational(RationalImpl) t = { -r.numerator, r.denominator };
+		return t;
+	} // -?
+
+	Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
+		if ( l.denominator == r.denominator ) {			// special case
+			Rational(RationalImpl) t = { l.numerator + r.numerator, l.denominator };
+			return t;
+		} else {
+			Rational(RationalImpl) t = { l.numerator * r.denominator + l.denominator * r.numerator, l.denominator * r.denominator };
+			return t;
+		} // if
+	} // ?+?
+
+	Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
+		if ( l.denominator == r.denominator ) {			// special case
+			Rational(RationalImpl) t = { l.numerator - r.numerator, l.denominator };
+			return t;
+		} else {
+			Rational(RationalImpl) t = { l.numerator * r.denominator - l.denominator * r.numerator, l.denominator * r.denominator };
+			return t;
+		} // if
+	} // ?-?
+
+	Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
+		Rational(RationalImpl) t = { l.numerator * r.numerator, l.denominator * r.denominator };
+		return t;
+	} // ?*?
+
+	Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
+		if ( r.numerator < (RationalImpl){0} ) {
+			r.numerator = -r.numerator;
+			r.denominator = -r.denominator;
+		} // if
+		Rational(RationalImpl) t = { l.numerator * r.denominator, l.denominator * r.numerator };
+		return t;
+	} // ?/?
+
+	// I/O
+
+	forall( dtype istype | istream( istype ) | { istype & ?|?( istype &, RationalImpl & ); } )
+	istype & ?|?( istype & is, Rational(RationalImpl) & r ) {
+		RationalImpl t;
+		is | r.numerator | r.denominator;
+		t = simplify( r.numerator, r.denominator );
+		r.numerator /= t;
+		r.denominator /= t;
+		return is;
+	} // ?|?
+
+	forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } )
+	ostype & ?|?( ostype & os, Rational(RationalImpl ) r ) {
+		return os | r.numerator | '/' | r.denominator;
+	} // ?|?
+} // distribution
+
+// conversion
+
+forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
+double widen( Rational(RationalImpl) r ) {
+ 	return convert( r.numerator ) / convert( r.denominator );
+} // widen
+
+forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double ); } )
+Rational(RationalImpl) narrow( double f, RationalImpl md ) {
+	// http://www.ics.uci.edu/~eppstein/numth/frap.c
+	if ( md <= (RationalImpl){1} ) {					// maximum fractional digits too small?
+		return (Rational(RationalImpl)){ convert( f ), (RationalImpl){1}}; // truncate fraction
+	} // if
+
+	// continued fraction coefficients
+	RationalImpl m00 = {1}, m11 = { 1 }, m01 = { 0 }, m10 = { 0 };
+	RationalImpl ai, t;
+
+	// find terms until denom gets too big
+	for ( ;; ) {
+		ai = convert( f );
+	  if ( ! (m10 * ai + m11 <= md) ) break;
+		t = m00 * ai + m01;
+		m01 = m00;
+		m00 = t;
+		t = m10 * ai + m11;
+		m11 = m10;
+		m10 = t;
+		double temp = convert( ai );
+	  if ( f == temp ) break;							// prevent division by zero
+		f = 1 / (f - temp);
+	  if ( f > (double)0x7FFFFFFF ) break;				// representation failure
+	} // for
+	return (Rational(RationalImpl)){ m00, m10 };
+} // narrow
+
+// Local Variables: //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/startup.c
===================================================================
--- libcfa/src/startup.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,47 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// startup.c --
-//
-// Author           : Peter A. Buhr
-// Created On       : Tue Jul 24 16:21:57 2018
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Jul 25 16:42:01 2018
-// Update Count     : 11
-//
-
-#include "startup.h"
-#include <unistd.h>
-
-
-extern "C" {
-    static void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) ));
-    void __cfaabi_appready_startup( void ) {
-		#ifdef __CFA_DEBUG__
-		extern void heapAppStart();
-		heapAppStart();
-		#endif // __CFA_DEBUG__
-    } // __cfaabi_appready_startup
-
-    static void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) ));
-    void __cfaabi_appready_shutdown( void ) {
-		#ifdef __CFA_DEBUG__
-		extern void heapAppStop();
-		heapAppStop();
-		#endif // __CFA_DEBUG__
-    } // __cfaabi_appready_shutdown
-
-    void disable_interrupts() __attribute__(( weak )) {}
-    void enable_interrupts_noPoll() __attribute__(( weak )) {}
-} // extern "C"
-
-struct __spinlock_t;
-void __cfaabi_dbg_record(struct __spinlock_t & this, const char * prev_name) __attribute__(( weak )) {}
-
-// Local Variables: //
-// mode: c //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/startup.cfa
===================================================================
--- libcfa/src/startup.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/startup.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,47 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// startup.c --
+//
+// Author           : Peter A. Buhr
+// Created On       : Tue Jul 24 16:21:57 2018
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Wed Jul 25 16:42:01 2018
+// Update Count     : 11
+//
+
+#include "startup.h"
+#include <unistd.h>
+
+
+extern "C" {
+    static void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) ));
+    void __cfaabi_appready_startup( void ) {
+		#ifdef __CFA_DEBUG__
+		extern void heapAppStart();
+		heapAppStart();
+		#endif // __CFA_DEBUG__
+    } // __cfaabi_appready_startup
+
+    static void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) ));
+    void __cfaabi_appready_shutdown( void ) {
+		#ifdef __CFA_DEBUG__
+		extern void heapAppStop();
+		heapAppStop();
+		#endif // __CFA_DEBUG__
+    } // __cfaabi_appready_shutdown
+
+    void disable_interrupts() __attribute__(( weak )) {}
+    void enable_interrupts_noPoll() __attribute__(( weak )) {}
+} // extern "C"
+
+struct __spinlock_t;
+void __cfaabi_dbg_record(struct __spinlock_t & this, const char * prev_name) __attribute__(( weak )) {}
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/stdlib.c
===================================================================
--- libcfa/src/stdlib.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,257 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// stdlib.c --
-//
-// Author           : Peter A. Buhr
-// Created On       : Thu Jan 28 17:10:29 2016
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jul 12 08:03:59 2018
-// Update Count     : 458
-//
-
-#include "stdlib"
-
-//---------------------------------------
-
-#define _XOPEN_SOURCE 600								// posix_memalign, *rand48
-#include <string.h>										// memcpy, memset
-#include <malloc.h>										// malloc_usable_size
-#include <math.h>										// fabsf, fabs, fabsl
-#include <complex.h>									// _Complex_I
-#include <assert.h>
-
-//---------------------------------------
-
-// resize, non-array types
-forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill ) {
-	size_t olen = malloc_usable_size( ptr );			// current allocation
-    char * nptr = (void *)realloc( (void *)ptr, dim * (size_t)sizeof(T) ); // C realloc
-	size_t nlen = malloc_usable_size( nptr );			// new allocation
-	if ( nlen > olen ) {								// larger ?
-		memset( nptr + olen, (int)fill, nlen - olen );	// initialize added storage
-	} //
-    return (T *)nptr;
-} // alloc
-
-// allocation/deallocation and constructor/destructor, non-array types
-forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } )
-T * new( Params p ) {
-	return &(*malloc()){ p };								// run constructor
-} // new
-
-forall( dtype T | sized(T) | { void ^?{}( T & ); } )
-void delete( T * ptr ) {
-	if ( ptr ) {										// ignore null
-		^(*ptr){};											// run destructor
-		free( ptr );
-	} // if
-} // delete
-
-forall( dtype T, ttype Params | sized(T) | { void ^?{}( T & ); void delete( Params ); } )
-void delete( T * ptr, Params rest ) {
-	if ( ptr ) {										// ignore null
-		^(*ptr){};											// run destructor
-		free( ptr );
-	} // if
-	delete( rest );
-} // delete
-
-
-// allocation/deallocation and constructor/destructor, array types
-forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } )
-T * anew( size_t dim, Params p ) {
-	T *arr = alloc( dim );
-	for ( unsigned int i = 0; i < dim; i += 1 ) {
-		(arr[i]){ p };									// run constructor
-	} // for
-	return arr;
-} // anew
-
-forall( dtype T | sized(T) | { void ^?{}( T & ); } )
-void adelete( size_t dim, T arr[] ) {
-	if ( arr ) {										// ignore null
-		for ( int i = dim - 1; i >= 0; i -= 1 ) {		// reverse allocation order, must be unsigned
-			^(arr[i]){};								// run destructor
-		} // for
-		free( arr );
-	} // if
-} // adelete
-
-forall( dtype T | sized(T) | { void ^?{}( T & ); }, ttype Params | { void adelete( Params ); } )
-void adelete( size_t dim, T arr[], Params rest ) {
-	if ( arr ) {										// ignore null
-		for ( int i = dim - 1; i >= 0; i -= 1 ) {		// reverse allocation order, must be unsigned
-			^(arr[i]){};								// run destructor
-		} // for
-		free( arr );
-	} // if
-	adelete( rest );
-} // adelete
-
-//---------------------------------------
-
-float _Complex strto( const char * sptr, char ** eptr ) {
-	float re, im;
-	char * eeptr;
-	re = strtof( sptr, &eeptr );
-	if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; }
-	im = strtof( eeptr, &eeptr );
-	if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; }
-	if ( *eeptr != 'i' ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; }
-	return re + im * _Complex_I;
-} // strto
-
-double _Complex strto( const char * sptr, char ** eptr ) {
-	double re, im;
-	char * eeptr;
-	re = strtod( sptr, &eeptr );
-	if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; }
-	im = strtod( eeptr, &eeptr );
-	if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; }
-	if ( *eeptr != 'i' ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; }
-	return re + im * _Complex_I;
-} // strto
-
-long double _Complex strto( const char * sptr, char ** eptr ) {
-	long double re, im;
-	char * eeptr;
-	re = strtold( sptr, &eeptr );
-	if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; }
-	im = strtold( eeptr, &eeptr );
-	if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; }
-	if ( *eeptr != 'i' ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; }
-	return re + im * _Complex_I;
-} // strto
-
-//---------------------------------------
-
-forall( otype E | { int ?<?( E, E ); } ) {
-	E * bsearch( E key, const E * vals, size_t dim ) {
-		int cmp( const void * t1, const void * t2 ) {
-			return *(E *)t1 < *(E *)t2 ? -1 : *(E *)t2 < *(E *)t1 ? 1 : 0;
-		} // cmp
-		return (E *)bsearch( &key, vals, dim, sizeof(E), cmp );
-	} // bsearch
-
-	size_t bsearch( E key, const E * vals, size_t dim ) {
-		E * result = bsearch( key, vals, dim );
-		return result ? result - vals : dim;			// pointer subtraction includes sizeof(E)
-	} // bsearch
-
-	size_t bsearchl( E key, const E * vals, size_t dim ) {
-		size_t l = 0, m, h = dim;
-		while ( l < h ) {
-			m = (l + h) / 2;
-			if ( (E &)(vals[m]) < key ) {				// cast away const
-				l = m + 1;
-			} else {
-				h = m;
-			} // if
-		} // while
-		return l;
-	} // bsearchl
-
-	E * bsearchl( E key, const E * vals, size_t dim ) {
-		size_t posn = bsearchl( key, vals, dim );
-		return (E *)(&vals[posn]);						// cast away const
-	} // bsearchl
-
-	size_t bsearchu( E key, const E * vals, size_t dim ) {
-		size_t l = 0, m, h = dim;
-		while ( l < h ) {
-			m = (l + h) / 2;
-			if ( ! ( key < (E &)(vals[m]) ) ) {			// cast away const
-				l = m + 1;
-			} else {
-				h = m;
-			} // if
-		} // while
-		return l;
-	} // bsearchu
-
-	E * bsearchu( E key, const E * vals, size_t dim ) {
-		size_t posn = bsearchu( key, vals, dim );
-		return (E *)(&vals[posn]);
-	} // bsearchu
-
-
-	void qsort( E * vals, size_t dim ) {
-		int cmp( const void * t1, const void * t2 ) {
-			return *(E *)t1 < *(E *)t2 ? -1 : *(E *)t2 < *(E *)t1 ? 1 : 0;
-		} // cmp
-		qsort( vals, dim, sizeof(E), cmp );
-	} // qsort
-} // distribution
-
-
-forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } ) {
-	E * bsearch( K key, const E * vals, size_t dim ) {
-		int cmp( const void * t1, const void * t2 ) {
-			return *(K *)t1 < getKey( *(E *)t2 ) ? -1 : getKey( *(E *)t2 ) < *(K *)t1 ? 1 : 0;
-		} // cmp
-		return (E *)bsearch( &key, vals, dim, sizeof(E), cmp );
-	} // bsearch
-
-	size_t bsearch( K key, const E * vals, size_t dim ) {
-		E * result = bsearch( key, vals, dim );
-		return result ? result - vals : dim;			// pointer subtraction includes sizeof(E)
-	} // bsearch
-
-	size_t bsearchl( K key, const E * vals, size_t dim ) {
-		size_t l = 0, m, h = dim;
-		while ( l < h ) {
-			m = (l + h) / 2;
-			if ( getKey( vals[m] ) < key ) {
-				l = m + 1;
-			} else {
-				h = m;
-			} // if
-		} // while
-		return l;
-	} // bsearchl
-
-	E * bsearchl( K key, const E * vals, size_t dim ) {
-		size_t posn = bsearchl( key, vals, dim );
-		return (E *)(&vals[posn]);						// cast away const
-	} // bsearchl
-
-	size_t bsearchu( K key, const E * vals, size_t dim ) {
-		size_t l = 0, m, h = dim;
-		while ( l < h ) {
-			m = (l + h) / 2;
-			if ( ! ( key < getKey( vals[m] ) ) ) {
-				l = m + 1;
-			} else {
-				h = m;
-			} // if
-		} // while
-		return l;
-	} // bsearchu
-
-	E * bsearchu( K key, const E * vals, size_t dim ) {
-		size_t posn = bsearchu( key, vals, dim );
-		return (E *)(&vals[posn]);
-	} // bsearchu
-} // distribution
-
-//---------------------------------------
-
-extern "C" {											// override C version
-	void srandom( unsigned int seed ) { srand48( (long int)seed ); }
-	long int random( void ) { return mrand48(); }
-} // extern "C"
-
-float random( void ) { return (float)drand48(); }		// cast otherwise float uses lrand48
-double random( void ) { return drand48(); }
-float _Complex random( void ) { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); }
-double _Complex random( void ) { return drand48() + (double _Complex)(drand48() * _Complex_I); }
-long double _Complex random( void ) { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); }
-
-
-// Local Variables: //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/stdlib.cfa
===================================================================
--- libcfa/src/stdlib.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/stdlib.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,257 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// stdlib.c --
+//
+// Author           : Peter A. Buhr
+// Created On       : Thu Jan 28 17:10:29 2016
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Thu Jul 12 08:03:59 2018
+// Update Count     : 458
+//
+
+#include "stdlib"
+
+//---------------------------------------
+
+#define _XOPEN_SOURCE 600								// posix_memalign, *rand48
+#include <string.h>										// memcpy, memset
+#include <malloc.h>										// malloc_usable_size
+#include <math.h>										// fabsf, fabs, fabsl
+#include <complex.h>									// _Complex_I
+#include <assert.h>
+
+//---------------------------------------
+
+// resize, non-array types
+forall( dtype T | sized(T) ) T * alloc( T ptr[], size_t dim, char fill ) {
+	size_t olen = malloc_usable_size( ptr );			// current allocation
+    char * nptr = (void *)realloc( (void *)ptr, dim * (size_t)sizeof(T) ); // C realloc
+	size_t nlen = malloc_usable_size( nptr );			// new allocation
+	if ( nlen > olen ) {								// larger ?
+		memset( nptr + olen, (int)fill, nlen - olen );	// initialize added storage
+	} //
+    return (T *)nptr;
+} // alloc
+
+// allocation/deallocation and constructor/destructor, non-array types
+forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } )
+T * new( Params p ) {
+	return &(*malloc()){ p };								// run constructor
+} // new
+
+forall( dtype T | sized(T) | { void ^?{}( T & ); } )
+void delete( T * ptr ) {
+	if ( ptr ) {										// ignore null
+		^(*ptr){};											// run destructor
+		free( ptr );
+	} // if
+} // delete
+
+forall( dtype T, ttype Params | sized(T) | { void ^?{}( T & ); void delete( Params ); } )
+void delete( T * ptr, Params rest ) {
+	if ( ptr ) {										// ignore null
+		^(*ptr){};											// run destructor
+		free( ptr );
+	} // if
+	delete( rest );
+} // delete
+
+
+// allocation/deallocation and constructor/destructor, array types
+forall( dtype T | sized(T), ttype Params | { void ?{}( T &, Params ); } )
+T * anew( size_t dim, Params p ) {
+	T *arr = alloc( dim );
+	for ( unsigned int i = 0; i < dim; i += 1 ) {
+		(arr[i]){ p };									// run constructor
+	} // for
+	return arr;
+} // anew
+
+forall( dtype T | sized(T) | { void ^?{}( T & ); } )
+void adelete( size_t dim, T arr[] ) {
+	if ( arr ) {										// ignore null
+		for ( int i = dim - 1; i >= 0; i -= 1 ) {		// reverse allocation order, must be unsigned
+			^(arr[i]){};								// run destructor
+		} // for
+		free( arr );
+	} // if
+} // adelete
+
+forall( dtype T | sized(T) | { void ^?{}( T & ); }, ttype Params | { void adelete( Params ); } )
+void adelete( size_t dim, T arr[], Params rest ) {
+	if ( arr ) {										// ignore null
+		for ( int i = dim - 1; i >= 0; i -= 1 ) {		// reverse allocation order, must be unsigned
+			^(arr[i]){};								// run destructor
+		} // for
+		free( arr );
+	} // if
+	adelete( rest );
+} // adelete
+
+//---------------------------------------
+
+float _Complex strto( const char * sptr, char ** eptr ) {
+	float re, im;
+	char * eeptr;
+	re = strtof( sptr, &eeptr );
+	if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; }
+	im = strtof( eeptr, &eeptr );
+	if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; }
+	if ( *eeptr != 'i' ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0f + 0.0f * _Complex_I; }
+	return re + im * _Complex_I;
+} // strto
+
+double _Complex strto( const char * sptr, char ** eptr ) {
+	double re, im;
+	char * eeptr;
+	re = strtod( sptr, &eeptr );
+	if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; }
+	im = strtod( eeptr, &eeptr );
+	if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; }
+	if ( *eeptr != 'i' ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0 + 0.0 * _Complex_I; }
+	return re + im * _Complex_I;
+} // strto
+
+long double _Complex strto( const char * sptr, char ** eptr ) {
+	long double re, im;
+	char * eeptr;
+	re = strtold( sptr, &eeptr );
+	if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; }
+	im = strtold( eeptr, &eeptr );
+	if ( sptr == eeptr ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; }
+	if ( *eeptr != 'i' ) { if ( eptr != 0 ) *eptr = eeptr; return 0.0L + 0.0L * _Complex_I; }
+	return re + im * _Complex_I;
+} // strto
+
+//---------------------------------------
+
+forall( otype E | { int ?<?( E, E ); } ) {
+	E * bsearch( E key, const E * vals, size_t dim ) {
+		int cmp( const void * t1, const void * t2 ) {
+			return *(E *)t1 < *(E *)t2 ? -1 : *(E *)t2 < *(E *)t1 ? 1 : 0;
+		} // cmp
+		return (E *)bsearch( &key, vals, dim, sizeof(E), cmp );
+	} // bsearch
+
+	size_t bsearch( E key, const E * vals, size_t dim ) {
+		E * result = bsearch( key, vals, dim );
+		return result ? result - vals : dim;			// pointer subtraction includes sizeof(E)
+	} // bsearch
+
+	size_t bsearchl( E key, const E * vals, size_t dim ) {
+		size_t l = 0, m, h = dim;
+		while ( l < h ) {
+			m = (l + h) / 2;
+			if ( (E &)(vals[m]) < key ) {				// cast away const
+				l = m + 1;
+			} else {
+				h = m;
+			} // if
+		} // while
+		return l;
+	} // bsearchl
+
+	E * bsearchl( E key, const E * vals, size_t dim ) {
+		size_t posn = bsearchl( key, vals, dim );
+		return (E *)(&vals[posn]);						// cast away const
+	} // bsearchl
+
+	size_t bsearchu( E key, const E * vals, size_t dim ) {
+		size_t l = 0, m, h = dim;
+		while ( l < h ) {
+			m = (l + h) / 2;
+			if ( ! ( key < (E &)(vals[m]) ) ) {			// cast away const
+				l = m + 1;
+			} else {
+				h = m;
+			} // if
+		} // while
+		return l;
+	} // bsearchu
+
+	E * bsearchu( E key, const E * vals, size_t dim ) {
+		size_t posn = bsearchu( key, vals, dim );
+		return (E *)(&vals[posn]);
+	} // bsearchu
+
+
+	void qsort( E * vals, size_t dim ) {
+		int cmp( const void * t1, const void * t2 ) {
+			return *(E *)t1 < *(E *)t2 ? -1 : *(E *)t2 < *(E *)t1 ? 1 : 0;
+		} // cmp
+		qsort( vals, dim, sizeof(E), cmp );
+	} // qsort
+} // distribution
+
+
+forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } ) {
+	E * bsearch( K key, const E * vals, size_t dim ) {
+		int cmp( const void * t1, const void * t2 ) {
+			return *(K *)t1 < getKey( *(E *)t2 ) ? -1 : getKey( *(E *)t2 ) < *(K *)t1 ? 1 : 0;
+		} // cmp
+		return (E *)bsearch( &key, vals, dim, sizeof(E), cmp );
+	} // bsearch
+
+	size_t bsearch( K key, const E * vals, size_t dim ) {
+		E * result = bsearch( key, vals, dim );
+		return result ? result - vals : dim;			// pointer subtraction includes sizeof(E)
+	} // bsearch
+
+	size_t bsearchl( K key, const E * vals, size_t dim ) {
+		size_t l = 0, m, h = dim;
+		while ( l < h ) {
+			m = (l + h) / 2;
+			if ( getKey( vals[m] ) < key ) {
+				l = m + 1;
+			} else {
+				h = m;
+			} // if
+		} // while
+		return l;
+	} // bsearchl
+
+	E * bsearchl( K key, const E * vals, size_t dim ) {
+		size_t posn = bsearchl( key, vals, dim );
+		return (E *)(&vals[posn]);						// cast away const
+	} // bsearchl
+
+	size_t bsearchu( K key, const E * vals, size_t dim ) {
+		size_t l = 0, m, h = dim;
+		while ( l < h ) {
+			m = (l + h) / 2;
+			if ( ! ( key < getKey( vals[m] ) ) ) {
+				l = m + 1;
+			} else {
+				h = m;
+			} // if
+		} // while
+		return l;
+	} // bsearchu
+
+	E * bsearchu( K key, const E * vals, size_t dim ) {
+		size_t posn = bsearchu( key, vals, dim );
+		return (E *)(&vals[posn]);
+	} // bsearchu
+} // distribution
+
+//---------------------------------------
+
+extern "C" {											// override C version
+	void srandom( unsigned int seed ) { srand48( (long int)seed ); }
+	long int random( void ) { return mrand48(); }
+} // extern "C"
+
+float random( void ) { return (float)drand48(); }		// cast otherwise float uses lrand48
+double random( void ) { return drand48(); }
+float _Complex random( void ) { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); }
+double _Complex random( void ) { return drand48() + (double _Complex)(drand48() * _Complex_I); }
+long double _Complex random( void ) { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); }
+
+
+// Local Variables: //
+// tab-width: 4 //
+// End: //
Index: libcfa/src/time.c
===================================================================
--- libcfa/src/time.c	(revision ff1e0f38b2bf523763024876e746508c1928685e)
+++ 	(revision )
@@ -1,161 +1,0 @@
-// 
-// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-// 
-// time.c -- 
-// 
-// Author           : Peter A. Buhr
-// Created On       : Tue Mar 27 13:33:14 2018
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sun May  6 22:26:00 2018
-// Update Count     : 37
-// 
-
-#include "time"
-#include "iostream"
-#include <stdio.h>										// snprintf
-#include <assert.h>
-
-static char * nanomsd( long int ns, char * buf ) {		// most significant digits
-	snprintf( buf, 16, ".%09ld", ns );
-	int i;
-	for ( i = 9; buf[i] == '0' ; i -= 1 );				// find least significant digit
-	buf[i + 1] = '\0';
-	return buf;
-} // nanomsd
-
-
-//######################### Duration #########################
-
-
-forall( dtype ostype | ostream( ostype ) )
-ostype & ?|?( ostype & os, Duration dur ) with( dur ) {
-	os | tv / TIMEGRAN;									// print seconds
-	long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN;		// compute nanoseconds
-	if ( ns != 0 ) {									// some ?
-		char buf[16];
-		os | nanomsd( ns, buf );						// print nanoseconds
-	} // if
-	return os;
-} // ?|?
-
-
-//######################### Time #########################
-
-
-#ifdef __CFA_DEBUG__
-#define CreateFmt "Attempt to create Time( year=%d (>=1970), month=%d (1-12), day=%d (1-31), hour=%d (0-23), min=%d (0-59), sec=%d (0-60), nsec=%d (0-999_999_999), " \
-	"which exceeds range 00:00:00 UTC, January 1, 1970 to 03:14:07 UTC, January 19, 2038."
-#endif // __CFA_DEBUG__
-
-void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, int nsec ) with( time ) {
-	tm tm;
-
-	tm.tm_isdst = -1;									// let mktime determine if alternate timezone is in effect
-	tm.tm_year = year - 1900;							// mktime uses 1900 as its starting point
-#ifdef __CFA_DEBUG__
-	if ( month < 1 || 12 < month ) {
-		abort( CreateFmt, year, month, day, hour, (int)min, sec, nsec );
-	} // if
-#endif // __CFA_DEBUG__
-	tm.tm_mon = month - 1;								// mktime uses range 0-11
-#ifdef __CFA_DEBUG__
-	if ( day < 1 || 31 < day ) {
-		abort( CreateFmt, year, month, day, hour, (int)min, sec, nsec );
-	} // if
-#endif // __CFA_DEBUG__
-	tm.tm_mday = day;									// mktime uses range 1-31
-	tm.tm_hour = hour;
-	tm.tm_min = min;
-	tm.tm_sec = sec;
-	time_t epochsec = mktime( &tm );
-#ifdef __CFA_DEBUG__
-	if ( epochsec == (time_t)-1 ) {
-		abort( CreateFmt, year, month, day, hour, (int)min, sec, nsec );
-	} // if
-#endif // __CFA_DEBUG__
-	tv = (int64_t)(epochsec) * TIMEGRAN + nsec;			// convert to nanoseconds
-#ifdef __CFA_DEBUG__
-	if ( tv > 2147483647LL * TIMEGRAN ) {				// between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038.
-		abort( CreateFmt, year, month, day, hour, (int)min, sec, nsec );
-	} // if
-#endif // __CFA_DEBUG__
-} // ?{}
-
-char * yy_mm_dd( Time time, char * buf ) with( time ) {
-	time_t s = tv / TIMEGRAN;
-	tm tm;
-	gmtime_r( &s, &tm );								// tm_mon <= 11, tm_mday <= 31
-#if defined(__GNUC__) && __GNUC__ >= 7
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-truncation"
-#endif
-	snprintf( buf, 9, "%02d/%02d/%02d", tm.tm_year % 99, tm.tm_mon + 1, tm.tm_mday );
-#if defined(__GNUC__) && __GNUC__ >= 7
-#pragma GCC diagnostic pop
-#endif
-	return buf;
-} // yy_mm_dd
-
-char * mm_dd_yy( Time time, char * buf ) with( time ) {
-	time_t s = tv / TIMEGRAN;
-	tm tm;
-	gmtime_r( &s, &tm );								// tm_mon <= 11, tm_mday <= 31
-#if defined(__GNUC__) && __GNUC__ >= 7
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-truncation"
-#endif
-	snprintf( buf, 9, "%02d/%02d/%02d", tm.tm_mon + 1, tm.tm_mday, tm.tm_year % 99 );
-#if defined(__GNUC__) && __GNUC__ >= 7
-#pragma GCC diagnostic pop
-#endif
-	return buf;
-} // mm_dd_yy
-
-char * dd_mm_yy( Time time, char * buf ) with( time ) {
-	time_t s = tv / TIMEGRAN;
-	tm tm;
-	gmtime_r( &s, &tm );								// tm_mon <= 11, tm_mday <= 31
-#if defined(__GNUC__) && __GNUC__ >= 7
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-truncation"
-#endif
-	snprintf( buf, 9, "%02d/%02d/%02d", tm.tm_mday, tm.tm_mon + 1, tm.tm_year % 99 );
-#if defined(__GNUC__) && __GNUC__ >= 7
-#pragma GCC diagnostic pop
-#endif
-	return buf;
-} // dd_mm_yy
-
-size_t strftime( char * buf, size_t size, const char * fmt, Time time ) with( time ) {
-	time_t s = tv / TIMEGRAN;
-	tm tm;
-	gmtime_r( &s, &tm );
-	return strftime( buf, size, fmt, &tm );
-} // strftime
-
-forall( dtype ostype | ostream( ostype ) )
-ostype & ?|?( ostype & os, Time time ) with( time ) {
-	char buf[32];										// at least 26
-	time_t s = tv / TIMEGRAN;
-    ctime_r( &s, (char *)&buf );						// 26 characters: "Wed Jun 30 21:49:08 1993\n"
-	buf[24] = '\0';										// remove trailing '\n'
-	long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN;		// compute nanoseconds
-	if ( ns == 0 ) {									// none ?
-		os | buf;										// print date/time/year
-	} else {
-		buf[19] = '\0';									// truncate to "Wed Jun 30 21:49:08"
-		os | buf;										// print date/time
-		char buf2[16];
-		nanomsd( ns, buf2 );							// compute nanoseconds
-		os | buf2 | ' ' | &buf[20];						// print nanoseconds and year
-	} // if
-	return os;
-} // ?|?
-
-// Local Variables: //
-// mode: c //
-// tab-width: 4 //
-// End: //
Index: libcfa/src/time.cfa
===================================================================
--- libcfa/src/time.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
+++ libcfa/src/time.cfa	(revision ba9baadeb7d347b3375a3c22e4ce3628359e9187)
@@ -0,0 +1,161 @@
+// 
+// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+// 
+// time.c -- 
+// 
+// Author           : Peter A. Buhr
+// Created On       : Tue Mar 27 13:33:14 2018
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Sun May  6 22:26:00 2018
+// Update Count     : 37
+// 
+
+#include "time"
+#include "iostream"
+#include <stdio.h>										// snprintf
+#include <assert.h>
+
+static char * nanomsd( long int ns, char * buf ) {		// most significant digits
+	snprintf( buf, 16, ".%09ld", ns );
+	int i;
+	for ( i = 9; buf[i] == '0' ; i -= 1 );				// find least significant digit
+	buf[i + 1] = '\0';
+	return buf;
+} // nanomsd
+
+
+//######################### Duration #########################
+
+
+forall( dtype ostype | ostream( ostype ) )
+ostype & ?|?( ostype & os, Duration dur ) with( dur ) {
+	os | tv / TIMEGRAN;									// print seconds
+	long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN;		// compute nanoseconds
+	if ( ns != 0 ) {									// some ?
+		char buf[16];
+		os | nanomsd( ns, buf );						// print nanoseconds
+	} // if
+	return os;
+} // ?|?
+
+
+//######################### Time #########################
+
+
+#ifdef __CFA_DEBUG__
+#define CreateFmt "Attempt to create Time( year=%d (>=1970), month=%d (1-12), day=%d (1-31), hour=%d (0-23), min=%d (0-59), sec=%d (0-60), nsec=%d (0-999_999_999), " \
+	"which exceeds range 00:00:00 UTC, January 1, 1970 to 03:14:07 UTC, January 19, 2038."
+#endif // __CFA_DEBUG__
+
+void ?{}( Time & time, int year, int month, int day, int hour, int min, int sec, int nsec ) with( time ) {
+	tm tm;
+
+	tm.tm_isdst = -1;									// let mktime determine if alternate timezone is in effect
+	tm.tm_year = year - 1900;							// mktime uses 1900 as its starting point
+#ifdef __CFA_DEBUG__
+	if ( month < 1 || 12 < month ) {
+		abort( CreateFmt, year, month, day, hour, (int)min, sec, nsec );
+	} // if
+#endif // __CFA_DEBUG__
+	tm.tm_mon = month - 1;								// mktime uses range 0-11
+#ifdef __CFA_DEBUG__
+	if ( day < 1 || 31 < day ) {
+		abort( CreateFmt, year, month, day, hour, (int)min, sec, nsec );
+	} // if
+#endif // __CFA_DEBUG__
+	tm.tm_mday = day;									// mktime uses range 1-31
+	tm.tm_hour = hour;
+	tm.tm_min = min;
+	tm.tm_sec = sec;
+	time_t epochsec = mktime( &tm );
+#ifdef __CFA_DEBUG__
+	if ( epochsec == (time_t)-1 ) {
+		abort( CreateFmt, year, month, day, hour, (int)min, sec, nsec );
+	} // if
+#endif // __CFA_DEBUG__
+	tv = (int64_t)(epochsec) * TIMEGRAN + nsec;			// convert to nanoseconds
+#ifdef __CFA_DEBUG__
+	if ( tv > 2147483647LL * TIMEGRAN ) {				// between 00:00:00 UTC, January 1, 1970 and 03:14:07 UTC, January 19, 2038.
+		abort( CreateFmt, year, month, day, hour, (int)min, sec, nsec );
+	} // if
+#endif // __CFA_DEBUG__
+} // ?{}
+
+char * yy_mm_dd( Time time, char * buf ) with( time ) {
+	time_t s = tv / TIMEGRAN;
+	tm tm;
+	gmtime_r( &s, &tm );								// tm_mon <= 11, tm_mday <= 31
+#if defined(__GNUC__) && __GNUC__ >= 7
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-truncation"
+#endif
+	snprintf( buf, 9, "%02d/%02d/%02d", tm.tm_year % 99, tm.tm_mon + 1, tm.tm_mday );
+#if defined(__GNUC__) && __GNUC__ >= 7
+#pragma GCC diagnostic pop
+#endif
+	return buf;
+} // yy_mm_dd
+
+char * mm_dd_yy( Time time, char * buf ) with( time ) {
+	time_t s = tv / TIMEGRAN;
+	tm tm;
+	gmtime_r( &s, &tm );								// tm_mon <= 11, tm_mday <= 31
+#if defined(__GNUC__) && __GNUC__ >= 7
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-truncation"
+#endif
+	snprintf( buf, 9, "%02d/%02d/%02d", tm.tm_mon + 1, tm.tm_mday, tm.tm_year % 99 );
+#if defined(__GNUC__) && __GNUC__ >= 7
+#pragma GCC diagnostic pop
+#endif
+	return buf;
+} // mm_dd_yy
+
+char * dd_mm_yy( Time time, char * buf ) with( time ) {
+	time_t s = tv / TIMEGRAN;
+	tm tm;
+	gmtime_r( &s, &tm );								// tm_mon <= 11, tm_mday <= 31
+#if defined(__GNUC__) && __GNUC__ >= 7
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-truncation"
+#endif
+	snprintf( buf, 9, "%02d/%02d/%02d", tm.tm_mday, tm.tm_mon + 1, tm.tm_year % 99 );
+#if defined(__GNUC__) && __GNUC__ >= 7
+#pragma GCC diagnostic pop
+#endif
+	return buf;
+} // dd_mm_yy
+
+size_t strftime( char * buf, size_t size, const char * fmt, Time time ) with( time ) {
+	time_t s = tv / TIMEGRAN;
+	tm tm;
+	gmtime_r( &s, &tm );
+	return strftime( buf, size, fmt, &tm );
+} // strftime
+
+forall( dtype ostype | ostream( ostype ) )
+ostype & ?|?( ostype & os, Time time ) with( time ) {
+	char buf[32];										// at least 26
+	time_t s = tv / TIMEGRAN;
+    ctime_r( &s, (char *)&buf );						// 26 characters: "Wed Jun 30 21:49:08 1993\n"
+	buf[24] = '\0';										// remove trailing '\n'
+	long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN;		// compute nanoseconds
+	if ( ns == 0 ) {									// none ?
+		os | buf;										// print date/time/year
+	} else {
+		buf[19] = '\0';									// truncate to "Wed Jun 30 21:49:08"
+		os | buf;										// print date/time
+		char buf2[16];
+		nanomsd( ns, buf2 );							// compute nanoseconds
+		os | buf2 | ' ' | &buf[20];						// print nanoseconds and year
+	} // if
+	return os;
+} // ?|?
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
