Fix: Check use_clone() instead of worker in run_as
[lttng-tools.git] / src / common / defaults.c
1 /*
2 * Copyright (C) 2012 - Simon Marchi <simon.marchi@polymtl.ca>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #define _GNU_SOURCE
19 #define _LGPL_SOURCE
20 #include <stddef.h>
21 #include <unistd.h>
22
23 #include "defaults.h"
24 #include "macros.h"
25
26 size_t default_channel_subbuf_size;
27 size_t default_metadata_subbuf_size;
28 size_t default_kernel_channel_subbuf_size;
29 size_t default_ust_pid_channel_subbuf_size;
30 size_t default_ust_uid_channel_subbuf_size;
31
32 static void __attribute__((constructor)) init_defaults(void)
33 {
34 /*
35 * The libringbuffer won't accept subbuf sizes smaller than the page size.
36 * If the default subbuf size is smaller, replace it by the page size.
37 */
38 long page_size = sysconf(_SC_PAGESIZE);
39
40 if (page_size < 0) {
41 page_size = 0;
42 }
43
44 default_channel_subbuf_size =
45 max(_DEFAULT_CHANNEL_SUBBUF_SIZE, page_size);
46 default_metadata_subbuf_size =
47 max(DEFAULT_METADATA_SUBBUF_SIZE, page_size);
48 default_kernel_channel_subbuf_size =
49 max(DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE, page_size);
50 default_ust_pid_channel_subbuf_size =
51 max(DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE, page_size);
52 default_ust_uid_channel_subbuf_size =
53 max(DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE, page_size);
54 }
This page took 0.03043 seconds and 4 git commands to generate.