Move the getcpu plugin implementation to liblttn-ust-common
[lttng-ust.git] / src / lib / lttng-ust-common / ust-common.c
index cefff67a82d721d0c63c6940e86563ed9cf53c38..1aee7ac7a7a99f4b47ce557ea68c9ab09eb80481 100644 (file)
@@ -4,18 +4,41 @@
  * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
  */
 
+#include <lttng/ust-common.h>
+
 #include "common/logging.h"
 #include "common/ust-fd.h"
+#include "common/getenv.h"
+
+#include "lib/lttng-ust-common/fd-tracker.h"
+#include "lib/lttng-ust-common/clock.h"
+#include "lib/lttng-ust-common/getcpu.h"
 
-static
-void lttng_ust_common_init(void)
-       __attribute__((constructor));
-static
-void lttng_ust_common_init(void)
+/*
+ * The liblttng-ust-common constructor, initialize the internal shared state.
+ * Libraries linking on liblttng-ust-common should also call this early in
+ * their constructor since there is no reliable way to guarantee the execution
+ * order of constructors across shared library.
+ */
+void lttng_ust_common_ctor(void)
 {
        /*
-        * Initialize the fd-tracker, other libraries using it should also call
-        * this in their constructor in case it gets executed before this one.
+        * Initialize the shared state of the fd tracker.
+        */
+       lttng_ust_fd_tracker_init();
+
+       /*
+        * Initialize the potential user-provided clock plugin.
         */
-       lttng_ust_init_fd_tracker();
+       lttng_ust_clock_init();
+
+       /*
+        * Initialize the potential user-provided getcpu plugin.
+        */
+       lttng_ust_getcpu_plugin_init();
+}
+
+void lttng_ust_common_alloc_tls(void)
+{
+       lttng_ust_fd_tracker_alloc_tls();
 }
This page took 0.023551 seconds and 4 git commands to generate.