Index: arch/amd64/include/atomic.h
===================================================================
--- arch/amd64/include/atomic.h	(revision 9e1c9420613588b3f800b5cc0675f338b0bafea8)
+++ arch/amd64/include/atomic.h	(revision 9a2d6e1cf6667f28beec57a2227821b398296732)
@@ -60,5 +60,5 @@
 }
 
-static inline count_t atomic_inc_pre(atomic_t *val) 
+static inline count_t atomic_postinc(atomic_t *val) 
 {
 	count_t r;
@@ -73,5 +73,5 @@
 }
 
-static inline count_t atomic_dec_pre(atomic_t *val) 
+static inline count_t atomic_postdec(atomic_t *val) 
 {
 	count_t r;
@@ -86,6 +86,6 @@
 }
 
-#define atomic_inc_post(val) (atomic_inc_pre(val)+1)
-#define atomic_dec_post(val) (atomic_dec_pre(val)-1)
+#define atomic_preinc(val) (atomic_postinc(val)+1)
+#define atomic_predec(val) (atomic_postdec(val)-1)
 
 static inline __u64 test_and_set(atomic_t *val) {
Index: arch/ia32/include/atomic.h
===================================================================
--- arch/ia32/include/atomic.h	(revision 9e1c9420613588b3f800b5cc0675f338b0bafea8)
+++ arch/ia32/include/atomic.h	(revision 9a2d6e1cf6667f28beec57a2227821b398296732)
@@ -60,5 +60,5 @@
 }
 
-static inline count_t atomic_inc_pre(atomic_t *val) 
+static inline count_t atomic_postinc(atomic_t *val) 
 {
 	count_t r;
@@ -73,5 +73,5 @@
 }
 
-static inline count_t atomic_dec_pre(atomic_t *val) 
+static inline count_t atomic_postdec(atomic_t *val) 
 {
 	count_t r;
@@ -86,6 +86,6 @@
 }
 
-#define atomic_inc_post(val) (atomic_inc_pre(val)+1)
-#define atomic_dec_post(val) (atomic_dec_pre(val)-1)
+#define atomic_preinc(val) (atomic_postinc(val)+1)
+#define atomic_predec(val) (atomic_postdec(val)-1)
 
 static inline __u32 test_and_set(atomic_t *val) {
Index: arch/ia64/include/atomic.h
===================================================================
--- arch/ia64/include/atomic.h	(revision 9e1c9420613588b3f800b5cc0675f338b0bafea8)
+++ arch/ia64/include/atomic.h	(revision 9a2d6e1cf6667f28beec57a2227821b398296732)
@@ -39,5 +39,5 @@
  * @param imm Value to add.
  *
- * @return Value after addition.
+ * @return Value before addition.
  */
 static inline count_t atomic_add(atomic_t *val, int imm)
@@ -63,9 +63,9 @@
 static inline void atomic_dec(atomic_t *val) { atomic_add(val, -1); }
 
-static inline count_t atomic_inc_pre(atomic_t *val) { return atomic_add(val, 1); }
-static inline count_t atomic_dec_pre(atomic_t *val) { return atomic_add(val, -1); }
+static inline count_t atomic_preinc(atomic_t *val) { return atomic_add(val, 1) + 1; }
+static inline count_t atomic_predec(atomic_t *val) { return atomic_add(val, -1) - 1; }
 
-static inline count_t atomic_inc_post(atomic_t *val) { return atomic_add(val, 1) + 1; }
-static inline count_t atomic_dec_post(atomic_t *val) { return atomic_add(val, -1) - 1; }
+static inline count_t atomic_postinc(atomic_t *val) { return atomic_add(val, 1); }
+static inline count_t atomic_postdec(atomic_t *val) { return atomic_add(val, -1); }
 
 #endif
Index: arch/mips32/include/atomic.h
===================================================================
--- arch/mips32/include/atomic.h	(revision 9e1c9420613588b3f800b5cc0675f338b0bafea8)
+++ arch/mips32/include/atomic.h	(revision 9a2d6e1cf6667f28beec57a2227821b398296732)
@@ -35,10 +35,9 @@
 #define atomic_dec(x)	((void) atomic_add(x, -1))
 
-#define atomic_inc_pre(x) (atomic_add(x, 1) - 1)
-#define atomic_dec_pre(x) (atomic_add(x, -1) + 1)
+#define atomic_postinc(x) (atomic_add(x, 1) - 1)
+#define atomic_postdec(x) (atomic_add(x, -1) + 1)
 
-#define atomic_inc_post(x) atomic_add(x, 1)
-#define atomic_dec_post(x) atomic_add(x, -1)
-
+#define atomic_preinc(x) atomic_add(x, 1)
+#define atomic_predec(x) atomic_add(x, -1)
 
 typedef struct { volatile __u32 count; } atomic_t;
Index: arch/ppc32/include/atomic.h
===================================================================
--- arch/ppc32/include/atomic.h	(revision 9e1c9420613588b3f800b5cc0675f338b0bafea8)
+++ arch/ppc32/include/atomic.h	(revision 9a2d6e1cf6667f28beec57a2227821b398296732)
@@ -64,5 +64,5 @@
 }
 
-static inline __u32 atomic_inc_pre(atomic_t *val)
+static inline __u32 atomic_postinc(atomic_t *val)
 {
 	atomic_inc(val);
@@ -70,5 +70,5 @@
 }
 
-static inline __u32 atomic_dec_pre(atomic_t *val)
+static inline __u32 atomic_postdec(atomic_t *val)
 {
 	atomic_dec(val);
@@ -76,5 +76,5 @@
 }
 
-static inline __u32 atomic_inc_post(atomic_t *val)
+static inline __u32 atomic_preinc(atomic_t *val)
 {
 	atomic_inc(val);
@@ -82,5 +82,5 @@
 }
 
-static inline __u32 atomic_dec_post(atomic_t *val)
+static inline __u32 atomic_predec(atomic_t *val)
 {
 	atomic_dec(val);
Index: arch/sparc64/include/atomic.h
===================================================================
--- arch/sparc64/include/atomic.h	(revision 9e1c9420613588b3f800b5cc0675f338b0bafea8)
+++ arch/sparc64/include/atomic.h	(revision 9a2d6e1cf6667f28beec57a2227821b398296732)
@@ -63,4 +63,24 @@
 }
 
+static inline count_t atomic_preinc(atomic_t *val)
+{
+	return atomic_add(val, 1) + 1;
+}
+
+static inline count_t atomic_postinc(atomic_t *val)
+{
+	return atomic_add(val, 1);
+}
+
+static inline count_t atomic_predec(atomic_t *val)
+{
+	return atomic_add(val, -1) - 1;
+}
+
+static inline count_t atomic_postdec(atomic_t *val)
+{
+	return atomic_add(val, 1);
+}
+
 static inline void atomic_inc(atomic_t *val)
 {
Index: generic/src/syscall/syscall.c
===================================================================
--- generic/src/syscall/syscall.c	(revision 9e1c9420613588b3f800b5cc0675f338b0bafea8)
+++ generic/src/syscall/syscall.c	(revision 9a2d6e1cf6667f28beec57a2227821b398296732)
@@ -125,5 +125,5 @@
 static int check_call_limit(void)
 {
-	if (atomic_inc_post(&TASK->active_calls) > IPC_MAX_ASYNC_CALLS) {
+	if (atomic_preinc(&TASK->active_calls) > IPC_MAX_ASYNC_CALLS) {
 		atomic_dec(&TASK->active_calls);
 		return -1;
Index: kernel.config
===================================================================
--- kernel.config	(revision 9e1c9420613588b3f800b5cc0675f338b0bafea8)
+++ kernel.config	(revision 9a2d6e1cf6667f28beec57a2227821b398296732)
@@ -75,4 +75,5 @@
 # Kernel test type
 @ "" No test
+@ "atomic/atomic1" Test of atomic operations.
 @ "synch/rwlock1" Read write test 1
 @ "synch/rwlock2" Read write test 2
Index: test/atomic/atomic1/test.c
===================================================================
--- test/atomic/atomic1/test.c	(revision 9a2d6e1cf6667f28beec57a2227821b398296732)
+++ test/atomic/atomic1/test.c	(revision 9a2d6e1cf6667f28beec57a2227821b398296732)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2006 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.
+ */
+
+#include <test.h>
+#include <print.h>
+#include <arch/atomic.h>
+#include <debug.h>
+
+void test(void)
+{
+	atomic_t a;
+
+	atomic_set(&a, 10);
+	printf("Testing atomic_set() and atomic_get().\n");
+	ASSERT(atomic_get(&a) == 10);
+	printf("Testing atomic_postinc()\n");
+	ASSERT(atomic_postinc(&a) == 10);
+	ASSERT(atomic_get(&a) == 11);
+	printf("Testing atomic_postdec()\n");
+	ASSERT(atomic_postdec(&a) == 11);
+	ASSERT(atomic_get(&a) == 10);
+	printf("Testing atomic_preinc()\n");
+	ASSERT(atomic_preinc(&a) == 11);
+	ASSERT(atomic_get(&a) == 11);
+	printf("Testing atomic_predec()\n");
+	ASSERT(atomic_postdec(&a) == 11);
+	ASSERT(atomic_get(&a) == 10);
+
+	printf("Test passed.\n");	
+	return;
+}
