From: Jan Blunck Date: Wed, 10 Jun 2009 18:07:19 +0000 (+0200) Subject: Use kref implementation from kcompat X-Git-Tag: v0.1~206 X-Git-Url: http://git.lttng.org/?p=ust.git;a=commitdiff_plain;h=79d4d5458786d6d946e9c44580e3a2cc8000736e Use kref implementation from kcompat The kref implementation from kcompat has LGPL license. Signed-off-by: Jan Blunck --- diff --git a/libust/Makefile.am b/libust/Makefile.am index 0faa8c0..1bc6110 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 4eb512d..d96e25b 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 530a496..4c57424 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 3df1275..cb5c438 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 f036df8..0000000 --- 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 ffb488c..0000000 --- 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 72f40a8..af6d306 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