From 79d4d5458786d6d946e9c44580e3a2cc8000736e Mon Sep 17 00:00:00 2001 From: Jan Blunck Date: Wed, 10 Jun 2009 20:07:19 +0200 Subject: [PATCH] Use kref implementation from kcompat The kref implementation from kcompat has LGPL license. Signed-off-by: Jan Blunck --- libust/Makefile.am | 2 +- libust/channels.h | 2 +- libust/relay.c | 2 +- libust/relay.h | 2 +- share/kref.c | 80 ---------------------------------------------- share/kref.h | 31 ------------------ ustd/Makefile.am | 2 +- 7 files changed, 5 insertions(+), 116 deletions(-) delete mode 100644 share/kref.c delete mode 100644 share/kref.h diff --git a/libust/Makefile.am b/libust/Makefile.am index 0faa8c01..1bc6110e 100644 --- a/libust/Makefile.am +++ b/libust/Makefile.am @@ -2,6 +2,6 @@ INCLUDES = -I$(top_builddir)/share -I$(top_builddir)/libustcomm \ $(KCOMPAT_CFLAGS) $(URCU_CFLAGS) lib_LTLIBRARIES = libust.la -libust_la_SOURCES = marker.c marker.h tracepoint.c tracepoint.h immediate.h channels.c channels.h marker-control.c marker-control.h relay.c relay.h tracer.c tracer.h tracercore.c tracercore.h serialize.c tracectl.c $(top_builddir)/libustcomm/ustcomm.c $(top_builddir)/share/kref.c $(top_builddir)/share/usterr.c +libust_la_SOURCES = marker.c marker.h tracepoint.c tracepoint.h immediate.h channels.c channels.h marker-control.c marker-control.h relay.c relay.h tracer.c tracer.h tracercore.c tracercore.h serialize.c tracectl.c $(top_builddir)/libustcomm/ustcomm.c $(top_builddir)/share/usterr.c $(top_builddir)/share/usterr.h libust_la_LDFLAGS = -no-undefined -version-info 0:0:0 libust_la_LIBADD = $(URCU_LIBS) -lpthread diff --git a/libust/channels.h b/libust/channels.h index 4eb512d4..d96e25b2 100644 --- a/libust/channels.h +++ b/libust/channels.h @@ -13,7 +13,7 @@ #include #include "kernelcompat.h" -#include "kref.h" +#include #define EVENTS_PER_CHANNEL 65536 diff --git a/libust/relay.c b/libust/relay.c index 530a4960..4c57424a 100644 --- a/libust/relay.c +++ b/libust/relay.c @@ -29,7 +29,7 @@ //#include "list.h" #include "relay.h" #include "channels.h" -#include "kref.h" +#include #include "tracer.h" #include "tracercore.h" #include "usterr.h" diff --git a/libust/relay.h b/libust/relay.h index 3df12753..cb5c4384 100644 --- a/libust/relay.h +++ b/libust/relay.h @@ -22,7 +22,7 @@ //ust// #include //ust// #include #include -#include "kref.h" +#include //#include "list.h" #include "channels.h" #include "buffer.h" diff --git a/share/kref.c b/share/kref.c deleted file mode 100644 index f036df80..00000000 --- a/share/kref.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * kref.c - library routines for handling generic reference counted objects - * - * Copyright (C) 2004 Greg Kroah-Hartman - * Copyright (C) 2004 IBM Corp. - * - * based on lib/kobject.c which was: - * Copyright (C) 2002-2003 Patrick Mochel - * - * This file is released under the GPLv2. - * - */ - -//#include "" -#include -//ust// #include -#include "usterr.h" -#include "compiler.h" - -/** - * kref_set - initialize object and set refcount to requested number. - * @kref: object in question. - * @num: initial reference counter - */ -void kref_set(struct kref *kref, int num) -{ - atomic_set(&kref->refcount, num); - smp_mb(); -} - -/** - * kref_init - initialize object. - * @kref: object in question. - */ -void kref_init(struct kref *kref) -{ - kref_set(kref, 1); -} - -/** - * kref_get - increment refcount for object. - * @kref: object. - */ -void kref_get(struct kref *kref) -{ - WARN_ON(!atomic_read(&kref->refcount)); - atomic_inc(&kref->refcount); - smp_mb__after_atomic_inc(); -} - -/** - * kref_put - decrement refcount for object. - * @kref: object. - * @release: pointer to the function that will clean up the object when the - * last reference to the object is released. - * This pointer is required, and it is not acceptable to pass kfree - * in as this function. - * - * Decrement the refcount, and if 0, call release(). - * Return 1 if the object was removed, otherwise return 0. Beware, if this - * function returns 0, you still can not count on the kref from remaining in - * memory. Only use the return value if you want to see if the kref is now - * gone, not present. - */ -int kref_put(struct kref *kref, void (*release)(struct kref *kref)) -{ - WARN_ON(release == NULL); -//ust// WARN_ON(release == (void (*)(struct kref *))kfree); - - if (atomic_dec_and_test(&kref->refcount)) { - release(kref); - return 1; - } - return 0; -} - -//ust// EXPORT_SYMBOL(kref_set); -//ust// EXPORT_SYMBOL(kref_init); -//ust// EXPORT_SYMBOL(kref_get); -//ust// EXPORT_SYMBOL(kref_put); diff --git a/share/kref.h b/share/kref.h deleted file mode 100644 index ffb488c6..00000000 --- a/share/kref.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * kref.h - library routines for handling generic reference counted objects - * - * Copyright (C) 2004 Greg Kroah-Hartman - * Copyright (C) 2004 IBM Corp. - * - * based on kobject.h which was: - * Copyright (C) 2002-2003 Patrick Mochel - * Copyright (C) 2002-2003 Open Source Development Labs - * - * This file is released under the GPLv2. - * - */ - -#ifndef _KREF_H_ -#define _KREF_H_ - -//ust// #include -//ust// #include -#include - -struct kref { - atomic_t refcount; -}; - -void kref_set(struct kref *kref, int num); -void kref_init(struct kref *kref); -void kref_get(struct kref *kref); -int kref_put(struct kref *kref, void (*release) (struct kref *kref)); - -#endif /* _KREF_H_ */ diff --git a/ustd/Makefile.am b/ustd/Makefile.am index 72f40a86..af6d306c 100644 --- a/ustd/Makefile.am +++ b/ustd/Makefile.am @@ -2,5 +2,5 @@ INCLUDES = -I$(top_builddir)/share -I$(top_builddir)/libust \ -I$(top_builddir)/libustcomm $(KCOMPAT_CFLAGS) bin_PROGRAMS = ustd -ustd_SOURCES = lowlevel.c localerr.h ustd.c ustd.h $(top_builddir)/libustcomm/ustcomm.c $(top_builddir)/libustcomm/ustcomm.h $(top_builddir)/share/kref.c +ustd_SOURCES = lowlevel.c localerr.h ustd.c ustd.h $(top_builddir)/libustcomm/ustcomm.c $(top_builddir)/libustcomm/ustcomm.h ustd_LDFLAGS = -lpthread -- 2.34.1