* 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"
-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();
+}
+
+void lttng_ust_common_alloc_tls(void)
+{
+ lttng_ust_fd_tracker_alloc_tls();
}