~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/util/expr.l

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/perf/util/expr.l (Version linux-6.12-rc7) and /tools/perf/util/expr.l (Version linux-5.13.19)


  1 %option prefix="expr_"                              1 %option prefix="expr_"
  2 %option reentrant                                   2 %option reentrant
  3 %option bison-bridge                                3 %option bison-bridge
  4                                                     4 
  5 %{                                                  5 %{
  6 #include <linux/compiler.h>                         6 #include <linux/compiler.h>
  7 #include "expr.h"                                   7 #include "expr.h"
  8 #include "expr-bison.h"                             8 #include "expr-bison.h"
  9 #include <math.h>                              << 
 10                                                     9 
 11 char *expr_get_text(yyscan_t yyscanner);           10 char *expr_get_text(yyscan_t yyscanner);
 12 YYSTYPE *expr_get_lval(yyscan_t yyscanner);        11 YYSTYPE *expr_get_lval(yyscan_t yyscanner);
 13                                                    12 
 14 static double __value(YYSTYPE *yylval, char *s     13 static double __value(YYSTYPE *yylval, char *str, int token)
 15 {                                                  14 {
 16         double num;                                15         double num;
 17                                                    16 
 18         errno = 0;                                 17         errno = 0;
 19         num = strtod(str, NULL);                   18         num = strtod(str, NULL);
 20         if (errno)                                 19         if (errno)
 21                 return EXPR_ERROR;                 20                 return EXPR_ERROR;
 22                                                    21 
 23         yylval->num = num;                         22         yylval->num = num;
 24         return token;                              23         return token;
 25 }                                                  24 }
 26                                                    25 
 27 static int value(yyscan_t scanner)                 26 static int value(yyscan_t scanner)
 28 {                                                  27 {
 29         YYSTYPE *yylval = expr_get_lval(scanne     28         YYSTYPE *yylval = expr_get_lval(scanner);
 30         char *text = expr_get_text(scanner);       29         char *text = expr_get_text(scanner);
 31                                                    30 
 32         return __value(yylval, text, NUMBER);      31         return __value(yylval, text, NUMBER);
 33 }                                                  32 }
 34                                                    33 
 35 /*                                                 34 /*
 36  * Allow @ instead of / to be able to specify      35  * Allow @ instead of / to be able to specify pmu/event/ without
 37  * conflicts with normal division.                 36  * conflicts with normal division.
 38  */                                                37  */
 39 static char *normalize(char *str, int runtime)     38 static char *normalize(char *str, int runtime)
 40 {                                                  39 {
 41         char *ret = str;                           40         char *ret = str;
 42         char *dst = str;                           41         char *dst = str;
 43                                                    42 
 44         while (*str) {                             43         while (*str) {
 45                 if (*str == '\\') {            !!  44                 if (*str == '@')
                                                   >>  45                         *dst++ = '/';
                                                   >>  46                 else if (*str == '\\')
 46                         *dst++ = *++str;           47                         *dst++ = *++str;
 47                         if (!*str)             !!  48                  else if (*str == '?') {
 48                                 break;         << 
 49                 }                              << 
 50                 else if (*str == '?') {        << 
 51                         char *paramval;            49                         char *paramval;
 52                         int i = 0;                 50                         int i = 0;
 53                         int size = asprintf(&p     51                         int size = asprintf(&paramval, "%d", runtime);
 54                                                    52 
 55                         if (size < 0)              53                         if (size < 0)
 56                                 *dst++ = '0';      54                                 *dst++ = '0';
 57                         else {                     55                         else {
 58                                 while (i < siz     56                                 while (i < size)
 59                                         *dst++     57                                         *dst++ = paramval[i++];
 60                                 free(paramval)     58                                 free(paramval);
 61                         }                          59                         }
 62                 }                                  60                 }
 63                 else                               61                 else
 64                         *dst++ = *str;             62                         *dst++ = *str;
 65                 str++;                             63                 str++;
 66         }                                          64         }
 67                                                    65 
 68         *dst = 0x0;                                66         *dst = 0x0;
 69         return ret;                                67         return ret;
 70 }                                                  68 }
 71                                                    69 
 72 static int str(yyscan_t scanner, int token, in     70 static int str(yyscan_t scanner, int token, int runtime)
 73 {                                                  71 {
 74         YYSTYPE *yylval = expr_get_lval(scanne     72         YYSTYPE *yylval = expr_get_lval(scanner);
 75         char *text = expr_get_text(scanner);       73         char *text = expr_get_text(scanner);
 76                                                    74 
 77         yylval->str = normalize(strdup(text),      75         yylval->str = normalize(strdup(text), runtime);
 78         if (!yylval->str)                          76         if (!yylval->str)
 79                 return EXPR_ERROR;                 77                 return EXPR_ERROR;
 80                                                    78 
 81         yylval->str = normalize(yylval->str, r     79         yylval->str = normalize(yylval->str, runtime);
 82         return token;                              80         return token;
 83 }                                                  81 }
 84                                                << 
 85 static int literal(yyscan_t scanner, const str << 
 86 {                                              << 
 87         YYSTYPE *yylval = expr_get_lval(scanne << 
 88                                                << 
 89         yylval->num = expr__get_literal(expr_g << 
 90         if (isnan(yylval->num)) {              << 
 91                 if (!sctx->is_test)            << 
 92                         return EXPR_ERROR;     << 
 93                 yylval->num = 1;               << 
 94         }                                      << 
 95         return LITERAL;                        << 
 96 }                                              << 
 97                                                << 
 98 static int nan_value(yyscan_t scanner)         << 
 99 {                                              << 
100         YYSTYPE *yylval = expr_get_lval(scanne << 
101                                                << 
102         yylval->num = NAN;                     << 
103         return NUMBER;                         << 
104 }                                              << 
105 %}                                                 82 %}
106                                                    83 
107 number          ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9 !!  84 number          ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)
108                                                    85 
109 sch             [-,=]                              86 sch             [-,=]
110 spec            \\{sch}                            87 spec            \\{sch}
111 sym             [0-9a-zA-Z_\.:@?]+                 88 sym             [0-9a-zA-Z_\.:@?]+
112 symbol          ({spec}|{sym})+                    89 symbol          ({spec}|{sym})+
113 literal         #[0-9a-zA-Z_\.\-]+             << 
114                                                    90 
115 %%                                                 91 %%
116         struct expr_scanner_ctx *sctx = expr_g     92         struct expr_scanner_ctx *sctx = expr_get_extra(yyscanner);
117                                                    93 
                                                   >>  94         {
                                                   >>  95                 int start_token = sctx->start_token;
                                                   >>  96 
                                                   >>  97                 if (sctx->start_token) {
                                                   >>  98                         sctx->start_token = 0;
                                                   >>  99                         return start_token;
                                                   >> 100                 }
                                                   >> 101         }
                                                   >> 102 
118 d_ratio         { return D_RATIO; }               103 d_ratio         { return D_RATIO; }
119 max             { return MAX; }                   104 max             { return MAX; }
120 min             { return MIN; }                   105 min             { return MIN; }
121 if              { return IF; }                    106 if              { return IF; }
122 else            { return ELSE; }                  107 else            { return ELSE; }
123 source_count    { return SOURCE_COUNT; }       !! 108 #smt_on         { return SMT_ON; }
124 has_event       { return HAS_EVENT; }          << 
125 strcmp_cpuid_str        { return STRCMP_CPUID_ << 
126 NaN             { return nan_value(yyscanner); << 
127 {literal}       { return literal(yyscanner, sc << 
128 {number}        { return value(yyscanner); }      109 {number}        { return value(yyscanner); }
129 {symbol}        { return str(yyscanner, ID, sc    110 {symbol}        { return str(yyscanner, ID, sctx->runtime); }
130 "|"             { return '|'; }                   111 "|"             { return '|'; }
131 "^"             { return '^'; }                   112 "^"             { return '^'; }
132 "&"             { return '&'; }                   113 "&"             { return '&'; }
133 "<"             { return '<'; }                   114 "<"             { return '<'; }
134 ">"             { return '>'; }                   115 ">"             { return '>'; }
135 "-"             { return '-'; }                   116 "-"             { return '-'; }
136 "+"             { return '+'; }                   117 "+"             { return '+'; }
137 "*"             { return '*'; }                   118 "*"             { return '*'; }
138 "/"             { return '/'; }                   119 "/"             { return '/'; }
139 "%"             { return '%'; }                   120 "%"             { return '%'; }
140 "("             { return '('; }                   121 "("             { return '('; }
141 ")"             { return ')'; }                   122 ")"             { return ')'; }
142 ","             { return ','; }                   123 ","             { return ','; }
143 .               { }                               124 .               { }
144 %%                                                125 %%
145                                                   126 
146 int expr_wrap(void *scanner __maybe_unused)       127 int expr_wrap(void *scanner __maybe_unused)
147 {                                                 128 {
148         return 1;                                 129         return 1;
149 }                                                 130 }
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php