#include "defaults.h"
#include "macros.h"
+#include "align.h"
-size_t default_channel_subbuf_size;
-size_t default_metadata_subbuf_size;
-size_t default_kernel_channel_subbuf_size;
-size_t default_ust_pid_channel_subbuf_size;
-size_t default_ust_uid_channel_subbuf_size;
+static size_t default_channel_subbuf_size;
+static size_t default_metadata_subbuf_size;
+static size_t default_kernel_channel_subbuf_size;
+static size_t default_ust_pid_channel_subbuf_size;
+static size_t default_ust_uid_channel_subbuf_size;
-static void __attribute__((constructor)) init_defaults(void)
+LTTNG_HIDDEN
+size_t default_get_channel_subbuf_size(void)
{
- /*
- * The libringbuffer won't accept subbuf sizes smaller than the page size.
- * If the default subbuf size is smaller, replace it by the page size.
- */
- long page_size = sysconf(_SC_PAGESIZE);
-
- if (page_size < 0) {
- page_size = 0;
- }
-
- default_channel_subbuf_size =
- max(_DEFAULT_CHANNEL_SUBBUF_SIZE, page_size);
- default_metadata_subbuf_size =
- max(DEFAULT_METADATA_SUBBUF_SIZE, page_size);
- default_kernel_channel_subbuf_size =
- max(DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE, page_size);
- default_ust_pid_channel_subbuf_size =
- max(DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE, page_size);
- default_ust_uid_channel_subbuf_size =
- max(DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE, page_size);
+ return max(_DEFAULT_CHANNEL_SUBBUF_SIZE, PAGE_SIZE);
+}
+
+LTTNG_HIDDEN
+size_t default_get_metadata_subbuf_size(void)
+{
+ return max(DEFAULT_METADATA_SUBBUF_SIZE, PAGE_SIZE);
+}
+
+LTTNG_HIDDEN
+size_t default_get_kernel_channel_subbuf_size(void)
+{
+ return max(DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE, PAGE_SIZE);
+}
+
+LTTNG_HIDDEN
+size_t default_get_ust_pid_channel_subbuf_size(void)
+{
+ return max(DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE, PAGE_SIZE);
+}
+
+LTTNG_HIDDEN
+size_t default_get_ust_uid_channel_subbuf_size(void)
+{
+ return max(DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE, PAGE_SIZE);
}
/*
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
* Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * 2015 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 only,
#ifndef _DEFAULTS_H
#define _DEFAULTS_H
+#include <src/common/macros.h>
+
/* Default unix group name for tracing. */
#define DEFAULT_TRACING_GROUP "tracing"
/* Default runas worker name */
#define DEFAULT_RUN_AS_WORKER_NAME "lttng-runas"
-extern size_t default_channel_subbuf_size;
-extern size_t default_metadata_subbuf_size;
-extern size_t default_ust_pid_channel_subbuf_size;
-extern size_t default_ust_uid_channel_subbuf_size;
-extern size_t default_kernel_channel_subbuf_size;
-
/*
* Returns the default subbuf size.
*
* This function depends on a value that is set at constructor time, so it is
* unsafe to call it from another constructor.
*/
-static inline
-size_t default_get_channel_subbuf_size(void)
-{
- return default_channel_subbuf_size;
-}
+LTTNG_HIDDEN
+size_t default_get_channel_subbuf_size(void);
/*
* Returns the default metadata subbuf size.
* This function depends on a value that is set at constructor time, so it is
* unsafe to call it from another constructor.
*/
-static inline
-size_t default_get_metadata_subbuf_size(void)
-{
- return default_metadata_subbuf_size;
-}
+LTTNG_HIDDEN
+size_t default_get_metadata_subbuf_size(void);
/*
* Returns the default subbuf size for the kernel domain.
* This function depends on a value that is set at constructor time, so it is
* unsafe to call it from another constructor.
*/
-static inline
-size_t default_get_kernel_channel_subbuf_size(void)
-{
- return default_kernel_channel_subbuf_size;
-}
+LTTNG_HIDDEN
+size_t default_get_kernel_channel_subbuf_size(void);
/*
* Returns the default subbuf size for the UST domain per PID.
* This function depends on a value that is set at constructor time, so it is
* unsafe to call it from another constructor.
*/
-static inline
-size_t default_get_ust_pid_channel_subbuf_size(void)
-{
- return default_ust_pid_channel_subbuf_size;
-}
+LTTNG_HIDDEN
+size_t default_get_ust_pid_channel_subbuf_size(void);
/*
* Returns the default subbuf size for the UST domain per UID.
* This function depends on a value that is set at constructor time, so it is
* unsafe to call it from another constructor.
*/
-static inline
-size_t default_get_ust_uid_channel_subbuf_size(void)
-{
- return default_ust_uid_channel_subbuf_size;
-}
+LTTNG_HIDDEN
+size_t default_get_ust_uid_channel_subbuf_size(void);
#endif /* _DEFAULTS_H */