84a5a80148
* Chardev fix from Marc-André * config.status tweak from David * Header file tweaks from Markus, myself and Veronia (Outreachy candidate) * get_ticks_per_sec() removal from Rutuja (Outreachy candidate) * Coverity fix from myself * PKE implementation from myself, based on rth's XSAVE support -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJW9ErPAAoJEL/70l94x66DJfEH/A/QkMpAhrgNdyVsahzsGrzE wx5gHFIc1nBYxyr62w4apUb5jPB7zaXu0LA7EAWDeAe0pyP8hZzLT9kJyOEDsuJu zwKN2QeLSNMtPbnbKN0I/YQ2za2xX1V5ruhSeOJoVslUI214hgnAURaGshhQNzuZ 2CluDT9KgL5cQifAnKs5kJrwhIYShYNQB+1eDC/7wk28dd/EH+sPALIoF+rqrSmt Zu4Mdqd+9Ns+oKOjA6br9ULq/Hzg0aDfY82J+XLVVqfF3PXQe8rTDmuMf/7jTn+M Un7ZOcei9oZF2/9vfAfKQpDCcgD9HvOUSbgqV/ubmkPPmN/LNJzeKj0fBhrRN+Y= =K12D -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging * Log filtering from Alex and Peter * Chardev fix from Marc-André * config.status tweak from David * Header file tweaks from Markus, myself and Veronia (Outreachy candidate) * get_ticks_per_sec() removal from Rutuja (Outreachy candidate) * Coverity fix from myself * PKE implementation from myself, based on rth's XSAVE support # gpg: Signature made Thu 24 Mar 2016 20:15:11 GMT using RSA key ID 78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" * remotes/bonzini/tags/for-upstream: (28 commits) target-i386: implement PKE for TCG config.status: Pass extra parameters char: translate from QIOChannel error to errno exec: fix error handling in file_ram_alloc cputlb: modernise the debug support qemu-log: support simple pid substitution for logs target-arm: dfilter support for in_asm qemu-log: dfilter-ise exec, out_asm, op and opt_op qemu-log: new option -dfilter to limit output qemu-log: Improve the "exec" TB execution logging qemu-log: Avoid function call for disabled qemu_log_mask logging qemu-log: correct help text for -d cpu tcg: pass down TranslationBlock to tcg_code_gen util: move declarations out of qemu-common.h Replaced get_tick_per_sec() by NANOSECONDS_PER_SECOND hw: explicitly include qemu-common.h and cpu.h include/crypto: Include qapi-types.h or qemu/bswap.h instead of qemu-common.h isa: Move DMA_transfer_handler from qemu-common.h to hw/isa/isa.h Move ParallelIOArg from qemu-common.h to sysemu/char.h Move QEMU_ALIGN_*() from qemu-common.h to qemu/osdep.h ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Conflicts: scripts/clean-includes
166 lines
4.7 KiB
Bash
Executable File
166 lines
4.7 KiB
Bash
Executable File
#!/bin/sh -e
|
|
#
|
|
# Clean up QEMU #include lines by ensuring that qemu/osdep.h
|
|
# is the first include listed in .c files, and no headers provided
|
|
# by osdep.h itself are redundantly included in either .c or .h files.
|
|
#
|
|
# Copyright (c) 2015 Linaro Limited
|
|
#
|
|
# Authors:
|
|
# Peter Maydell <peter.maydell@linaro.org>
|
|
#
|
|
# This work is licensed under the terms of the GNU GPL, version 2
|
|
# or (at your option) any later version. See the COPYING file in
|
|
# the top-level directory.
|
|
|
|
# Usage:
|
|
# clean-includes [--git subjectprefix] file ...
|
|
# or
|
|
# clean-includes [--git subjectprefix] --all
|
|
#
|
|
# If the --git subjectprefix option is given, then after making
|
|
# the changes to the files this script will create a git commit
|
|
# with the subject line "subjectprefix: Clean up includes"
|
|
# and a boilerplate commit message.
|
|
#
|
|
# Using --all will cause clean-includes to run on the whole source
|
|
# tree (excluding certain directories which are known not to need
|
|
# handling).
|
|
|
|
# This script requires Coccinelle to be installed.
|
|
|
|
# .c files will have the osdep.h included added, and redundant
|
|
# includes removed.
|
|
# .h files will have redundant includes (including includes of osdep.h)
|
|
# removed.
|
|
# Other files (including C++ and ObjectiveC) can't be handled by this script.
|
|
|
|
# The following one-liner may be handy for finding files to run this on.
|
|
# However some caution is required regarding files that might be part
|
|
# of the guest agent or standalone tests.
|
|
|
|
# for i in `git ls-tree --name-only HEAD` ; do test -f $i && \
|
|
# grep -E '^# *include' $i | head -1 | grep 'osdep.h' ; test $? != 0 && \
|
|
# echo $i ; done
|
|
|
|
|
|
GIT=no
|
|
|
|
# Extended regular expression defining files to ignore when using --all
|
|
XDIRREGEX='^(tests/tcg|tests/multiboot|pc-bios|disas/libvixl)'
|
|
|
|
if [ $# -ne 0 ] && [ "$1" = "--git" ]; then
|
|
if [ $# -eq 1 ]; then
|
|
echo "--git option requires an argument"
|
|
exit 1
|
|
fi
|
|
GITSUBJ="$2"
|
|
GIT=yes
|
|
shift
|
|
shift
|
|
fi
|
|
|
|
if [ $# -eq 0 ]; then
|
|
echo "Usage: clean-includes [--git subjectprefix] [--all | foo.c ...]"
|
|
echo "(modifies the files in place)"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$1" = "--all" ]; then
|
|
# We assume there are no files in the tree with spaces in their name
|
|
set -- $(git ls-files '*.[ch]' | grep -E -v "$XDIRREGEX")
|
|
fi
|
|
|
|
# Annoyingly coccinelle won't read a scriptfile unless its
|
|
# name ends '.cocci', so write it out to a tempfile with the
|
|
# right kind of name.
|
|
COCCIFILE="$(mktemp --suffix=.cocci)"
|
|
|
|
trap 'rm -f -- "$COCCIFILE"' INT TERM HUP EXIT
|
|
|
|
cat >"$COCCIFILE" <<EOT
|
|
@@
|
|
@@
|
|
|
|
(
|
|
+ #include "qemu/osdep.h"
|
|
#include "..."
|
|
|
|
|
+ #include "qemu/osdep.h"
|
|
#include <...>
|
|
)
|
|
EOT
|
|
|
|
|
|
for f in "$@"; do
|
|
case "$f" in
|
|
*.inc.c)
|
|
# These aren't standalone C source files
|
|
echo "SKIPPING $f (not a standalone source file)"
|
|
continue
|
|
;;
|
|
*.c)
|
|
MODE=c
|
|
;;
|
|
*include/qemu/osdep.h | \
|
|
*include/qemu/compiler.h | \
|
|
*include/standard-headers/ )
|
|
# Removing include lines from osdep.h itself would be counterproductive.
|
|
echo "SKIPPING $f (special case header)"
|
|
continue
|
|
;;
|
|
*include/standard-headers/*)
|
|
echo "SKIPPING $f (autogenerated header)"
|
|
continue
|
|
;;
|
|
*.h)
|
|
MODE=h
|
|
;;
|
|
*)
|
|
echo "WARNING: ignoring $f (cannot handle non-C files)"
|
|
continue
|
|
;;
|
|
esac
|
|
|
|
if [ "$MODE" = "c" ]; then
|
|
# First, use Coccinelle to add qemu/osdep.h before the first existing include
|
|
# (this will add two lines if the file uses both "..." and <...> #includes,
|
|
# but we will remove the extras in the next step)
|
|
spatch --in-place --no-show-diff --cocci-file "$COCCIFILE" "$f"
|
|
|
|
# Now remove any duplicate osdep.h includes
|
|
perl -n -i -e 'print if !/#include "qemu\/osdep.h"/ || !$n++;' "$f"
|
|
else
|
|
# Remove includes of osdep.h itself
|
|
perl -n -i -e 'print if !/\s*#\s*include\s*(["<][^>"]*[">])/ ||
|
|
! (grep { $_ eq $1 } qw ("qemu/osdep.h"))' "$f"
|
|
fi
|
|
|
|
# Remove includes that osdep.h already provides
|
|
perl -n -i -e 'print if !/\s*#\s*include\s*(["<][^>"]*[">])/ ||
|
|
! (grep { $_ eq $1 } qw (
|
|
"config-host.h" "config-target.h" "qemu/compiler.h"
|
|
<setjmp.h> <stdarg.h> <stddef.h> <stdbool.h> <stdint.h> <sys/types.h>
|
|
<stdlib.h> <stdio.h> <string.h> <strings.h> <inttypes.h>
|
|
<limits.h> <unistd.h> <time.h> <ctype.h> <errno.h> <fcntl.h>
|
|
<sys/stat.h> <sys/time.h> <assert.h> <signal.h>
|
|
"sysemu/os-posix.h, sysemu/os-win32.h "glib-compat.h"
|
|
"qemu/typedefs.h"
|
|
))' "$f"
|
|
|
|
done
|
|
|
|
if [ "$GIT" = "yes" ]; then
|
|
git add -- "$@"
|
|
git commit --signoff -F - <<EOF
|
|
$GITSUBJ: Clean up includes
|
|
|
|
Clean up includes so that osdep.h is included first and headers
|
|
which it implies are not included manually.
|
|
|
|
This commit was created with scripts/clean-includes.
|
|
|
|
EOF
|
|
|
|
fi
|