Index: src/Makefile.in
===================================================================
--- src/Makefile.in	(revision c5cb613099f2fdd80518c1423be411f72bd629c4)
+++ src/Makefile.in	(revision e4745d7a69e805e1610459cace93880b062586f3)
@@ -69,4 +69,6 @@
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
 DIST_COMMON = $(srcdir)/CodeGen/module.mk $(srcdir)/Common/module.mk \
 	$(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk \
@@ -296,4 +298,5 @@
 LIBS = @LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+MACHINE_TYPE = @MACHINE_TYPE@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
@@ -327,5 +330,9 @@
 am__untar = @am__untar@
 bindir = @bindir@
+build = @build@
 build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
 builddir = @builddir@
 datadir = @datadir@
@@ -334,5 +341,9 @@
 dvidir = @dvidir@
 exec_prefix = @exec_prefix@
+host = @host@
 host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
 htmldir = @htmldir@
 includedir = @includedir@
Index: src/driver/Makefile.in
===================================================================
--- src/driver/Makefile.in	(revision c5cb613099f2fdd80518c1423be411f72bd629c4)
+++ src/driver/Makefile.in	(revision e4745d7a69e805e1610459cace93880b062586f3)
@@ -36,4 +36,6 @@
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
 bin_PROGRAMS = cfa$(EXEEXT)
 cc1lib_PROGRAMS = cc1$(EXEEXT)
@@ -129,4 +131,5 @@
 LIBS = @LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+MACHINE_TYPE = @MACHINE_TYPE@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
@@ -160,5 +163,9 @@
 am__untar = @am__untar@
 bindir = @bindir@
+build = @build@
 build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
 builddir = @builddir@
 datadir = @datadir@
@@ -167,5 +174,9 @@
 dvidir = @dvidir@
 exec_prefix = @exec_prefix@
+host = @host@
 host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
 htmldir = @htmldir@
 includedir = @includedir@
Index: src/examples/Makefile.in
===================================================================
--- src/examples/Makefile.in	(revision c5cb613099f2fdd80518c1423be411f72bd629c4)
+++ src/examples/Makefile.in	(revision e4745d7a69e805e1610459cace93880b062586f3)
@@ -36,4 +36,6 @@
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
 noinst_PROGRAMS = fstream_test$(EXEEXT) vector_test$(EXEEXT) \
 	avl_test$(EXEEXT)
@@ -140,4 +142,5 @@
 LIBS = @LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+MACHINE_TYPE = @MACHINE_TYPE@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
@@ -171,5 +174,9 @@
 am__untar = @am__untar@
 bindir = @bindir@
+build = @build@
 build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
 builddir = @builddir@
 datadir = @datadir@
@@ -178,5 +185,9 @@
 dvidir = @dvidir@
 exec_prefix = @exec_prefix@
+host = @host@
 host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
 htmldir = @htmldir@
 includedir = @includedir@
Index: src/libcfa/Makefile.am
===================================================================
--- src/libcfa/Makefile.am	(revision c5cb613099f2fdd80518c1423be411f72bd629c4)
+++ src/libcfa/Makefile.am	(revision e4745d7a69e805e1610459cace93880b062586f3)
@@ -61,4 +61,5 @@
 	# TEMPORARY: does not build with -O2
 
+AM_CCASFLAGS = @CFA_FLAGS@
 CFLAGS = ${EXTRA_FLAGS}	-quiet -no-include-stdhdr -XCFA -t -B${abs_top_srcdir}/src/driver
 CC = ${abs_top_srcdir}/src/driver/cfa
@@ -77,5 +78,5 @@
 ${libobjs} : ${abs_top_srcdir}/src/driver/cfa-cpp ${cfalib_DATA} # add dependency to cfa-cpp so all libraries are rebuilt with new translator
 
-libcfa_a_SOURCES = libcfa-prelude.c ${headers:=.c} concurrency/CtxSwitch-x86_64.S concurrency/invoke.c
+libcfa_a_SOURCES = libcfa-prelude.c ${headers:=.c} concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/invoke.c
 
 stdhdr = ${shell echo stdhdr/*}
Index: src/libcfa/Makefile.in
===================================================================
--- src/libcfa/Makefile.in	(revision c5cb613099f2fdd80518c1423be411f72bd629c4)
+++ src/libcfa/Makefile.in	(revision e4745d7a69e805e1610459cace93880b062586f3)
@@ -38,4 +38,6 @@
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
 subdir = src/libcfa
 DIST_COMMON = $(nobase_include_HEADERS) $(srcdir)/Makefile.am \
@@ -95,5 +97,5 @@
 	containers/vector.$(OBJEXT) concurrency/threads.$(OBJEXT)
 am_libcfa_a_OBJECTS = libcfa-prelude.$(OBJEXT) $(am__objects_1) \
-	concurrency/CtxSwitch-x86_64.$(OBJEXT) \
+	concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT) \
 	concurrency/invoke.$(OBJEXT)
 libcfa_a_OBJECTS = $(am_libcfa_a_OBJECTS)
@@ -174,4 +176,5 @@
 LIBS = @LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+MACHINE_TYPE = @MACHINE_TYPE@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
@@ -205,5 +208,9 @@
 am__untar = @am__untar@
 bindir = @bindir@
+build = @build@
 build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
 builddir = @builddir@
 datadir = @datadir@
@@ -212,5 +219,9 @@
 dvidir = @dvidir@
 exec_prefix = @exec_prefix@
+host = @host@
 host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
 htmldir = @htmldir@
 includedir = @includedir@
@@ -253,8 +264,9 @@
 	# TEMPORARY: does not build with -O2
 
+AM_CCASFLAGS = @CFA_FLAGS@
 headers = limits stdlib math iostream fstream iterator rational assert containers/vector concurrency/threads
 runtimehdrs = concurrency
 libobjs = ${headers:=.o}
-libcfa_a_SOURCES = libcfa-prelude.c ${headers:=.c} concurrency/CtxSwitch-x86_64.S concurrency/invoke.c
+libcfa_a_SOURCES = libcfa-prelude.c ${headers:=.c} concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/invoke.c
 stdhdr = ${shell echo stdhdr/*}
 nobase_include_HEADERS = ${headers} ${stdhdr}
@@ -340,5 +352,6 @@
 concurrency/threads.$(OBJEXT): concurrency/$(am__dirstamp) \
 	concurrency/$(DEPDIR)/$(am__dirstamp)
-concurrency/CtxSwitch-x86_64.$(OBJEXT): concurrency/$(am__dirstamp) \
+concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT):  \
+	concurrency/$(am__dirstamp) \
 	concurrency/$(DEPDIR)/$(am__dirstamp)
 concurrency/invoke.$(OBJEXT): concurrency/$(am__dirstamp) \
@@ -351,5 +364,5 @@
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
-	-rm -f concurrency/CtxSwitch-x86_64.$(OBJEXT)
+	-rm -f concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT)
 	-rm -f concurrency/invoke.$(OBJEXT)
 	-rm -f concurrency/threads.$(OBJEXT)
@@ -368,5 +381,5 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rational.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdlib.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/CtxSwitch-x86_64.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)/invoke.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/threads.Po@am__quote@
Index: src/libcfa/concurrency/CtxSwitch-i386.S
===================================================================
--- src/libcfa/concurrency/CtxSwitch-i386.S	(revision e4745d7a69e805e1610459cace93880b062586f3)
+++ src/libcfa/concurrency/CtxSwitch-i386.S	(revision e4745d7a69e805e1610459cace93880b062586f3)
@@ -0,0 +1,90 @@
+//                               -*- Mode: Asm -*-
+//
+// 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.
+//
+// CtxSwitch-i386.S --
+//
+// Author           : Thierry Delisle
+// Created On       : Tue Dec 6 12:27:26 2016
+// Last Modified By : Thierry Delisle
+// Last Modified On : Tue Dec 6 12:27:26 2016
+// Update Count     : 0
+//
+// This  library is free  software; you  can redistribute  it and/or  modify it
+// under the terms of the GNU Lesser General Public License as published by the
+// Free Software  Foundation; either  version 2.1 of  the License, or  (at your
+// option) any later version.
+//
+// This library is distributed in the  hope that it will be useful, but WITHOUT
+// ANY  WARRANTY;  without even  the  implied  warranty  of MERCHANTABILITY  or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+// for more details.
+//
+// You should  have received a  copy of the  GNU Lesser General  Public License
+// along  with this library.
+//
+
+// This context switch routine depends on the fact that the stack of a new
+// thread has been set up to look like the thread has saved its context in
+// the normal manner.
+//
+// void CtxSwitch( machine_context *from, machine_context *to );
+
+// Offsets in the context structure. This needs to be synchronized with the
+// high level code a little better.
+
+#define PTR_BYTE	4
+#define SP_OFFSET	( 0 * PTR_BYTE )
+#define FP_OFFSET	( 1 * PTR_BYTE )
+#define PC_OFFSET	( 2 * PTR_BYTE )
+
+.text
+	.align 2
+.globl	CtxSwitch
+CtxSwitch:
+
+	// Copy the "from" context argument from the stack to register eax
+	// Return address is at 0(%esp), with parameters following
+
+	movl 4(%esp),%eax
+
+	// Save volatile registers on the stack.
+
+	pushl %ebx
+	pushl %edi
+	pushl %esi
+
+	// Save old context in the "from" area.
+
+	movl %esp,SP_OFFSET(%eax)
+	movl %ebp,FP_OFFSET(%eax)
+//	movl 4(%ebp),%ebx	// save previous eip for debugger
+//	movl %ebx,PC_OFFSET(%eax)
+
+	// Copy the "to" context argument from the stack to register eax
+	// Having pushed three words (= 12 bytes) on the stack, the
+	// argument is now at 8 + 12 = 20(%esp)
+
+	movl 20(%esp),%eax
+
+	// Load new context from the "to" area.
+
+	movl SP_OFFSET(%eax),%esp
+	movl FP_OFFSET(%eax),%ebp
+
+	// Load volatile registers from the stack.
+
+	popl %esi
+	popl %edi
+	popl %ebx
+
+	// Return to thread.
+
+	ret
+
+// Local Variables: //
+// compile-command: "make install" //
+// End: //
Index: src/libcfa/concurrency/invoke.c
===================================================================
--- src/libcfa/concurrency/invoke.c	(revision c5cb613099f2fdd80518c1423be411f72bd629c4)
+++ src/libcfa/concurrency/invoke.c	(revision e4745d7a69e805e1610459cace93880b062586f3)
@@ -28,13 +28,13 @@
 
 void __startCoroutine__A0_1_0___this_coroutine__PFP10scoroutine_Pd0___co_main__PF_Pd0___vtable__PFP9scoVtable_Pd0__F_Pd0PF_P9scoVtablePv___1(
-      struct coroutine *(*this_coroutine)(void * ), 
-      void (*co_main)(void *), 
-      struct coVtable *(*get_vtable)(void *), 
-      void *vthis, 
+      struct coroutine *(*this_coroutine)(void * ),
+      void (*co_main)(void *),
+      struct coVtable *(*get_vtable)(void *),
+      void *vthis,
       void (*invoke)(struct coVtable *, void *)
 ) {
 
-      #if ! defined( __x86_64__ )
-            #error Only __x86_64__ is supported for threads in cfa
+      #if ! defined( __x86_64__ ) && ! defined( __i386__ )
+            #error Only __x86_64__ and __i386__ is supported for threads in cfa
       #endif
 
Index: src/tests/Makefile.in
===================================================================
--- src/tests/Makefile.in	(revision c5cb613099f2fdd80518c1423be411f72bd629c4)
+++ src/tests/Makefile.in	(revision e4745d7a69e805e1610459cace93880b062586f3)
@@ -35,4 +35,6 @@
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
 EXTRA_PROGRAMS = fstream_test$(EXEEXT) vector_test$(EXEEXT) \
 	avl_test$(EXEEXT) constant0-1DP$(EXEEXT) \
@@ -150,4 +152,5 @@
 LIBS = @LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+MACHINE_TYPE = @MACHINE_TYPE@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
@@ -181,5 +184,9 @@
 am__untar = @am__untar@
 bindir = @bindir@
+build = @build@
 build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
 builddir = @builddir@
 datadir = @datadir@
@@ -188,5 +195,9 @@
 dvidir = @dvidir@
 exec_prefix = @exec_prefix@
+host = @host@
 host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
 htmldir = @htmldir@
 includedir = @includedir@
