]> granicus.if.org Git - strace/commitdiff
Mpersify ioctl macros
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 2 May 2016 22:06:56 +0000 (22:06 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 5 May 2016 21:20:47 +0000 (21:20 +0000)
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 <lineprinter0@gmail.com>
Makefile.am
defs.h

index b14f8ed8b1b916e0b597ca09ad356642053eccda..df7366ba65679aa8d0ac9314b9fd6b50e602a41e 100644 (file)
@@ -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 d1e8e1bfd4a1a313c8ad3e6987713d3a84d29a16..fe2e46b5909aa11d26bed2951460c4ed50dbe927 100644 (file)
--- 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