Index: uspace/lib/libc/arch/amd64/include/syscall.h
===================================================================
--- uspace/lib/libc/arch/amd64/include/syscall.h	(revision ddb0df58c37d07e66431a6471044949a96ecaf7d)
+++ uspace/lib/libc/arch/amd64/include/syscall.h	(revision 338a8382de09e384c0b79d87833774b803981ddf)
@@ -37,4 +37,6 @@
 #define LIBC_amd64_SYSCALL_H_
 
+#define LIBARCH_SYSCALL_GENERIC
+
 #include <syscall.h>
 
Index: uspace/lib/libc/arch/arm32/include/syscall.h
===================================================================
--- uspace/lib/libc/arch/arm32/include/syscall.h	(revision ddb0df58c37d07e66431a6471044949a96ecaf7d)
+++ uspace/lib/libc/arch/arm32/include/syscall.h	(revision 338a8382de09e384c0b79d87833774b803981ddf)
@@ -31,9 +31,11 @@
  */
 /** @file
- *  @brief Empty.
+ *  @brief
  */
 
 #ifndef LIBC_arm32_SYSCALL_H_
 #define LIBC_arm32_SYSCALL_H_
+
+#define LIBARCH_SYSCALL_GENERIC
 
 #include <syscall.h>
Index: uspace/lib/libc/arch/ia32/include/syscall.h
===================================================================
--- uspace/lib/libc/arch/ia32/include/syscall.h	(revision ddb0df58c37d07e66431a6471044949a96ecaf7d)
+++ uspace/lib/libc/arch/ia32/include/syscall.h	(revision 338a8382de09e384c0b79d87833774b803981ddf)
@@ -37,5 +37,22 @@
 #define LIBC_ia32_SYSCALL_H_
 
-#include <syscall.h>
+#include <sys/types.h>
+#include <kernel/syscall/syscall.h>
+
+#define __syscall0	__syscall_sysenter
+#define __syscall1	__syscall_sysenter
+#define __syscall2	__syscall_sysenter
+#define __syscall3	__syscall_sysenter
+#define __syscall4	__syscall_sysenter
+#define __syscall5	__syscall_int
+#define __syscall6	__syscall_int
+
+extern sysarg_t
+__syscall_sysenter(const sysarg_t, const sysarg_t, const sysarg_t, const sysarg_t,
+     const sysarg_t, const sysarg_t, const syscall_t);
+
+extern sysarg_t
+__syscall_int(const sysarg_t, const sysarg_t, const sysarg_t, const sysarg_t,
+     const sysarg_t, const sysarg_t, const syscall_t);
 
 #endif
Index: uspace/lib/libc/arch/ia32/src/syscall.S
===================================================================
--- uspace/lib/libc/arch/ia32/src/syscall.S	(revision ddb0df58c37d07e66431a6471044949a96ecaf7d)
+++ uspace/lib/libc/arch/ia32/src/syscall.S	(revision 338a8382de09e384c0b79d87833774b803981ddf)
@@ -29,5 +29,5 @@
 .text
 
-/** Syscall wrapper.
+/** Syscall wrapper - INT $0x30 version.
  *
  * Mind the order of arguments. First two arguments and the syscall number go to
@@ -35,6 +35,6 @@
  * could benefit from this and not save unused registers on the stack.
  */
-.global __syscall
-__syscall:
+.global __syscall_int
+__syscall_int:
 	pushl %ebx
 	pushl %esi
@@ -54,2 +54,37 @@
 	popl %ebx
 	ret
+
+
+/** Syscall wrapper - SYSENTER version.
+ *
+ * This is an optimized version of syscall for four or less arguments.  Note
+ * that EBP and EDI are used to remember user stack address and the return
+ * address. The kernel part doesn't save DS, ES and FS so the handler restores
+ * these to the selector immediately following CS (it must be the flat data
+ * segment, otherwise the SYSENTER wouldn't work in the first place).
+ */
+.global __syscall_sysenter
+__syscall_sysenter:
+	pushl %ebx
+	pushl %esi
+	pushl %edi
+	pushl %ebp
+	mov %esp, %ebp
+	lea ra, %edi
+	movl 20(%esp), %edx	# First argument.
+	movl 24(%esp), %ecx	# Second argument.
+	movl 28(%esp), %ebx	# Third argument.
+	movl 32(%esp), %esi	# Fourth argument.
+	movl 44(%esp), %eax	# Syscall number.
+	sysenter
+ra:
+	movw %cs, %cx
+	addw $8, %cx
+	movw %cx, %ds
+	movw %cx, %es
+	movw %cx, %fs
+	popl %ebp
+	popl %edi
+	popl %esi
+	popl %ebx
+	ret
Index: uspace/lib/libc/arch/ia64/include/syscall.h
===================================================================
--- uspace/lib/libc/arch/ia64/include/syscall.h	(revision ddb0df58c37d07e66431a6471044949a96ecaf7d)
+++ uspace/lib/libc/arch/ia64/include/syscall.h	(revision 338a8382de09e384c0b79d87833774b803981ddf)
@@ -37,4 +37,6 @@
 #define LIBC_ia64_SYSCALL_H_
 
+#define LIBARCH_SYSCALL_GENERIC
+
 #include <syscall.h>
 
Index: uspace/lib/libc/arch/mips32/include/syscall.h
===================================================================
--- uspace/lib/libc/arch/mips32/include/syscall.h	(revision ddb0df58c37d07e66431a6471044949a96ecaf7d)
+++ uspace/lib/libc/arch/mips32/include/syscall.h	(revision 338a8382de09e384c0b79d87833774b803981ddf)
@@ -37,4 +37,6 @@
 #define LIBC_mips32_SYSCALL_H_
 
+#define LIBARCH_SYSCALL_GENERIC
+
 #include <syscall.h>
 
Index: uspace/lib/libc/arch/ppc32/include/syscall.h
===================================================================
--- uspace/lib/libc/arch/ppc32/include/syscall.h	(revision ddb0df58c37d07e66431a6471044949a96ecaf7d)
+++ uspace/lib/libc/arch/ppc32/include/syscall.h	(revision 338a8382de09e384c0b79d87833774b803981ddf)
@@ -37,4 +37,6 @@
 #define LIBC_ppc32_SYSCALL_H_
 
+#define LIBARCH_SYSCALL_GENERIC
+
 #include <syscall.h>
 
Index: uspace/lib/libc/arch/ppc64/include/syscall.h
===================================================================
--- uspace/lib/libc/arch/ppc64/include/syscall.h	(revision ddb0df58c37d07e66431a6471044949a96ecaf7d)
+++ uspace/lib/libc/arch/ppc64/include/syscall.h	(revision 338a8382de09e384c0b79d87833774b803981ddf)
@@ -37,4 +37,6 @@
 #define LIBC_ppc64_SYSCALL_H_
 
+#define LIBARCH_SYSCALL_GENERIC
+
 #include <syscall.h>
 
Index: uspace/lib/libc/arch/sparc64/include/syscall.h
===================================================================
--- uspace/lib/libc/arch/sparc64/include/syscall.h	(revision ddb0df58c37d07e66431a6471044949a96ecaf7d)
+++ uspace/lib/libc/arch/sparc64/include/syscall.h	(revision 338a8382de09e384c0b79d87833774b803981ddf)
@@ -39,4 +39,12 @@
 #include <kernel/syscall/syscall.h>
 
+#define __syscall0	__syscall
+#define __syscall1	__syscall
+#define __syscall2	__syscall
+#define __syscall3	__syscall
+#define __syscall4	__syscall
+#define __syscall5	__syscall
+#define __syscall6	__syscall
+
 static inline sysarg_t
 __syscall(const sysarg_t p1, const sysarg_t p2, const sysarg_t p3,
