Index: uspace/lib/libc/arch/ia32/src/fibril.S
===================================================================
--- uspace/lib/libc/arch/ia32/src/fibril.S	(revision d2fa31f73ac58ff863812ce8f87f1fab50d27cf9)
+++ uspace/lib/libc/arch/ia32/src/fibril.S	(revision baac91190efc683948e46ad8fc0384ce74181ea5)
@@ -27,4 +27,6 @@
 #
 
+#include <kernel/arch/context_offset.h>
+
 .text
 
@@ -42,14 +44,10 @@
 	movl 4(%esp),%edx	# address of the context variable to save context to
 
-	movl %esp,0(%edx)	# %esp -> ctx->sp
-	movl %eax,4(%edx)	# %eip -> ctx->pc
-	movl %ebx,8(%edx)	# %ebx -> ctx->ebx
-	movl %esi,12(%edx)	# %esi -> ctx->esi
-	movl %edi,16(%edx)	# %edi -> ctx->edi
-	movl %ebp,20(%edx)	# %ebp -> ctx->ebp
+		# save registers to given structure
+	CONTEXT_SAVE_ARCH_CORE %edx %eax
 
 	# Save TLS
 	movl %gs:0, %eax
-	movl %eax, 24(%edx)     # tls -> ctx->tls
+	movl %eax, OFFSET_TLS(%edx)     # tls -> ctx->tls
 	
 	xorl %eax,%eax		# context_save returns 1
@@ -65,10 +63,7 @@
 context_restore:
 	movl 4(%esp),%eax	# address of the context variable to restore context from
-	movl 0(%eax),%esp	# ctx->sp -> %esp
-	movl 4(%eax),%edx	# ctx->pc -> %edx
-	movl 8(%eax),%ebx	# ctx->ebx -> %ebx
-	movl 12(%eax),%esi	# ctx->esi -> %esi
-	movl 16(%eax),%edi	# ctx->edi -> %edi
-	movl 20(%eax),%ebp	# ctx->ebp -> %ebp
+
+		# restore registers from jmp_buf
+	CONTEXT_RESTORE_ARCH_CORE %eax %edx
 
 	movl %edx,0(%esp)	# ctx->pc -> saver's return %eip
@@ -76,5 +71,5 @@
 	# Set thread local storage
 	pushl %edx
-	movl 24(%eax), %edx   # Set arg1 to TLS addr
+	movl OFFSET_TLS(%eax), %edx   # Set arg1 to TLS addr
 	movl $1, %eax         # Syscall SYS_TLS_SET
 	int $0x30
