BUILD: flags: really restrict the cases where flags are exposed
A number of internal flags started to be exposed to external programs
at the location of their definition since commit 77acaf5af
("MINOR:
flags: add a new file to host flag dumping macros"). This allowed the
"flags" utility to decode many more of them and always correctly. The
condition to expose them was to rely on the preliminary definition of
EOF that indicates that stdio is already included. But this was a
wrong approach. It only guarantees that snprintf() can safely be used
but still causes large functions to be built. But stdio is often
included before some of these includes, so these heavy inline functions
actually have to be compiled in many cases. The result is that the
build time significantly increased, especially with fast compilers
like gcc -O0 which took +50% or TCC which took +100%!
This patch addresses the problem by instead relying on an explicit
macro HA_EXPOSE_FLAGS that the calling program must explicitly define
before including these files. flags.c does this and that's all. The
previous build time is now restored with a speed up of 20 to 50%
depending on the build options.
This commit is contained in:
parent
08093cc0fa
commit
946d370d22
|
@ -1,6 +1,9 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* make the include files below expose their flags */
|
||||
#define HA_EXPOSE_FLAGS
|
||||
|
||||
#include <haproxy/channel-t.h>
|
||||
#include <haproxy/connection-t.h>
|
||||
#include <haproxy/fd-t.h>
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#ifndef _HAPROXY_SHOW_FLAGS_H
|
||||
#define _HAPROXY_SHOW_FLAGS_H
|
||||
|
||||
/* Only define the macro below if the caller included stdio, that we need for
|
||||
* snprintf(). It will be used by many low-level includes and we don't want to
|
||||
/* Only define the macro below if the caller requests it using HA_EXPOSE_FLAGS.
|
||||
* It will be used by many low-level includes and we don't want to
|
||||
* include the huge stdio here by default. The macro is used to make a string
|
||||
* of a set of flags (and handles one flag at a time). It will append into
|
||||
* <_buf>:<_len> the state of flag <_val> in <_flg>, appending string <_del> as
|
||||
|
@ -49,7 +49,7 @@
|
|||
* to isolate bits to compare to the enum's value, and will remove the mask's
|
||||
* bits at once in case of match.
|
||||
*/
|
||||
#ifdef EOF
|
||||
#ifdef HA_EXPOSE_FLAGS
|
||||
|
||||
#define __APPEND_FLAG(_buf, _len, _del, _flg, _val, _nam, ...) \
|
||||
do { \
|
||||
|
|
Loading…
Reference in New Issue