Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ uspace/lib/c/Makefile	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -47,10 +47,9 @@
 -include arch/$(UARCH)/Makefile.inc
 
-ARCH_AUTOGENS_H := $(addsuffix .h,$(basename $(ARCH_AUTOGENS_AG)))
-ARCH_AUTOGENS_PROBE_C := $(addsuffix .ag.probe.c,$(basename $(ARCH_AUTOGENS_AG)))
-ARCH_AUTOGENS_PROBE_S := $(addsuffix .ag.probe.s,$(basename $(ARCH_AUTOGENS_AG)))
-
-PRE_DEPEND += $(ARCH_AUTOGENS_H)
-EXTRA_CLEAN += $(ARCH_AUTOGENS_H) $(ARCH_AUTOGENS_PROBE_C) $(ARCH_AUTOGENS_PROBE_S)
+ARCH_AUTOGENS_PROBE_C := $(ARCH_AUTOGENS_AG:%.ag.h=.ag.c)
+ARCH_AUTOGENS_PROBE_S := $(ARCH_AUTOGENS_AG:%.ag.h=.ag.s)
+
+PRE_DEPEND += $(ARCH_AUTOGENS_AG)
+EXTRA_CLEAN += $(ARCH_AUTOGENS_AG) $(ARCH_AUTOGENS_PROBE_C) $(ARCH_AUTOGENS_PROBE_S)
 
 GENERIC_SOURCES = \
@@ -179,4 +178,6 @@
 endif
 
+ARCH_SOURCES += $(ARCH_AUTOCHECK_HEADERS:%.h=%.check.c)
+
 SOURCES = \
 	$(GENERIC_SOURCES) \
@@ -195,9 +196,4 @@
 include $(USPACE_PREFIX)/Makefile.common
 
-%.h: %.ag
-	$(AUTOGEN) probe $< >$<.probe.c
-	$(CC_AUTOGEN) $(DEFS) $(CFLAGS) -S -o $<.probe.s $<.probe.c
-	$(AUTOGEN) generate $< <$<.probe.s >$@
-
 $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
 	$(CC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -E -x c $< | grep -v "^\#" > $@
@@ -208,2 +204,7 @@
 $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
 	$(CC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -DDLEXE -E -x c $< | grep -v "^\#" > $@
+
+AUTOCHECK = $(realpath $(ROOT_PATH)/tools/autocheck.awk)
+
+%.check.c: %.h $(AUTOCHECK)
+	cd $(<D) && $(AUTOCHECK) $(<F) > $(@F)
Index: uspace/lib/c/arch/amd64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/amd64/Makefile.inc	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ uspace/lib/c/arch/amd64/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -36,7 +36,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: uspace/lib/c/arch/amd64/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/fibril_context.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,86 +1,0 @@
-# Copyright (c) 2014 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-{
-        name : context,
-
-        includes : [
-                {
-                        include : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                },
-        ],
-
-        members : [
-                #
-                # We include only registers that must be preserved
-                # during function call.
-                #
-
-                {
-                        name : sp,
-                        type : uint64_t
-                },
-                {
-                        name : pc,
-                        type : uint64_t
-                },
-
-                {
-                        name : rbx,
-                        type : uint64_t
-                },
-                {
-                        name : rbp,
-                        type : uint64_t
-                },
-
-                {
-                        name : r12,
-                        type : uint64_t
-                },
-                {
-                        name : r13,
-                        type : uint64_t
-                },
-                {
-                        name : r14,
-                        type : uint64_t
-                },
-                {
-                        name : r15,
-                        type : uint64_t
-                },
-
-                {
-                        name : tls,
-                        type : uint64_t
-                }
-        ]
-}
Index: uspace/lib/c/arch/amd64/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/amd64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,63 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define CONTEXT_OFFSET_SP   0x00
+#define CONTEXT_OFFSET_PC   0x08
+#define CONTEXT_OFFSET_RBX  0x10
+#define CONTEXT_OFFSET_RBP  0x18
+#define CONTEXT_OFFSET_R12  0x20
+#define CONTEXT_OFFSET_R13  0x28
+#define CONTEXT_OFFSET_R14  0x30
+#define CONTEXT_OFFSET_R15  0x38
+#define CONTEXT_OFFSET_TLS  0x40
+#define CONTEXT_SIZE        0x48
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+typedef struct context {
+	/* We include only registers that must be preserved
+	 * during function call.
+	 */
+	uint64_t sp;
+	uint64_t pc;
+	uint64_t rbx;
+	uint64_t rbp;
+	uint64_t r12;
+	uint64_t r13;
+	uint64_t r14;
+	uint64_t r15;
+	uint64_t tls;
+} context_t;
+
+#endif
+#endif
+
Index: uspace/lib/c/arch/amd64/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/istate_struct.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/amd64/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/amd64/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/amd64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/amd64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/amd64/include/arch/istate_struct.h
Index: uspace/lib/c/arch/arm32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/arm32/Makefile.inc	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ uspace/lib/c/arch/arm32/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -38,8 +38,4 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
-
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
 
Index: uspace/lib/c/arch/arm32/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/fibril_context.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,92 +1,0 @@
-# Copyright (c) 2014 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-{
-        name : context,
-
-        includes : [
-                {
-                        include : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-       #
-       # Only registers preserved accross function calls are included. r9 is
-       # used to store a TLS address. -ffixed-r9 gcc forces gcc not to use this
-       # register. -mtp=soft forces gcc to use #__aeabi_read_tp to obtain
-       # TLS address.
-       #
-        members : [
-                {
-                        name : sp,
-                        type : uintptr_t
-                },
-                {
-                        name : pc,
-                        type : uintptr_t
-                },
-
-                {
-                        name : r4,
-                        type : uint32_t
-                },
-                {
-                        name : r5,
-                        type : uint32_t
-                },
-                {
-                        name : r6,
-                        type : uint32_t
-                },
-                {
-                        name : r7,
-                        type : uint32_t
-                },
-                {
-                        name : r8,
-                        type : uint32_t
-                },
-                {
-                        # r9
-                        name : tls,
-                        type : uint32_t
-                },
-                {
-                        name : r10,
-                        type : uint32_t
-                },
-                {
-                        # r11
-                        name : fp,
-                        type : uint32_t
-                }
-        ]
-}
-
Index: uspace/lib/c/arch/arm32/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/arm32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,58 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#include <stdint.h>
+
+/*
+ * Only registers preserved accross function calls are included. r9 is
+ * used to store a TLS address. -ffixed-r9 gcc forces gcc not to use this
+ * register. -mtp=soft forces gcc to use #__aeabi_read_tp to obtain
+ * TLS address.
+ */
+
+// XXX: This struct must match the assembly code in src/fibril.S
+
+typedef struct context {
+	uintptr_t sp;
+	uintptr_t pc;
+	uint32_t r4;
+	uint32_t r5;
+	uint32_t r6;
+	uint32_t r7;
+	uint32_t r8;
+	/* r9*/
+	uint32_t tls;
+	uint32_t r10;
+	/* r11 */
+	uint32_t fp;
+} context_t;
+
+#endif
+
Index: uspace/lib/c/arch/arm32/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/istate_struct.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/arm32/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/arm32/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/arm32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/arm32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/arm32/include/arch/istate_struct.h
Index: uspace/lib/c/arch/ia32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/ia32/Makefile.inc	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ uspace/lib/c/arch/ia32/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -38,7 +38,6 @@
 	arch/$(UARCH)/src/rtld/reloc.c
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: uspace/lib/c/arch/ia32/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/fibril_context.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,77 +1,0 @@
-# Copyright (c) 2014 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-{
-        name : context,
-
-        includes : [
-                {
-                        include : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-        members : [
-                #
-                # We include only registers that must be preserved
-                # during function call.
-                #
-
-                {
-                        name : sp,
-                        type : uint32_t
-                },
-                {
-                        name : pc,
-                        type : uint32_t
-                },
-
-                {
-                        name : ebx,
-                        type : uint32_t
-                },
-                {
-                        name : esi,
-                        type : uint32_t
-                },
-                {
-                        name : edi,
-                        type : uint32_t
-                },
-                {
-                        name : ebp,
-                        type : uint32_t
-                },
-
-                {
-                        name : tls,
-                        type : uint32_t
-                }
-        ]
-}
Index: uspace/lib/c/arch/ia32/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/ia32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,57 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights preserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define CONTEXT_OFFSET_SP   0x00
+#define CONTEXT_OFFSET_PC   0x04
+#define CONTEXT_OFFSET_EBX  0x08
+#define CONTEXT_OFFSET_ESI  0x0c
+#define CONTEXT_OFFSET_EDI  0x10
+#define CONTEXT_OFFSET_EBP  0x14
+#define CONTEXT_OFFSET_TLS  0x18
+#define CONTEXT_SIZE        0x1c
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+/* We include only registers that must be preserved during function call. */
+typedef struct context {
+	uint32_t sp;
+	uint32_t pc;
+	uint32_t ebx;
+	uint32_t esi;
+	uint32_t edi;
+	uint32_t ebp;
+	uint32_t tls;
+} context_t;
+
+#endif
+#endif
+
Index: uspace/lib/c/arch/ia32/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/istate_struct.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/ia32/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/ia32/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/ia32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/ia32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/ia32/include/arch/istate_struct.h
Index: uspace/lib/c/arch/ia64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/ia64/Makefile.inc	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ uspace/lib/c/arch/ia64/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -37,7 +37,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: uspace/lib/c/arch/ia64/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/ia64/include/libarch/fibril_context.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,235 +1,0 @@
-# Copyright (c) 2014 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-{
-        name : context,
-
-        includes : [
-                {
-                        include : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-        #
-        # Only save registers that must be preserved across function calls.
-        #
-        members : [
-                #
-                # Application registers
-                #
-                {
-                        name : ar_pfs,
-                        type : uint64_t
-                },
-                {
-                        name : ar_unat_caller,
-                        type : uint64_t
-                },
-                {
-                        name : ar_unat_callee,
-                        type : uint64_t
-                },
-                {
-                        name : ar_rsc,
-                        type : uint64_t
-                },
-                {
-                        # ar_bsp
-                        name : bsp,
-                        type : uint64_t
-                },
-                {
-                        name : ar_rnat,
-                        type : uint64_t
-                },
-                {
-                        name : ar_lc,
-                        type : uint64_t
-                },
-
-
-                #
-                # General registers
-                #
-                {
-                        name : r1,
-                        type : uint64_t
-                },
-                {
-                        name : r4,
-                        type : uint64_t
-                },
-                {
-                        name : r5,
-                        type : uint64_t
-                },
-                {
-                        name : r6,
-                        type : uint64_t
-                },
-                {
-                        name : r7,
-                        type : uint64_t
-                },
-                {
-                        # r12
-                        name : sp,
-                        type : uint64_t
-                },
-                {
-                        # r13
-                        name : tp,
-                        type : uint64_t
-                },
-
-
-                #
-                # Branch registers
-                #
-                {
-                        # b0
-                        name : pc,
-                        type : uint64_t
-                },
-                {
-                        name : b1,
-                        type : uint64_t
-                },
-                {
-                        name : b2,
-                        type : uint64_t
-                },
-                {
-                        name : b3,
-                        type : uint64_t
-                },
-                {
-                        name : b4,
-                        type : uint64_t
-                },
-                {
-                        name : b5,
-                        type : uint64_t
-                },
-
-
-                #
-                # Predicate registers
-                #
-                {
-                        name : pr,
-                        type : uint64_t
-                },
-
-                {
-                        name : f2,
-                        type : uint128_t
-                },
-                {
-                        name : f3,
-                        type : uint128_t
-                },
-                {
-                        name : f4,
-                        type : uint128_t
-                },
-                {
-                        name : f5,
-                        type : uint128_t
-                },
-
-                {
-                        name : f16,
-                        type : uint128_t
-                },
-                {
-                        name : f17,
-                        type : uint128_t
-                },
-                {
-                        name : f18,
-                        type : uint128_t
-                },
-                {
-                        name : f19,
-                        type : uint128_t
-                },
-                {
-                        name : f20,
-                        type : uint128_t
-                },
-                {
-                        name : f21,
-                        type : uint128_t
-                },
-                {
-                        name : f22,
-                        type : uint128_t
-                },
-                {
-                        name : f23,
-                        type : uint128_t
-                },
-                {
-                        name : f24,
-                        type : uint128_t
-                },
-                {
-                        name : f25,
-                        type : uint128_t
-                },
-                {
-                        name : f26,
-                        type : uint128_t
-                },
-                {
-                        name : f27,
-                        type : uint128_t
-                },
-                {
-                        name : f28,
-                        type : uint128_t
-                },
-                {
-                        name : f29,
-                        type : uint128_t
-                },
-                {
-                        name : f30,
-                        type : uint128_t
-                },
-                {
-                        name : f31,
-                        type : uint128_t
-                }
-
-        ]
-}
-
Index: uspace/lib/c/arch/ia64/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/ia64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/ia64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,136 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights preserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define CONTEXT_OFFSET_AR_PFS          0x000
+#define CONTEXT_OFFSET_AR_UNAT_CALLER  0x008
+#define CONTEXT_OFFSET_AR_UNAT_CALLEE  0x010
+#define CONTEXT_OFFSET_AR_RSC          0x018
+#define CONTEXT_OFFSET_BSP             0x020
+#define CONTEXT_OFFSET_AR_RNAT         0x028
+#define CONTEXT_OFFSET_AR_LC           0x030
+#define CONTEXT_OFFSET_R1              0x038
+#define CONTEXT_OFFSET_R4              0x040
+#define CONTEXT_OFFSET_R5              0x048
+#define CONTEXT_OFFSET_R6              0x050
+#define CONTEXT_OFFSET_R7              0x058
+#define CONTEXT_OFFSET_SP              0x060
+#define CONTEXT_OFFSET_TP              0x068
+#define CONTEXT_OFFSET_PC              0x070
+#define CONTEXT_OFFSET_B1              0x078
+#define CONTEXT_OFFSET_B2              0x080
+#define CONTEXT_OFFSET_B3              0x088
+#define CONTEXT_OFFSET_B4              0x090
+#define CONTEXT_OFFSET_B5              0x098
+#define CONTEXT_OFFSET_PR              0x0a0
+#define CONTEXT_OFFSET_F2              0x0b0
+#define CONTEXT_OFFSET_F3              0x0c0
+#define CONTEXT_OFFSET_F4              0x0d0
+#define CONTEXT_OFFSET_F5              0x0e0
+#define CONTEXT_OFFSET_F16             0x0f0
+#define CONTEXT_OFFSET_F17             0x100
+#define CONTEXT_OFFSET_F18             0x110
+#define CONTEXT_OFFSET_F19             0x120
+#define CONTEXT_OFFSET_F20             0x130
+#define CONTEXT_OFFSET_F21             0x140
+#define CONTEXT_OFFSET_F22             0x150
+#define CONTEXT_OFFSET_F23             0x160
+#define CONTEXT_OFFSET_F24             0x170
+#define CONTEXT_OFFSET_F25             0x180
+#define CONTEXT_OFFSET_F26             0x190
+#define CONTEXT_OFFSET_F27             0x1a0
+#define CONTEXT_OFFSET_F28             0x1b0
+#define CONTEXT_OFFSET_F29             0x1c0
+#define CONTEXT_OFFSET_F30             0x1d0
+#define CONTEXT_OFFSET_F31             0x1e0
+#define CONTEXT_SIZE                   0x1f0
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+// Only save registers that must be preserved across function calls.
+typedef struct context {
+	// Application registers.
+	uint64_t ar_pfs;
+	uint64_t ar_unat_caller;
+	uint64_t ar_unat_callee;
+	uint64_t ar_rsc;
+	// ar_bsp
+	uint64_t bsp;
+	uint64_t ar_rnat;
+	uint64_t ar_lc;
+
+	// General registers.
+	uint64_t r1;
+	uint64_t r4;
+	uint64_t r5;
+	uint64_t r6;
+	uint64_t r7;
+	// r12
+	uint64_t sp;
+	// r13
+	uint64_t tp;
+
+	// Branch registers.
+	// b0
+	uint64_t pc;
+	uint64_t b1;
+	uint64_t b2;
+	uint64_t b3;
+	uint64_t b4;
+	uint64_t b5;
+
+	// Predicate registers.
+	uint64_t pr;
+	uint128_t f2;
+	uint128_t f3;
+	uint128_t f4;
+	uint128_t f5;
+	uint128_t f16;
+	uint128_t f17;
+	uint128_t f18;
+	uint128_t f19;
+	uint128_t f20;
+	uint128_t f21;
+	uint128_t f22;
+	uint128_t f23;
+	uint128_t f24;
+	uint128_t f25;
+	uint128_t f26;
+	uint128_t f27;
+	uint128_t f28;
+	uint128_t f29;
+	uint128_t f30;
+	uint128_t f31;
+} context_t;
+
+#endif  /* __ASSEMBLER__ */
+#endif
+
Index: uspace/lib/c/arch/ia64/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/ia64/include/libarch/istate_struct.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/ia64/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/ia64/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/ia64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/ia64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/ia64/include/arch/istate_struct.h
Index: uspace/lib/c/arch/mips32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/mips32/Makefile.inc	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ uspace/lib/c/arch/mips32/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -36,7 +36,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: uspace/lib/c/arch/mips32/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/fibril_context.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,141 +1,0 @@
-# Copyright (c) 2014 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-{
-        name : context,
-
-        includes : [
-                {
-                        include : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-        members : [
-                {
-                        name : sp,
-                        type : uint32_t
-                },
-                {
-                        name : pc,
-                        type : uint32_t
-                },
-
-                {
-                        name : s0,
-                        type : uint32_t
-                },
-                {
-                        name : s1,
-                        type : uint32_t
-                },
-                {
-                        name : s2,
-                        type : uint32_t
-                },
-                {
-                        name : s3,
-                        type : uint32_t
-                },
-                {
-                        name : s4,
-                        type : uint32_t
-                },
-                {
-                        name : s5,
-                        type : uint32_t
-                },
-                {
-                        name : s6,
-                        type : uint32_t
-                },
-                {
-                        name : s7,
-                        type : uint32_t
-                },
-                {
-                        name : s8,
-                        type : uint32_t
-                },
-                {
-                        name : gp,
-                        type : uint32_t
-                },
-                {
-                        # Thread local storage (k1)
-                        name : tls,
-                        type : uint32_t
-                },
-
-                {
-                        name : f20,
-                        type : uint32_t
-                },
-                {
-                        name : f21,
-                        type : uint32_t
-                },
-                {
-                        name : f22,
-                        type : uint32_t
-                },
-                {
-                        name : f23,
-                        type : uint32_t
-                },
-                {
-                        name : f24,
-                        type : uint32_t
-                },
-                {
-                        name : f25,
-                        type : uint32_t
-                },
-                {
-                        name : f26,
-                        type : uint32_t
-                },
-                {
-                        name : f27,
-                        type : uint32_t
-                },
-                {
-                        name : f28,
-                        type : uint32_t
-                },
-                {
-                        name : f29,
-                        type : uint32_t
-                },
-                {
-                        name : f30,
-                        type : uint32_t
-                }
-        ]
-}
Index: uspace/lib/c/arch/mips32/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/mips32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,92 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define CONTEXT_OFFSET_SP   0x00
+#define CONTEXT_OFFSET_PC   0x04
+#define CONTEXT_OFFSET_S0   0x08
+#define CONTEXT_OFFSET_S1   0x0c
+#define CONTEXT_OFFSET_S2   0x10
+#define CONTEXT_OFFSET_S3   0x14
+#define CONTEXT_OFFSET_S4   0x18
+#define CONTEXT_OFFSET_S5   0x1c
+#define CONTEXT_OFFSET_S6   0x20
+#define CONTEXT_OFFSET_S7   0x24
+#define CONTEXT_OFFSET_S8   0x28
+#define CONTEXT_OFFSET_GP   0x2c
+#define CONTEXT_OFFSET_TLS  0x30
+#define CONTEXT_OFFSET_F20  0x34
+#define CONTEXT_OFFSET_F21  0x38
+#define CONTEXT_OFFSET_F22  0x3c
+#define CONTEXT_OFFSET_F23  0x40
+#define CONTEXT_OFFSET_F24  0x44
+#define CONTEXT_OFFSET_F25  0x48
+#define CONTEXT_OFFSET_F26  0x4c
+#define CONTEXT_OFFSET_F27  0x50
+#define CONTEXT_OFFSET_F28  0x54
+#define CONTEXT_OFFSET_F29  0x58
+#define CONTEXT_OFFSET_F30  0x5c
+#define CONTEXT_SIZE        0x60
+
+#ifndef __ASSEMBLER__
+
+#include <stddef.h>
+#include <stdint.h>
+
+typedef struct context {
+	uint32_t sp;
+	uint32_t pc;
+	uint32_t s0;
+	uint32_t s1;
+	uint32_t s2;
+	uint32_t s3;
+	uint32_t s4;
+	uint32_t s5;
+	uint32_t s6;
+	uint32_t s7;
+	uint32_t s8;
+	uint32_t gp;
+	/* Thread local storage (k1) */
+	uint32_t tls;
+	uint32_t f20;
+	uint32_t f21;
+	uint32_t f22;
+	uint32_t f23;
+	uint32_t f24;
+	uint32_t f25;
+	uint32_t f26;
+	uint32_t f27;
+	uint32_t f28;
+	uint32_t f29;
+	uint32_t f30;
+} context_t;
+
+#endif
+#endif
+
Index: uspace/lib/c/arch/mips32/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/istate_struct.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/mips32/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/mips32/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/mips32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/mips32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/mips32/include/arch/istate_struct.h
Index: uspace/lib/c/arch/mips32eb/Makefile.inc
===================================================================
--- uspace/lib/c/arch/mips32eb/Makefile.inc	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ uspace/lib/c/arch/mips32eb/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -36,7 +36,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: uspace/lib/c/arch/mips32eb/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/fibril_context.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../mips32/include/libarch/fibril_context.ag
Index: uspace/lib/c/arch/mips32eb/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/mips32eb/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../mips32/include/libarch/fibril_context.h
Index: uspace/lib/c/arch/mips32eb/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/istate_struct.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../mips32/include/libarch/istate_struct.ag
Index: uspace/lib/c/arch/mips32eb/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/mips32eb/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/mips32eb/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../mips32/include/libarch/istate_struct.h
Index: uspace/lib/c/arch/ppc32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/ppc32/Makefile.inc	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ uspace/lib/c/arch/ppc32/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -36,7 +36,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: uspace/lib/c/arch/ppc32/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/fibril_context.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,137 +1,0 @@
-# Copyright (c) 2014 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-{
-        name : context,
-
-        includes : [
-                {
-                        include : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-        members : [
-                {
-                        name : sp,
-                        type : uint32_t
-                },
-                {
-                        name : pc,
-                        type : uint32_t
-                },
-
-                {
-                        name : tls,
-                        type : uint32_t
-                },
-                {
-                        name : r13,
-                        type : uint32_t
-                },
-                {
-                        name : r14,
-                        type : uint32_t
-                },
-                {
-                        name : r15,
-                        type : uint32_t
-                },
-                {
-                        name : r16,
-                        type : uint32_t
-                },
-                {
-                        name : r17,
-                        type : uint32_t
-                },
-                {
-                        name : r18,
-                        type : uint32_t
-                },
-                {
-                        name : r19,
-                        type : uint32_t
-                },
-                {
-                        name : r20,
-                        type : uint32_t
-                },
-                {
-                        name : r21,
-                        type : uint32_t
-                },
-                {
-                        name : r22,
-                        type : uint32_t
-                },
-                {
-                        name : r23,
-                        type : uint32_t
-                },
-                {
-                        name : r24,
-                        type : uint32_t
-                },
-                {
-                        name : r25,
-                        type : uint32_t
-                },
-                {
-                        name : r26,
-                        type : uint32_t
-                },
-                {
-                        name : r27,
-                        type : uint32_t
-                },
-                {
-                        name : r28,
-                        type : uint32_t
-                },
-                {
-                        name : r29,
-                        type : uint32_t
-                },
-                {
-                        name : r30,
-                        type : uint32_t
-                },
-                {
-                        name : r31,
-                        type : uint32_t
-                },
-
-                {
-                        name : cr,
-                        type : uint32_t
-                }
-        ]
-}
-
Index: uspace/lib/c/arch/ppc32/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/ppc32/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,89 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define CONTEXT_OFFSET_SP   0x00
+#define CONTEXT_OFFSET_PC   0x04
+#define CONTEXT_OFFSET_TLS  0x08
+#define CONTEXT_OFFSET_R13  0x0c
+#define CONTEXT_OFFSET_R14  0x10
+#define CONTEXT_OFFSET_R15  0x14
+#define CONTEXT_OFFSET_R16  0x18
+#define CONTEXT_OFFSET_R17  0x1c
+#define CONTEXT_OFFSET_R18  0x20
+#define CONTEXT_OFFSET_R19  0x24
+#define CONTEXT_OFFSET_R20  0x28
+#define CONTEXT_OFFSET_R21  0x2c
+#define CONTEXT_OFFSET_R22  0x30
+#define CONTEXT_OFFSET_R23  0x34
+#define CONTEXT_OFFSET_R24  0x38
+#define CONTEXT_OFFSET_R25  0x3c
+#define CONTEXT_OFFSET_R26  0x40
+#define CONTEXT_OFFSET_R27  0x44
+#define CONTEXT_OFFSET_R28  0x48
+#define CONTEXT_OFFSET_R29  0x4c
+#define CONTEXT_OFFSET_R30  0x50
+#define CONTEXT_OFFSET_R31  0x54
+#define CONTEXT_OFFSET_CR   0x58
+#define CONTEXT_SIZE        0x5c
+
+#ifndef __ASSEMBLER__
+
+#include <stddef.h>
+#include <stdint.h>
+
+typedef struct context {
+	uint32_t sp;
+	uint32_t pc;
+	uint32_t tls;
+	uint32_t r13;
+	uint32_t r14;
+	uint32_t r15;
+	uint32_t r16;
+	uint32_t r17;
+	uint32_t r18;
+	uint32_t r19;
+	uint32_t r20;
+	uint32_t r21;
+	uint32_t r22;
+	uint32_t r23;
+	uint32_t r24;
+	uint32_t r25;
+	uint32_t r26;
+	uint32_t r27;
+	uint32_t r28;
+	uint32_t r29;
+	uint32_t r30;
+	uint32_t r31;
+	uint32_t cr;
+} context_t;
+
+#endif
+#endif
+
Index: uspace/lib/c/arch/ppc32/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/istate_struct.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/ppc32/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/ppc32/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/ppc32/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/ppc32/include/arch/istate_struct.h
Index: uspace/lib/c/arch/riscv64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/riscv64/Makefile.inc	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ uspace/lib/c/arch/riscv64/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -35,7 +35,6 @@
 	arch/$(UARCH)/src/stacktrace.c
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: uspace/lib/c/arch/riscv64/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/riscv64/include/libarch/fibril_context.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,182 +1,0 @@
-#
-# Copyright (c) 2016 Martin Decky
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-{
-        name : context,
-
-        includes : [
-                {
-                        include : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-        members : [
-                #
-                # There is a room for optimization (we can store just those
-                # registers that must be preserved during ABI function call).
-                #
-
-                {
-                        name : sp,
-                        type : uint64_t
-                },
-                {
-                        name : pc,
-                        type : uint64_t
-                },
-
-                {
-                        name : zero,
-                        type : uint64_t
-                },
-                {
-                        name : ra,
-                        type : uint64_t
-                },
-
-                {
-                        name : x3,
-                        type : uint64_t
-                },
-                {
-                        name : x4,
-                        type : uint64_t
-                },
-                {
-                        name : x5,
-                        type : uint64_t
-                },
-                {
-                        name : x6,
-                        type : uint64_t
-                },
-                {
-                        name : x7,
-                        type : uint64_t
-                },
-                {
-                        name : x8,
-                        type : uint64_t
-                },
-                {
-                        name : x9,
-                        type : uint64_t
-                },
-                {
-                        name : x10,
-                        type : uint64_t
-                },
-                {
-                        name : x11,
-                        type : uint64_t
-                },
-                {
-                        name : x12,
-                        type : uint64_t
-                },
-                {
-                        name : x13,
-                        type : uint64_t
-                },
-                {
-                        name : x14,
-                        type : uint64_t
-                },
-                {
-                        name : x15,
-                        type : uint64_t
-                },
-                {
-                        name : x16,
-                        type : uint64_t
-                },
-                {
-                        name : x17,
-                        type : uint64_t
-                },
-                {
-                        name : x18,
-                        type : uint64_t
-                },
-                {
-                        name : x19,
-                        type : uint64_t
-                },
-                {
-                        name : x20,
-                        type : uint64_t
-                },
-                {
-                        name : x21,
-                        type : uint64_t
-                },
-                {
-                        name : x22,
-                        type : uint64_t
-                },
-                {
-                        name : x23,
-                        type : uint64_t
-                },
-                {
-                        name : x24,
-                        type : uint64_t
-                },
-                {
-                        name : x25,
-                        type : uint64_t
-                },
-                {
-                        name : x26,
-                        type : uint64_t
-                },
-                {
-                        name : x27,
-                        type : uint64_t
-                },
-                {
-                        name : x28,
-                        type : uint64_t
-                },
-                {
-                        name : x29,
-                        type : uint64_t
-                },
-                {
-                        name : x30,
-                        type : uint64_t
-                },
-                {
-                        name : x31,
-                        type : uint64_t
-                }
-        ]
-}
Index: uspace/lib/c/arch/riscv64/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/riscv64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/riscv64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,114 @@
+/* Copyright (c) 2016 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define CONTEXT_OFFSET_SP   0x00
+#define CONTEXT_OFFSET_PC   0x08
+#define CONTEXT_OFFSET_ZERO 0x10
+#define CONTEXT_OFFSET_RA   0x18
+#define CONTEXT_OFFSET_X3   0x20
+#define CONTEXT_OFFSET_X4   0x28
+#define CONTEXT_OFFSET_X5   0x30
+#define CONTEXT_OFFSET_X6   0x38
+#define CONTEXT_OFFSET_X7   0x40
+#define CONTEXT_OFFSET_X8   0x48
+#define CONTEXT_OFFSET_X9   0x50
+#define CONTEXT_OFFSET_X10  0x58
+#define CONTEXT_OFFSET_X11  0x60
+#define CONTEXT_OFFSET_X12  0x68
+#define CONTEXT_OFFSET_X13  0x70
+#define CONTEXT_OFFSET_X14  0x78
+#define CONTEXT_OFFSET_X15  0x80
+#define CONTEXT_OFFSET_X16  0x88
+#define CONTEXT_OFFSET_X17  0x90
+#define CONTEXT_OFFSET_X18  0x98
+#define CONTEXT_OFFSET_X19  0xa0
+#define CONTEXT_OFFSET_X20  0xa8
+#define CONTEXT_OFFSET_X21  0xb0
+#define CONTEXT_OFFSET_X22  0xb8
+#define CONTEXT_OFFSET_X23  0xc0
+#define CONTEXT_OFFSET_X24  0xc8
+#define CONTEXT_OFFSET_X25  0xd0
+#define CONTEXT_OFFSET_X26  0xd8
+#define CONTEXT_OFFSET_X27  0xe0
+#define CONTEXT_OFFSET_X28  0xe8
+#define CONTEXT_OFFSET_X29  0xf0
+#define CONTEXT_OFFSET_X30  0xf8
+#define CONTEXT_OFFSET_X31  0x100
+#define CONTEXT_SIZE        0x108
+
+#ifndef __ASSEMBLER__
+
+#include <stddef.h>
+#include <stdint.h>
+
+/*
+ * There is a room for optimization (we can store just those
+ * registers that must be preserved during ABI function call).
+ */
+
+typedef struct context {
+	uint64_t sp;
+	uint64_t pc;
+	uint64_t zero;
+	uint64_t ra;
+	uint64_t x3;
+	uint64_t x4;
+	uint64_t x5;
+	uint64_t x6;
+	uint64_t x7;
+	uint64_t x8;
+	uint64_t x9;
+	uint64_t x10;
+	uint64_t x11;
+	uint64_t x12;
+	uint64_t x13;
+	uint64_t x14;
+	uint64_t x15;
+	uint64_t x16;
+	uint64_t x17;
+	uint64_t x18;
+	uint64_t x19;
+	uint64_t x20;
+	uint64_t x21;
+	uint64_t x22;
+	uint64_t x23;
+	uint64_t x24;
+	uint64_t x25;
+	uint64_t x26;
+	uint64_t x27;
+	uint64_t x28;
+	uint64_t x29;
+	uint64_t x30;
+	uint64_t x31;
+} context_t;
+
+#endif
+#endif
+
Index: uspace/lib/c/arch/riscv64/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/riscv64/include/libarch/istate_struct.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/riscv64/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/riscv64/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/riscv64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/riscv64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/riscv64/include/arch/istate_struct.h
Index: uspace/lib/c/arch/sparc64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/sparc64/Makefile.inc	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ uspace/lib/c/arch/sparc64/Makefile.inc	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -35,7 +35,6 @@
 	arch/$(UARCH)/src/stacktrace_asm.S
 
-ARCH_AUTOGENS_AG = \
-	arch/$(UARCH)/include/libarch/istate_struct.ag \
-	arch/$(UARCH)/include/libarch/fibril_context.ag
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
 
 EXTRA_OUTPUT += arch/$(UARCH)/src/entry.o
Index: uspace/lib/c/arch/sparc64/include/libarch/fibril_context.ag
===================================================================
--- uspace/lib/c/arch/sparc64/include/libarch/fibril_context.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,126 +1,0 @@
-# Copyright (c) 2014 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-{
-        name : context,
-
-        includes : [
-                {
-                        include : <stddef.h>
-                },
-                {
-                        include : <stdint.h>
-                }
-        ],
-
-        #
-        # Save only registers that must be preserved across function calls.
-        #
-        members : [
-                {
-                        # %o6
-                        name : sp,
-                        type : uintptr_t
-                },
-                {
-                        # %o7
-                        name : pc,
-                        type : uintptr_t
-                },
-                {
-                        name : i0,
-                        type : uint64_t
-                },
-                {
-                        name : i1,
-                        type : uint64_t
-                },
-                {
-                        name : i2,
-                        type : uint64_t
-                },
-                {
-                        name : i3,
-                        type : uint64_t
-                },
-                {
-                        name : i4,
-                        type : uint64_t
-                },
-                {
-                        name : i5,
-                        type : uint64_t
-                },
-                {
-                        # %i6
-                        name : fp,
-                        type : uintptr_t
-                },
-                {
-                        name : i7,
-                        type : uintptr_t
-                },
-                {
-                        name : l0,
-                        type : uint64_t
-                },
-                {
-                        name : l1,
-                        type : uint64_t
-                },
-                {
-                        name : l2,
-                        type : uint64_t
-                },
-                {
-                        name : l3,
-                        type : uint64_t
-                },
-                {
-                        name : l4,
-                        type : uint64_t
-                },
-                {
-                        name : l5,
-                        type : uint64_t
-                },
-                {
-                        name : l6,
-                        type : uint64_t
-                },
-                {
-                        name : l7,
-                        type : uint64_t
-                },
-                {
-                        # %g7
-                        name : tp,
-                        type : uint64_t
-                }
-        ]
-}
-
Index: uspace/lib/c/arch/sparc64/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/sparc64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/sparc64/include/libarch/fibril_context.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,81 @@
+/* Copyright (c) 2014 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define CONTEXT_OFFSET_SP  0x00
+#define CONTEXT_OFFSET_PC  0x08
+#define CONTEXT_OFFSET_I0  0x10
+#define CONTEXT_OFFSET_I1  0x18
+#define CONTEXT_OFFSET_I2  0x20
+#define CONTEXT_OFFSET_I3  0x28
+#define CONTEXT_OFFSET_I4  0x30
+#define CONTEXT_OFFSET_I5  0x38
+#define CONTEXT_OFFSET_FP  0x40
+#define CONTEXT_OFFSET_I7  0x48
+#define CONTEXT_OFFSET_L0  0x50
+#define CONTEXT_OFFSET_L1  0x58
+#define CONTEXT_OFFSET_L2  0x60
+#define CONTEXT_OFFSET_L3  0x68
+#define CONTEXT_OFFSET_L4  0x70
+#define CONTEXT_OFFSET_L5  0x78
+#define CONTEXT_OFFSET_L6  0x80
+#define CONTEXT_OFFSET_L7  0x88
+#define CONTEXT_OFFSET_TP  0x90
+#define CONTEXT_SIZE       0x98
+
+#ifndef __ASSEMBLER__
+
+#include <stddef.h>
+#include <stdint.h>
+
+typedef struct context {
+	uintptr_t sp;  // %o6
+	uintptr_t pc;  // %o7
+	uint64_t i0;
+	uint64_t i1;
+	uint64_t i2;
+	uint64_t i3;
+	uint64_t i4;
+	uint64_t i5;
+	uintptr_t fp;  // %i6
+	uintptr_t i7;
+	uint64_t l0;
+	uint64_t l1;
+	uint64_t l2;
+	uint64_t l3;
+	uint64_t l4;
+	uint64_t l5;
+	uint64_t l6;
+	uint64_t l7;
+	uint64_t tp;  // %g7
+} context_t;
+
+#endif
+#endif
+
Index: uspace/lib/c/arch/sparc64/include/libarch/istate_struct.ag
===================================================================
--- uspace/lib/c/arch/sparc64/include/libarch/istate_struct.ag	(revision 18b6a8849d630cc3bca153fb21bd225eebb16f4c)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../../../../../../kernel/arch/sparc64/include/arch/istate_struct.ag
Index: uspace/lib/c/arch/sparc64/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/sparc64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
+++ uspace/lib/c/arch/sparc64/include/libarch/istate_struct.h	(revision d2f75eb31efa7109d60f52eb578fddc21c8d1e2d)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/sparc64/include/arch/istate_struct.h
