Remove hlist from kcompat's headers and code
authorDavid Goulet <david.goulet@polymtl.ca>
Sat, 27 Nov 2010 19:05:07 +0000 (14:05 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 27 Nov 2010 19:05:07 +0000 (14:05 -0500)
The hlist structure is no longer needed since it's the exact
same implementation in liburcu.

Signed-off-by: David Goulet <david.goulet@polymtl.ca>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/Makefile.am
include/ust/kcompat/hlist.h [deleted file]
include/ust/kcompat/kcompat.h
libust/marker.c
libust/tracepoint.c

index b89de205199be00a08d383676dcbfbd94760d30e..dd000baa62f35e5f650d0cf1a3bc1d252800cc5f 100644 (file)
@@ -14,7 +14,6 @@ nobase_include_HEADERS = \
        ust/kcompat/kcompat.h \
        ust/kcompat/compiler.h \
        ust/kcompat/disable.h \
-       ust/kcompat/hlist.h \
        ust/kcompat/jhash.h \
        ust/kcompat/kref.h \
        ust/kcompat/simple.h \
diff --git a/include/ust/kcompat/hlist.h b/include/ust/kcompat/hlist.h
deleted file mode 100644 (file)
index 1bec11a..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef _KCOMPAT_HLIST_H
-#define _KCOMPAT_HLIST_H
-
-/*
- * Kernel sourcecode compatible lightweight single pointer list head useful
- * for implementing hash tables
- *
- * Copyright (C) 2009 Novell Inc.
- *
- * Author: Jan Blunck <jblunck@suse.de>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License version 2.1 as
- * published by the Free  Software Foundation.
- */
-
-struct hlist_head
-{
-       struct hlist_node *next;
-};
-
-struct hlist_node
-{
-       struct hlist_node *next;
-       struct hlist_node *prev;
-};
-
-/* Initialize a new list head.  */
-static inline void  INIT_HLIST_HEAD(struct hlist_head *ptr)
-{
-       ptr->next = NULL;
-}
-
-/* Get typed element from list at a given position.  */
-#define hlist_entry(ptr, type, member)                                 \
-       ((type *) ((char *) (ptr) - (unsigned long) (&((type *) 0)->member)))
-
-/* Add new element at the head of the list.  */
-static inline void hlist_add_head (struct hlist_node *newp,
-                                  struct hlist_head *head)
-{
-       if (head->next)
-               head->next->prev = newp;
-
-       newp->next = head->next;
-       newp->prev = (struct hlist_node *)head;
-       head->next = newp;
-}
-
-/* Remove element from list.  */
-static inline void hlist_del (struct hlist_node *elem)
-{
-       if (elem->next)
-               elem->next->prev = elem->prev;
-
-       elem->prev->next = elem->next;
-}
-
-#define hlist_for_each_entry(entry, pos, head, member)                 \
-       for (pos = (head)->next,                                        \
-                    entry = hlist_entry(pos, typeof(*entry), member);  \
-            pos != NULL;                                               \
-            pos = pos->next,                                   \
-                    entry = hlist_entry(pos, typeof(*entry), member))
-
-#define hlist_for_each_entry_safe(entry, pos, p, head, member)         \
-       for (pos = (head)->next,                                        \
-                    entry = hlist_entry(pos, typeof(*entry), member);  \
-            (pos != NULL) && ({ p = pos->next; 1;});                   \
-            pos = p,                                                   \
-                    entry = hlist_entry(pos, typeof(*entry), member))
-
-#endif /* _KCOMPAT_HLIST_H */
index 4aea4ccda938c6ad6e3658a684419e0a8152f54f..b506afaede6e0e2072b50a43ea96a06ce118a20e 100644 (file)
@@ -59,8 +59,6 @@
 #include <ust/kcompat/simple.h>
 #include <ust/kcompat/compiler.h>
 #include <ust/kcompat/types.h>
-#include <ust/kcompat/hlist.h>
-
 #include <ust/kcompat/jhash.h>
 
 #include <ust/kcompat/disable.h>
index 39e12bb2307423c0e97164fbdcd0ae59d98798d4..2618b1aea1efea88c67d8b424b0c866b046e9be6 100644 (file)
@@ -21,6 +21,7 @@
 #define _LGPL_SOURCE
 #include <urcu-bp.h>
 #include <urcu/rculist.h>
+#include <urcu/hlist.h>
 
 #include <ust/core.h>
 #include <ust/marker.h>
@@ -64,7 +65,7 @@ void unlock_markers(void)
  */
 #define MARKER_HASH_BITS 6
 #define MARKER_TABLE_SIZE (1 << MARKER_HASH_BITS)
-static struct hlist_head marker_table[MARKER_TABLE_SIZE];
+static struct cds_hlist_head marker_table[MARKER_TABLE_SIZE];
 
 /*
  * Note about RCU :
@@ -75,7 +76,7 @@ static struct hlist_head marker_table[MARKER_TABLE_SIZE];
  * marker entries modifications are protected by the markers_mutex.
  */
 struct marker_entry {
-       struct hlist_node hlist;
+       struct cds_hlist_node hlist;
        char *format;
        char *name;
                        /* Probe wrapper */
@@ -386,8 +387,8 @@ marker_entry_remove_probe(struct marker_entry *entry,
  */
 static struct marker_entry *get_marker(const char *channel, const char *name)
 {
-       struct hlist_head *head;
-       struct hlist_node *node;
+       struct cds_hlist_head *head;
+       struct cds_hlist_node *node;
        struct marker_entry *e;
        size_t channel_len = strlen(channel) + 1;
        size_t name_len = strlen(name) + 1;
@@ -395,7 +396,7 @@ static struct marker_entry *get_marker(const char *channel, const char *name)
 
        hash = jhash(channel, channel_len-1, 0) ^ jhash(name, name_len-1, 0);
        head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
-       hlist_for_each_entry(e, node, head, hlist) {
+       cds_hlist_for_each_entry(e, node, head, hlist) {
                if (!strcmp(channel, e->channel) && !strcmp(name, e->name))
                        return e;
        }
@@ -409,8 +410,8 @@ static struct marker_entry *get_marker(const char *channel, const char *name)
 static struct marker_entry *add_marker(const char *channel, const char *name,
                const char *format)
 {
-       struct hlist_head *head;
-       struct hlist_node *node;
+       struct cds_hlist_head *head;
+       struct cds_hlist_node *node;
        struct marker_entry *e;
        size_t channel_len = strlen(channel) + 1;
        size_t name_len = strlen(name) + 1;
@@ -421,7 +422,7 @@ static struct marker_entry *add_marker(const char *channel, const char *name,
        if (format)
                format_len = strlen(format) + 1;
        head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
-       hlist_for_each_entry(e, node, head, hlist) {
+       cds_hlist_for_each_entry(e, node, head, hlist) {
                if (!strcmp(channel, e->channel) && !strcmp(name, e->name)) {
                        DBG("Marker %s.%s busy", channel, name);
                        return ERR_PTR(-EBUSY); /* Already there */
@@ -459,7 +460,7 @@ static struct marker_entry *add_marker(const char *channel, const char *name,
        e->format_allocated = 0;
        e->refcount = 0;
        e->rcu_pending = 0;
-       hlist_add_head(&e->hlist, head);
+       cds_hlist_add_head(&e->hlist, head);
        return e;
 }
 
@@ -469,8 +470,8 @@ static struct marker_entry *add_marker(const char *channel, const char *name,
  */
 static int remove_marker(const char *channel, const char *name)
 {
-       struct hlist_head *head;
-       struct hlist_node *node;
+       struct cds_hlist_head *head;
+       struct cds_hlist_node *node;
        struct marker_entry *e;
        int found = 0;
        size_t channel_len = strlen(channel) + 1;
@@ -480,7 +481,7 @@ static int remove_marker(const char *channel, const char *name)
 
        hash = jhash(channel, channel_len-1, 0) ^ jhash(name, name_len-1, 0);
        head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
-       hlist_for_each_entry(e, node, head, hlist) {
+       cds_hlist_for_each_entry(e, node, head, hlist) {
                if (!strcmp(channel, e->channel) && !strcmp(name, e->name)) {
                        found = 1;
                        break;
@@ -490,7 +491,7 @@ static int remove_marker(const char *channel, const char *name)
                return -ENOENT;
        if (e->single.func != __mark_empty_function)
                return -EBUSY;
-       hlist_del(&e->hlist);
+       cds_hlist_del(&e->hlist);
        if (e->format_allocated)
                free(e->format);
        ret = ltt_channels_unregister(e->channel);
@@ -912,12 +913,12 @@ get_marker_from_private_data(marker_probe_func *probe, void *probe_private)
 {
        struct marker_entry *entry;
        unsigned int i;
-       struct hlist_head *head;
-       struct hlist_node *node;
+       struct cds_hlist_head *head;
+       struct cds_hlist_node *node;
 
        for (i = 0; i < MARKER_TABLE_SIZE; i++) {
                head = &marker_table[i];
-               hlist_for_each_entry(entry, node, head, hlist) {
+               cds_hlist_for_each_entry(entry, node, head, hlist) {
                        if (!entry->ptype) {
                                if (entry->single.func == probe
                                                && entry->single.probe_private
@@ -1013,8 +1014,8 @@ end:
 void *marker_get_private_data(const char *channel, const char *name,
                              marker_probe_func *probe, int num)
 {
-       struct hlist_head *head;
-       struct hlist_node *node;
+       struct cds_hlist_head *head;
+       struct cds_hlist_node *node;
        struct marker_entry *e;
        size_t channel_len = strlen(channel) + 1;
        size_t name_len = strlen(name) + 1;
@@ -1023,7 +1024,7 @@ void *marker_get_private_data(const char *channel, const char *name,
 
        hash = jhash(channel, channel_len-1, 0) ^ jhash(name, name_len-1, 0);
        head = &marker_table[hash & ((1 << MARKER_HASH_BITS)-1)];
-       hlist_for_each_entry(e, node, head, hlist) {
+       cds_hlist_for_each_entry(e, node, head, hlist) {
                if (!strcmp(channel, e->channel) && !strcmp(name, e->name)) {
                        if (!e->ptype) {
                                if (num == 0 && e->single.func == probe)
@@ -1178,14 +1179,14 @@ void marker_iter_reset(struct marker_iter *iter)
 /*
  * must be called with current->user_markers_mutex held
  */
-static void free_user_marker(char __user *state, struct hlist_head *head)
+static void free_user_marker(char __user *state, struct cds_hlist_head *head)
 {
        struct user_marker *umark;
-       struct hlist_node *pos, *n;
+       struct cds_hlist_node *pos, *n;
 
-       hlist_for_each_entry_safe(umark, pos, n, head, hlist) {
+       cds_hlist_for_each_entry_safe(umark, pos, n, head, hlist) {
                if (umark->state == state) {
-                       hlist_del(&umark->hlist);
+                       cds_hlist_del(&umark->hlist);
                        free(umark);
                }
        }
@@ -1243,12 +1244,12 @@ static void free_user_marker(char __user *state, struct hlist_head *head)
 void exit_user_markers(struct task_struct *p)
 {
        struct user_marker *umark;
-       struct hlist_node *pos, *n;
+       struct cds_hlist_node *pos, *n;
 
        if (thread_group_leader(p)) {
                pthread_mutex_lock(&markers_mutex);
                pthread_mutex_lock(&p->user_markers_mutex);
-               hlist_for_each_entry_safe(umark, pos, n, &p->user_markers,
+               cds_hlist_for_each_entry_safe(umark, pos, n, &p->user_markers,
                        hlist)
                    free(umark);
                INIT_HLIST_HEAD(&p->user_markers);
@@ -1306,8 +1307,8 @@ void ltt_dump_marker_state(struct ust_trace *trace)
 {
        struct marker_entry *entry;
        struct ltt_probe_private_data call_data;
-       struct hlist_head *head;
-       struct hlist_node *node;
+       struct cds_hlist_head *head;
+       struct cds_hlist_node *node;
        unsigned int i;
 
        pthread_mutex_lock(&markers_mutex);
@@ -1316,7 +1317,7 @@ void ltt_dump_marker_state(struct ust_trace *trace)
 
        for (i = 0; i < MARKER_TABLE_SIZE; i++) {
                head = &marker_table[i];
-               hlist_for_each_entry(entry, node, head, hlist) {
+               cds_hlist_for_each_entry(entry, node, head, hlist) {
                        __trace_mark(0, metadata, core_marker_id,
                                &call_data,
                                "channel %s name %s event_id %hu "
index dbaca6fcee0f65086a2a54217ebc6a680271bed3..47d3785a1a1bede84f356cefdf45736a7d037601 100644 (file)
@@ -27,6 +27,7 @@
 
 #define _LGPL_SOURCE
 #include <urcu-bp.h>
+#include <urcu/hlist.h>
 
 //extern struct tracepoint __start___tracepoints[] __attribute__((visibility("hidden")));
 //extern struct tracepoint __stop___tracepoints[] __attribute__((visibility("hidden")));
@@ -49,7 +50,7 @@ static DEFINE_MUTEX(tracepoints_mutex);
  */
 #define TRACEPOINT_HASH_BITS 6
 #define TRACEPOINT_TABLE_SIZE (1 << TRACEPOINT_HASH_BITS)
-static struct hlist_head tracepoint_table[TRACEPOINT_TABLE_SIZE];
+static struct cds_hlist_head tracepoint_table[TRACEPOINT_TABLE_SIZE];
 
 /*
  * Note about RCU :
@@ -58,7 +59,7 @@ static struct hlist_head tracepoint_table[TRACEPOINT_TABLE_SIZE];
  * Tracepoint entries modifications are protected by the tracepoints_mutex.
  */
 struct tracepoint_entry {
-       struct hlist_node hlist;
+       struct cds_hlist_node hlist;
        struct probe *probes;
        int refcount;   /* Number of times armed. 0 if disarmed. */
        char name[0];
@@ -192,13 +193,13 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry, void *probe,
  */
 static struct tracepoint_entry *get_tracepoint(const char *name)
 {
-       struct hlist_head *head;
-       struct hlist_node *node;
+       struct cds_hlist_head *head;
+       struct cds_hlist_node *node;
        struct tracepoint_entry *e;
        u32 hash = jhash(name, strlen(name), 0);
 
        head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
-       hlist_for_each_entry(e, node, head, hlist) {
+       cds_hlist_for_each_entry(e, node, head, hlist) {
                if (!strcmp(name, e->name))
                        return e;
        }
@@ -211,14 +212,14 @@ static struct tracepoint_entry *get_tracepoint(const char *name)
  */
 static struct tracepoint_entry *add_tracepoint(const char *name)
 {
-       struct hlist_head *head;
-       struct hlist_node *node;
+       struct cds_hlist_head *head;
+       struct cds_hlist_node *node;
        struct tracepoint_entry *e;
        size_t name_len = strlen(name) + 1;
        u32 hash = jhash(name, name_len-1, 0);
 
        head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
-       hlist_for_each_entry(e, node, head, hlist) {
+       cds_hlist_for_each_entry(e, node, head, hlist) {
                if (!strcmp(name, e->name)) {
                        DBG("tracepoint %s busy", name);
                        return ERR_PTR(-EEXIST);        /* Already there */
@@ -234,7 +235,7 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
        memcpy(&e->name[0], name, name_len);
        e->probes = NULL;
        e->refcount = 0;
-       hlist_add_head(&e->hlist, head);
+       cds_hlist_add_head(&e->hlist, head);
        return e;
 }
 
@@ -244,7 +245,7 @@ static struct tracepoint_entry *add_tracepoint(const char *name)
  */
 static inline void remove_tracepoint(struct tracepoint_entry *e)
 {
-       hlist_del(&e->hlist);
+       cds_hlist_del(&e->hlist);
        free(e);
 }
 
This page took 0.031682 seconds and 4 git commands to generate.