compiler: add compiler.h header

parent 97fd1175
...@@ -6,6 +6,7 @@ noinst_HEADERS = attach.h \ ...@@ -6,6 +6,7 @@ noinst_HEADERS = attach.h \
caps.h \ caps.h \
cgroups/cgroup.h \ cgroups/cgroup.h \
cgroups/cgroup_utils.h \ cgroups/cgroup_utils.h \
compiler.h \
conf.h \ conf.h \
confile.h \ confile.h \
confile_utils.h \ confile_utils.h \
...@@ -86,6 +87,7 @@ liblxc_la_SOURCES = af_unix.c af_unix.h \ ...@@ -86,6 +87,7 @@ liblxc_la_SOURCES = af_unix.c af_unix.h \
cgroups/cgfsng.c \ cgroups/cgfsng.c \
cgroups/cgroup.c cgroups/cgroup.h \ cgroups/cgroup.c cgroups/cgroup.h \
cgroups/cgroup_utils.c cgroups/cgroup_utils.h \ cgroups/cgroup_utils.c cgroups/cgroup_utils.h \
compiler.h \
commands.c commands.h \ commands.c commands.h \
commands_utils.c commands_utils.h \ commands_utils.c commands_utils.h \
conf.c conf.h \ conf.c conf.h \
......
/* liblxcapi
*
* Copyright © 2018 Christian Brauner <christian.brauner@ubuntu.com>.
* Copyright © 2018 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
* This program 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.
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __LXC_COMPILER_H
#define __LXC_COMPILER_H
#include "config.h"
#ifndef thread_local
#if __STDC_VERSION__ >= 201112L && \
!(defined(__STDC_NO_THREADS__) || \
(defined(__GNU_LIBRARY__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 16))
#define thread_local _Thread_local
#else
#define thread_local __thread
#endif
#endif
#endif /* __LXC_COMPILER_H */
...@@ -124,7 +124,7 @@ lxc_log_define(conf, lxc); ...@@ -124,7 +124,7 @@ lxc_log_define(conf, lxc);
* This is used in the error calls. * This is used in the error calls.
*/ */
#ifdef HAVE_TLS #ifdef HAVE_TLS
__thread struct lxc_conf *current_config; thread_local struct lxc_conf *current_config;
#else #else
struct lxc_conf *current_config; struct lxc_conf *current_config;
#endif #endif
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
#include "compiler.h"
#include "list.h" #include "list.h"
#include "ringbuf.h" #include "ringbuf.h"
#include "start.h" /* for lxc_handler */ #include "start.h" /* for lxc_handler */
...@@ -379,7 +380,7 @@ extern int write_id_mapping(enum idtype idtype, pid_t pid, const char *buf, ...@@ -379,7 +380,7 @@ extern int write_id_mapping(enum idtype idtype, pid_t pid, const char *buf,
size_t buf_size); size_t buf_size);
#ifdef HAVE_TLS #ifdef HAVE_TLS
extern __thread struct lxc_conf *current_config; extern thread_local struct lxc_conf *current_config;
#else #else
extern struct lxc_conf *current_config; extern struct lxc_conf *current_config;
#endif #endif
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "initutils.h" #include "initutils.h"
#include "log.h" #include "log.h"
#include "macro.h" #include "macro.h"
#include "compiler.h"
#ifndef HAVE_STRLCPY #ifndef HAVE_STRLCPY
#include "include/strlcpy.h" #include "include/strlcpy.h"
...@@ -72,9 +73,9 @@ const char *lxc_global_config_value(const char *option_name) ...@@ -72,9 +73,9 @@ const char *lxc_global_config_value(const char *option_name)
/* placed in the thread local storage pool for non-bionic targets */ /* placed in the thread local storage pool for non-bionic targets */
#ifdef HAVE_TLS #ifdef HAVE_TLS
static __thread const char *values[sizeof(options) / sizeof(options[0])] = { 0 }; static thread_local const char *values[sizeof(options) / sizeof(options[0])] = {0};
#else #else
static const char *values[sizeof(options) / sizeof(options[0])] = { 0 }; static const char *values[sizeof(options) / sizeof(options[0])] = {0};
#endif #endif
/* user_config_path is freed as soon as it is used */ /* user_config_path is freed as soon as it is used */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment