[PATCH 2/3] Move shorthand notations to separate file

Eugene Syromiatnikov esyr at redhat.com
Mon Aug 7 08:37:30 UTC 2017


On Sat, Aug 05, 2017 at 04:57:35AM +0300, Edgar Kaziakhmedov wrote:
> In order to allow usage shorthand notations of defines in sysent.h file
"usage of shorthand notations of definitions from sysent.h used in
syscallent.h files"

> by other binaries in the strace package these defines should be moved to
> separate file.
"to a separate file"

> 
> * Makefile.am (strace_SOURCES): Add shorthand_def.h.
> * shorthand_def.h: New file.
> * syscall.c: Use it.

* shorthand_def.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* syscall.c: Use it.

Also, I'd prefer shorthand_defs.h.

> 
> Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov at virtuozzo.com>
> ---
>  Makefile.am     |  1 +
>  shorthand_def.h | 42 ++++++++++++++++++++++++++++++++++++++++++
>  syscall.c       | 43 ++++---------------------------------------
>  3 files changed, 47 insertions(+), 39 deletions(-)
>  create mode 100644 shorthand_def.h
> 
> diff --git a/Makefile.am b/Makefile.am
> index 20708711..ae119a75 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -248,6 +248,7 @@ strace_SOURCES =	\
>  	scsi.c		\
>  	seccomp.c	\
>  	sendfile.c	\
> +	shorthand_def.h	\
>  	sg_io_v3.c	\
>  	sg_io_v4.c	\
>  	shutdown.c	\
> diff --git a/shorthand_def.h b/shorthand_def.h
> new file mode 100644
> index 00000000..70e4fd4a
> --- /dev/null
> +++ b/shorthand_def.h
> @@ -0,0 +1,42 @@
> +#ifdef DEFINE_SHORTHAND
> +#define TD TRACE_DESC
> +#define TF TRACE_FILE
> +#define TI TRACE_IPC
> +#define TN TRACE_NETWORK
> +#define TP TRACE_PROCESS
> +#define TS TRACE_SIGNAL
> +#define TM TRACE_MEMORY
> +#define TST TRACE_STAT
> +#define TLST TRACE_LSTAT
> +#define TFST TRACE_FSTAT
> +#define TSTA TRACE_STAT_LIKE
> +#define TSF TRACE_STATFS
> +#define TFSF TRACE_FSTATFS
> +#define TSFA TRACE_STATFS_LIKE
> +#define NF SYSCALL_NEVER_FAILS
> +#define MA MAX_ARGS
> +#define SI STACKTRACE_INVALIDATE_CACHE
> +#define SE STACKTRACE_CAPTURE_ON_ENTER
> +#define CST COMPAT_SYSCALL_TYPES
> +#else
> +#undef SEN
> +#undef TD
> +#undef TF
> +#undef TI
> +#undef TN
> +#undef TP
> +#undef TS
> +#undef TM
> +#undef TST
> +#undef TLST
> +#undef TFST
> +#undef TSTA
> +#undef TSF
> +#undef TFSF
> +#undef TSFA
> +#undef NF
> +#undef MA
> +#undef SI
> +#undef SE
> +#undef CST
> +#endif
> diff --git a/syscall.c b/syscall.c
> index f21a1467..7884e00f 100644
> --- a/syscall.c
> +++ b/syscall.c
> @@ -70,25 +70,8 @@
>  #include "syscall.h"
>  
>  /* Define these shorthand notations to simplify the syscallent files. */
> -#define TD TRACE_DESC
> -#define TF TRACE_FILE
> -#define TI TRACE_IPC
> -#define TN TRACE_NETWORK
> -#define TP TRACE_PROCESS
> -#define TS TRACE_SIGNAL
> -#define TM TRACE_MEMORY
> -#define TST TRACE_STAT
> -#define TLST TRACE_LSTAT
> -#define TFST TRACE_FSTAT
> -#define TSTA TRACE_STAT_LIKE
> -#define TSF TRACE_STATFS
> -#define TFSF TRACE_FSTATFS
> -#define TSFA TRACE_STATFS_LIKE
> -#define NF SYSCALL_NEVER_FAILS
> -#define MA MAX_ARGS
> -#define SI STACKTRACE_INVALIDATE_CACHE
> -#define SE STACKTRACE_CAPTURE_ON_ENTER
> -#define CST COMPAT_SYSCALL_TYPES
> +#define DEFINE_SHORTHAND
> +#include "shorthand_def.h"
>  
>  #define SEN(syscall_name) SEN_ ## syscall_name, SYS_FUNC_NAME(sys_ ## syscall_name)
>  
> @@ -111,26 +94,8 @@ static const struct_sysent sysent2[] = {
>  #endif
>  
>  /* Now undef them since short defines cause wicked namespace pollution. */
> -#undef SEN
> -#undef TD
> -#undef TF
> -#undef TI
> -#undef TN
> -#undef TP
> -#undef TS
> -#undef TM
> -#undef TST
> -#undef TLST
> -#undef TFST
> -#undef TSTA
> -#undef TSF
> -#undef TFSF
> -#undef TSFA
> -#undef NF
> -#undef MA
> -#undef SI
> -#undef SE
> -#undef CST
> +#undef DEFINE_SHORTHAND
> +#include "shorthand_def.h"
>  
>  /*
>   * `ioctlent[012].h' files are automatically generated by the auxiliary
> -- 
> 2.11.0




More information about the Strace-devel mailing list