From: Dmitry V. Levin Date: Mon, 2 May 2016 22:06:56 +0000 (+0000) Subject: Mpersify ioctl macros X-Git-Tag: v4.12~229 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1822546133f017c0379d3fffa0797a26ae00387d;p=strace Mpersify ioctl macros As values of some ioctl macros differ between personalities, these personality specific ioctl macros should be properly defined for mpersified code. Implement this by redefining personality specific ioctl macros from ioctlent*.h for each file that includes MPERS_DEFS. * Makefile.am (ioctl_macros_h): New variable. (ioctl_macros%.h): New rule. (BUILT_SOURCES, CLEANFILES): Add $(ioctl_macros_h). (m%_type_defs.h): #include MPERS_$(mpers_PREFIX)IOCTL_MACROS. * defs.h [HAVE_M32_MPERS] (MPERS_m32_IOCTL_MACROS): New macro. [HAVE_MX32_MPERS] (MPERS_mx32_IOCTL_MACROS): Likewise. Acked-by: Elvira Khabirova --- diff --git a/Makefile.am b/Makefile.am index b14f8ed8..df7366ba 100644 --- a/Makefile.am +++ b/Makefile.am @@ -693,6 +693,15 @@ ioctlsort_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_FOR_BUILD) ioctls_inc_h = $(wildcard $(srcdir)/$(OS)/$(ARCH)/ioctls_inc*.h) ioctlent_h = $(patsubst $(srcdir)/$(OS)/$(ARCH)/ioctls_inc%,ioctlent%,$(ioctls_inc_h)) +ioctl_redefs_h = $(filter-out ioctl_redefs0.h,$(subst ioctlent,ioctl_redefs,$(ioctlent_h))) + +ioctl_redefs%.h: ioctlent%.h ioctlent0.h + sort $< > $<-t + sort ioctlent0.h | comm -23 $<-t - | \ + sed -n 's/^{ "\([^"]\+\)", \(0x[[:xdigit:]]\+\) },$$/#ifdef \1\n# undef \1\n# define \1 \2\n#endif/p' \ + > $@-t + rm -f $<-t + mv $@-t $@ ioctlent%.h: ioctlsort% ./$< > $@ @@ -706,8 +715,10 @@ ioctlsort%.o: ioctls_all%.h $(srcdir)/ioctlsort.c ioctls_all%.h: $(srcdir)/$(OS)/$(ARCH)/ioctls_inc%.h $(srcdir)/$(OS)/$(ARCH)/ioctls_arch%.h cat $^ > $@ -BUILT_SOURCES = $(ioctlent_h) native_printer_decls.h native_printer_defs.h printers.h sen.h sys_func.h .version -CLEANFILES = $(ioctlent_h) native_printer_decls.h native_printer_defs.h printers.h sen.h sys_func.h +BUILT_SOURCES = $(ioctl_redefs_h) $(ioctlent_h) \ + native_printer_decls.h native_printer_defs.h printers.h sen.h sys_func.h .version +CLEANFILES = $(ioctl_redefs_h) $(ioctlent_h) \ + native_printer_decls.h native_printer_defs.h printers.h sen.h sys_func.h DISTCLEANFILES = gnu/stubs-32.h gnu/stubs-x32.h # defines mpers_source_files @@ -740,6 +751,7 @@ m%_type_defs.h: $(srcdir_mpers_source_files) echo '#undef MPERS_PRINTER_NAME' >> $@-t echo '#define MPERS_PRINTER_NAME(printer_name) printer_name' >> $@-t echo '#include "$(mpers_PREFIX)printer_decls.h"' >> $@-t + echo '#include MPERS_$(mpers_PREFIX)IOCTL_MACROS' >> $@-t mv $@-t $@ m%_funcs.h: $(srcdir_mpers_source_files) diff --git a/defs.h b/defs.h index d1e8e1bf..fe2e46b5 100644 --- a/defs.h +++ b/defs.h @@ -157,6 +157,7 @@ extern char *stpcpy(char *dst, const char *src); # define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h" # define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h" # define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h" +# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h" # endif # endif #endif @@ -170,11 +171,13 @@ extern char *stpcpy(char *dst, const char *src); # define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h" # define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h" # define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h" +# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h" # endif # ifdef HAVE_MX32_MPERS # define PERSONALITY2_INCLUDE_FUNCS "mx32_funcs.h" # define PERSONALITY2_INCLUDE_PRINTERS_DECLS "mx32_printer_decls.h" # define PERSONALITY2_INCLUDE_PRINTERS_DEFS "mx32_printer_defs.h" +# define MPERS_mx32_IOCTL_MACROS "ioctl_redefs2.h" # endif #endif @@ -186,6 +189,7 @@ extern char *stpcpy(char *dst, const char *src); # define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h" # define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h" # define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h" +# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h" # endif #endif @@ -202,6 +206,7 @@ extern char *stpcpy(char *dst, const char *src); # define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h" # define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h" # define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h" +# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h" # endif #endif @@ -213,6 +218,7 @@ extern char *stpcpy(char *dst, const char *src); # define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h" # define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h" # define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h" +# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h" # endif #endif @@ -227,6 +233,7 @@ extern char *stpcpy(char *dst, const char *src); # define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h" # define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h" # define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h" +# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h" # endif #endif