From nobody Mon May 30 18:10:30 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 58DD71B47648; Mon, 30 May 2022 18:10:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LBk3V3kpZz3DPN; Mon, 30 May 2022 18:10:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653934231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mouCiAdFj5vXWvYezj32748bFbYozOlDkUgyZQyCe98=; b=XgR8Kr4qG9RvFEckYpjo+0TffJY5blydOCOnSlIWPeO0yZjEQMpg0L7jJr8Cc8AAChG7uA CBQo9Gnyby5A/Ae7pp2f+jN78Jjjhu4GQ23gPhyAFmoA6Oka5yJ/wKJutETTwtqImbQi8/ wAejVfvm1NwtwLZELIU9PSg/rH/AhbaSKX6etFz/Pho7Q/FF9j+DRYDK0lGIOos3Xfbal1 9gT1DTgCOCaggpLbBs+1sMHt8QUY2Wn9qMcI9tJHQY64RYOqV8Er6WM+tmJsEh49AMQR3q QWFNgIXav0x94Fjjogzm/4aRbw19A/vyggHUz+z03VeVzCP9JaerpWQcY/mRrw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5B95F1BED5; Mon, 30 May 2022 18:10:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24UIAUOS056845; Mon, 30 May 2022 18:10:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24UIAUIx056844; Mon, 30 May 2022 18:10:30 GMT (envelope-from git) Date: Mon, 30 May 2022 18:10:30 GMT Message-Id: <202205301810.24UIAUIx056844@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 51f329660f1c - main - Revert "libpmc: jevents: Partial style(9) pass" List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 51f329660f1c56f295fb13bb3a34fb0895f485a1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653934231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mouCiAdFj5vXWvYezj32748bFbYozOlDkUgyZQyCe98=; b=M1zpACsHnANloFWBbDaC+v+p2H61WOd4O3udNdYNqpvH9VfNjb1OubrPPYg3+gGQxspYYq IA2wSDQfNRM88dguFZ8XSNZtoQCDffZLwpbfx75lGPv/tqKKmL1URXo0TUVhilC8FkCqmE Nx6UuC60oGJCOTms0FwSV29NcQ+qCeDjt3lAGXpE3/MSnzeddVseOvzvA/7iuwFEHYp0CH EALZZYANRPuOhkuVJoWx/CpcCm1pMBS9nPsT3kJawXAVhpn7LYdh2dUttZbB3/IukCw37H eSHCyS5ncwT2hWrgVFszV2Em24PhNQWFz+VJD/5lO6KWRaKfx84m98NTBGu7+Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653934231; a=rsa-sha256; cv=none; b=DJo4Adm7+XqO/VpajybJe9kGNXHQTt/MkBf/4aisGg4K2FfkZwr+9+joQz7HR1RWHwKFJh bQOLSL2gj6DWpEi4IvRenYShoEqQN4KC3uGwm02GX/E8RZBH5Dpqn3CmMZSV/xzRdfDKbr RFxxjCT0oZXkyvcIKAY45qvNRw0rR+W3sM4e2c7TT2Y63SDvLyDIY5ziKVHeKd5T1CiaRm KTQxI7kM43a4ZDBDeuzbfMfT6K8GuBGUS4f3N74fH8y++iZ79HIx8ZDYx6PFO7fa6QxHiJ ghlKpYfOQ4/YhA1iXGsvlx0bl2Nd9HDexVmZa5cLCcf08Qt2yL7rcuxkpVzv+w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=51f329660f1c56f295fb13bb3a34fb0895f485a1 commit 51f329660f1c56f295fb13bb3a34fb0895f485a1 Author: Alexander Motin AuthorDate: 2022-05-30 14:07:31 +0000 Commit: Alexander Motin CommitDate: 2022-05-30 18:10:21 +0000 Revert "libpmc: jevents: Partial style(9) pass" This file is shared with Linux. Having local style patches does not help with updating it. This reverts commit 3ea691c2612952dc5e6963649ad64312bd6dff4f. --- lib/libpmc/pmu-events/jevents.c | 123 ++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 74 deletions(-) diff --git a/lib/libpmc/pmu-events/jevents.c b/lib/libpmc/pmu-events/jevents.c index cca088e8b924..b411329dd35a 100644 --- a/lib/libpmc/pmu-events/jevents.c +++ b/lib/libpmc/pmu-events/jevents.c @@ -35,22 +35,18 @@ #include /* getrlimit */ #include #include /* getrlimit */ - #include #include #include -#include -#include #include #include #include -#include #include #include #include #include #include - +#include #include "list.h" #include "jsmn.h" #include "json.h" @@ -60,11 +56,12 @@ static int nftw_ordered(const char *path, int (*fn)(const char *, const struct stat *, int, struct FTW *), int nfds, int ftwflags); +_Noreturn void _Exit(int); + int verbose; static char *prog; -int -eprintf(int level, int var, const char *fmt, ...) +int eprintf(int level, int var, const char *fmt, ...) { int ret; @@ -82,14 +79,13 @@ eprintf(int level, int var, const char *fmt, ...) return ret; } -__attribute__((weak)) char * -get_cpu_str(void) +__attribute__((weak)) char *get_cpu_str(void) { return NULL; } -static void -addfield(char *map, char **dst, const char *sep, const char *a, jsmntok_t *bt) +static void addfield(char *map, char **dst, const char *sep, + const char *a, jsmntok_t *bt) { unsigned int len = strlen(a) + 1 + strlen(sep); int olen = *dst ? strlen(*dst) : 0; @@ -112,15 +108,13 @@ addfield(char *map, char **dst, const char *sep, const char *a, jsmntok_t *bt) strncat(*dst, map + bt->start, blen); } -static void -fixname(char *s) +static void fixname(char *s) { for (; *s; s++) *s = tolower(*s); } -static void -fixdesc(char *s) +static void fixdesc(char *s) { char *e = s + strlen(s); @@ -133,8 +127,7 @@ fixdesc(char *s) } /* Add escapes for '\' so they are proper C strings. */ -static char * -fixregex(char *s) +static char *fixregex(char *s) { int len = 0; int esc_count = 0; @@ -198,8 +191,7 @@ static struct field { { NULL, NULL } }; -static void -cut_comma(char *map, jsmntok_t *newval) +static void cut_comma(char *map, jsmntok_t *newval) { int i; @@ -210,8 +202,8 @@ cut_comma(char *map, jsmntok_t *newval) } } -static int -match_field(char *map, jsmntok_t *field, int nz, char **event, jsmntok_t *val) +static int match_field(char *map, jsmntok_t *field, int nz, + char **event, jsmntok_t *val) { struct field *f; jsmntok_t newval = *val; @@ -225,8 +217,7 @@ match_field(char *map, jsmntok_t *field, int nz, char **event, jsmntok_t *val) return 0; } -static struct msrmap * -lookup_msr(char *map, jsmntok_t *val) +static struct msrmap *lookup_msr(char *map, jsmntok_t *val) { jsmntok_t newval = *val; static bool warned; @@ -260,8 +251,7 @@ static struct map { {} }; -static const char * -field_to_perf(struct map *table, char *map, jsmntok_t *val) +static const char *field_to_perf(struct map *table, char *map, jsmntok_t *val) { int i; @@ -285,8 +275,7 @@ field_to_perf(struct map *table, char *map, jsmntok_t *val) static char *topic; -static char * -get_topic(void) +static char *get_topic(void) { char *tp; int i; @@ -312,8 +301,7 @@ get_topic(void) return tp; } -static int -add_topic(const char *bname) +static int add_topic(const char *bname) { free(topic); topic = strdup(bname); @@ -332,17 +320,17 @@ struct perf_entry_data { static int close_table; -static void -print_events_table_prefix(FILE *fp, const char *tblname) +static void print_events_table_prefix(FILE *fp, const char *tblname) { fprintf(fp, "static struct pmu_event %s[] = {\n", tblname); close_table = 1; } -static int -print_events_table_entry(void *data, char *name, const char *event, char *desc, - char *long_desc, char *pmu, char *unit, char *perpkg, char *metric_expr, - char *metric_name, char *metric_group) +static int print_events_table_entry(void *data, char *name, const char *event, + char *desc, char *long_desc, + char *pmu, char *unit, char *perpkg, + char *metric_expr, + char *metric_name, char *metric_group) { struct perf_entry_data *pd = data; FILE *outfp = pd->outfp; @@ -422,8 +410,7 @@ struct event_struct { static LIST_HEAD(arch_std_events); -static void -free_arch_std_events(void) +static void free_arch_std_events(void) { struct event_struct *es, *next; @@ -434,10 +421,10 @@ free_arch_std_events(void) } } -static int -save_arch_std_events(void *data __unused, char *name, const char *event, - char *desc, char *long_desc, char *pmu, char *unit, char *perpkg, - char *metric_expr, char *metric_name, char *metric_group) +static int save_arch_std_events(void *data __unused, char *name, const char *event, + char *desc, char *long_desc, char *pmu, + char *unit, char *perpkg, char *metric_expr, + char *metric_name, char *metric_group) { struct event_struct *es; @@ -454,8 +441,7 @@ out_free: return -ENOMEM; } -static void -print_events_table_suffix(FILE *outfp) +static void print_events_table_suffix(FILE *outfp) { fprintf(outfp, "{\n"); @@ -483,8 +469,7 @@ static struct fixed { /* * Handle different fixed counter encodings between JSON and perf. */ -static const char * -real_event(const char *name, char *event) +static const char *real_event(const char *name, char *event) { int i; @@ -499,9 +484,9 @@ real_event(const char *name, char *event) static int try_fixup(const char *fn, char *arch_std, char **event, char **desc, - char **name, char **long_desc, char **pmu, char **filter __unused, - char **perpkg, char **unit, char **metric_expr, char **metric_name, - char **metric_group, unsigned long long eventcode) + char **name, char **long_desc, char **pmu, char **filter __unused, + char **perpkg, char **unit, char **metric_expr, char **metric_name, + char **metric_group, unsigned long long eventcode) { /* try to find matching event from arch standard values */ struct event_struct *es; @@ -524,8 +509,7 @@ try_fixup(const char *fn, char *arch_std, char **event, char **desc, } /* Call func with each event in the json file */ -int -json_events(const char *fn, +int json_events(const char *fn, int (*func)(void *data, char *name, const char *event, char *desc, char *long_desc, char *pmu, char *unit, char *perpkg, @@ -713,8 +697,7 @@ out_free: return err; } -static char * -file_name_to_table_name(const char *fname) +static char *file_name_to_table_name(const char *fname) { unsigned int i; int n; @@ -756,14 +739,12 @@ file_name_to_table_name(const char *fname) return tblname; } -static void -print_mapping_table_prefix(FILE *outfp) +static void print_mapping_table_prefix(FILE *outfp) { fprintf(outfp, "struct pmu_events_map pmu_events_map[] = {\n"); } -static void -print_mapping_table_suffix(FILE *outfp) +static void print_mapping_table_suffix(FILE *outfp) { /* * Print the terminating, NULL entry. @@ -779,8 +760,7 @@ print_mapping_table_suffix(FILE *outfp) fprintf(outfp, "};\n"); } -static int -process_mapfile(FILE *outfp, char *fpath) +static int process_mapfile(FILE *outfp, char *fpath) { int n = 16384; FILE *mapfp; @@ -868,8 +848,7 @@ out: * table. This would at least allow perf to build even if we can't find/use * the aliases. */ -static void -create_empty_mapping(const char *output_file) +static void create_empty_mapping(const char *output_file) { FILE *outfp; @@ -888,8 +867,7 @@ create_empty_mapping(const char *output_file) fclose(outfp); } -static int -get_maxfds(void) +static int get_maxfds(void) { struct rlimit rlim; @@ -909,8 +887,7 @@ get_maxfds(void) static FILE *eventsfp; static char *mapfile; -static int -is_leaf_dir(const char *fpath) +static int is_leaf_dir(const char *fpath) { DIR *d; struct dirent *dir; @@ -948,8 +925,7 @@ is_leaf_dir(const char *fpath) return res; } -static int -is_json_file(const char *name) +static int is_json_file(const char *name) { const char *suffix; @@ -963,9 +939,8 @@ is_json_file(const char *name) return 0; } -static int -preprocess_arch_std_files(const char *fpath, const struct stat *sb, - int typeflag, struct FTW *ftwbuf) +static int preprocess_arch_std_files(const char *fpath, const struct stat *sb, + int typeflag, struct FTW *ftwbuf) { int level = ftwbuf->level; int is_file = typeflag == FTW_F; @@ -976,9 +951,8 @@ preprocess_arch_std_files(const char *fpath, const struct stat *sb, return 0; } -static int -process_one_file(const char *fpath, const struct stat *sb, int typeflag, - struct FTW *ftwbuf) +static int process_one_file(const char *fpath, const struct stat *sb, + int typeflag, struct FTW *ftwbuf) { char *tblname; const char *bname; @@ -1103,8 +1077,7 @@ process_one_file(const char *fpath, const struct stat *sb, int typeflag, * * Write out the PMU events tables and the mapping table to pmu-event.c. */ -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int rc; int maxfds; @@ -1206,6 +1179,8 @@ empty_map: return 0; } +#include + static int fts_compare(const FTSENT * const *a, const FTSENT * const *b) {