VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / ipc / util.c
index 310ccc5..d84ac51 100644 (file)
@@ -24,6 +24,9 @@
 #include <linux/security.h>
 #include <linux/rcupdate.h>
 #include <linux/workqueue.h>
+#include <linux/vs_base.h>
+
+#include <asm/unistd.h>
 
 #include "util.h"
 
@@ -333,25 +336,40 @@ void* ipc_rcu_alloc(int size)
  * Since RCU callback function is called in bh,
  * we need to defer the vfree to schedule_work
  */
-static void ipc_schedule_free(void* arg)
+static void ipc_schedule_free(struct rcu_head *head)
 {
-       struct ipc_rcu_vmalloc *free = arg;
+       struct ipc_rcu_vmalloc *free =
+               container_of(head, struct ipc_rcu_vmalloc, rcu);
 
        INIT_WORK(&free->work, vfree, free);
        schedule_work(&free->work);
 }
 
+/**
+ *     ipc_immediate_free      - free ipc + rcu space
+ *
+ *     Free from the RCU callback context
+ *
+ */
+static void ipc_immediate_free(struct rcu_head *head)
+{
+       struct ipc_rcu_kmalloc *free =
+               container_of(head, struct ipc_rcu_kmalloc, rcu);
+       kfree(free);
+}
+
+
+
 void ipc_rcu_free(void* ptr, int size)
 {
        if (rcu_use_vmalloc(size)) {
                struct ipc_rcu_vmalloc *free;
                free = ptr - sizeof(*free);
-               call_rcu(&free->rcu, ipc_schedule_free, free);
+               call_rcu(&free->rcu, ipc_schedule_free);
        } else {
                struct ipc_rcu_kmalloc *free;
                free = ptr - sizeof(*free);
-               /* kfree takes a "const void *" so gcc warns.  So we cast. */
-               call_rcu(&free->rcu, (void (*)(void *))kfree, free);
+               call_rcu(&free->rcu, ipc_immediate_free);
        }
 
 }
@@ -511,7 +529,8 @@ int ipc_checkid(struct ipc_ids* ids, struct kern_ipc_perm* ipcp, int uid)
        return 0;
 }
 
-#if !defined(__ia64__) && !defined(__x86_64__) && !defined(__hppa__)
+#ifdef __ARCH_WANT_IPC_PARSE_VERSION
+
 
 /**
  *     ipc_parse_version       -       IPC call version
@@ -532,4 +551,4 @@ int ipc_parse_version (int *cmd)
        }
 }
 
-#endif /* __ia64__ */
+#endif /* __ARCH_WANT_IPC_PARSE_VERSION */