From afeec9b7397f862b535846f03be535677c5ce19c Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 26 Sep 2018 14:52:27 +0200 Subject: [PATCH] compiler: add __hot attribute This instructs the compiler to better optimize the config parsing code. Signed-off-by: Christian Brauner --- src/lxc/compiler.h | 4 ++++ src/lxc/confile.c | 13 +++++++------ src/lxc/parse.h | 10 ++++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/lxc/compiler.h b/src/lxc/compiler.h index 76a7b733d..b6fbbc0e0 100644 --- a/src/lxc/compiler.h +++ b/src/lxc/compiler.h @@ -46,6 +46,10 @@ #endif #endif +#ifndef __hot +# define __hot __attribute__((hot)) +#endif + #define __cgfsng_ops #endif /* __LXC_COMPILER_H */ diff --git a/src/lxc/confile.c b/src/lxc/confile.c index c55ea7872..6312fdf90 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -70,12 +70,13 @@ lxc_log_define(confile, lxc); -#define lxc_config_define(name) \ - static int set_config_##name(const char *, const char *, \ - struct lxc_conf *, void *); \ - static int get_config_##name(const char *, char *, int, \ - struct lxc_conf *, void *); \ - static int clr_config_##name(const char *, struct lxc_conf *, void *); +#define lxc_config_define(name) \ + __hot static int set_config_##name(const char *, const char *, \ + struct lxc_conf *, void *); \ + __hot static int get_config_##name(const char *, char *, int, \ + struct lxc_conf *, void *); \ + __hot static int clr_config_##name(const char *, struct lxc_conf *, \ + void *); lxc_config_define(autodev); lxc_config_define(apparmor_allow_incomplete); diff --git a/src/lxc/parse.h b/src/lxc/parse.h index 913472740..bea45ef12 100644 --- a/src/lxc/parse.h +++ b/src/lxc/parse.h @@ -26,16 +26,18 @@ #include #include +#include "compiler.h" + typedef int (*lxc_dir_cb)(const char *name, const char *directory, const char *file, void *data); typedef int (*lxc_file_cb)(char *buffer, void *data); -extern int lxc_file_for_each_line(const char *file, lxc_file_cb callback, - void* data); +__hot extern int lxc_file_for_each_line(const char *file, lxc_file_cb callback, + void *data); -extern int lxc_file_for_each_line_mmap(const char *file, lxc_file_cb callback, - void *data); +__hot extern int lxc_file_for_each_line_mmap(const char *file, + lxc_file_cb callback, void *data); /* mmap() wrapper. lxc_strmmap() will take care to \0-terminate files so that * normal string-handling functions can be used on the buffer. */