Index: uspace/lib/c/generic/setjmp.c
===================================================================
--- uspace/lib/c/generic/setjmp.c	(revision 8797bae1cfd5fa5ca11764060af285fe3fa72ceb)
+++ uspace/lib/c/generic/setjmp.c	(revision 91e22dcf5c44d908b24ae2bcd292787f0a7b8d96)
@@ -40,25 +40,4 @@
 #include <fibril.h>
 
-struct jmp_buf_interal {
-	context_t context;
-	int return_value;
-};
-
-/**
- * Save current environment (registers).
- *
- * This function may return twice.
- *
- * @param env Variable where to save the environment.
- * @return Whether the call returned after longjmp.
- * @retval 0 Environment was saved, normal execution.
- * @retval other longjmp was executed and returned here.
- */
-int setjmp(jmp_buf env) {
-	env->return_value = 0;
-	context_save(&env[0].context);
-	return env->return_value;
-}
-
 /**
  * Restore environment previously stored by setjmp.
Index: uspace/lib/c/include/setjmp.h
===================================================================
--- uspace/lib/c/include/setjmp.h	(revision 8797bae1cfd5fa5ca11764060af285fe3fa72ceb)
+++ uspace/lib/c/include/setjmp.h	(revision 91e22dcf5c44d908b24ae2bcd292787f0a7b8d96)
@@ -31,5 +31,8 @@
  * @{
  */
-/** @file
+/** @file Long jump implementation.
+ *
+ * Implementation inspired by Jiri Zarevucky's code from
+ * http://bazaar.launchpad.net/~zarevucky-jiri/helenos/stdc/revision/1544/uspace/lib/posix/setjmp.h
  */
 
@@ -37,12 +40,33 @@
 #define LIBC_SETJMP_H_
 
+#include <libarch/fibril.h>
+
+struct jmp_buf_interal {
+	context_t context;
+	int return_value;
+};
+typedef struct jmp_buf_interal jmp_buf[1];
+
 /*
- * We hide the structure to allow smooth inclusion from libposix
- * as no other types are necessary (and thus no includes are needed).
+ * Specified as extern to minimize number of included headers
+ * because this file is used as is in libposix too.
  */
-struct jmp_buf_interal;
-typedef struct jmp_buf_interal *jmp_buf;
+extern int context_save(context_t *ctx) __attribute__((returns_twice));
 
-extern int setjmp(jmp_buf env);
+/**
+ * Save current environment (registers).
+ *
+ * This function may return twice.
+ *
+ * @param env Variable where to save the environment (of type jmp_buf).
+ * @return Whether the call returned after longjmp.
+ * @retval 0 Environment was saved, normal execution.
+ * @retval other longjmp was executed and returned here.
+ */
+#define setjmp(env) \
+	((env)[0].return_value = 0, \
+	context_save(&(env)[0].context), \
+	(env)[0].return_value)
+
 extern void longjmp(jmp_buf env, int val) __attribute__((noreturn));
 
