From: Eugene Syromyatnikov Date: Thu, 22 Aug 2019 14:06:41 +0000 (+0200) Subject: Move FLAG_ macro from defs.h to macros.h X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ee949aeb234e7e0fcbed72889e253da041dd8e1;p=strace Move FLAG_ macro from defs.h to macros.h Rename it to FLAG and implement via newly added BIT helper macro, in preparation for general use * defs.h: Use FLAG instead of FLAG_. (FLAG_): Move it... * macros.h (FLAG): Here, implement using BIT macro. [!BIT] (BIT): New macro. --- diff --git a/defs.h b/defs.h index 06bf1248..5be982ac 100644 --- a/defs.h +++ b/defs.h @@ -775,19 +775,15 @@ enum xlat_style_private_flag_bits { PXF_DEFAULT_STR_BIT, }; -# define FLAG_(name_) name_ = 1 << name_##_BIT - enum xlat_style_private_flags { /* print_array */ - FLAG_(PAF_PRINT_INDICES), - FLAG_(PAF_ARRAY_TRUNCATED), + FLAG(PAF_PRINT_INDICES), + FLAG(PAF_ARRAY_TRUNCATED), /* print_xlat */ - FLAG_(PXF_DEFAULT_STR), + FLAG(PXF_DEFAULT_STR), }; -# undef FLAG_ - /** Print a value in accordance with xlat formatting settings. */ extern void print_xlat_ex(uint64_t val, const char *str, enum xlat_style style); # define print_xlat(val_) \ diff --git a/macros.h b/macros.h index f3ebdaf4..1a250140 100644 --- a/macros.h +++ b/macros.h @@ -73,4 +73,10 @@ is_filled(const char *ptr, char fill, size_t size) # define IS_ARRAY_ZERO(arr_) \ is_filled((const char *) (arr_), 0, sizeof(arr_) + MUST_BE_ARRAY(arr_)) +# ifndef BIT +# define BIT(x_) (1U << (x_)) +# endif + +# define FLAG(name_) name_ = BIT(name_##_BIT) + #endif /* !STRACE_MACROS_H */