Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Avoid strict-aliasing related issues when compiling with optimization
[palacios.git] / linux_module / util-queue.c
index f7f6146..0dba00b 100644 (file)
@@ -13,7 +13,14 @@ void init_queue(struct gen_queue * queue, unsigned int max_entries) {
     queue->max_entries = max_entries;
 
     INIT_LIST_HEAD(&(queue->entries));
-    spin_lock_init(&(queue->lock));
+    palacios_spinlock_init(&(queue->lock));
+}
+
+void deinit_queue(struct gen_queue * queue) {
+    while (dequeue(queue)) {
+       ERROR("Freeing non-empty queue. PROBABLE MEMORY LEAK DETECTED\n");
+    }
+    palacios_spinlock_deinit(&(queue->lock));
 }
 
 struct gen_queue * create_queue(unsigned int max_entries) {
@@ -41,13 +48,13 @@ int enqueue(struct gen_queue * queue, void * entry) {
        return -1;
     }
 
-    spin_lock_irqsave(&(queue->lock), flags);
+    palacios_spinlock_lock_irqsave(&(queue->lock), flags);
 
     q_entry->entry = entry;
     list_add_tail(&(q_entry->node), &(queue->entries));
     queue->num_entries++;
 
-    spin_unlock_irqrestore(&(queue->lock), flags);
+    palacios_spinlock_unlock_irqrestore(&(queue->lock), flags);
 
     return 0;
 }
@@ -57,7 +64,7 @@ void * dequeue(struct gen_queue * queue) {
     void * entry_val = 0;
     unsigned long flags;
 
-    spin_lock_irqsave(&(queue->lock), flags);
+    palacios_spinlock_lock_irqsave(&(queue->lock), flags);
 
     if (!list_empty(&(queue->entries))) {
        struct list_head * q_entry = queue->entries.next;
@@ -71,7 +78,7 @@ void * dequeue(struct gen_queue * queue) {
 
     }
 
-    spin_unlock_irqrestore(&(queue->lock), flags);
+    palacios_spinlock_unlock_irqrestore(&(queue->lock), flags);
 
     return entry_val;
 }