Re: [PATCH v4 7/9] perf: Finalize subcmd independence
On Wed, Dec 16, 2015 at 10:27:11PM -0300, Arnaldo Carvalho de Melo wrote: > Em Wed, Dec 16, 2015 at 07:09:53PM -0600, Josh Poimboeuf escreveu: > > On Wed, Dec 16, 2015 at 09:57:41PM -0300, Arnaldo Carvalho de Melo wrote: > > > Em Tue, Dec 15, 2015 at 09:39:38AM -0600, Josh Poimboeuf escreveu: > > > > For the files that will be moved to the subcmd library, remove all their > > > > perf-specific includes and duplicate any needed functionality. > > > > > > Breaks rhel6.7 building: > > > > > > > > > > > +typedef uint64_t u64; > > > > + > > > > > > > > > [acme@sandy linux]$ cat /etc/redhat-release > > > Red Hat Enterprise Linux Server release 6.7 (Santiago) > > > > > > CC /tmp/build/perf/parse-options.o > > > parse-options.c:15: error: redefinition of typedef ‘u64’ > > > /home/acme/git/linux/tools/include/linux/types.h:28: note: previous > > > declaration of ‘u64’ was here > > > mv: cannot stat `/tmp/build/perf/.parse-options.o.tmp': No such file or > > > directory > > > make[3]: *** [/tmp/build/perf/parse-options.o] Error 1 > > > make[2]: *** [/tmp/build/perf/libsubcmd-in.o] Error 2 > > > make[1]: *** [/tmp/build/perf/libsubcmd.a] Error 2 > > > make[1]: *** Waiting for unfinished jobs > > > MKDIR/tmp/build/perf/util/ > > > > Does this fix it? > > Yes, and it continues to build on fedora 21. > > - Arnaldo > > > ---8<--- > > > > diff --git a/tools/lib/subcmd/parse-options.c > > b/tools/lib/subcmd/parse-options.c > > index f424027..981bb44 100644 > > --- a/tools/lib/subcmd/parse-options.c > > +++ b/tools/lib/subcmd/parse-options.c > > @@ -1,4 +1,5 @@ > > #include > > +#include > > #include > > #include > > #include > > @@ -12,8 +13,6 @@ > > #define OPT_SHORT 1 > > #define OPT_UNSET 2 > > > > -typedef uint64_t u64; > > - > > char *error_buf; > > > > static int opterror(const struct option *opt, const char *reason, int > > flags) Here's the same patch but without the unnecessary addition of the include. Ideally it would be folded into "perf tools: Finalize subcmd independence" but in case it's too late for that, I added a changelog. ---8<--- Subject: [PATCH] tools subcmd: Fix 'u64' build error with older compilers Arnaldo reported the following error when building perf on RHEL 6.7: parse-options.c:15: error: redefinition of typedef ‘u64’ /home/acme/git/linux/tools/include/linux/types.h:28: note: previous declaration of ‘u64’ was here The parse-options.c file includes , which includes , which has a u64 typedef. So the u64 typedef in parse-options.c is unnecessary (and seems to trigger the above error on compilers which don't allow duplicate typedefs). Reported-by: Arnaldo Carvalho de Melo Signed-off-by: Josh Poimboeuf --- tools/lib/subcmd/parse-options.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c index f424027..c0c911a 100644 --- a/tools/lib/subcmd/parse-options.c +++ b/tools/lib/subcmd/parse-options.c @@ -12,8 +12,6 @@ #define OPT_SHORT 1 #define OPT_UNSET 2 -typedef uint64_t u64; - char *error_buf; static int opterror(const struct option *opt, const char *reason, int flags) -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 7/9] perf: Finalize subcmd independence
Em Wed, Dec 16, 2015 at 07:09:53PM -0600, Josh Poimboeuf escreveu: > On Wed, Dec 16, 2015 at 09:57:41PM -0300, Arnaldo Carvalho de Melo wrote: > > Em Tue, Dec 15, 2015 at 09:39:38AM -0600, Josh Poimboeuf escreveu: > > > For the files that will be moved to the subcmd library, remove all their > > > perf-specific includes and duplicate any needed functionality. > > > > Breaks rhel6.7 building: > > > > > > > > +typedef uint64_t u64; > > > + > > > > > > [acme@sandy linux]$ cat /etc/redhat-release > > Red Hat Enterprise Linux Server release 6.7 (Santiago) > > > > CC /tmp/build/perf/parse-options.o > > parse-options.c:15: error: redefinition of typedef ‘u64’ > > /home/acme/git/linux/tools/include/linux/types.h:28: note: previous > > declaration of ‘u64’ was here > > mv: cannot stat `/tmp/build/perf/.parse-options.o.tmp': No such file or > > directory > > make[3]: *** [/tmp/build/perf/parse-options.o] Error 1 > > make[2]: *** [/tmp/build/perf/libsubcmd-in.o] Error 2 > > make[1]: *** [/tmp/build/perf/libsubcmd.a] Error 2 > > make[1]: *** Waiting for unfinished jobs > > MKDIR/tmp/build/perf/util/ > > Does this fix it? Yes, and it continues to build on fedora 21. - Arnaldo > ---8<--- > > diff --git a/tools/lib/subcmd/parse-options.c > b/tools/lib/subcmd/parse-options.c > index f424027..981bb44 100644 > --- a/tools/lib/subcmd/parse-options.c > +++ b/tools/lib/subcmd/parse-options.c > @@ -1,4 +1,5 @@ > #include > +#include > #include > #include > #include > @@ -12,8 +13,6 @@ > #define OPT_SHORT 1 > #define OPT_UNSET 2 > > -typedef uint64_t u64; > - > char *error_buf; > > static int opterror(const struct option *opt, const char *reason, int flags) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 7/9] perf: Finalize subcmd independence
On Wed, Dec 16, 2015 at 09:57:41PM -0300, Arnaldo Carvalho de Melo wrote: > Em Tue, Dec 15, 2015 at 09:39:38AM -0600, Josh Poimboeuf escreveu: > > For the files that will be moved to the subcmd library, remove all their > > perf-specific includes and duplicate any needed functionality. > > Breaks rhel6.7 building: > > > #include "run-command.h" > > #include "sigchain.h" > > #include "subcmd-config.h" > > diff --git a/tools/perf/util/parse-options.c > > b/tools/perf/util/parse-options.c > > index c1da2a5..f424027 100644 > > --- a/tools/perf/util/parse-options.c > > +++ b/tools/perf/util/parse-options.c > > @@ -1,33 +1,47 @@ > > -#include "util.h" > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > #include "subcmd-util.h" > > #include "parse-options.h" > > -#include "cache.h" > > -#include "header.h" > > #include "subcmd-config.h" > > -#include > > +#include "pager.h" > > > > #define OPT_SHORT 1 > > #define OPT_UNSET 2 > > > > +typedef uint64_t u64; > > + > > > [acme@sandy linux]$ cat /etc/redhat-release > Red Hat Enterprise Linux Server release 6.7 (Santiago) > > CC /tmp/build/perf/parse-options.o > parse-options.c:15: error: redefinition of typedef ‘u64’ > /home/acme/git/linux/tools/include/linux/types.h:28: note: previous > declaration of ‘u64’ was here > mv: cannot stat `/tmp/build/perf/.parse-options.o.tmp': No such file or > directory > make[3]: *** [/tmp/build/perf/parse-options.o] Error 1 > make[2]: *** [/tmp/build/perf/libsubcmd-in.o] Error 2 > make[1]: *** [/tmp/build/perf/libsubcmd.a] Error 2 > make[1]: *** Waiting for unfinished jobs > MKDIR/tmp/build/perf/util/ Does this fix it? ---8<--- diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c index f424027..981bb44 100644 --- a/tools/lib/subcmd/parse-options.c +++ b/tools/lib/subcmd/parse-options.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -12,8 +13,6 @@ #define OPT_SHORT 1 #define OPT_UNSET 2 -typedef uint64_t u64; - char *error_buf; static int opterror(const struct option *opt, const char *reason, int flags) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 7/9] perf: Finalize subcmd independence
Em Tue, Dec 15, 2015 at 09:39:38AM -0600, Josh Poimboeuf escreveu: > For the files that will be moved to the subcmd library, remove all their > perf-specific includes and duplicate any needed functionality. Breaks rhel6.7 building: > #include "run-command.h" > #include "sigchain.h" > #include "subcmd-config.h" > diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c > index c1da2a5..f424027 100644 > --- a/tools/perf/util/parse-options.c > +++ b/tools/perf/util/parse-options.c > @@ -1,33 +1,47 @@ > -#include "util.h" > +#include > +#include > +#include > +#include > +#include > +#include > #include "subcmd-util.h" > #include "parse-options.h" > -#include "cache.h" > -#include "header.h" > #include "subcmd-config.h" > -#include > +#include "pager.h" > > #define OPT_SHORT 1 > #define OPT_UNSET 2 > > +typedef uint64_t u64; > + [acme@sandy linux]$ cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.7 (Santiago) CC /tmp/build/perf/parse-options.o parse-options.c:15: error: redefinition of typedef ‘u64’ /home/acme/git/linux/tools/include/linux/types.h:28: note: previous declaration of ‘u64’ was here mv: cannot stat `/tmp/build/perf/.parse-options.o.tmp': No such file or directory make[3]: *** [/tmp/build/perf/parse-options.o] Error 1 make[2]: *** [/tmp/build/perf/libsubcmd-in.o] Error 2 make[1]: *** [/tmp/build/perf/libsubcmd.a] Error 2 make[1]: *** Waiting for unfinished jobs MKDIR/tmp/build/perf/util/ > char *error_buf; > > static int opterror(const struct option *opt, const char *reason, int flags) > { > if (flags & OPT_SHORT) > - return error("switch `%c' %s", opt->short_name, reason); > - if (flags & OPT_UNSET) > - return error("option `no-%s' %s", opt->long_name, reason); > - return error("option `%s' %s", opt->long_name, reason); > + fprintf(stderr, " Error: switch `%c' %s", opt->short_name, > reason); > + else if (flags & OPT_UNSET) > + fprintf(stderr, " Error: option `no-%s' %s", opt->long_name, > reason); > + else > + fprintf(stderr, " Error: option `%s' %s", opt->long_name, > reason); > + > + return -1; > +} > + > +static const char *skip_prefix(const char *str, const char *prefix) > +{ > + size_t len = strlen(prefix); > + return strncmp(str, prefix, len) ? NULL : str + len; > } > > static void optwarning(const struct option *opt, const char *reason, int > flags) > { > if (flags & OPT_SHORT) > - warning("switch `%c' %s", opt->short_name, reason); > + fprintf(stderr, " Warning: switch `%c' %s", opt->short_name, > reason); > else if (flags & OPT_UNSET) > - warning("option `no-%s' %s", opt->long_name, reason); > + fprintf(stderr, " Warning: option `no-%s' %s", opt->long_name, > reason); > else > - warning("option `%s' %s", opt->long_name, reason); > + fprintf(stderr, " Warning: option `%s' %s", opt->long_name, > reason); > } > > static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt, > @@ -71,11 +85,11 @@ static int get_value(struct parse_opt_ctx_t *p, > > if (((flags & OPT_SHORT) && p->excl_opt->short_name) || > p->excl_opt->long_name == NULL) { > - scnprintf(msg, sizeof(msg), "cannot be used > with switch `%c'", > - p->excl_opt->short_name); > + snprintf(msg, sizeof(msg), "cannot be used with > switch `%c'", > + p->excl_opt->short_name); > } else { > - scnprintf(msg, sizeof(msg), "cannot be used > with %s", > - p->excl_opt->long_name); > + snprintf(msg, sizeof(msg), "cannot be used with > %s", > + p->excl_opt->long_name); > } > opterror(opt, msg, flags); > return -3; > @@ -401,14 +415,16 @@ match: > return get_value(p, options, flags); > } > > - if (ambiguous_option) > - return error("Ambiguous option: %s " > - "(could be --%s%s or --%s%s)", > - arg, > - (ambiguous_flags & OPT_UNSET) ? "no-" : "", > - ambiguous_option->long_name, > - (abbrev_flags & OPT_UNSET) ? "no-" : "", > - abbrev_option->long_name); > + if (ambiguous_option) { > + fprintf(stderr, > + " Error: Ambiguous option: %s (could be --%s%s or > --%s%s)", > + arg, > + (ambiguous_flags & OPT_UNSET) ? "no-" : "", > + ambiguous_option->long_name, > + (abbrev_flags &
Re: [PATCH v4 7/9] perf: Finalize subcmd independence
On Wed, Dec 16, 2015 at 10:27:11PM -0300, Arnaldo Carvalho de Melo wrote: > Em Wed, Dec 16, 2015 at 07:09:53PM -0600, Josh Poimboeuf escreveu: > > On Wed, Dec 16, 2015 at 09:57:41PM -0300, Arnaldo Carvalho de Melo wrote: > > > Em Tue, Dec 15, 2015 at 09:39:38AM -0600, Josh Poimboeuf escreveu: > > > > For the files that will be moved to the subcmd library, remove all their > > > > perf-specific includes and duplicate any needed functionality. > > > > > > Breaks rhel6.7 building: > > > > > > > > > > > +typedef uint64_t u64; > > > > + > > > > > > > > > [acme@sandy linux]$ cat /etc/redhat-release > > > Red Hat Enterprise Linux Server release 6.7 (Santiago) > > > > > > CC /tmp/build/perf/parse-options.o > > > parse-options.c:15: error: redefinition of typedef ‘u64’ > > > /home/acme/git/linux/tools/include/linux/types.h:28: note: previous > > > declaration of ‘u64’ was here > > > mv: cannot stat `/tmp/build/perf/.parse-options.o.tmp': No such file or > > > directory > > > make[3]: *** [/tmp/build/perf/parse-options.o] Error 1 > > > make[2]: *** [/tmp/build/perf/libsubcmd-in.o] Error 2 > > > make[1]: *** [/tmp/build/perf/libsubcmd.a] Error 2 > > > make[1]: *** Waiting for unfinished jobs > > > MKDIR/tmp/build/perf/util/ > > > > Does this fix it? > > Yes, and it continues to build on fedora 21. > > - Arnaldo > > > ---8<--- > > > > diff --git a/tools/lib/subcmd/parse-options.c > > b/tools/lib/subcmd/parse-options.c > > index f424027..981bb44 100644 > > --- a/tools/lib/subcmd/parse-options.c > > +++ b/tools/lib/subcmd/parse-options.c > > @@ -1,4 +1,5 @@ > > #include > > +#include > > #include > > #include > > #include > > @@ -12,8 +13,6 @@ > > #define OPT_SHORT 1 > > #define OPT_UNSET 2 > > > > -typedef uint64_t u64; > > - > > char *error_buf; > > > > static int opterror(const struct option *opt, const char *reason, int > > flags) Here's the same patch but without the unnecessary addition of the include. Ideally it would be folded into "perf tools: Finalize subcmd independence" but in case it's too late for that, I added a changelog. ---8<--- Subject: [PATCH] tools subcmd: Fix 'u64' build error with older compilers Arnaldo reported the following error when building perf on RHEL 6.7: parse-options.c:15: error: redefinition of typedef ‘u64’ /home/acme/git/linux/tools/include/linux/types.h:28: note: previous declaration of ‘u64’ was here The parse-options.c file includes , which includes , which has a u64 typedef. So the u64 typedef in parse-options.c is unnecessary (and seems to trigger the above error on compilers which don't allow duplicate typedefs). Reported-by: Arnaldo Carvalho de MeloSigned-off-by: Josh Poimboeuf --- tools/lib/subcmd/parse-options.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c index f424027..c0c911a 100644 --- a/tools/lib/subcmd/parse-options.c +++ b/tools/lib/subcmd/parse-options.c @@ -12,8 +12,6 @@ #define OPT_SHORT 1 #define OPT_UNSET 2 -typedef uint64_t u64; - char *error_buf; static int opterror(const struct option *opt, const char *reason, int flags) -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 7/9] perf: Finalize subcmd independence
Em Tue, Dec 15, 2015 at 09:39:38AM -0600, Josh Poimboeuf escreveu: > For the files that will be moved to the subcmd library, remove all their > perf-specific includes and duplicate any needed functionality. Breaks rhel6.7 building: > #include "run-command.h" > #include "sigchain.h" > #include "subcmd-config.h" > diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c > index c1da2a5..f424027 100644 > --- a/tools/perf/util/parse-options.c > +++ b/tools/perf/util/parse-options.c > @@ -1,33 +1,47 @@ > -#include "util.h" > +#include > +#include > +#include > +#include > +#include > +#include > #include "subcmd-util.h" > #include "parse-options.h" > -#include "cache.h" > -#include "header.h" > #include "subcmd-config.h" > -#include > +#include "pager.h" > > #define OPT_SHORT 1 > #define OPT_UNSET 2 > > +typedef uint64_t u64; > + [acme@sandy linux]$ cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.7 (Santiago) CC /tmp/build/perf/parse-options.o parse-options.c:15: error: redefinition of typedef ‘u64’ /home/acme/git/linux/tools/include/linux/types.h:28: note: previous declaration of ‘u64’ was here mv: cannot stat `/tmp/build/perf/.parse-options.o.tmp': No such file or directory make[3]: *** [/tmp/build/perf/parse-options.o] Error 1 make[2]: *** [/tmp/build/perf/libsubcmd-in.o] Error 2 make[1]: *** [/tmp/build/perf/libsubcmd.a] Error 2 make[1]: *** Waiting for unfinished jobs MKDIR/tmp/build/perf/util/ > char *error_buf; > > static int opterror(const struct option *opt, const char *reason, int flags) > { > if (flags & OPT_SHORT) > - return error("switch `%c' %s", opt->short_name, reason); > - if (flags & OPT_UNSET) > - return error("option `no-%s' %s", opt->long_name, reason); > - return error("option `%s' %s", opt->long_name, reason); > + fprintf(stderr, " Error: switch `%c' %s", opt->short_name, > reason); > + else if (flags & OPT_UNSET) > + fprintf(stderr, " Error: option `no-%s' %s", opt->long_name, > reason); > + else > + fprintf(stderr, " Error: option `%s' %s", opt->long_name, > reason); > + > + return -1; > +} > + > +static const char *skip_prefix(const char *str, const char *prefix) > +{ > + size_t len = strlen(prefix); > + return strncmp(str, prefix, len) ? NULL : str + len; > } > > static void optwarning(const struct option *opt, const char *reason, int > flags) > { > if (flags & OPT_SHORT) > - warning("switch `%c' %s", opt->short_name, reason); > + fprintf(stderr, " Warning: switch `%c' %s", opt->short_name, > reason); > else if (flags & OPT_UNSET) > - warning("option `no-%s' %s", opt->long_name, reason); > + fprintf(stderr, " Warning: option `no-%s' %s", opt->long_name, > reason); > else > - warning("option `%s' %s", opt->long_name, reason); > + fprintf(stderr, " Warning: option `%s' %s", opt->long_name, > reason); > } > > static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt, > @@ -71,11 +85,11 @@ static int get_value(struct parse_opt_ctx_t *p, > > if (((flags & OPT_SHORT) && p->excl_opt->short_name) || > p->excl_opt->long_name == NULL) { > - scnprintf(msg, sizeof(msg), "cannot be used > with switch `%c'", > - p->excl_opt->short_name); > + snprintf(msg, sizeof(msg), "cannot be used with > switch `%c'", > + p->excl_opt->short_name); > } else { > - scnprintf(msg, sizeof(msg), "cannot be used > with %s", > - p->excl_opt->long_name); > + snprintf(msg, sizeof(msg), "cannot be used with > %s", > + p->excl_opt->long_name); > } > opterror(opt, msg, flags); > return -3; > @@ -401,14 +415,16 @@ match: > return get_value(p, options, flags); > } > > - if (ambiguous_option) > - return error("Ambiguous option: %s " > - "(could be --%s%s or --%s%s)", > - arg, > - (ambiguous_flags & OPT_UNSET) ? "no-" : "", > - ambiguous_option->long_name, > - (abbrev_flags & OPT_UNSET) ? "no-" : "", > - abbrev_option->long_name); > + if (ambiguous_option) { > + fprintf(stderr, > + " Error: Ambiguous option: %s (could be --%s%s or > --%s%s)", > + arg, > + (ambiguous_flags & OPT_UNSET) ? "no-" : "", > + ambiguous_option->long_name, > + (abbrev_flags &
Re: [PATCH v4 7/9] perf: Finalize subcmd independence
Em Wed, Dec 16, 2015 at 07:09:53PM -0600, Josh Poimboeuf escreveu: > On Wed, Dec 16, 2015 at 09:57:41PM -0300, Arnaldo Carvalho de Melo wrote: > > Em Tue, Dec 15, 2015 at 09:39:38AM -0600, Josh Poimboeuf escreveu: > > > For the files that will be moved to the subcmd library, remove all their > > > perf-specific includes and duplicate any needed functionality. > > > > Breaks rhel6.7 building: > > > > > > > > +typedef uint64_t u64; > > > + > > > > > > [acme@sandy linux]$ cat /etc/redhat-release > > Red Hat Enterprise Linux Server release 6.7 (Santiago) > > > > CC /tmp/build/perf/parse-options.o > > parse-options.c:15: error: redefinition of typedef ‘u64’ > > /home/acme/git/linux/tools/include/linux/types.h:28: note: previous > > declaration of ‘u64’ was here > > mv: cannot stat `/tmp/build/perf/.parse-options.o.tmp': No such file or > > directory > > make[3]: *** [/tmp/build/perf/parse-options.o] Error 1 > > make[2]: *** [/tmp/build/perf/libsubcmd-in.o] Error 2 > > make[1]: *** [/tmp/build/perf/libsubcmd.a] Error 2 > > make[1]: *** Waiting for unfinished jobs > > MKDIR/tmp/build/perf/util/ > > Does this fix it? Yes, and it continues to build on fedora 21. - Arnaldo > ---8<--- > > diff --git a/tools/lib/subcmd/parse-options.c > b/tools/lib/subcmd/parse-options.c > index f424027..981bb44 100644 > --- a/tools/lib/subcmd/parse-options.c > +++ b/tools/lib/subcmd/parse-options.c > @@ -1,4 +1,5 @@ > #include > +#include > #include > #include > #include > @@ -12,8 +13,6 @@ > #define OPT_SHORT 1 > #define OPT_UNSET 2 > > -typedef uint64_t u64; > - > char *error_buf; > > static int opterror(const struct option *opt, const char *reason, int flags) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 7/9] perf: Finalize subcmd independence
On Wed, Dec 16, 2015 at 09:57:41PM -0300, Arnaldo Carvalho de Melo wrote: > Em Tue, Dec 15, 2015 at 09:39:38AM -0600, Josh Poimboeuf escreveu: > > For the files that will be moved to the subcmd library, remove all their > > perf-specific includes and duplicate any needed functionality. > > Breaks rhel6.7 building: > > > #include "run-command.h" > > #include "sigchain.h" > > #include "subcmd-config.h" > > diff --git a/tools/perf/util/parse-options.c > > b/tools/perf/util/parse-options.c > > index c1da2a5..f424027 100644 > > --- a/tools/perf/util/parse-options.c > > +++ b/tools/perf/util/parse-options.c > > @@ -1,33 +1,47 @@ > > -#include "util.h" > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > #include "subcmd-util.h" > > #include "parse-options.h" > > -#include "cache.h" > > -#include "header.h" > > #include "subcmd-config.h" > > -#include > > +#include "pager.h" > > > > #define OPT_SHORT 1 > > #define OPT_UNSET 2 > > > > +typedef uint64_t u64; > > + > > > [acme@sandy linux]$ cat /etc/redhat-release > Red Hat Enterprise Linux Server release 6.7 (Santiago) > > CC /tmp/build/perf/parse-options.o > parse-options.c:15: error: redefinition of typedef ‘u64’ > /home/acme/git/linux/tools/include/linux/types.h:28: note: previous > declaration of ‘u64’ was here > mv: cannot stat `/tmp/build/perf/.parse-options.o.tmp': No such file or > directory > make[3]: *** [/tmp/build/perf/parse-options.o] Error 1 > make[2]: *** [/tmp/build/perf/libsubcmd-in.o] Error 2 > make[1]: *** [/tmp/build/perf/libsubcmd.a] Error 2 > make[1]: *** Waiting for unfinished jobs > MKDIR/tmp/build/perf/util/ Does this fix it? ---8<--- diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c index f424027..981bb44 100644 --- a/tools/lib/subcmd/parse-options.c +++ b/tools/lib/subcmd/parse-options.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -12,8 +13,6 @@ #define OPT_SHORT 1 #define OPT_UNSET 2 -typedef uint64_t u64; - char *error_buf; static int opterror(const struct option *opt, const char *reason, int flags) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v4 7/9] perf: Finalize subcmd independence
For the files that will be moved to the subcmd library, remove all their perf-specific includes and duplicate any needed functionality. Signed-off-by: Josh Poimboeuf --- tools/perf/util/exec_cmd.c | 64 +++ tools/perf/util/help.c | 47 +++--- tools/perf/util/help.h | 4 ++- tools/perf/util/pager.c | 7 +++- tools/perf/util/parse-options.c | 74 + tools/perf/util/parse-options.h | 2 +- tools/perf/util/run-command.c | 16 ++--- tools/perf/util/run-command.h | 2 ++ tools/perf/util/sigchain.c | 3 +- tools/perf/util/subcmd-util.h | 67 + tools/perf/util/util.h | 14 11 files changed, 238 insertions(+), 62 deletions(-) diff --git a/tools/perf/util/exec_cmd.c b/tools/perf/util/exec_cmd.c index 70a..e7f9ed79 100644 --- a/tools/perf/util/exec_cmd.c +++ b/tools/perf/util/exec_cmd.c @@ -1,12 +1,17 @@ -#include "cache.h" -#include "exec_cmd.h" -#include "quote.h" -#include "subcmd-config.h" - +#include +#include +#include +#include +#include #include +#include +#include #include "subcmd-util.h" +#include "exec_cmd.h" +#include "subcmd-config.h" #define MAX_ARGS 32 +#define PATH_MAX 4096 static const char *argv_exec_path; static const char *argv0_path; @@ -20,6 +25,49 @@ void exec_cmd_init(const char *exec_name, const char *prefix, subcmd_config.exec_path_env = exec_path_env; } +#define is_dir_sep(c) ((c) == '/') + +static int is_absolute_path(const char *path) +{ + return path[0] == '/'; +} + +static const char *get_pwd_cwd(void) +{ + static char cwd[PATH_MAX + 1]; + char *pwd; + struct stat cwd_stat, pwd_stat; + if (getcwd(cwd, PATH_MAX) == NULL) + return NULL; + pwd = getenv("PWD"); + if (pwd && strcmp(pwd, cwd)) { + stat(cwd, _stat); + if (!stat(pwd, _stat) && + pwd_stat.st_dev == cwd_stat.st_dev && + pwd_stat.st_ino == cwd_stat.st_ino) { + strlcpy(cwd, pwd, PATH_MAX); + } + } + return cwd; +} + +static const char *make_nonrelative_path(const char *path) +{ + static char buf[PATH_MAX + 1]; + + if (is_absolute_path(path)) { + if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX) + die("Too long path: %.*s", 60, path); + } else { + const char *cwd = get_pwd_cwd(); + if (!cwd) + die("Cannot determine the current working directory"); + if (snprintf(buf, PATH_MAX, "%s/%s", cwd, path) >= PATH_MAX) + die("Too long path: %.*s", 60, path); + } + return buf; +} + char *system_path(const char *path) { char *buf = NULL; @@ -151,8 +199,10 @@ int execl_cmd(const char *cmd,...) break; } va_end(param); - if (MAX_ARGS <= argc) - return error("too many args to run %s", cmd); + if (MAX_ARGS <= argc) { + fprintf(stderr, " Error: too many args to run %s\n", cmd); + return -1; + } argv[argc] = NULL; return execv_cmd(argv); diff --git a/tools/perf/util/help.c b/tools/perf/util/help.c index 303a347..8169480 100644 --- a/tools/perf/util/help.c +++ b/tools/perf/util/help.c @@ -1,8 +1,15 @@ -#include "cache.h" -#include "../builtin.h" -#include "exec_cmd.h" -#include "help.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "subcmd-util.h" +#include "help.h" +#include "exec_cmd.h" void add_cmdname(struct cmdnames *cmds, const char *name, size_t len) { @@ -70,6 +77,28 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes) cmds->cnt = cj; } +static void get_term_dimensions(struct winsize *ws) +{ + char *s = getenv("LINES"); + + if (s != NULL) { + ws->ws_row = atoi(s); + s = getenv("COLUMNS"); + if (s != NULL) { + ws->ws_col = atoi(s); + if (ws->ws_row && ws->ws_col) + return; + } + } +#ifdef TIOCGWINSZ + if (ioctl(1, TIOCGWINSZ, ws) == 0 && + ws->ws_row && ws->ws_col) + return; +#endif + ws->ws_row = 25; + ws->ws_col = 80; +} + static void pretty_print_string_list(struct cmdnames *cmds, int longest) { int cols = 1, rows; @@ -113,6 +142,14 @@ static int is_executable(const char *name) return st.st_mode & S_IXUSR; } +static int has_extension(const char *filename, const char *ext) +{ + size_t len = strlen(filename); + size_t extlen = strlen(ext); + + return len > extlen && !memcmp(filename + len - extlen, ext, extlen); +} + static void
[PATCH v4 7/9] perf: Finalize subcmd independence
For the files that will be moved to the subcmd library, remove all their perf-specific includes and duplicate any needed functionality. Signed-off-by: Josh Poimboeuf--- tools/perf/util/exec_cmd.c | 64 +++ tools/perf/util/help.c | 47 +++--- tools/perf/util/help.h | 4 ++- tools/perf/util/pager.c | 7 +++- tools/perf/util/parse-options.c | 74 + tools/perf/util/parse-options.h | 2 +- tools/perf/util/run-command.c | 16 ++--- tools/perf/util/run-command.h | 2 ++ tools/perf/util/sigchain.c | 3 +- tools/perf/util/subcmd-util.h | 67 + tools/perf/util/util.h | 14 11 files changed, 238 insertions(+), 62 deletions(-) diff --git a/tools/perf/util/exec_cmd.c b/tools/perf/util/exec_cmd.c index 70a..e7f9ed79 100644 --- a/tools/perf/util/exec_cmd.c +++ b/tools/perf/util/exec_cmd.c @@ -1,12 +1,17 @@ -#include "cache.h" -#include "exec_cmd.h" -#include "quote.h" -#include "subcmd-config.h" - +#include +#include +#include +#include +#include #include +#include +#include #include "subcmd-util.h" +#include "exec_cmd.h" +#include "subcmd-config.h" #define MAX_ARGS 32 +#define PATH_MAX 4096 static const char *argv_exec_path; static const char *argv0_path; @@ -20,6 +25,49 @@ void exec_cmd_init(const char *exec_name, const char *prefix, subcmd_config.exec_path_env = exec_path_env; } +#define is_dir_sep(c) ((c) == '/') + +static int is_absolute_path(const char *path) +{ + return path[0] == '/'; +} + +static const char *get_pwd_cwd(void) +{ + static char cwd[PATH_MAX + 1]; + char *pwd; + struct stat cwd_stat, pwd_stat; + if (getcwd(cwd, PATH_MAX) == NULL) + return NULL; + pwd = getenv("PWD"); + if (pwd && strcmp(pwd, cwd)) { + stat(cwd, _stat); + if (!stat(pwd, _stat) && + pwd_stat.st_dev == cwd_stat.st_dev && + pwd_stat.st_ino == cwd_stat.st_ino) { + strlcpy(cwd, pwd, PATH_MAX); + } + } + return cwd; +} + +static const char *make_nonrelative_path(const char *path) +{ + static char buf[PATH_MAX + 1]; + + if (is_absolute_path(path)) { + if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX) + die("Too long path: %.*s", 60, path); + } else { + const char *cwd = get_pwd_cwd(); + if (!cwd) + die("Cannot determine the current working directory"); + if (snprintf(buf, PATH_MAX, "%s/%s", cwd, path) >= PATH_MAX) + die("Too long path: %.*s", 60, path); + } + return buf; +} + char *system_path(const char *path) { char *buf = NULL; @@ -151,8 +199,10 @@ int execl_cmd(const char *cmd,...) break; } va_end(param); - if (MAX_ARGS <= argc) - return error("too many args to run %s", cmd); + if (MAX_ARGS <= argc) { + fprintf(stderr, " Error: too many args to run %s\n", cmd); + return -1; + } argv[argc] = NULL; return execv_cmd(argv); diff --git a/tools/perf/util/help.c b/tools/perf/util/help.c index 303a347..8169480 100644 --- a/tools/perf/util/help.c +++ b/tools/perf/util/help.c @@ -1,8 +1,15 @@ -#include "cache.h" -#include "../builtin.h" -#include "exec_cmd.h" -#include "help.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "subcmd-util.h" +#include "help.h" +#include "exec_cmd.h" void add_cmdname(struct cmdnames *cmds, const char *name, size_t len) { @@ -70,6 +77,28 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes) cmds->cnt = cj; } +static void get_term_dimensions(struct winsize *ws) +{ + char *s = getenv("LINES"); + + if (s != NULL) { + ws->ws_row = atoi(s); + s = getenv("COLUMNS"); + if (s != NULL) { + ws->ws_col = atoi(s); + if (ws->ws_row && ws->ws_col) + return; + } + } +#ifdef TIOCGWINSZ + if (ioctl(1, TIOCGWINSZ, ws) == 0 && + ws->ws_row && ws->ws_col) + return; +#endif + ws->ws_row = 25; + ws->ws_col = 80; +} + static void pretty_print_string_list(struct cmdnames *cmds, int longest) { int cols = 1, rows; @@ -113,6 +142,14 @@ static int is_executable(const char *name) return st.st_mode & S_IXUSR; } +static int has_extension(const char *filename, const char *ext) +{ + size_t len = strlen(filename); + size_t extlen = strlen(ext); + + return len > extlen && !memcmp(filename + len - extlen, ext, extlen); +} + static