]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
compiler: add compiler.h header
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 24 Aug 2018 14:07:07 +0000 (16:07 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 28 Aug 2018 18:10:47 +0000 (20:10 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/Makefile.am
src/lxc/compiler.h [new file with mode: 0644]
src/lxc/conf.c
src/lxc/conf.h
src/lxc/initutils.c

index 0322a0d651c6fb135a4ea30e7563939f0e52190f..266b2a36a4ceb7c49e56f91a9709874db81526d2 100644 (file)
@@ -6,6 +6,7 @@ noinst_HEADERS = attach.h \
                 caps.h \
                 cgroups/cgroup.h \
                 cgroups/cgroup_utils.h \
+                compiler.h \
                 conf.h \
                 confile.h \
                 confile_utils.h \
@@ -86,6 +87,7 @@ liblxc_la_SOURCES = af_unix.c af_unix.h \
                    cgroups/cgfsng.c \
                    cgroups/cgroup.c cgroups/cgroup.h \
                    cgroups/cgroup_utils.c cgroups/cgroup_utils.h \
+                   compiler.h \
                    commands.c commands.h \
                    commands_utils.c commands_utils.h \
                    conf.c conf.h \
diff --git a/src/lxc/compiler.h b/src/lxc/compiler.h
new file mode 100644 (file)
index 0000000..cda44c9
--- /dev/null
@@ -0,0 +1,35 @@
+/* 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 */
index dfca5923acea570ef8bfd48ebfd91383b607dc2f..30663312037e961ddc7a7527b9b1df05712ea5a4 100644 (file)
@@ -125,7 +125,7 @@ lxc_log_define(conf, lxc);
  * This is used in the error calls.
  */
 #ifdef HAVE_TLS
-__thread struct lxc_conf *current_config;
+thread_local struct lxc_conf *current_config;
 #else
 struct lxc_conf *current_config;
 #endif
index 070dd22921c957d4f1b7146b55d0e796f3326c42..eddf97a1a96e402eefe10013eec3f1035263024d 100644 (file)
@@ -38,6 +38,7 @@
 #include <sys/resource.h>
 #endif
 
+#include "compiler.h"
 #include "list.h"
 #include "ringbuf.h"
 #include "start.h" /* for lxc_handler */
@@ -395,7 +396,7 @@ extern int write_id_mapping(enum idtype idtype, pid_t pid, const char *buf,
                            size_t buf_size);
 
 #ifdef HAVE_TLS
-extern __thread struct lxc_conf *current_config;
+extern thread_local struct lxc_conf *current_config;
 #else
 extern struct lxc_conf *current_config;
 #endif
index c582b2d0063353b93bbd58a6b38860e41d2f02ed..467d3f0bceb163758d04eb857eaeb8b6056e9875 100644 (file)
@@ -28,6 +28,7 @@
 #include "initutils.h"
 #include "log.h"
 #include "macro.h"
+#include "compiler.h"
 
 #ifndef HAVE_STRLCPY
 #include "include/strlcpy.h"
@@ -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 */
 #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
-       static const char *values[sizeof(options) / sizeof(options[0])] = { 0 };
+       static const char *values[sizeof(options) / sizeof(options[0])] = {0};
 #endif
 
        /* user_config_path is freed as soon as it is used */