compiler: add __hot attribute

This instructs the compiler to better optimize the config parsing code.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2018-09-26 14:52:27 +02:00
parent 810fd51c92
commit afeec9b739
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D
3 changed files with 17 additions and 10 deletions

View File

@ -46,6 +46,10 @@
#endif #endif
#endif #endif
#ifndef __hot
# define __hot __attribute__((hot))
#endif
#define __cgfsng_ops #define __cgfsng_ops
#endif /* __LXC_COMPILER_H */ #endif /* __LXC_COMPILER_H */

View File

@ -71,11 +71,12 @@
lxc_log_define(confile, lxc); lxc_log_define(confile, lxc);
#define lxc_config_define(name) \ #define lxc_config_define(name) \
static int set_config_##name(const char *, const char *, \ __hot static int set_config_##name(const char *, const char *, \
struct lxc_conf *, void *); \ struct lxc_conf *, void *); \
static int get_config_##name(const char *, char *, int, \ __hot static int get_config_##name(const char *, char *, int, \
struct lxc_conf *, void *); \ struct lxc_conf *, void *); \
static int clr_config_##name(const char *, struct lxc_conf *, void *); __hot static int clr_config_##name(const char *, struct lxc_conf *, \
void *);
lxc_config_define(autodev); lxc_config_define(autodev);
lxc_config_define(apparmor_allow_incomplete); lxc_config_define(apparmor_allow_incomplete);

View File

@ -26,17 +26,19 @@
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include "compiler.h"
typedef int (*lxc_dir_cb)(const char *name, const char *directory, typedef int (*lxc_dir_cb)(const char *name, const char *directory,
const char *file, void *data); const char *file, void *data);
typedef int (*lxc_file_cb)(char *buffer, 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, __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); 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 /* mmap() wrapper. lxc_strmmap() will take care to \0-terminate files so that
* normal string-handling functions can be used on the buffer. */ * normal string-handling functions can be used on the buffer. */
extern void *lxc_strmmap(void *addr, size_t length, int prot, int flags, int fd, extern void *lxc_strmmap(void *addr, size_t length, int prot, int flags, int fd,