/*
* Copyright (C) 2007 Mathieu Desnoyers
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * LTT marker control module over /proc
*/
-//ust// #include <linux/proc_fs.h>
-//ust// #include <linux/module.h>
-//ust// #include <linux/stat.h>
-//ust// #include <linux/vmalloc.h>
-//ust// #include <linux/marker.h>
-//ust// #include <linux/ltt-tracer.h>
-//ust// #include <linux/uaccess.h>
-//ust// #include <linux/string.h>
-//ust// #include <linux/ctype.h>
-//ust// #include <linux/list.h>
-//ust// #include <linux/mutex.h>
-//ust// #include <linux/seq_file.h>
-//ust// #include <linux/slab.h>
-#include "kernelcompat.h"
-#include "list.h"
+/* This file contains a high-level API for activating and deactivating markers,
+ * and making sure markers in a given library can be released when the library
+ * is unloaded.
+ */
+
+#include <ctype.h>
+#include <stdlib.h>
+
#include "tracer.h"
-#include "localerr.h"
+#include "usterr.h"
#define DEFAULT_CHANNEL "cpu"
#define DEFAULT_PROBE "default"
-LIST_HEAD(probes_list);
+CDS_LIST_HEAD(probes_list);
/*
* Mutex protecting the probe slab cache.
};
//ust//static struct kmem_cache *markers_loaded_cachep;
-static LIST_HEAD(markers_loaded_list);
+static CDS_LIST_HEAD(markers_loaded_list);
/*
* List sorted by name strcmp order.
*/
-static LIST_HEAD(probes_registered_list);
+static CDS_LIST_HEAD(probes_registered_list);
//ust// static struct proc_dir_entry *pentry;
if (!pname)
pname = DEFAULT_PROBE;
- list_for_each_entry(iter, &probes_registered_list, node) {
+ cds_list_for_each_entry(iter, &probes_registered_list, node) {
comparison = strcmp(pname, iter->name);
if (!comparison)
found = 1;
return NULL;
}
+/* (unused)
static char *skip_spaces(char *buf)
{
while (*buf != '\0' && isspace(*buf))
*end = skip_nonspaces(*start);
**end = '\0';
}
+*/
int ltt_probe_register(struct ltt_available_probe *pdata)
{
int comparison;
struct ltt_available_probe *iter;
- mutex_lock(&probes_mutex);
- list_for_each_entry_reverse(iter, &probes_registered_list, node) {
+ pthread_mutex_lock(&probes_mutex);
+ cds_list_for_each_entry_reverse(iter, &probes_registered_list, node) {
comparison = strcmp(pdata->name, iter->name);
if (!comparison) {
ret = -EBUSY;
goto end;
} else if (comparison > 0) {
/* We belong to the location right after iter. */
- list_add(&pdata->node, &iter->node);
+ cds_list_add(&pdata->node, &iter->node);
goto end;
}
}
/* Should be added at the head of the list */
- list_add(&pdata->node, &probes_registered_list);
+ cds_list_add(&pdata->node, &probes_registered_list);
end:
- mutex_unlock(&probes_mutex);
+ pthread_mutex_unlock(&probes_mutex);
return ret;
}
-EXPORT_SYMBOL_GPL(ltt_probe_register);
/*
* Called when a probe does not want to be called anymore.
int ret = 0;
struct ltt_active_marker *amark, *tmp;
- mutex_lock(&probes_mutex);
- list_for_each_entry_safe(amark, tmp, &markers_loaded_list, node) {
+ pthread_mutex_lock(&probes_mutex);
+ cds_list_for_each_entry_safe(amark, tmp, &markers_loaded_list, node) {
if (amark->probe == pdata) {
ret = marker_probe_unregister_private_data(
pdata->probe_func, amark);
if (ret)
goto end;
- list_del(&amark->node);
+ cds_list_del(&amark->node);
free(amark);
}
}
- list_del(&pdata->node);
+ cds_list_del(&pdata->node);
end:
- mutex_unlock(&probes_mutex);
+ pthread_mutex_unlock(&probes_mutex);
return ret;
}
-EXPORT_SYMBOL_GPL(ltt_probe_unregister);
/*
* Connect marker "mname" to probe "pname".
struct ltt_available_probe *probe;
ltt_lock_traces();
- mutex_lock(&probes_mutex);
+ pthread_mutex_lock(&probes_mutex);
probe = get_probe_from_name(pname);
if (!probe) {
ret = -ENOENT;
if (ret)
free(pdata);
else
- list_add(&pdata->node, &markers_loaded_list);
+ cds_list_add(&pdata->node, &markers_loaded_list);
end:
- mutex_unlock(&probes_mutex);
+ pthread_mutex_unlock(&probes_mutex);
ltt_unlock_traces();
return ret;
}
-EXPORT_SYMBOL_GPL(ltt_marker_connect);
/*
* Disconnect marker "mname", probe "pname".
struct ltt_available_probe *probe;
int ret = 0;
- mutex_lock(&probes_mutex);
+ pthread_mutex_lock(&probes_mutex);
probe = get_probe_from_name(pname);
if (!probe) {
ret = -ENOENT;
if (ret)
goto end;
else {
- list_del(&pdata->node);
+ cds_list_del(&pdata->node);
free(pdata);
}
end:
- mutex_unlock(&probes_mutex);
+ pthread_mutex_unlock(&probes_mutex);
return ret;
}
-EXPORT_SYMBOL_GPL(ltt_marker_disconnect);
/*
* function handling proc entry write.
{
struct ltt_active_marker *pdata, *tmp;
- list_for_each_entry_safe(pdata, tmp, &markers_loaded_list, node) {
+ cds_list_for_each_entry_safe(pdata, tmp, &markers_loaded_list, node) {
marker_probe_unregister_private_data(pdata->probe->probe_func,
pdata);
- list_del(&pdata->node);
+ cds_list_del(&pdata->node);
free(pdata);
}
}
}
//ust// module_init(marker_control_init);
-static void __exit marker_control_exit(void)
+static void __attribute__((destructor)) marker_control_exit(void)
{
int ret;