/native_printer_decls.h
/native_printer_defs.h
/printers.h
+/*.mpers.i
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) \
+CLEANFILES = $(ioctl_redefs_h) $(ioctlent_h) $(mpers_preproc_files) \
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
include mpers.am
srcdir_mpers_source_files = $(patsubst %,$(srcdir)/%,$(mpers_source_files))
+mpers_preproc_files = $(mpers_source_files:.c=.c.mpers.i)
mpers_NAME =
mpers_PREFIX = $(mpers_NAME)_
# printers
-printers.h: $(srcdir_mpers_source_files)
+%.c.mpers.i: $(srcdir)/%.c
+ $(CPP) -P $(mpers_sh_opts) -DIN_MPERS_BOOTSTRAP $< -o $@
+
+mpers_printer_decl_pattern = ^MPERS_PRINTER_DECL(\([^,)]\+\),[[:space:]]*\([^,)]\+\),[[:space:]]*\([^)]\+\))$$
+
+printers.h: $(mpers_preproc_files)
echo '/* Generated by Makefile from $^; do not edit. */' > $@-t
echo 'typedef struct {' >> $@-t
for f in $^; do \
- sed -n 's/^MPERS_PRINTER_DECL(\([^,]\+\),[[:space:]]*\([^)]\+\))\(.*\)/ \1 (*\2) \3;\n#define \2 MPERS_PRINTER_NAME(\2)\n/p' $$f || exit; \
+ sed -n 's/$(mpers_printer_decl_pattern)/ \1 (*\2)(\3);\n#define \2 MPERS_PRINTER_NAME(\2)\n/p' $$f \
+ || exit; \
done >> $@-t
echo '} struct_printers;' >> $@-t
echo 'extern const struct_printers *printers;' >> $@-t
echo '#define MPERS_PRINTER_NAME(printer_name) printers->printer_name' >> $@-t
mv $@-t $@
-%_printer_decls.h: $(srcdir_mpers_source_files)
+%_printer_decls.h: $(mpers_preproc_files)
echo '/* Generated by Makefile from $^; do not edit. */' > $@-t
for f in $^; do \
- sed -n 's/^MPERS_PRINTER_DECL(\([^,]\+\),[[:space:]]*\([^)]\+\))\(.*\)/extern \1 $(mpers_PREFIX)\2\3;/p' $$f || exit; \
+ sed -n 's/$(mpers_printer_decl_pattern)/extern \1 $(mpers_PREFIX)\2(\3);/p' $$f \
+ || exit; \
done >> $@-t
mv $@-t $@
-%_printer_defs.h: $(srcdir_mpers_source_files)
+%_printer_defs.h: $(mpers_preproc_files)
echo '/* Generated by Makefile from $^; do not edit. */' > $@-t
for f in $^; do \
- sed -n 's/^MPERS_PRINTER_DECL(\([^,]\+\),[[:space:]]*\([^)]\+\))\(.*\)/\.\2 = $(mpers_PREFIX)\2,/p' $$f || exit; \
+ sed -n 's/$(mpers_printer_decl_pattern)/\.\2 = $(mpers_PREFIX)\2,/p' $$f \
+ || exit; \
done >> $@-t
mv $@-t $@
(containing definitions of these types or other behaviour-affecting
defines);
* printers should be defined
-as MPERS_PRINTER_DECL(return_type, function_name)(args),
+as MPERS_PRINTER_DECL(return_type, function_name, args),
inside files that include MPERS_DEFS these printers should be called
as MPERS_FUNC_NAME(function_name)(args), in other files
they should be called just as function_name(args).
extern unsigned nioctlents;
extern unsigned num_quals;
-#if SUPPORTED_PERSONALITIES > 1
-# include "printers.h"
-#else
-# include "native_printer_decls.h"
-#endif
+#ifdef IN_MPERS_BOOTSTRAP
+/* Transform multi-line MPERS_PRINTER_DECL statements to one-liners. */
+# define MPERS_PRINTER_DECL(type, name, ...) MPERS_PRINTER_DECL(type, name, __VA_ARGS__)
+#else /* !IN_MPERS_BOOTSTRAP */
+# if SUPPORTED_PERSONALITIES > 1
+# include "printers.h"
+# else
+# include "native_printer_decls.h"
+# endif
+# define MPERS_PRINTER_DECL(type, name, ...) type MPERS_FUNC_NAME(name)(__VA_ARGS__)
+#endif /* !IN_MPERS_BOOTSTRAP */
/*
* If you need non-NULL sysent[scno].sys_func and sysent[scno].sys_name
#define SYS_FUNC(syscall_name) int SYS_FUNC_NAME(sys_ ## syscall_name)(struct tcb *tcp)
-#define MPERS_PRINTER_DECL(type, name) type MPERS_FUNC_NAME(name)
-
/*
* The kernel used to define 64-bit types on 64-bit systems on a per-arch
* basis. Some architectures would use unsigned long and others would use
#include MPERS_DEFS
-MPERS_PRINTER_DECL(bool, fetch_seccomp_fprog)(struct tcb *tcp, const long addr, void *p)
+MPERS_PRINTER_DECL(bool, fetch_seccomp_fprog,
+ struct tcb *tcp, const long addr, void *p)
{
struct seccomp_fprog *pfp = p;
seccomp_fprog_t mfp;
&& FLOCK_MEMBERS_EQ(type, l_len) \
&& FLOCK_MEMBERS_EQ(type, l_pid))
-MPERS_PRINTER_DECL(bool, fetch_struct_flock)(struct tcb *tcp, const long addr, void *p)
+MPERS_PRINTER_DECL(bool, fetch_struct_flock,
+ struct tcb *tcp, const long addr, void *p)
{
struct_kernel_flock64 *pfl = p;
struct_flock mfl;
return true;
}
-MPERS_PRINTER_DECL(bool, fetch_struct_flock64)(struct tcb *tcp, const long addr, void *p)
+MPERS_PRINTER_DECL(bool, fetch_struct_flock64,
+ struct tcb *tcp, const long addr, void *p)
{
struct_kernel_flock64 *pfl = p;
struct_flock64 mfl;
else \
dst = (unsigned long long) (src)
-MPERS_PRINTER_DECL(bool, fetch_struct_statfs)(struct tcb *tcp, const long addr, struct strace_statfs *p)
+MPERS_PRINTER_DECL(bool, fetch_struct_statfs,
+ struct tcb *tcp, const long addr, struct strace_statfs *p)
{
struct_statfs b;
# define COMPAT_STATFS64_PADDED_SIZE (sizeof(struct_statfs64) + 4)
#endif
-MPERS_PRINTER_DECL(bool, fetch_struct_statfs64)(struct tcb *tcp, const long addr, const unsigned long size, struct strace_statfs *p)
+MPERS_PRINTER_DECL(bool, fetch_struct_statfs64,
+ struct tcb *tcp, const long addr, const unsigned long size,
+ struct strace_statfs *p)
{
struct_statfs64 b;
#else
# define MPERS_PREFIX
# define DEF_MPERS_TYPE(args) "empty.h"
-# define MPERS_DEFS "native_defs.h"
+# if IN_MPERS_BOOTSTRAP
+# define MPERS_DEFS "empty.h"
+# else
+# define MPERS_DEFS "native_defs.h"
+# endif
#endif
#include MPERS_DEFS
-MPERS_PRINTER_DECL(void, printmqattr)(struct tcb *tcp, const long addr)
+MPERS_PRINTER_DECL(void, printmqattr, struct tcb *tcp, const long addr)
{
#if defined HAVE_MQUEUE_H || defined HAVE_LINUX_MQUEUE_H
mq_attr_t attr;
typedef struct msgbuf msgbuf_t;
#include MPERS_DEFS
-MPERS_PRINTER_DECL(void, tprint_msgbuf)(struct tcb *tcp, const long addr, const unsigned long count)
+MPERS_PRINTER_DECL(void, tprint_msgbuf,
+ struct tcb *tcp, const long addr, const unsigned long count)
{
msgbuf_t msg;
#include <signal.h>
#include "xlat/sigev_value.h"
-MPERS_PRINTER_DECL(void, print_sigevent)(struct tcb *tcp, const long addr)
+MPERS_PRINTER_DECL(void, print_sigevent, struct tcb *tcp, const long addr)
{
struct_sigevent sev;
tprintf(time_fmt, (intmax_t) t->tv_sec, (intmax_t) t->tv_usec);
}
-MPERS_PRINTER_DECL(void, print_timespec)(struct tcb *tcp, const long addr)
+MPERS_PRINTER_DECL(void, print_timespec,
+ struct tcb *tcp, const long addr)
{
timespec_t t;
print_timespec_t(&t);
}
-MPERS_PRINTER_DECL(const char *, sprint_timespec)(struct tcb *tcp, const long addr)
+MPERS_PRINTER_DECL(const char *, sprint_timespec,
+ struct tcb *tcp, const long addr)
{
timespec_t t;
static char buf[sizeof(time_fmt) + 3 * sizeof(t)];
return buf;
}
-MPERS_PRINTER_DECL(void, print_timespec_utime_pair)(struct tcb *tcp, const long addr)
+MPERS_PRINTER_DECL(void, print_timespec_utime_pair,
+ struct tcb *tcp, const long addr)
{
timespec_t t[2];
tprints("]");
}
-MPERS_PRINTER_DECL(void, print_itimerspec)(struct tcb *tcp, const long addr)
+MPERS_PRINTER_DECL(void, print_itimerspec,
+ struct tcb *tcp, const long addr)
{
timespec_t t[2];
tprints("}");
}
-MPERS_PRINTER_DECL(void, print_timeval)(struct tcb *tcp, const long addr)
+MPERS_PRINTER_DECL(void, print_timeval,
+ struct tcb *tcp, const long addr)
{
timeval_t t;
print_timeval_t(&t);
}
-MPERS_PRINTER_DECL(void, print_timeval_pair)(struct tcb *tcp, const long addr)
+MPERS_PRINTER_DECL(void, print_timeval_pair,
+ struct tcb *tcp, const long addr)
{
timeval_t t[2];
tprints("]");
}
-MPERS_PRINTER_DECL(const char *, sprint_timeval)(struct tcb *tcp, const long addr)
+MPERS_PRINTER_DECL(const char *, sprint_timeval,
+ struct tcb *tcp, const long addr)
{
timeval_t t;
static char buf[sizeof(time_fmt) + 3 * sizeof(t)];
return buf;
}
-MPERS_PRINTER_DECL(void, print_itimerval)(struct tcb *tcp, const long addr)
+MPERS_PRINTER_DECL(void, print_itimerval,
+ struct tcb *tcp, const long addr)
{
timeval_t t[2];
#include "xlat/adjtimex_modes.h"
#include "xlat/adjtimex_status.h"
-MPERS_PRINTER_DECL(int, print_timex)(struct tcb *tcp, const long addr)
+MPERS_PRINTER_DECL(int, print_timex, struct tcb *tcp, const long addr)
{
struct_timex tx;
#include MPERS_DEFS
-MPERS_PRINTER_DECL(void, printrusage)(struct tcb *tcp, long addr)
+MPERS_PRINTER_DECL(void, printrusage, struct tcb *tcp, long addr)
{
rusage_t ru;
tprints("}");
}
-MPERS_PRINTER_DECL(void, printsiginfo_at)(struct tcb *tcp, long addr)
+MPERS_PRINTER_DECL(void, printsiginfo_at,
+ struct tcb *tcp, long addr)
{
siginfo_t si;
return true;
}
-MPERS_PRINTER_DECL(void, print_siginfo_array)(struct tcb *tcp, unsigned long addr, unsigned long len)
+MPERS_PRINTER_DECL(void, print_siginfo_array,
+ struct tcb *tcp, unsigned long addr, unsigned long len)
{
siginfo_t si;
}
#endif /* VIDIOC_CREATE_BUFS */
-MPERS_PRINTER_DECL(int, v4l2_ioctl)(struct tcb *tcp, const unsigned int code, const long arg)
+MPERS_PRINTER_DECL(int, v4l2_ioctl,
+ struct tcb *tcp, const unsigned int code, const long arg)
{
if (!verbose(tcp))
return RVAL_DECODED;