diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-03-15 15:09:17 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-03-16 13:29:35 -0400 |
commit | cd82a32e9924d3a82bd27f830755d23e4ded25bc (patch) | |
tree | 63ff4fe274d372c22de3937bb867cfe37c7737d6 | |
parent | 8f707d843c2f4023490a873dbc182f632a3a5906 (diff) |
perf tools: Add perf pmu object to access pmu format definition
Adding pmu object which provides interface to pmu's sysfs
event format definition located at:
${sysfs_mount}/bus/event_source/devices/${pmu}/format
Following interface is exported:
struct perf_pmu* perf_pmu__find(char *name);
- this function returns pmu object, which is then
passed as a handle to other interface functions
int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
struct list_head *head_terms);
- this function configures perf_event_attr struct based
on pmu's format definitions and config terms data,
containined in head_terms list.
Parser generator is used to retrive the pmu's format definition.
The generated parser is part of the patch. Added makefile rule
'pmu-parser' to generate the parser code out of the bison/flex
sources.
Added builtin test 'Test perf pmu format parsing', which could
be run like:
perf test pmu
Acked-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/n/tip-errz96u1668gj9wlop1zhpht@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/Makefile | 12 | ||||
-rw-r--r-- | tools/perf/builtin-test.c | 10 | ||||
-rw-r--r-- | tools/perf/util/pmu-bison.c | 1663 | ||||
-rw-r--r-- | tools/perf/util/pmu-bison.h | 73 | ||||
-rw-r--r-- | tools/perf/util/pmu-flex.c | 1821 | ||||
-rw-r--r-- | tools/perf/util/pmu-flex.h | 316 | ||||
-rw-r--r-- | tools/perf/util/pmu.c | 469 | ||||
-rw-r--r-- | tools/perf/util/pmu.h | 41 | ||||
-rw-r--r-- | tools/perf/util/pmu.l | 43 | ||||
-rw-r--r-- | tools/perf/util/pmu.y | 93 |
10 files changed, 4541 insertions, 0 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index dfc80289d7ff..e07fbd838749 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -276,6 +276,7 @@ LIB_H += util/build-id.h | |||
276 | LIB_H += util/debug.h | 276 | LIB_H += util/debug.h |
277 | LIB_H += util/debugfs.h | 277 | LIB_H += util/debugfs.h |
278 | LIB_H += util/sysfs.h | 278 | LIB_H += util/sysfs.h |
279 | LIB_H += util/pmu.h | ||
279 | LIB_H += util/event.h | 280 | LIB_H += util/event.h |
280 | LIB_H += util/evsel.h | 281 | LIB_H += util/evsel.h |
281 | LIB_H += util/evlist.h | 282 | LIB_H += util/evlist.h |
@@ -323,6 +324,7 @@ LIB_OBJS += $(OUTPUT)util/config.o | |||
323 | LIB_OBJS += $(OUTPUT)util/ctype.o | 324 | LIB_OBJS += $(OUTPUT)util/ctype.o |
324 | LIB_OBJS += $(OUTPUT)util/debugfs.o | 325 | LIB_OBJS += $(OUTPUT)util/debugfs.o |
325 | LIB_OBJS += $(OUTPUT)util/sysfs.o | 326 | LIB_OBJS += $(OUTPUT)util/sysfs.o |
327 | LIB_OBJS += $(OUTPUT)util/pmu.o | ||
326 | LIB_OBJS += $(OUTPUT)util/environment.o | 328 | LIB_OBJS += $(OUTPUT)util/environment.o |
327 | LIB_OBJS += $(OUTPUT)util/event.o | 329 | LIB_OBJS += $(OUTPUT)util/event.o |
328 | LIB_OBJS += $(OUTPUT)util/evlist.o | 330 | LIB_OBJS += $(OUTPUT)util/evlist.o |
@@ -361,6 +363,8 @@ LIB_OBJS += $(OUTPUT)util/thread_map.o | |||
361 | LIB_OBJS += $(OUTPUT)util/trace-event-parse.o | 363 | LIB_OBJS += $(OUTPUT)util/trace-event-parse.o |
362 | LIB_OBJS += $(OUTPUT)util/parse-events-flex.o | 364 | LIB_OBJS += $(OUTPUT)util/parse-events-flex.o |
363 | LIB_OBJS += $(OUTPUT)util/parse-events-bison.o | 365 | LIB_OBJS += $(OUTPUT)util/parse-events-bison.o |
366 | LIB_OBJS += $(OUTPUT)util/pmu-flex.o | ||
367 | LIB_OBJS += $(OUTPUT)util/pmu-bison.o | ||
364 | LIB_OBJS += $(OUTPUT)util/trace-event-read.o | 368 | LIB_OBJS += $(OUTPUT)util/trace-event-read.o |
365 | LIB_OBJS += $(OUTPUT)util/trace-event-info.o | 369 | LIB_OBJS += $(OUTPUT)util/trace-event-info.o |
366 | LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o | 370 | LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o |
@@ -773,6 +777,9 @@ $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS | |||
773 | $(OUTPUT)util/parse-events-flex.o: util/parse-events-flex.c $(OUTPUT)PERF-CFLAGS | 777 | $(OUTPUT)util/parse-events-flex.o: util/parse-events-flex.c $(OUTPUT)PERF-CFLAGS |
774 | $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $< | 778 | $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $< |
775 | 779 | ||
780 | $(OUTPUT)util/pmu-flex.o: util/pmu-flex.c $(OUTPUT)PERF-CFLAGS | ||
781 | $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -Wno-redundant-decls -Wno-switch-default -Wno-unused-function $< | ||
782 | |||
776 | $(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS | 783 | $(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS |
777 | $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $< | 784 | $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $< |
778 | 785 | ||
@@ -810,6 +817,7 @@ help: | |||
810 | @echo ' info - make GNU info documentation (access with info <foo>)' | 817 | @echo ' info - make GNU info documentation (access with info <foo>)' |
811 | @echo ' pdf - make pdf documentation' | 818 | @echo ' pdf - make pdf documentation' |
812 | @echo ' event-parser - make event parser code' | 819 | @echo ' event-parser - make event parser code' |
820 | @echo ' pmu-parser - make pmu format parser code' | ||
813 | @echo ' TAGS - use etags to make tag information for source browsing' | 821 | @echo ' TAGS - use etags to make tag information for source browsing' |
814 | @echo ' tags - use ctags to make tag information for source browsing' | 822 | @echo ' tags - use ctags to make tag information for source browsing' |
815 | @echo ' cscope - use cscope to make interactive browsing database' | 823 | @echo ' cscope - use cscope to make interactive browsing database' |
@@ -863,6 +871,10 @@ event-parser: | |||
863 | $(QUIET_BISON)$(BISON) -v util/parse-events.y -d -o util/parse-events-bison.c | 871 | $(QUIET_BISON)$(BISON) -v util/parse-events.y -d -o util/parse-events-bison.c |
864 | $(QUIET_FLEX)$(FLEX) --header-file=util/parse-events-flex.h -t util/parse-events.l > util/parse-events-flex.c | 872 | $(QUIET_FLEX)$(FLEX) --header-file=util/parse-events-flex.h -t util/parse-events.l > util/parse-events-flex.c |
865 | 873 | ||
874 | pmu-parser: | ||
875 | $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o util/pmu-bison.c | ||
876 | $(QUIET_FLEX)$(FLEX) --header-file=util/pmu-flex.h -t util/pmu.l > util/pmu-flex.c | ||
877 | |||
866 | ### Detect prefix changes | 878 | ### Detect prefix changes |
867 | TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\ | 879 | TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\ |
868 | $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ) | 880 | $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ) |
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index 8b5359506505..58bfe8bde5ee 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include "util/parse-events.h" | 13 | #include "util/parse-events.h" |
14 | #include "util/symbol.h" | 14 | #include "util/symbol.h" |
15 | #include "util/thread_map.h" | 15 | #include "util/thread_map.h" |
16 | #include "util/pmu.h" | ||
16 | #include "../../include/linux/hw_breakpoint.h" | 17 | #include "../../include/linux/hw_breakpoint.h" |
17 | 18 | ||
18 | #include <sys/mman.h> | 19 | #include <sys/mman.h> |
@@ -1484,6 +1485,11 @@ static int test__rdpmc(void) | |||
1484 | 1485 | ||
1485 | #endif | 1486 | #endif |
1486 | 1487 | ||
1488 | static int test__perf_pmu(void) | ||
1489 | { | ||
1490 | return perf_pmu__test(); | ||
1491 | } | ||
1492 | |||
1487 | static struct test { | 1493 | static struct test { |
1488 | const char *desc; | 1494 | const char *desc; |
1489 | int (*func)(void); | 1495 | int (*func)(void); |
@@ -1519,6 +1525,10 @@ static struct test { | |||
1519 | .func = test__PERF_RECORD, | 1525 | .func = test__PERF_RECORD, |
1520 | }, | 1526 | }, |
1521 | { | 1527 | { |
1528 | .desc = "Test perf pmu format parsing", | ||
1529 | .func = test__perf_pmu, | ||
1530 | }, | ||
1531 | { | ||
1522 | .func = NULL, | 1532 | .func = NULL, |
1523 | }, | 1533 | }, |
1524 | }; | 1534 | }; |
diff --git a/tools/perf/util/pmu-bison.c b/tools/perf/util/pmu-bison.c new file mode 100644 index 000000000000..343521ec589f --- /dev/null +++ b/tools/perf/util/pmu-bison.c | |||
@@ -0,0 +1,1663 @@ | |||
1 | /* A Bison parser, made by GNU Bison 2.4.3. */ | ||
2 | |||
3 | /* Skeleton implementation for Bison's Yacc-like parsers in C | ||
4 | |||
5 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, | ||
6 | 2009, 2010 Free Software Foundation, Inc. | ||
7 | |||
8 | This program is free software: you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation, either version 3 of the License, or | ||
11 | (at your option) any later version. | ||
12 | |||
13 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
20 | |||
21 | /* As a special exception, you may create a larger work that contains | ||
22 | part or all of the Bison parser skeleton and distribute that work | ||
23 | under terms of your choice, so long as that work isn't itself a | ||
24 | parser generator using the skeleton or a modified version thereof | ||
25 | as a parser skeleton. Alternatively, if you modify or redistribute | ||
26 | the parser skeleton itself, you may (at your option) remove this | ||
27 | special exception, which will cause the skeleton and the resulting | ||
28 | Bison output files to be licensed under the GNU General Public | ||
29 | License without this special exception. | ||
30 | |||
31 | This special exception was added by the Free Software Foundation in | ||
32 | version 2.2 of Bison. */ | ||
33 | |||
34 | /* C LALR(1) parser skeleton written by Richard Stallman, by | ||
35 | simplifying the original so-called "semantic" parser. */ | ||
36 | |||
37 | /* All symbols defined below should begin with yy or YY, to avoid | ||
38 | infringing on user name space. This should be done even for local | ||
39 | variables, as they might otherwise be expanded by user macros. | ||
40 | There are some unavoidable exceptions within include files to | ||
41 | define necessary library symbols; they are noted "INFRINGES ON | ||
42 | USER NAME SPACE" below. */ | ||
43 | |||
44 | /* Identify Bison output. */ | ||
45 | #define YYBISON 1 | ||
46 | |||
47 | /* Bison version. */ | ||
48 | #define YYBISON_VERSION "2.4.3" | ||
49 | |||
50 | /* Skeleton name. */ | ||
51 | #define YYSKELETON_NAME "yacc.c" | ||
52 | |||
53 | /* Pure parsers. */ | ||
54 | #define YYPURE 0 | ||
55 | |||
56 | /* Push parsers. */ | ||
57 | #define YYPUSH 0 | ||
58 | |||
59 | /* Pull parsers. */ | ||
60 | #define YYPULL 1 | ||
61 | |||
62 | /* Using locations. */ | ||
63 | #define YYLSP_NEEDED 0 | ||
64 | |||
65 | /* Substitute the variable and function names. */ | ||
66 | #define yyparse perf_pmu_parse | ||
67 | #define yylex perf_pmu_lex | ||
68 | #define yyerror perf_pmu_error | ||
69 | #define yylval perf_pmu_lval | ||
70 | #define yychar perf_pmu_char | ||
71 | #define yydebug perf_pmu_debug | ||
72 | #define yynerrs perf_pmu_nerrs | ||
73 | |||
74 | |||
75 | /* Copy the first part of user declarations. */ | ||
76 | |||
77 | /* Line 189 of yacc.c */ | ||
78 | #line 6 "util/pmu.y" | ||
79 | |||
80 | |||
81 | #include <linux/compiler.h> | ||
82 | #include <linux/list.h> | ||
83 | #include <linux/bitmap.h> | ||
84 | #include <string.h> | ||
85 | #include "pmu.h" | ||
86 | |||
87 | extern int perf_pmu_lex (void); | ||
88 | |||
89 | #define ABORT_ON(val) \ | ||
90 | do { \ | ||
91 | if (val) \ | ||
92 | YYABORT; \ | ||
93 | } while (0) | ||
94 | |||
95 | |||
96 | |||
97 | /* Line 189 of yacc.c */ | ||
98 | #line 99 "util/pmu-bison.c" | ||
99 | |||
100 | /* Enabling traces. */ | ||
101 | #ifndef YYDEBUG | ||
102 | # define YYDEBUG 0 | ||
103 | #endif | ||
104 | |||
105 | /* Enabling verbose error messages. */ | ||
106 | #ifdef YYERROR_VERBOSE | ||
107 | # undef YYERROR_VERBOSE | ||
108 | # define YYERROR_VERBOSE 1 | ||
109 | #else | ||
110 | # define YYERROR_VERBOSE 0 | ||
111 | #endif | ||
112 | |||
113 | /* Enabling the token table. */ | ||
114 | #ifndef YYTOKEN_TABLE | ||
115 | # define YYTOKEN_TABLE 0 | ||
116 | #endif | ||
117 | |||
118 | |||
119 | /* Tokens. */ | ||
120 | #ifndef YYTOKENTYPE | ||
121 | # define YYTOKENTYPE | ||
122 | /* Put the tokens into the symbol table, so that GDB and other debuggers | ||
123 | know about them. */ | ||
124 | enum yytokentype { | ||
125 | PP_CONFIG = 258, | ||
126 | PP_CONFIG1 = 259, | ||
127 | PP_CONFIG2 = 260, | ||
128 | PP_VALUE = 261, | ||
129 | PP_ERROR = 262 | ||
130 | }; | ||
131 | #endif | ||
132 | |||
133 | |||
134 | |||
135 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED | ||
136 | typedef union YYSTYPE | ||
137 | { | ||
138 | |||
139 | /* Line 214 of yacc.c */ | ||
140 | #line 31 "util/pmu.y" | ||
141 | |||
142 | unsigned long num; | ||
143 | DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS); | ||
144 | |||
145 | |||
146 | |||
147 | /* Line 214 of yacc.c */ | ||
148 | #line 149 "util/pmu-bison.c" | ||
149 | } YYSTYPE; | ||
150 | # define YYSTYPE_IS_TRIVIAL 1 | ||
151 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ | ||
152 | # define YYSTYPE_IS_DECLARED 1 | ||
153 | #endif | ||
154 | |||
155 | |||
156 | /* Copy the second part of user declarations. */ | ||
157 | |||
158 | |||
159 | /* Line 264 of yacc.c */ | ||
160 | #line 161 "util/pmu-bison.c" | ||
161 | |||
162 | #ifdef short | ||
163 | # undef short | ||
164 | #endif | ||
165 | |||
166 | #ifdef YYTYPE_UINT8 | ||
167 | typedef YYTYPE_UINT8 yytype_uint8; | ||
168 | #else | ||
169 | typedef unsigned char yytype_uint8; | ||
170 | #endif | ||
171 | |||
172 | #ifdef YYTYPE_INT8 | ||
173 | typedef YYTYPE_INT8 yytype_int8; | ||
174 | #elif (defined __STDC__ || defined __C99__FUNC__ \ | ||
175 | || defined __cplusplus || defined _MSC_VER) | ||
176 | typedef signed char yytype_int8; | ||
177 | #else | ||
178 | typedef short int yytype_int8; | ||
179 | #endif | ||
180 | |||
181 | #ifdef YYTYPE_UINT16 | ||
182 | typedef YYTYPE_UINT16 yytype_uint16; | ||
183 | #else | ||
184 | typedef unsigned short int yytype_uint16; | ||
185 | #endif | ||
186 | |||
187 | #ifdef YYTYPE_INT16 | ||
188 | typedef YYTYPE_INT16 yytype_int16; | ||
189 | #else | ||
190 | typedef short int yytype_int16; | ||
191 | #endif | ||
192 | |||
193 | #ifndef YYSIZE_T | ||
194 | # ifdef __SIZE_TYPE__ | ||
195 | # define YYSIZE_T __SIZE_TYPE__ | ||
196 | # elif defined size_t | ||
197 | # define YYSIZE_T size_t | ||
198 | # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ | ||
199 | || defined __cplusplus || defined _MSC_VER) | ||
200 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ | ||
201 | # define YYSIZE_T size_t | ||
202 | # else | ||
203 | # define YYSIZE_T unsigned int | ||
204 | # endif | ||
205 | #endif | ||
206 | |||
207 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) | ||
208 | |||
209 | #ifndef YY_ | ||
210 | # if defined YYENABLE_NLS && YYENABLE_NLS | ||
211 | # if ENABLE_NLS | ||
212 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ | ||
213 | # define YY_(msgid) dgettext ("bison-runtime", msgid) | ||
214 | # endif | ||
215 | # endif | ||
216 | # ifndef YY_ | ||
217 | # define YY_(msgid) msgid | ||
218 | # endif | ||
219 | #endif | ||
220 | |||
221 | /* Suppress unused-variable warnings by "using" E. */ | ||
222 | #if ! defined lint || defined __GNUC__ | ||
223 | # define YYUSE(e) ((void) (e)) | ||
224 | #else | ||
225 | # define YYUSE(e) /* empty */ | ||
226 | #endif | ||
227 | |||
228 | /* Identity function, used to suppress warnings about constant conditions. */ | ||
229 | #ifndef lint | ||
230 | # define YYID(n) (n) | ||
231 | #else | ||
232 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
233 | || defined __cplusplus || defined _MSC_VER) | ||
234 | static int | ||
235 | YYID (int yyi) | ||
236 | #else | ||
237 | static int | ||
238 | YYID (yyi) | ||
239 | int yyi; | ||
240 | #endif | ||
241 | { | ||
242 | return yyi; | ||
243 | } | ||
244 | #endif | ||
245 | |||
246 | #if ! defined yyoverflow || YYERROR_VERBOSE | ||
247 | |||
248 | /* The parser invokes alloca or malloc; define the necessary symbols. */ | ||
249 | |||
250 | # ifdef YYSTACK_USE_ALLOCA | ||
251 | # if YYSTACK_USE_ALLOCA | ||
252 | # ifdef __GNUC__ | ||
253 | # define YYSTACK_ALLOC __builtin_alloca | ||
254 | # elif defined __BUILTIN_VA_ARG_INCR | ||
255 | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ | ||
256 | # elif defined _AIX | ||
257 | # define YYSTACK_ALLOC __alloca | ||
258 | # elif defined _MSC_VER | ||
259 | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ | ||
260 | # define alloca _alloca | ||
261 | # else | ||
262 | # define YYSTACK_ALLOC alloca | ||
263 | # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ | ||
264 | || defined __cplusplus || defined _MSC_VER) | ||
265 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | ||
266 | # ifndef _STDLIB_H | ||
267 | # define _STDLIB_H 1 | ||
268 | # endif | ||
269 | # endif | ||
270 | # endif | ||
271 | # endif | ||
272 | # endif | ||
273 | |||
274 | # ifdef YYSTACK_ALLOC | ||
275 | /* Pacify GCC's `empty if-body' warning. */ | ||
276 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) | ||
277 | # ifndef YYSTACK_ALLOC_MAXIMUM | ||
278 | /* The OS might guarantee only one guard page at the bottom of the stack, | ||
279 | and a page size can be as small as 4096 bytes. So we cannot safely | ||
280 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number | ||
281 | to allow for a few compiler-allocated temporary stack slots. */ | ||
282 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ | ||
283 | # endif | ||
284 | # else | ||
285 | # define YYSTACK_ALLOC YYMALLOC | ||
286 | # define YYSTACK_FREE YYFREE | ||
287 | # ifndef YYSTACK_ALLOC_MAXIMUM | ||
288 | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM | ||
289 | # endif | ||
290 | # if (defined __cplusplus && ! defined _STDLIB_H \ | ||
291 | && ! ((defined YYMALLOC || defined malloc) \ | ||
292 | && (defined YYFREE || defined free))) | ||
293 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | ||
294 | # ifndef _STDLIB_H | ||
295 | # define _STDLIB_H 1 | ||
296 | # endif | ||
297 | # endif | ||
298 | # ifndef YYMALLOC | ||
299 | # define YYMALLOC malloc | ||
300 | # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ | ||
301 | || defined __cplusplus || defined _MSC_VER) | ||
302 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ | ||
303 | # endif | ||
304 | # endif | ||
305 | # ifndef YYFREE | ||
306 | # define YYFREE free | ||
307 | # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ | ||
308 | || defined __cplusplus || defined _MSC_VER) | ||
309 | void free (void *); /* INFRINGES ON USER NAME SPACE */ | ||
310 | # endif | ||
311 | # endif | ||
312 | # endif | ||
313 | #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ | ||
314 | |||
315 | |||
316 | #if (! defined yyoverflow \ | ||
317 | && (! defined __cplusplus \ | ||
318 | || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) | ||
319 | |||
320 | /* A type that is properly aligned for any stack member. */ | ||
321 | union yyalloc | ||
322 | { | ||
323 | yytype_int16 yyss_alloc; | ||
324 | YYSTYPE yyvs_alloc; | ||
325 | }; | ||
326 | |||
327 | /* The size of the maximum gap between one aligned stack and the next. */ | ||
328 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) | ||
329 | |||
330 | /* The size of an array large to enough to hold all stacks, each with | ||
331 | N elements. */ | ||
332 | # define YYSTACK_BYTES(N) \ | ||
333 | ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ | ||
334 | + YYSTACK_GAP_MAXIMUM) | ||
335 | |||
336 | /* Copy COUNT objects from FROM to TO. The source and destination do | ||
337 | not overlap. */ | ||
338 | # ifndef YYCOPY | ||
339 | # if defined __GNUC__ && 1 < __GNUC__ | ||
340 | # define YYCOPY(To, From, Count) \ | ||
341 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) | ||
342 | # else | ||
343 | # define YYCOPY(To, From, Count) \ | ||
344 | do \ | ||
345 | { \ | ||
346 | YYSIZE_T yyi; \ | ||
347 | for (yyi = 0; yyi < (Count); yyi++) \ | ||
348 | (To)[yyi] = (From)[yyi]; \ | ||
349 | } \ | ||
350 | while (YYID (0)) | ||
351 | # endif | ||
352 | # endif | ||
353 | |||
354 | /* Relocate STACK from its old location to the new one. The | ||
355 | local variables YYSIZE and YYSTACKSIZE give the old and new number of | ||
356 | elements in the stack, and YYPTR gives the new location of the | ||
357 | stack. Advance YYPTR to a properly aligned location for the next | ||
358 | stack. */ | ||
359 | # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ | ||
360 | do \ | ||
361 | { \ | ||
362 | YYSIZE_T yynewbytes; \ | ||
363 | YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ | ||
364 | Stack = &yyptr->Stack_alloc; \ | ||
365 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ | ||
366 | yyptr += yynewbytes / sizeof (*yyptr); \ | ||
367 | } \ | ||
368 | while (YYID (0)) | ||
369 | |||
370 | #endif | ||
371 | |||
372 | /* YYFINAL -- State number of the termination state. */ | ||
373 | #define YYFINAL 9 | ||
374 | /* YYLAST -- Last index in YYTABLE. */ | ||
375 | #define YYLAST 17 | ||
376 | |||
377 | /* YYNTOKENS -- Number of terminals. */ | ||
378 | #define YYNTOKENS 11 | ||
379 | /* YYNNTS -- Number of nonterminals. */ | ||
380 | #define YYNNTS 5 | ||
381 | /* YYNRULES -- Number of rules. */ | ||
382 | #define YYNRULES 10 | ||
383 | /* YYNRULES -- Number of states. */ | ||
384 | #define YYNSTATES 20 | ||
385 | |||
386 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ | ||
387 | #define YYUNDEFTOK 2 | ||
388 | #define YYMAXUTOK 262 | ||
389 | |||
390 | #define YYTRANSLATE(YYX) \ | ||
391 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) | ||
392 | |||
393 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ | ||
394 | static const yytype_uint8 yytranslate[] = | ||
395 | { | ||
396 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
397 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
398 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
399 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
400 | 2, 2, 2, 2, 9, 10, 2, 2, 2, 2, | ||
401 | 2, 2, 2, 2, 2, 2, 2, 2, 8, 2, | ||
402 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
403 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
404 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
405 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
406 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
407 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
408 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
409 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
410 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
411 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
412 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
413 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
414 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
415 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
416 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
417 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
418 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
419 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
420 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
421 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, | ||
422 | 5, 6, 7 | ||
423 | }; | ||
424 | |||
425 | #if YYDEBUG | ||
426 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in | ||
427 | YYRHS. */ | ||
428 | static const yytype_uint8 yyprhs[] = | ||
429 | { | ||
430 | 0, 0, 3, 6, 8, 12, 16, 20, 24, 26, | ||
431 | 30 | ||
432 | }; | ||
433 | |||
434 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ | ||
435 | static const yytype_int8 yyrhs[] = | ||
436 | { | ||
437 | 12, 0, -1, 12, 13, -1, 13, -1, 3, 8, | ||
438 | 14, -1, 4, 8, 14, -1, 5, 8, 14, -1, | ||
439 | 14, 9, 15, -1, 15, -1, 6, 10, 6, -1, | ||
440 | 6, -1 | ||
441 | }; | ||
442 | |||
443 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ | ||
444 | static const yytype_uint8 yyrline[] = | ||
445 | { | ||
446 | 0, 39, 39, 41, 44, 51, 58, 66, 71, 77, | ||
447 | 82 | ||
448 | }; | ||
449 | #endif | ||
450 | |||
451 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE | ||
452 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. | ||
453 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ | ||
454 | static const char *const yytname[] = | ||
455 | { | ||
456 | "$end", "error", "$undefined", "PP_CONFIG", "PP_CONFIG1", "PP_CONFIG2", | ||
457 | "PP_VALUE", "PP_ERROR", "':'", "','", "'-'", "$accept", "format", | ||
458 | "format_term", "bits", "bit_term", 0 | ||
459 | }; | ||
460 | #endif | ||
461 | |||
462 | # ifdef YYPRINT | ||
463 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to | ||
464 | token YYLEX-NUM. */ | ||
465 | static const yytype_uint16 yytoknum[] = | ||
466 | { | ||
467 | 0, 256, 257, 258, 259, 260, 261, 262, 58, 44, | ||
468 | 45 | ||
469 | }; | ||
470 | # endif | ||
471 | |||
472 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ | ||
473 | static const yytype_uint8 yyr1[] = | ||
474 | { | ||
475 | 0, 11, 12, 12, 13, 13, 13, 14, 14, 15, | ||
476 | 15 | ||
477 | }; | ||
478 | |||
479 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ | ||
480 | static const yytype_uint8 yyr2[] = | ||
481 | { | ||
482 | 0, 2, 2, 1, 3, 3, 3, 3, 1, 3, | ||
483 | 1 | ||
484 | }; | ||
485 | |||
486 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state | ||
487 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero | ||
488 | means the default is an error. */ | ||
489 | static const yytype_uint8 yydefact[] = | ||
490 | { | ||
491 | 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, | ||
492 | 2, 10, 4, 8, 5, 6, 0, 0, 9, 7 | ||
493 | }; | ||
494 | |||
495 | /* YYDEFGOTO[NTERM-NUM]. */ | ||
496 | static const yytype_int8 yydefgoto[] = | ||
497 | { | ||
498 | -1, 4, 5, 12, 13 | ||
499 | }; | ||
500 | |||
501 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing | ||
502 | STATE-NUM. */ | ||
503 | #define YYPACT_NINF -7 | ||
504 | static const yytype_int8 yypact[] = | ||
505 | { | ||
506 | 3, 1, 2, 4, 0, -7, 5, 5, 5, -7, | ||
507 | -7, 6, 8, -7, 8, 8, 7, 5, -7, -7 | ||
508 | }; | ||
509 | |||
510 | /* YYPGOTO[NTERM-NUM]. */ | ||
511 | static const yytype_int8 yypgoto[] = | ||
512 | { | ||
513 | -7, -7, 10, -6, -2 | ||
514 | }; | ||
515 | |||
516 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If | ||
517 | positive, shift that token. If negative, reduce the rule which | ||
518 | number is the opposite. If zero, do what YYDEFACT says. | ||
519 | If YYTABLE_NINF, syntax error. */ | ||
520 | #define YYTABLE_NINF -1 | ||
521 | static const yytype_uint8 yytable[] = | ||
522 | { | ||
523 | 9, 14, 15, 1, 2, 3, 1, 2, 3, 6, | ||
524 | 7, 11, 8, 18, 10, 19, 16, 17 | ||
525 | }; | ||
526 | |||
527 | static const yytype_uint8 yycheck[] = | ||
528 | { | ||
529 | 0, 7, 8, 3, 4, 5, 3, 4, 5, 8, | ||
530 | 8, 6, 8, 6, 4, 17, 10, 9 | ||
531 | }; | ||
532 | |||
533 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing | ||
534 | symbol of state STATE-NUM. */ | ||
535 | static const yytype_uint8 yystos[] = | ||
536 | { | ||
537 | 0, 3, 4, 5, 12, 13, 8, 8, 8, 0, | ||
538 | 13, 6, 14, 15, 14, 14, 10, 9, 6, 15 | ||
539 | }; | ||
540 | |||
541 | #define yyerrok (yyerrstatus = 0) | ||
542 | #define yyclearin (yychar = YYEMPTY) | ||
543 | #define YYEMPTY (-2) | ||
544 | #define YYEOF 0 | ||
545 | |||
546 | #define YYACCEPT goto yyacceptlab | ||
547 | #define YYABORT goto yyabortlab | ||
548 | #define YYERROR goto yyerrorlab | ||
549 | |||
550 | |||
551 | /* Like YYERROR except do call yyerror. This remains here temporarily | ||
552 | to ease the transition to the new meaning of YYERROR, for GCC. | ||
553 | Once GCC version 2 has supplanted version 1, this can go. However, | ||
554 | YYFAIL appears to be in use. Nevertheless, it is formally deprecated | ||
555 | in Bison 2.4.2's NEWS entry, where a plan to phase it out is | ||
556 | discussed. */ | ||
557 | |||
558 | #define YYFAIL goto yyerrlab | ||
559 | #if defined YYFAIL | ||
560 | /* This is here to suppress warnings from the GCC cpp's | ||
561 | -Wunused-macros. Normally we don't worry about that warning, but | ||
562 | some users do, and we want to make it easy for users to remove | ||
563 | YYFAIL uses, which will produce warnings from Bison 2.5. */ | ||
564 | #endif | ||
565 | |||
566 | #define YYRECOVERING() (!!yyerrstatus) | ||
567 | |||
568 | #define YYBACKUP(Token, Value) \ | ||
569 | do \ | ||
570 | if (yychar == YYEMPTY && yylen == 1) \ | ||
571 | { \ | ||
572 | yychar = (Token); \ | ||
573 | yylval = (Value); \ | ||
574 | yytoken = YYTRANSLATE (yychar); \ | ||
575 | YYPOPSTACK (1); \ | ||
576 | goto yybackup; \ | ||
577 | } \ | ||
578 | else \ | ||
579 | { \ | ||
580 | yyerror (format, name, YY_("syntax error: cannot back up")); \ | ||
581 | YYERROR; \ | ||
582 | } \ | ||
583 | while (YYID (0)) | ||
584 | |||
585 | |||
586 | #define YYTERROR 1 | ||
587 | #define YYERRCODE 256 | ||
588 | |||
589 | |||
590 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. | ||
591 | If N is 0, then set CURRENT to the empty location which ends | ||
592 | the previous symbol: RHS[0] (always defined). */ | ||
593 | |||
594 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) | ||
595 | #ifndef YYLLOC_DEFAULT | ||
596 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ | ||
597 | do \ | ||
598 | if (YYID (N)) \ | ||
599 | { \ | ||
600 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ | ||
601 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ | ||
602 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ | ||
603 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ | ||
604 | } \ | ||
605 | else \ | ||
606 | { \ | ||
607 | (Current).first_line = (Current).last_line = \ | ||
608 | YYRHSLOC (Rhs, 0).last_line; \ | ||
609 | (Current).first_column = (Current).last_column = \ | ||
610 | YYRHSLOC (Rhs, 0).last_column; \ | ||
611 | } \ | ||
612 | while (YYID (0)) | ||
613 | #endif | ||
614 | |||
615 | |||
616 | /* YY_LOCATION_PRINT -- Print the location on the stream. | ||
617 | This macro was not mandated originally: define only if we know | ||
618 | we won't break user code: when these are the locations we know. */ | ||
619 | |||
620 | #ifndef YY_LOCATION_PRINT | ||
621 | # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL | ||
622 | # define YY_LOCATION_PRINT(File, Loc) \ | ||
623 | fprintf (File, "%d.%d-%d.%d", \ | ||
624 | (Loc).first_line, (Loc).first_column, \ | ||
625 | (Loc).last_line, (Loc).last_column) | ||
626 | # else | ||
627 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) | ||
628 | # endif | ||
629 | #endif | ||
630 | |||
631 | |||
632 | /* YYLEX -- calling `yylex' with the right arguments. */ | ||
633 | |||
634 | #ifdef YYLEX_PARAM | ||
635 | # define YYLEX yylex (YYLEX_PARAM) | ||
636 | #else | ||
637 | # define YYLEX yylex () | ||
638 | #endif | ||
639 | |||
640 | /* Enable debugging if requested. */ | ||
641 | #if YYDEBUG | ||
642 | |||
643 | # ifndef YYFPRINTF | ||
644 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ | ||
645 | # define YYFPRINTF fprintf | ||
646 | # endif | ||
647 | |||
648 | # define YYDPRINTF(Args) \ | ||
649 | do { \ | ||
650 | if (yydebug) \ | ||
651 | YYFPRINTF Args; \ | ||
652 | } while (YYID (0)) | ||
653 | |||
654 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ | ||
655 | do { \ | ||
656 | if (yydebug) \ | ||
657 | { \ | ||
658 | YYFPRINTF (stderr, "%s ", Title); \ | ||
659 | yy_symbol_print (stderr, \ | ||
660 | Type, Value, format, name); \ | ||
661 | YYFPRINTF (stderr, "\n"); \ | ||
662 | } \ | ||
663 | } while (YYID (0)) | ||
664 | |||
665 | |||
666 | /*--------------------------------. | ||
667 | | Print this symbol on YYOUTPUT. | | ||
668 | `--------------------------------*/ | ||
669 | |||
670 | /*ARGSUSED*/ | ||
671 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
672 | || defined __cplusplus || defined _MSC_VER) | ||
673 | static void | ||
674 | yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct list_head *format, char *name) | ||
675 | #else | ||
676 | static void | ||
677 | yy_symbol_value_print (yyoutput, yytype, yyvaluep, format, name) | ||
678 | FILE *yyoutput; | ||
679 | int yytype; | ||
680 | YYSTYPE const * const yyvaluep; | ||
681 | struct list_head *format; | ||
682 | char *name; | ||
683 | #endif | ||
684 | { | ||
685 | if (!yyvaluep) | ||
686 | return; | ||
687 | YYUSE (format); | ||
688 | YYUSE (name); | ||
689 | # ifdef YYPRINT | ||
690 | if (yytype < YYNTOKENS) | ||
691 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | ||
692 | # else | ||
693 | YYUSE (yyoutput); | ||
694 | # endif | ||
695 | switch (yytype) | ||
696 | { | ||
697 | default: | ||
698 | break; | ||
699 | } | ||
700 | } | ||
701 | |||
702 | |||
703 | /*--------------------------------. | ||
704 | | Print this symbol on YYOUTPUT. | | ||
705 | `--------------------------------*/ | ||
706 | |||
707 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
708 | || defined __cplusplus || defined _MSC_VER) | ||
709 | static void | ||
710 | yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct list_head *format, char *name) | ||
711 | #else | ||
712 | static void | ||
713 | yy_symbol_print (yyoutput, yytype, yyvaluep, format, name) | ||
714 | FILE *yyoutput; | ||
715 | int yytype; | ||
716 | YYSTYPE const * const yyvaluep; | ||
717 | struct list_head *format; | ||
718 | char *name; | ||
719 | #endif | ||
720 | { | ||
721 | if (yytype < YYNTOKENS) | ||
722 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); | ||
723 | else | ||
724 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); | ||
725 | |||
726 | yy_symbol_value_print (yyoutput, yytype, yyvaluep, format, name); | ||
727 | YYFPRINTF (yyoutput, ")"); | ||
728 | } | ||
729 | |||
730 | /*------------------------------------------------------------------. | ||
731 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | | ||
732 | | TOP (included). | | ||
733 | `------------------------------------------------------------------*/ | ||
734 | |||
735 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
736 | || defined __cplusplus || defined _MSC_VER) | ||
737 | static void | ||
738 | yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) | ||
739 | #else | ||
740 | static void | ||
741 | yy_stack_print (yybottom, yytop) | ||
742 | yytype_int16 *yybottom; | ||
743 | yytype_int16 *yytop; | ||
744 | #endif | ||
745 | { | ||
746 | YYFPRINTF (stderr, "Stack now"); | ||
747 | for (; yybottom <= yytop; yybottom++) | ||
748 | { | ||
749 | int yybot = *yybottom; | ||
750 | YYFPRINTF (stderr, " %d", yybot); | ||
751 | } | ||
752 | YYFPRINTF (stderr, "\n"); | ||
753 | } | ||
754 | |||
755 | # define YY_STACK_PRINT(Bottom, Top) \ | ||
756 | do { \ | ||
757 | if (yydebug) \ | ||
758 | yy_stack_print ((Bottom), (Top)); \ | ||
759 | } while (YYID (0)) | ||
760 | |||
761 | |||
762 | /*------------------------------------------------. | ||
763 | | Report that the YYRULE is going to be reduced. | | ||
764 | `------------------------------------------------*/ | ||
765 | |||
766 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
767 | || defined __cplusplus || defined _MSC_VER) | ||
768 | static void | ||
769 | yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct list_head *format, char *name) | ||
770 | #else | ||
771 | static void | ||
772 | yy_reduce_print (yyvsp, yyrule, format, name) | ||
773 | YYSTYPE *yyvsp; | ||
774 | int yyrule; | ||
775 | struct list_head *format; | ||
776 | char *name; | ||
777 | #endif | ||
778 | { | ||
779 | int yynrhs = yyr2[yyrule]; | ||
780 | int yyi; | ||
781 | unsigned long int yylno = yyrline[yyrule]; | ||
782 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", | ||
783 | yyrule - 1, yylno); | ||
784 | /* The symbols being reduced. */ | ||
785 | for (yyi = 0; yyi < yynrhs; yyi++) | ||
786 | { | ||
787 | YYFPRINTF (stderr, " $%d = ", yyi + 1); | ||
788 | yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], | ||
789 | &(yyvsp[(yyi + 1) - (yynrhs)]) | ||
790 | , format, name); | ||
791 | YYFPRINTF (stderr, "\n"); | ||
792 | } | ||
793 | } | ||
794 | |||
795 | # define YY_REDUCE_PRINT(Rule) \ | ||
796 | do { \ | ||
797 | if (yydebug) \ | ||
798 | yy_reduce_print (yyvsp, Rule, format, name); \ | ||
799 | } while (YYID (0)) | ||
800 | |||
801 | /* Nonzero means print parse trace. It is left uninitialized so that | ||
802 | multiple parsers can coexist. */ | ||
803 | int yydebug; | ||
804 | #else /* !YYDEBUG */ | ||
805 | # define YYDPRINTF(Args) | ||
806 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) | ||
807 | # define YY_STACK_PRINT(Bottom, Top) | ||
808 | # define YY_REDUCE_PRINT(Rule) | ||
809 | #endif /* !YYDEBUG */ | ||
810 | |||
811 | |||
812 | /* YYINITDEPTH -- initial size of the parser's stacks. */ | ||
813 | #ifndef YYINITDEPTH | ||
814 | # define YYINITDEPTH 200 | ||
815 | #endif | ||
816 | |||
817 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only | ||
818 | if the built-in stack extension method is used). | ||
819 | |||
820 | Do not make this value too large; the results are undefined if | ||
821 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) | ||
822 | evaluated with infinite-precision integer arithmetic. */ | ||
823 | |||
824 | #ifndef YYMAXDEPTH | ||
825 | # define YYMAXDEPTH 10000 | ||
826 | #endif | ||
827 | |||
828 | |||
829 | |||
830 | #if YYERROR_VERBOSE | ||
831 | |||
832 | # ifndef yystrlen | ||
833 | # if defined __GLIBC__ && defined _STRING_H | ||
834 | # define yystrlen strlen | ||
835 | # else | ||
836 | /* Return the length of YYSTR. */ | ||
837 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
838 | || defined __cplusplus || defined _MSC_VER) | ||
839 | static YYSIZE_T | ||
840 | yystrlen (const char *yystr) | ||
841 | #else | ||
842 | static YYSIZE_T | ||
843 | yystrlen (yystr) | ||
844 | const char *yystr; | ||
845 | #endif | ||
846 | { | ||
847 | YYSIZE_T yylen; | ||
848 | for (yylen = 0; yystr[yylen]; yylen++) | ||
849 | continue; | ||
850 | return yylen; | ||
851 | } | ||
852 | # endif | ||
853 | # endif | ||
854 | |||
855 | # ifndef yystpcpy | ||
856 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE | ||
857 | # define yystpcpy stpcpy | ||
858 | # else | ||
859 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in | ||
860 | YYDEST. */ | ||
861 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
862 | || defined __cplusplus || defined _MSC_VER) | ||
863 | static char * | ||
864 | yystpcpy (char *yydest, const char *yysrc) | ||
865 | #else | ||
866 | static char * | ||
867 | yystpcpy (yydest, yysrc) | ||
868 | char *yydest; | ||
869 | const char *yysrc; | ||
870 | #endif | ||
871 | { | ||
872 | char *yyd = yydest; | ||
873 | const char *yys = yysrc; | ||
874 | |||
875 | while ((*yyd++ = *yys++) != '\0') | ||
876 | continue; | ||
877 | |||
878 | return yyd - 1; | ||
879 | } | ||
880 | # endif | ||
881 | # endif | ||
882 | |||
883 | # ifndef yytnamerr | ||
884 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary | ||
885 | quotes and backslashes, so that it's suitable for yyerror. The | ||
886 | heuristic is that double-quoting is unnecessary unless the string | ||
887 | contains an apostrophe, a comma, or backslash (other than | ||
888 | backslash-backslash). YYSTR is taken from yytname. If YYRES is | ||
889 | null, do not copy; instead, return the length of what the result | ||
890 | would have been. */ | ||
891 | static YYSIZE_T | ||
892 | yytnamerr (char *yyres, const char *yystr) | ||
893 | { | ||
894 | if (*yystr == '"') | ||
895 | { | ||
896 | YYSIZE_T yyn = 0; | ||
897 | char const *yyp = yystr; | ||
898 | |||
899 | for (;;) | ||
900 | switch (*++yyp) | ||
901 | { | ||
902 | case '\'': | ||
903 | case ',': | ||
904 | goto do_not_strip_quotes; | ||
905 | |||
906 | case '\\': | ||
907 | if (*++yyp != '\\') | ||
908 | goto do_not_strip_quotes; | ||
909 | /* Fall through. */ | ||
910 | default: | ||
911 | if (yyres) | ||
912 | yyres[yyn] = *yyp; | ||
913 | yyn++; | ||
914 | break; | ||
915 | |||
916 | case '"': | ||
917 | if (yyres) | ||
918 | yyres[yyn] = '\0'; | ||
919 | return yyn; | ||
920 | } | ||
921 | do_not_strip_quotes: ; | ||
922 | } | ||
923 | |||
924 | if (! yyres) | ||
925 | return yystrlen (yystr); | ||
926 | |||
927 | return yystpcpy (yyres, yystr) - yyres; | ||
928 | } | ||
929 | # endif | ||
930 | |||
931 | /* Copy into YYRESULT an error message about the unexpected token | ||
932 | YYCHAR while in state YYSTATE. Return the number of bytes copied, | ||
933 | including the terminating null byte. If YYRESULT is null, do not | ||
934 | copy anything; just return the number of bytes that would be | ||
935 | copied. As a special case, return 0 if an ordinary "syntax error" | ||
936 | message will do. Return YYSIZE_MAXIMUM if overflow occurs during | ||
937 | size calculation. */ | ||
938 | static YYSIZE_T | ||
939 | yysyntax_error (char *yyresult, int yystate, int yychar) | ||
940 | { | ||
941 | int yyn = yypact[yystate]; | ||
942 | |||
943 | if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) | ||
944 | return 0; | ||
945 | else | ||
946 | { | ||
947 | int yytype = YYTRANSLATE (yychar); | ||
948 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); | ||
949 | YYSIZE_T yysize = yysize0; | ||
950 | YYSIZE_T yysize1; | ||
951 | int yysize_overflow = 0; | ||
952 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; | ||
953 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; | ||
954 | int yyx; | ||
955 | |||
956 | # if 0 | ||
957 | /* This is so xgettext sees the translatable formats that are | ||
958 | constructed on the fly. */ | ||
959 | YY_("syntax error, unexpected %s"); | ||
960 | YY_("syntax error, unexpected %s, expecting %s"); | ||
961 | YY_("syntax error, unexpected %s, expecting %s or %s"); | ||
962 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); | ||
963 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); | ||
964 | # endif | ||
965 | char *yyfmt; | ||
966 | char const *yyf; | ||
967 | static char const yyunexpected[] = "syntax error, unexpected %s"; | ||
968 | static char const yyexpecting[] = ", expecting %s"; | ||
969 | static char const yyor[] = " or %s"; | ||
970 | char yyformat[sizeof yyunexpected | ||
971 | + sizeof yyexpecting - 1 | ||
972 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) | ||
973 | * (sizeof yyor - 1))]; | ||
974 | char const *yyprefix = yyexpecting; | ||
975 | |||
976 | /* Start YYX at -YYN if negative to avoid negative indexes in | ||
977 | YYCHECK. */ | ||
978 | int yyxbegin = yyn < 0 ? -yyn : 0; | ||
979 | |||
980 | /* Stay within bounds of both yycheck and yytname. */ | ||
981 | int yychecklim = YYLAST - yyn + 1; | ||
982 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; | ||
983 | int yycount = 1; | ||
984 | |||
985 | yyarg[0] = yytname[yytype]; | ||
986 | yyfmt = yystpcpy (yyformat, yyunexpected); | ||
987 | |||
988 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) | ||
989 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) | ||
990 | { | ||
991 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) | ||
992 | { | ||
993 | yycount = 1; | ||
994 | yysize = yysize0; | ||
995 | yyformat[sizeof yyunexpected - 1] = '\0'; | ||
996 | break; | ||
997 | } | ||
998 | yyarg[yycount++] = yytname[yyx]; | ||
999 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); | ||
1000 | yysize_overflow |= (yysize1 < yysize); | ||
1001 | yysize = yysize1; | ||
1002 | yyfmt = yystpcpy (yyfmt, yyprefix); | ||
1003 | yyprefix = yyor; | ||
1004 | } | ||
1005 | |||
1006 | yyf = YY_(yyformat); | ||
1007 | yysize1 = yysize + yystrlen (yyf); | ||
1008 | yysize_overflow |= (yysize1 < yysize); | ||
1009 | yysize = yysize1; | ||
1010 | |||
1011 | if (yysize_overflow) | ||
1012 | return YYSIZE_MAXIMUM; | ||
1013 | |||
1014 | if (yyresult) | ||
1015 | { | ||
1016 | /* Avoid sprintf, as that infringes on the user's name space. | ||
1017 | Don't have undefined behavior even if the translation | ||
1018 | produced a string with the wrong number of "%s"s. */ | ||
1019 | char *yyp = yyresult; | ||
1020 | int yyi = 0; | ||
1021 | while ((*yyp = *yyf) != '\0') | ||
1022 | { | ||
1023 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) | ||
1024 | { | ||
1025 | yyp += yytnamerr (yyp, yyarg[yyi++]); | ||
1026 | yyf += 2; | ||
1027 | } | ||
1028 | else | ||
1029 | { | ||
1030 | yyp++; | ||
1031 | yyf++; | ||
1032 | } | ||
1033 | } | ||
1034 | } | ||
1035 | return yysize; | ||
1036 | } | ||
1037 | } | ||
1038 | #endif /* YYERROR_VERBOSE */ | ||
1039 | |||
1040 | |||
1041 | /*-----------------------------------------------. | ||
1042 | | Release the memory associated to this symbol. | | ||
1043 | `-----------------------------------------------*/ | ||
1044 | |||
1045 | /*ARGSUSED*/ | ||
1046 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
1047 | || defined __cplusplus || defined _MSC_VER) | ||
1048 | static void | ||
1049 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct list_head *format, char *name) | ||
1050 | #else | ||
1051 | static void | ||
1052 | yydestruct (yymsg, yytype, yyvaluep, format, name) | ||
1053 | const char *yymsg; | ||
1054 | int yytype; | ||
1055 | YYSTYPE *yyvaluep; | ||
1056 | struct list_head *format; | ||
1057 | char *name; | ||
1058 | #endif | ||
1059 | { | ||
1060 | YYUSE (yyvaluep); | ||
1061 | YYUSE (format); | ||
1062 | YYUSE (name); | ||
1063 | |||
1064 | if (!yymsg) | ||
1065 | yymsg = "Deleting"; | ||
1066 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); | ||
1067 | |||
1068 | switch (yytype) | ||
1069 | { | ||
1070 | |||
1071 | default: | ||
1072 | break; | ||
1073 | } | ||
1074 | } | ||
1075 | |||
1076 | /* Prevent warnings from -Wmissing-prototypes. */ | ||
1077 | #ifdef YYPARSE_PARAM | ||
1078 | #if defined __STDC__ || defined __cplusplus | ||
1079 | int yyparse (void *YYPARSE_PARAM); | ||
1080 | #else | ||
1081 | int yyparse (); | ||
1082 | #endif | ||
1083 | #else /* ! YYPARSE_PARAM */ | ||
1084 | #if defined __STDC__ || defined __cplusplus | ||
1085 | int yyparse (struct list_head *format, char *name); | ||
1086 | #else | ||
1087 | int yyparse (); | ||
1088 | #endif | ||
1089 | #endif /* ! YYPARSE_PARAM */ | ||
1090 | |||
1091 | |||
1092 | /* The lookahead symbol. */ | ||
1093 | int yychar; | ||
1094 | |||
1095 | /* The semantic value of the lookahead symbol. */ | ||
1096 | YYSTYPE yylval; | ||
1097 | |||
1098 | /* Number of syntax errors so far. */ | ||
1099 | int yynerrs; | ||
1100 | |||
1101 | |||
1102 | |||
1103 | /*-------------------------. | ||
1104 | | yyparse or yypush_parse. | | ||
1105 | `-------------------------*/ | ||
1106 | |||
1107 | #ifdef YYPARSE_PARAM | ||
1108 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
1109 | || defined __cplusplus || defined _MSC_VER) | ||
1110 | int | ||
1111 | yyparse (void *YYPARSE_PARAM) | ||
1112 | #else | ||
1113 | int | ||
1114 | yyparse (YYPARSE_PARAM) | ||
1115 | void *YYPARSE_PARAM; | ||
1116 | #endif | ||
1117 | #else /* ! YYPARSE_PARAM */ | ||
1118 | #if (defined __STDC__ || defined __C99__FUNC__ \ | ||
1119 | || defined __cplusplus || defined _MSC_VER) | ||
1120 | int | ||
1121 | yyparse (struct list_head *format, char *name) | ||
1122 | #else | ||
1123 | int | ||
1124 | yyparse (format, name) | ||
1125 | struct list_head *format; | ||
1126 | char *name; | ||
1127 | #endif | ||
1128 | #endif | ||
1129 | { | ||
1130 | |||
1131 | |||
1132 | int yystate; | ||
1133 | /* Number of tokens to shift before error messages enabled. */ | ||
1134 | int yyerrstatus; | ||
1135 | |||
1136 | /* The stacks and their tools: | ||
1137 | `yyss': related to states. | ||
1138 | `yyvs': related to semantic values. | ||
1139 | |||
1140 | Refer to the stacks thru separate pointers, to allow yyoverflow | ||
1141 | to reallocate them elsewhere. */ | ||
1142 | |||
1143 | /* The state stack. */ | ||
1144 | yytype_int16 yyssa[YYINITDEPTH]; | ||
1145 | yytype_int16 *yyss; | ||
1146 | yytype_int16 *yyssp; | ||
1147 | |||
1148 | /* The semantic value stack. */ | ||
1149 | YYSTYPE yyvsa[YYINITDEPTH]; | ||
1150 | YYSTYPE *yyvs; | ||
1151 | YYSTYPE *yyvsp; | ||
1152 | |||
1153 | YYSIZE_T yystacksize; | ||
1154 | |||
1155 | int yyn; | ||
1156 | int yyresult; | ||
1157 | /* Lookahead token as an internal (translated) token number. */ | ||
1158 | int yytoken; | ||
1159 | /* The variables used to return semantic value and location from the | ||
1160 | action routines. */ | ||
1161 | YYSTYPE yyval; | ||
1162 | |||
1163 | #if YYERROR_VERBOSE | ||
1164 | /* Buffer for error messages, and its allocated size. */ | ||
1165 | char yymsgbuf[128]; | ||
1166 | char *yymsg = yymsgbuf; | ||
1167 | YYSIZE_T yymsg_alloc = sizeof yymsgbuf; | ||
1168 | #endif | ||
1169 | |||
1170 | #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) | ||
1171 | |||
1172 | /* The number of symbols on the RHS of the reduced rule. | ||
1173 | Keep to zero when no symbol should be popped. */ | ||
1174 | int yylen = 0; | ||
1175 | |||
1176 | yytoken = 0; | ||
1177 | yyss = yyssa; | ||
1178 | yyvs = yyvsa; | ||
1179 | yystacksize = YYINITDEPTH; | ||
1180 | |||
1181 | YYDPRINTF ((stderr, "Starting parse\n")); | ||
1182 | |||
1183 | yystate = 0; | ||
1184 | yyerrstatus = 0; | ||
1185 | yynerrs = 0; | ||
1186 | yychar = YYEMPTY; /* Cause a token to be read. */ | ||
1187 | |||
1188 | /* Initialize stack pointers. | ||
1189 | Waste one element of value and location stack | ||
1190 | so that they stay on the same level as the state stack. | ||
1191 | The wasted elements are never initialized. */ | ||
1192 | yyssp = yyss; | ||
1193 | yyvsp = yyvs; | ||
1194 | |||
1195 | goto yysetstate; | ||
1196 | |||
1197 | /*------------------------------------------------------------. | ||
1198 | | yynewstate -- Push a new state, which is found in yystate. | | ||
1199 | `------------------------------------------------------------*/ | ||
1200 | yynewstate: | ||
1201 | /* In all cases, when you get here, the value and location stacks | ||
1202 | have just been pushed. So pushing a state here evens the stacks. */ | ||
1203 | yyssp++; | ||
1204 | |||
1205 | yysetstate: | ||
1206 | *yyssp = yystate; | ||
1207 | |||
1208 | if (yyss + yystacksize - 1 <= yyssp) | ||
1209 | { | ||
1210 | /* Get the current used size of the three stacks, in elements. */ | ||
1211 | YYSIZE_T yysize = yyssp - yyss + 1; | ||
1212 | |||
1213 | #ifdef yyoverflow | ||
1214 | { | ||
1215 | /* Give user a chance to reallocate the stack. Use copies of | ||
1216 | these so that the &'s don't force the real ones into | ||
1217 | memory. */ | ||
1218 | YYSTYPE *yyvs1 = yyvs; | ||
1219 | yytype_int16 *yyss1 = yyss; | ||
1220 | |||
1221 | /* Each stack pointer address is followed by the size of the | ||
1222 | data in use in that stack, in bytes. This used to be a | ||
1223 | conditional around just the two extra args, but that might | ||
1224 | be undefined if yyoverflow is a macro. */ | ||
1225 | yyoverflow (YY_("memory exhausted"), | ||
1226 | &yyss1, yysize * sizeof (*yyssp), | ||
1227 | &yyvs1, yysize * sizeof (*yyvsp), | ||
1228 | &yystacksize); | ||
1229 | |||
1230 | yyss = yyss1; | ||
1231 | yyvs = yyvs1; | ||
1232 | } | ||
1233 | #else /* no yyoverflow */ | ||
1234 | # ifndef YYSTACK_RELOCATE | ||
1235 | goto yyexhaustedlab; | ||
1236 | # else | ||
1237 | /* Extend the stack our own way. */ | ||
1238 | if (YYMAXDEPTH <= yystacksize) | ||
1239 | goto yyexhaustedlab; | ||
1240 | yystacksize *= 2; | ||
1241 | if (YYMAXDEPTH < yystacksize) | ||
1242 | yystacksize = YYMAXDEPTH; | ||
1243 | |||
1244 | { | ||
1245 | yytype_int16 *yyss1 = yyss; | ||
1246 | union yyalloc *yyptr = | ||
1247 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); | ||
1248 | if (! yyptr) | ||
1249 | goto yyexhaustedlab; | ||
1250 | YYSTACK_RELOCATE (yyss_alloc, yyss); | ||
1251 | YYSTACK_RELOCATE (yyvs_alloc, yyvs); | ||
1252 | # undef YYSTACK_RELOCATE | ||
1253 | if (yyss1 != yyssa) | ||
1254 | YYSTACK_FREE (yyss1); | ||
1255 | } | ||
1256 | # endif | ||
1257 | #endif /* no yyoverflow */ | ||
1258 | |||
1259 | yyssp = yyss + yysize - 1; | ||
1260 | yyvsp = yyvs + yysize - 1; | ||
1261 | |||
1262 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", | ||
1263 | (unsigned long int) yystacksize)); | ||
1264 | |||
1265 | if (yyss + yystacksize - 1 <= yyssp) | ||
1266 | YYABORT; | ||
1267 | } | ||
1268 | |||
1269 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); | ||
1270 | |||
1271 | if (yystate == YYFINAL) | ||
1272 | YYACCEPT; | ||
1273 | |||
1274 | goto yybackup; | ||
1275 | |||
1276 | /*-----------. | ||
1277 | | yybackup. | | ||
1278 | `-----------*/ | ||
1279 | yybackup: | ||
1280 | |||
1281 | /* Do appropriate processing given the current state. Read a | ||
1282 | lookahead token if we need one and don't already have one. */ | ||
1283 | |||
1284 | /* First try to decide what to do without reference to lookahead token. */ | ||
1285 | yyn = yypact[yystate]; | ||
1286 | if (yyn == YYPACT_NINF) | ||
1287 | goto yydefault; | ||
1288 | |||
1289 | /* Not known => get a lookahead token if don't already have one. */ | ||
1290 | |||
1291 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | ||
1292 | if (yychar == YYEMPTY) | ||
1293 | { | ||
1294 | YYDPRINTF ((stderr, "Reading a token: ")); | ||
1295 | yychar = YYLEX; | ||
1296 | } | ||
1297 | |||
1298 | if (yychar <= YYEOF) | ||
1299 | { | ||
1300 | yychar = yytoken = YYEOF; | ||
1301 | YYDPRINTF ((stderr, "Now at end of input.\n")); | ||
1302 | } | ||
1303 | else | ||
1304 | { | ||
1305 | yytoken = YYTRANSLATE (yychar); | ||
1306 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); | ||
1307 | } | ||
1308 | |||
1309 | /* If the proper action on seeing token YYTOKEN is to reduce or to | ||
1310 | detect an error, take that action. */ | ||
1311 | yyn += yytoken; | ||
1312 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) | ||
1313 | goto yydefault; | ||
1314 | yyn = yytable[yyn]; | ||
1315 | if (yyn <= 0) | ||
1316 | { | ||
1317 | if (yyn == 0 || yyn == YYTABLE_NINF) | ||
1318 | goto yyerrlab; | ||
1319 | yyn = -yyn; | ||
1320 | goto yyreduce; | ||
1321 | } | ||
1322 | |||
1323 | /* Count tokens shifted since error; after three, turn off error | ||
1324 | status. */ | ||
1325 | if (yyerrstatus) | ||
1326 | yyerrstatus--; | ||
1327 | |||
1328 | /* Shift the lookahead token. */ | ||
1329 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); | ||
1330 | |||
1331 | /* Discard the shifted token. */ | ||
1332 | yychar = YYEMPTY; | ||
1333 | |||
1334 | yystate = yyn; | ||
1335 | *++yyvsp = yylval; | ||
1336 | |||
1337 | goto yynewstate; | ||
1338 | |||
1339 | |||
1340 | /*-----------------------------------------------------------. | ||
1341 | | yydefault -- do the default action for the current state. | | ||
1342 | `-----------------------------------------------------------*/ | ||
1343 | yydefault: | ||
1344 | yyn = yydefact[yystate]; | ||
1345 | if (yyn == 0) | ||
1346 | goto yyerrlab; | ||
1347 | goto yyreduce; | ||
1348 | |||
1349 | |||
1350 | /*-----------------------------. | ||
1351 | | yyreduce -- Do a reduction. | | ||
1352 | `-----------------------------*/ | ||
1353 | yyreduce: | ||
1354 | /* yyn is the number of a rule to reduce with. */ | ||
1355 | yylen = yyr2[yyn]; | ||
1356 | |||
1357 | /* If YYLEN is nonzero, implement the default value of the action: | ||
1358 | `$$ = $1'. | ||
1359 | |||
1360 | Otherwise, the following line sets YYVAL to garbage. | ||
1361 | This behavior is undocumented and Bison | ||
1362 | users should not rely upon it. Assigning to YYVAL | ||
1363 | unconditionally makes the parser a bit smaller, and it avoids a | ||
1364 | GCC warning that YYVAL may be used uninitialized. */ | ||
1365 | yyval = yyvsp[1-yylen]; | ||
1366 | |||
1367 | |||
1368 | YY_REDUCE_PRINT (yyn); | ||
1369 | switch (yyn) | ||
1370 | { | ||
1371 | case 4: | ||
1372 | |||
1373 | /* Line 1464 of yacc.c */ | ||
1374 | #line 45 "util/pmu.y" | ||
1375 | { | ||
1376 | ABORT_ON(perf_pmu__new_format(format, name, | ||
1377 | PERF_PMU_FORMAT_VALUE_CONFIG, | ||
1378 | (yyvsp[(3) - (3)].bits))); | ||
1379 | ;} | ||
1380 | break; | ||
1381 | |||
1382 | case 5: | ||
1383 | |||
1384 | /* Line 1464 of yacc.c */ | ||
1385 | #line 52 "util/pmu.y" | ||
1386 | { | ||
1387 | ABORT_ON(perf_pmu__new_format(format, name, | ||
1388 | PERF_PMU_FORMAT_VALUE_CONFIG1, | ||
1389 | (yyvsp[(3) - (3)].bits))); | ||
1390 | ;} | ||
1391 | break; | ||
1392 | |||
1393 | case 6: | ||
1394 | |||
1395 | /* Line 1464 of yacc.c */ | ||
1396 | #line 59 "util/pmu.y" | ||
1397 | { | ||
1398 | ABORT_ON(perf_pmu__new_format(format, name, | ||
1399 | PERF_PMU_FORMAT_VALUE_CONFIG2, | ||
1400 | (yyvsp[(3) - (3)].bits))); | ||
1401 | ;} | ||
1402 | break; | ||
1403 | |||
1404 | case 7: | ||
1405 | |||
1406 | /* Line 1464 of yacc.c */ | ||
1407 | #line 67 "util/pmu.y" | ||
1408 | { | ||
1409 | bitmap_or((yyval.bits), (yyvsp[(1) - (3)].bits), (yyvsp[(3) - (3)].bits), 64); | ||
1410 | ;} | ||
1411 | break; | ||
1412 | |||
1413 | case 8: | ||
1414 | |||
1415 | /* Line 1464 of yacc.c */ | ||
1416 | #line 72 "util/pmu.y" | ||
1417 | { | ||
1418 | memcpy((yyval.bits), (yyvsp[(1) - (1)].bits), sizeof((yyvsp[(1) - (1)].bits))); | ||
1419 | ;} | ||
1420 | break; | ||
1421 | |||
1422 | case 9: | ||
1423 | |||
1424 | /* Line 1464 of yacc.c */ | ||
1425 | #line 78 "util/pmu.y" | ||
1426 | { | ||
1427 | perf_pmu__set_format((yyval.bits), (yyvsp[(1) - (3)].num), (yyvsp[(3) - (3)].num)); | ||
1428 | ;} | ||
1429 | break; | ||
1430 | |||
1431 | case 10: | ||
1432 | |||
1433 | /* Line 1464 of yacc.c */ | ||
1434 | #line 83 "util/pmu.y" | ||
1435 | { | ||
1436 | perf_pmu__set_format((yyval.bits), (yyvsp[(1) - (1)].num), 0); | ||
1437 | ;} | ||
1438 | break; | ||
1439 | |||
1440 | |||
1441 | |||
1442 | /* Line 1464 of yacc.c */ | ||
1443 | #line 1444 "util/pmu-bison.c" | ||
1444 | default: break; | ||
1445 | } | ||
1446 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); | ||
1447 | |||
1448 | YYPOPSTACK (yylen); | ||
1449 | yylen = 0; | ||
1450 | YY_STACK_PRINT (yyss, yyssp); | ||
1451 | |||
1452 | *++yyvsp = yyval; | ||
1453 | |||
1454 | /* Now `shift' the result of the reduction. Determine what state | ||
1455 | that goes to, based on the state we popped back to and the rule | ||
1456 | number reduced by. */ | ||
1457 | |||
1458 | yyn = yyr1[yyn]; | ||
1459 | |||
1460 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; | ||
1461 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) | ||
1462 | yystate = yytable[yystate]; | ||
1463 | else | ||
1464 | yystate = yydefgoto[yyn - YYNTOKENS]; | ||
1465 | |||
1466 | goto yynewstate; | ||
1467 | |||
1468 | |||
1469 | /*------------------------------------. | ||
1470 | | yyerrlab -- here on detecting error | | ||
1471 | `------------------------------------*/ | ||
1472 | yyerrlab: | ||
1473 | /* If not already recovering from an error, report this error. */ | ||
1474 | if (!yyerrstatus) | ||
1475 | { | ||
1476 | ++yynerrs; | ||
1477 | #if ! YYERROR_VERBOSE | ||
1478 | yyerror (format, name, YY_("syntax error")); | ||
1479 | #else | ||
1480 | { | ||
1481 | YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); | ||
1482 | if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) | ||
1483 | { | ||
1484 | YYSIZE_T yyalloc = 2 * yysize; | ||
1485 | if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) | ||
1486 | yyalloc = YYSTACK_ALLOC_MAXIMUM; | ||
1487 | if (yymsg != yymsgbuf) | ||
1488 | YYSTACK_FREE (yymsg); | ||
1489 | yymsg = (char *) YYSTACK_ALLOC (yyalloc); | ||
1490 | if (yymsg) | ||
1491 | yymsg_alloc = yyalloc; | ||
1492 | else | ||
1493 | { | ||
1494 | yymsg = yymsgbuf; | ||
1495 | yymsg_alloc = sizeof yymsgbuf; | ||
1496 | } | ||
1497 | } | ||
1498 | |||
1499 | if (0 < yysize && yysize <= yymsg_alloc) | ||
1500 | { | ||
1501 | (void) yysyntax_error (yymsg, yystate, yychar); | ||
1502 | yyerror (format, name, yymsg); | ||
1503 | } | ||
1504 | else | ||
1505 | { | ||
1506 | yyerror (format, name, YY_("syntax error")); | ||
1507 | if (yysize != 0) | ||
1508 | goto yyexhaustedlab; | ||
1509 | } | ||
1510 | } | ||
1511 | #endif | ||
1512 | } | ||
1513 | |||
1514 | |||
1515 | |||
1516 | if (yyerrstatus == 3) | ||
1517 | { | ||
1518 | /* If just tried and failed to reuse lookahead token after an | ||
1519 | error, discard it. */ | ||
1520 | |||
1521 | if (yychar <= YYEOF) | ||
1522 | { | ||
1523 | /* Return failure if at end of input. */ | ||
1524 | if (yychar == YYEOF) | ||
1525 | YYABORT; | ||
1526 | } | ||
1527 | else | ||
1528 | { | ||
1529 | yydestruct ("Error: discarding", | ||
1530 | yytoken, &yylval, format, name); | ||
1531 | yychar = YYEMPTY; | ||
1532 | } | ||
1533 | } | ||
1534 | |||
1535 | /* Else will try to reuse lookahead token after shifting the error | ||
1536 | token. */ | ||
1537 | goto yyerrlab1; | ||
1538 | |||
1539 | |||
1540 | /*---------------------------------------------------. | ||
1541 | | yyerrorlab -- error raised explicitly by YYERROR. | | ||
1542 | `---------------------------------------------------*/ | ||
1543 | yyerrorlab: | ||
1544 | |||
1545 | /* Pacify compilers like GCC when the user code never invokes | ||
1546 | YYERROR and the label yyerrorlab therefore never appears in user | ||
1547 | code. */ | ||
1548 | if (/*CONSTCOND*/ 0) | ||
1549 | goto yyerrorlab; | ||
1550 | |||
1551 | /* Do not reclaim the symbols of the rule which action triggered | ||
1552 | this YYERROR. */ | ||
1553 | YYPOPSTACK (yylen); | ||
1554 | yylen = 0; | ||
1555 | YY_STACK_PRINT (yyss, yyssp); | ||
1556 | yystate = *yyssp; | ||
1557 | goto yyerrlab1; | ||
1558 | |||
1559 | |||
1560 | /*-------------------------------------------------------------. | ||
1561 | | yyerrlab1 -- common code for both syntax error and YYERROR. | | ||
1562 | `-------------------------------------------------------------*/ | ||
1563 | yyerrlab1: | ||
1564 | yyerrstatus = 3; /* Each real token shifted decrements this. */ | ||
1565 | |||
1566 | for (;;) | ||
1567 | { | ||
1568 | yyn = yypact[yystate]; | ||
1569 | if (yyn != YYPACT_NINF) | ||
1570 | { | ||
1571 | yyn += YYTERROR; | ||
1572 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) | ||
1573 | { | ||
1574 | yyn = yytable[yyn]; | ||
1575 | if (0 < yyn) | ||
1576 | break; | ||
1577 | } | ||
1578 | } | ||
1579 | |||
1580 | /* Pop the current state because it cannot handle the error token. */ | ||
1581 | if (yyssp == yyss) | ||
1582 | YYABORT; | ||
1583 | |||
1584 | |||
1585 | yydestruct ("Error: popping", | ||
1586 | yystos[yystate], yyvsp, format, name); | ||
1587 | YYPOPSTACK (1); | ||
1588 | yystate = *yyssp; | ||
1589 | YY_STACK_PRINT (yyss, yyssp); | ||
1590 | } | ||
1591 | |||
1592 | *++yyvsp = yylval; | ||
1593 | |||
1594 | |||
1595 | /* Shift the error token. */ | ||
1596 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); | ||
1597 | |||
1598 | yystate = yyn; | ||
1599 | goto yynewstate; | ||
1600 | |||
1601 | |||
1602 | /*-------------------------------------. | ||
1603 | | yyacceptlab -- YYACCEPT comes here. | | ||
1604 | `-------------------------------------*/ | ||
1605 | yyacceptlab: | ||
1606 | yyresult = 0; | ||
1607 | goto yyreturn; | ||
1608 | |||
1609 | /*-----------------------------------. | ||
1610 | | yyabortlab -- YYABORT comes here. | | ||
1611 | `-----------------------------------*/ | ||
1612 | yyabortlab: | ||
1613 | yyresult = 1; | ||
1614 | goto yyreturn; | ||
1615 | |||
1616 | #if !defined(yyoverflow) || YYERROR_VERBOSE | ||
1617 | /*-------------------------------------------------. | ||
1618 | | yyexhaustedlab -- memory exhaustion comes here. | | ||
1619 | `-------------------------------------------------*/ | ||
1620 | yyexhaustedlab: | ||
1621 | yyerror (format, name, YY_("memory exhausted")); | ||
1622 | yyresult = 2; | ||
1623 | /* Fall through. */ | ||
1624 | #endif | ||
1625 | |||
1626 | yyreturn: | ||
1627 | if (yychar != YYEMPTY) | ||
1628 | yydestruct ("Cleanup: discarding lookahead", | ||
1629 | yytoken, &yylval, format, name); | ||
1630 | /* Do not reclaim the symbols of the rule which action triggered | ||
1631 | this YYABORT or YYACCEPT. */ | ||
1632 | YYPOPSTACK (yylen); | ||
1633 | YY_STACK_PRINT (yyss, yyssp); | ||
1634 | while (yyssp != yyss) | ||
1635 | { | ||
1636 | yydestruct ("Cleanup: popping", | ||
1637 | yystos[*yyssp], yyvsp, format, name); | ||
1638 | YYPOPSTACK (1); | ||
1639 | } | ||
1640 | #ifndef yyoverflow | ||
1641 | if (yyss != yyssa) | ||
1642 | YYSTACK_FREE (yyss); | ||
1643 | #endif | ||
1644 | #if YYERROR_VERBOSE | ||
1645 | if (yymsg != yymsgbuf) | ||
1646 | YYSTACK_FREE (yymsg); | ||
1647 | #endif | ||
1648 | /* Make sure YYID is used. */ | ||
1649 | return YYID (yyresult); | ||
1650 | } | ||
1651 | |||
1652 | |||
1653 | |||
1654 | /* Line 1684 of yacc.c */ | ||
1655 | #line 87 "util/pmu.y" | ||
1656 | |||
1657 | |||
1658 | void perf_pmu_error(struct list_head *list __used, | ||
1659 | char *name __used, | ||
1660 | char const *msg __used) | ||
1661 | { | ||
1662 | } | ||
1663 | |||
diff --git a/tools/perf/util/pmu-bison.h b/tools/perf/util/pmu-bison.h new file mode 100644 index 000000000000..54f4a0d7829b --- /dev/null +++ b/tools/perf/util/pmu-bison.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /* A Bison parser, made by GNU Bison 2.4.3. */ | ||
2 | |||
3 | /* Skeleton interface for Bison's Yacc-like parsers in C | ||
4 | |||
5 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, | ||
6 | 2009, 2010 Free Software Foundation, Inc. | ||
7 | |||
8 | This program is free software: you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation, either version 3 of the License, or | ||
11 | (at your option) any later version. | ||
12 | |||
13 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
20 | |||
21 | /* As a special exception, you may create a larger work that contains | ||
22 | part or all of the Bison parser skeleton and distribute that work | ||
23 | under terms of your choice, so long as that work isn't itself a | ||
24 | parser generator using the skeleton or a modified version thereof | ||
25 | as a parser skeleton. Alternatively, if you modify or redistribute | ||
26 | the parser skeleton itself, you may (at your option) remove this | ||
27 | special exception, which will cause the skeleton and the resulting | ||
28 | Bison output files to be licensed under the GNU General Public | ||
29 | License without this special exception. | ||
30 | |||
31 | This special exception was added by the Free Software Foundation in | ||
32 | version 2.2 of Bison. */ | ||
33 | |||
34 | |||
35 | /* Tokens. */ | ||
36 | #ifndef YYTOKENTYPE | ||
37 | # define YYTOKENTYPE | ||
38 | /* Put the tokens into the symbol table, so that GDB and other debuggers | ||
39 | know about them. */ | ||
40 | enum yytokentype { | ||
41 | PP_CONFIG = 258, | ||
42 | PP_CONFIG1 = 259, | ||
43 | PP_CONFIG2 = 260, | ||
44 | PP_VALUE = 261, | ||
45 | PP_ERROR = 262 | ||
46 | }; | ||
47 | #endif | ||
48 | |||
49 | |||
50 | |||
51 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED | ||
52 | typedef union YYSTYPE | ||
53 | { | ||
54 | |||
55 | /* Line 1685 of yacc.c */ | ||
56 | #line 31 "util/pmu.y" | ||
57 | |||
58 | unsigned long num; | ||
59 | DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS); | ||
60 | |||
61 | |||
62 | |||
63 | /* Line 1685 of yacc.c */ | ||
64 | #line 65 "util/pmu-bison.h" | ||
65 | } YYSTYPE; | ||
66 | # define YYSTYPE_IS_TRIVIAL 1 | ||
67 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ | ||
68 | # define YYSTYPE_IS_DECLARED 1 | ||
69 | #endif | ||
70 | |||
71 | extern YYSTYPE perf_pmu_lval; | ||
72 | |||
73 | |||
diff --git a/tools/perf/util/pmu-flex.c b/tools/perf/util/pmu-flex.c new file mode 100644 index 000000000000..5a8c15966d5c --- /dev/null +++ b/tools/perf/util/pmu-flex.c | |||
@@ -0,0 +1,1821 @@ | |||
1 | |||
2 | #line 3 "<stdout>" | ||
3 | |||
4 | #define YY_INT_ALIGNED short int | ||
5 | |||
6 | /* A lexical scanner generated by flex */ | ||
7 | |||
8 | #define yy_create_buffer perf_pmu__create_buffer | ||
9 | #define yy_delete_buffer perf_pmu__delete_buffer | ||
10 | #define yy_flex_debug perf_pmu__flex_debug | ||
11 | #define yy_init_buffer perf_pmu__init_buffer | ||
12 | #define yy_flush_buffer perf_pmu__flush_buffer | ||
13 | #define yy_load_buffer_state perf_pmu__load_buffer_state | ||
14 | #define yy_switch_to_buffer perf_pmu__switch_to_buffer | ||
15 | #define yyin perf_pmu_in | ||
16 | #define yyleng perf_pmu_leng | ||
17 | #define yylex perf_pmu_lex | ||
18 | #define yylineno perf_pmu_lineno | ||
19 | #define yyout perf_pmu_out | ||
20 | #define yyrestart perf_pmu_restart | ||
21 | #define yytext perf_pmu_text | ||
22 | #define yywrap perf_pmu_wrap | ||
23 | #define yyalloc perf_pmu_alloc | ||
24 | #define yyrealloc perf_pmu_realloc | ||
25 | #define yyfree perf_pmu_free | ||
26 | |||
27 | #define FLEX_SCANNER | ||
28 | #define YY_FLEX_MAJOR_VERSION 2 | ||
29 | #define YY_FLEX_MINOR_VERSION 5 | ||
30 | #define YY_FLEX_SUBMINOR_VERSION 35 | ||
31 | #if YY_FLEX_SUBMINOR_VERSION > 0 | ||
32 | #define FLEX_BETA | ||
33 | #endif | ||
34 | |||
35 | /* First, we deal with platform-specific or compiler-specific issues. */ | ||
36 | |||
37 | /* begin standard C headers. */ | ||
38 | #include <stdio.h> | ||
39 | #include <string.h> | ||
40 | #include <errno.h> | ||
41 | #include <stdlib.h> | ||
42 | |||
43 | /* end standard C headers. */ | ||
44 | |||
45 | /* flex integer type definitions */ | ||
46 | |||
47 | #ifndef FLEXINT_H | ||
48 | #define FLEXINT_H | ||
49 | |||
50 | /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ | ||
51 | |||
52 | #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L | ||
53 | |||
54 | /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, | ||
55 | * if you want the limit (max/min) macros for int types. | ||
56 | */ | ||
57 | #ifndef __STDC_LIMIT_MACROS | ||
58 | #define __STDC_LIMIT_MACROS 1 | ||
59 | #endif | ||
60 | |||
61 | #include <inttypes.h> | ||
62 | typedef int8_t flex_int8_t; | ||
63 | typedef uint8_t flex_uint8_t; | ||
64 | typedef int16_t flex_int16_t; | ||
65 | typedef uint16_t flex_uint16_t; | ||
66 | typedef int32_t flex_int32_t; | ||
67 | typedef uint32_t flex_uint32_t; | ||
68 | #else | ||
69 | typedef signed char flex_int8_t; | ||
70 | typedef short int flex_int16_t; | ||
71 | typedef int flex_int32_t; | ||
72 | typedef unsigned char flex_uint8_t; | ||
73 | typedef unsigned short int flex_uint16_t; | ||
74 | typedef unsigned int flex_uint32_t; | ||
75 | #endif /* ! C99 */ | ||
76 | |||
77 | /* Limits of integral types. */ | ||
78 | #ifndef INT8_MIN | ||
79 | #define INT8_MIN (-128) | ||
80 | #endif | ||
81 | #ifndef INT16_MIN | ||
82 | #define INT16_MIN (-32767-1) | ||
83 | #endif | ||
84 | #ifndef INT32_MIN | ||
85 | #define INT32_MIN (-2147483647-1) | ||
86 | #endif | ||
87 | #ifndef INT8_MAX | ||
88 | #define INT8_MAX (127) | ||
89 | #endif | ||
90 | #ifndef INT16_MAX | ||
91 | #define INT16_MAX (32767) | ||
92 | #endif | ||
93 | #ifndef INT32_MAX | ||
94 | #define INT32_MAX (2147483647) | ||
95 | #endif | ||
96 | #ifndef UINT8_MAX | ||
97 | #define UINT8_MAX (255U) | ||
98 | #endif | ||
99 | #ifndef UINT16_MAX | ||
100 | #define UINT16_MAX (65535U) | ||
101 | #endif | ||
102 | #ifndef UINT32_MAX | ||
103 | #define UINT32_MAX (4294967295U) | ||
104 | #endif | ||
105 | |||
106 | #endif /* ! FLEXINT_H */ | ||
107 | |||
108 | #ifdef __cplusplus | ||
109 | |||
110 | /* The "const" storage-class-modifier is valid. */ | ||
111 | #define YY_USE_CONST | ||
112 | |||
113 | #else /* ! __cplusplus */ | ||
114 | |||
115 | /* C99 requires __STDC__ to be defined as 1. */ | ||
116 | #if defined (__STDC__) | ||
117 | |||
118 | #define YY_USE_CONST | ||
119 | |||
120 | #endif /* defined (__STDC__) */ | ||
121 | #endif /* ! __cplusplus */ | ||
122 | |||
123 | #ifdef YY_USE_CONST | ||
124 | #define yyconst const | ||
125 | #else | ||
126 | #define yyconst | ||
127 | #endif | ||
128 | |||
129 | /* Returned upon end-of-file. */ | ||
130 | #define YY_NULL 0 | ||
131 | |||
132 | /* Promotes a possibly negative, possibly signed char to an unsigned | ||
133 | * integer for use as an array index. If the signed char is negative, | ||
134 | * we want to instead treat it as an 8-bit unsigned char, hence the | ||
135 | * double cast. | ||
136 | */ | ||
137 | #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) | ||
138 | |||
139 | /* Enter a start condition. This macro really ought to take a parameter, | ||
140 | * but we do it the disgusting crufty way forced on us by the ()-less | ||
141 | * definition of BEGIN. | ||
142 | */ | ||
143 | #define BEGIN (yy_start) = 1 + 2 * | ||
144 | |||
145 | /* Translate the current start state into a value that can be later handed | ||
146 | * to BEGIN to return to the state. The YYSTATE alias is for lex | ||
147 | * compatibility. | ||
148 | */ | ||
149 | #define YY_START (((yy_start) - 1) / 2) | ||
150 | #define YYSTATE YY_START | ||
151 | |||
152 | /* Action number for EOF rule of a given start state. */ | ||
153 | #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) | ||
154 | |||
155 | /* Special action meaning "start processing a new file". */ | ||
156 | #define YY_NEW_FILE perf_pmu_restart(perf_pmu_in ) | ||
157 | |||
158 | #define YY_END_OF_BUFFER_CHAR 0 | ||
159 | |||
160 | /* Size of default input buffer. */ | ||
161 | #ifndef YY_BUF_SIZE | ||
162 | #define YY_BUF_SIZE 16384 | ||
163 | #endif | ||
164 | |||
165 | /* The state buf must be large enough to hold one state per character in the main buffer. | ||
166 | */ | ||
167 | #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) | ||
168 | |||
169 | #ifndef YY_TYPEDEF_YY_BUFFER_STATE | ||
170 | #define YY_TYPEDEF_YY_BUFFER_STATE | ||
171 | typedef struct yy_buffer_state *YY_BUFFER_STATE; | ||
172 | #endif | ||
173 | |||
174 | extern int perf_pmu_leng; | ||
175 | |||
176 | extern FILE *perf_pmu_in, *perf_pmu_out; | ||
177 | |||
178 | #define EOB_ACT_CONTINUE_SCAN 0 | ||
179 | #define EOB_ACT_END_OF_FILE 1 | ||
180 | #define EOB_ACT_LAST_MATCH 2 | ||
181 | |||
182 | #define YY_LESS_LINENO(n) | ||
183 | |||
184 | /* Return all but the first "n" matched characters back to the input stream. */ | ||
185 | #define yyless(n) \ | ||
186 | do \ | ||
187 | { \ | ||
188 | /* Undo effects of setting up perf_pmu_text. */ \ | ||
189 | int yyless_macro_arg = (n); \ | ||
190 | YY_LESS_LINENO(yyless_macro_arg);\ | ||
191 | *yy_cp = (yy_hold_char); \ | ||
192 | YY_RESTORE_YY_MORE_OFFSET \ | ||
193 | (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ | ||
194 | YY_DO_BEFORE_ACTION; /* set up perf_pmu_text again */ \ | ||
195 | } \ | ||
196 | while ( 0 ) | ||
197 | |||
198 | #define unput(c) yyunput( c, (yytext_ptr) ) | ||
199 | |||
200 | #ifndef YY_TYPEDEF_YY_SIZE_T | ||
201 | #define YY_TYPEDEF_YY_SIZE_T | ||
202 | typedef size_t yy_size_t; | ||
203 | #endif | ||
204 | |||
205 | #ifndef YY_STRUCT_YY_BUFFER_STATE | ||
206 | #define YY_STRUCT_YY_BUFFER_STATE | ||
207 | struct yy_buffer_state | ||
208 | { | ||
209 | FILE *yy_input_file; | ||
210 | |||
211 | char *yy_ch_buf; /* input buffer */ | ||
212 | char *yy_buf_pos; /* current position in input buffer */ | ||
213 | |||
214 | /* Size of input buffer in bytes, not including room for EOB | ||
215 | * characters. | ||
216 | */ | ||
217 | yy_size_t yy_buf_size; | ||
218 | |||
219 | /* Number of characters read into yy_ch_buf, not including EOB | ||
220 | * characters. | ||
221 | */ | ||
222 | int yy_n_chars; | ||
223 | |||
224 | /* Whether we "own" the buffer - i.e., we know we created it, | ||
225 | * and can realloc() it to grow it, and should free() it to | ||
226 | * delete it. | ||
227 | */ | ||
228 | int yy_is_our_buffer; | ||
229 | |||
230 | /* Whether this is an "interactive" input source; if so, and | ||
231 | * if we're using stdio for input, then we want to use getc() | ||
232 | * instead of fread(), to make sure we stop fetching input after | ||
233 | * each newline. | ||
234 | */ | ||
235 | int yy_is_interactive; | ||
236 | |||
237 | /* Whether we're considered to be at the beginning of a line. | ||
238 | * If so, '^' rules will be active on the next match, otherwise | ||
239 | * not. | ||
240 | */ | ||
241 | int yy_at_bol; | ||
242 | |||
243 | int yy_bs_lineno; /**< The line count. */ | ||
244 | int yy_bs_column; /**< The column count. */ | ||
245 | |||
246 | /* Whether to try to fill the input buffer when we reach the | ||
247 | * end of it. | ||
248 | */ | ||
249 | int yy_fill_buffer; | ||
250 | |||
251 | int yy_buffer_status; | ||
252 | |||
253 | #define YY_BUFFER_NEW 0 | ||
254 | #define YY_BUFFER_NORMAL 1 | ||
255 | /* When an EOF's been seen but there's still some text to process | ||
256 | * then we mark the buffer as YY_EOF_PENDING, to indicate that we | ||
257 | * shouldn't try reading from the input source any more. We might | ||
258 | * still have a bunch of tokens to match, though, because of | ||
259 | * possible backing-up. | ||
260 | * | ||
261 | * When we actually see the EOF, we change the status to "new" | ||
262 | * (via perf_pmu_restart()), so that the user can continue scanning by | ||
263 | * just pointing perf_pmu_in at a new input file. | ||
264 | */ | ||
265 | #define YY_BUFFER_EOF_PENDING 2 | ||
266 | |||
267 | }; | ||
268 | #endif /* !YY_STRUCT_YY_BUFFER_STATE */ | ||
269 | |||
270 | /* Stack of input buffers. */ | ||
271 | static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ | ||
272 | static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ | ||
273 | static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ | ||
274 | |||
275 | /* We provide macros for accessing buffer states in case in the | ||
276 | * future we want to put the buffer states in a more general | ||
277 | * "scanner state". | ||
278 | * | ||
279 | * Returns the top of the stack, or NULL. | ||
280 | */ | ||
281 | #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ | ||
282 | ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ | ||
283 | : NULL) | ||
284 | |||
285 | /* Same as previous macro, but useful when we know that the buffer stack is not | ||
286 | * NULL or when we need an lvalue. For internal use only. | ||
287 | */ | ||
288 | #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] | ||
289 | |||
290 | /* yy_hold_char holds the character lost when perf_pmu_text is formed. */ | ||
291 | static char yy_hold_char; | ||
292 | static int yy_n_chars; /* number of characters read into yy_ch_buf */ | ||
293 | int perf_pmu_leng; | ||
294 | |||
295 | /* Points to current character in buffer. */ | ||
296 | static char *yy_c_buf_p = (char *) 0; | ||
297 | static int yy_init = 0; /* whether we need to initialize */ | ||
298 | static int yy_start = 0; /* start state number */ | ||
299 | |||
300 | /* Flag which is used to allow perf_pmu_wrap()'s to do buffer switches | ||
301 | * instead of setting up a fresh perf_pmu_in. A bit of a hack ... | ||
302 | */ | ||
303 | static int yy_did_buffer_switch_on_eof; | ||
304 | |||
305 | void perf_pmu_restart (FILE *input_file ); | ||
306 | void perf_pmu__switch_to_buffer (YY_BUFFER_STATE new_buffer ); | ||
307 | YY_BUFFER_STATE perf_pmu__create_buffer (FILE *file,int size ); | ||
308 | void perf_pmu__delete_buffer (YY_BUFFER_STATE b ); | ||
309 | void perf_pmu__flush_buffer (YY_BUFFER_STATE b ); | ||
310 | void perf_pmu_push_buffer_state (YY_BUFFER_STATE new_buffer ); | ||
311 | void perf_pmu_pop_buffer_state (void ); | ||
312 | |||
313 | static void perf_pmu_ensure_buffer_stack (void ); | ||
314 | static void perf_pmu__load_buffer_state (void ); | ||
315 | static void perf_pmu__init_buffer (YY_BUFFER_STATE b,FILE *file ); | ||
316 | |||
317 | #define YY_FLUSH_BUFFER perf_pmu__flush_buffer(YY_CURRENT_BUFFER ) | ||
318 | |||
319 | YY_BUFFER_STATE perf_pmu__scan_buffer (char *base,yy_size_t size ); | ||
320 | YY_BUFFER_STATE perf_pmu__scan_string (yyconst char *yy_str ); | ||
321 | YY_BUFFER_STATE perf_pmu__scan_bytes (yyconst char *bytes,int len ); | ||
322 | |||
323 | void *perf_pmu_alloc (yy_size_t ); | ||
324 | void *perf_pmu_realloc (void *,yy_size_t ); | ||
325 | void perf_pmu_free (void * ); | ||
326 | |||
327 | #define yy_new_buffer perf_pmu__create_buffer | ||
328 | |||
329 | #define yy_set_interactive(is_interactive) \ | ||
330 | { \ | ||
331 | if ( ! YY_CURRENT_BUFFER ){ \ | ||
332 | perf_pmu_ensure_buffer_stack (); \ | ||
333 | YY_CURRENT_BUFFER_LVALUE = \ | ||
334 | perf_pmu__create_buffer(perf_pmu_in,YY_BUF_SIZE ); \ | ||
335 | } \ | ||
336 | YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ | ||
337 | } | ||
338 | |||
339 | #define yy_set_bol(at_bol) \ | ||
340 | { \ | ||
341 | if ( ! YY_CURRENT_BUFFER ){\ | ||
342 | perf_pmu_ensure_buffer_stack (); \ | ||
343 | YY_CURRENT_BUFFER_LVALUE = \ | ||
344 | perf_pmu__create_buffer(perf_pmu_in,YY_BUF_SIZE ); \ | ||
345 | } \ | ||
346 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ | ||
347 | } | ||
348 | |||
349 | #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) | ||
350 | |||
351 | /* Begin user sect3 */ | ||
352 | |||
353 | typedef unsigned char YY_CHAR; | ||
354 | |||
355 | FILE *perf_pmu_in = (FILE *) 0, *perf_pmu_out = (FILE *) 0; | ||
356 | |||
357 | typedef int yy_state_type; | ||
358 | |||
359 | extern int perf_pmu_lineno; | ||
360 | |||
361 | int perf_pmu_lineno = 1; | ||
362 | |||
363 | extern char *perf_pmu_text; | ||
364 | #define yytext_ptr perf_pmu_text | ||
365 | |||
366 | static yy_state_type yy_get_previous_state (void ); | ||
367 | static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); | ||
368 | static int yy_get_next_buffer (void ); | ||
369 | static void yy_fatal_error (yyconst char msg[] ); | ||
370 | |||
371 | /* Done after the current pattern has been matched and before the | ||
372 | * corresponding action - sets up perf_pmu_text. | ||
373 | */ | ||
374 | #define YY_DO_BEFORE_ACTION \ | ||
375 | (yytext_ptr) = yy_bp; \ | ||
376 | perf_pmu_leng = (size_t) (yy_cp - yy_bp); \ | ||
377 | (yy_hold_char) = *yy_cp; \ | ||
378 | *yy_cp = '\0'; \ | ||
379 | (yy_c_buf_p) = yy_cp; | ||
380 | |||
381 | #define YY_NUM_RULES 10 | ||
382 | #define YY_END_OF_BUFFER 11 | ||
383 | /* This struct is not used in this scanner, | ||
384 | but its presence is necessary. */ | ||
385 | struct yy_trans_info | ||
386 | { | ||
387 | flex_int32_t yy_verify; | ||
388 | flex_int32_t yy_nxt; | ||
389 | }; | ||
390 | static yyconst flex_int16_t yy_accept[20] = | ||
391 | { 0, | ||
392 | 0, 0, 11, 8, 9, 7, 5, 1, 6, 8, | ||
393 | 1, 0, 0, 0, 0, 2, 3, 4, 0 | ||
394 | } ; | ||
395 | |||
396 | static yyconst flex_int32_t yy_ec[256] = | ||
397 | { 0, | ||
398 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, | ||
399 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
400 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
401 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
402 | 1, 1, 1, 3, 4, 1, 1, 5, 6, 7, | ||
403 | 5, 5, 5, 5, 5, 5, 5, 8, 1, 1, | ||
404 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
405 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
406 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
407 | 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, | ||
408 | |||
409 | 1, 10, 11, 1, 12, 1, 1, 1, 1, 13, | ||
410 | 14, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
411 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
412 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
413 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
414 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
415 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
416 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
417 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
418 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
419 | |||
420 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
421 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
422 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
423 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
424 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
425 | 1, 1, 1, 1, 1 | ||
426 | } ; | ||
427 | |||
428 | static yyconst flex_int32_t yy_meta[15] = | ||
429 | { 0, | ||
430 | 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, | ||
431 | 1, 1, 1, 1 | ||
432 | } ; | ||
433 | |||
434 | static yyconst flex_int16_t yy_base[21] = | ||
435 | { 0, | ||
436 | 0, 0, 23, 24, 24, 24, 24, 0, 24, 8, | ||
437 | 0, 8, 10, 7, 7, 9, 24, 24, 24, 15 | ||
438 | } ; | ||
439 | |||
440 | static yyconst flex_int16_t yy_def[21] = | ||
441 | { 0, | ||
442 | 19, 1, 19, 19, 19, 19, 19, 20, 19, 19, | ||
443 | 20, 19, 19, 19, 19, 19, 19, 19, 0, 19 | ||
444 | } ; | ||
445 | |||
446 | static yyconst flex_int16_t yy_nxt[39] = | ||
447 | { 0, | ||
448 | 4, 5, 6, 7, 8, 8, 8, 9, 10, 4, | ||
449 | 4, 4, 4, 4, 17, 18, 11, 16, 15, 14, | ||
450 | 13, 12, 19, 3, 19, 19, 19, 19, 19, 19, | ||
451 | 19, 19, 19, 19, 19, 19, 19, 19 | ||
452 | } ; | ||
453 | |||
454 | static yyconst flex_int16_t yy_chk[39] = | ||
455 | { 0, | ||
456 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
457 | 1, 1, 1, 1, 16, 16, 20, 15, 14, 13, | ||
458 | 12, 10, 3, 19, 19, 19, 19, 19, 19, 19, | ||
459 | 19, 19, 19, 19, 19, 19, 19, 19 | ||
460 | } ; | ||
461 | |||
462 | static yy_state_type yy_last_accepting_state; | ||
463 | static char *yy_last_accepting_cpos; | ||
464 | |||
465 | extern int perf_pmu__flex_debug; | ||
466 | int perf_pmu__flex_debug = 0; | ||
467 | |||
468 | /* The intent behind this definition is that it'll catch | ||
469 | * any uses of REJECT which flex missed. | ||
470 | */ | ||
471 | #define REJECT reject_used_but_not_detected | ||
472 | #define yymore() yymore_used_but_not_detected | ||
473 | #define YY_MORE_ADJ 0 | ||
474 | #define YY_RESTORE_YY_MORE_OFFSET | ||
475 | char *perf_pmu_text; | ||
476 | #line 1 "util/pmu.l" | ||
477 | #line 4 "util/pmu.l" | ||
478 | #include <stdlib.h> | ||
479 | #include <linux/bitops.h> | ||
480 | #include "pmu.h" | ||
481 | #include "pmu-bison.h" | ||
482 | |||
483 | static int value(int base) | ||
484 | { | ||
485 | long num; | ||
486 | |||
487 | errno = 0; | ||
488 | num = strtoul(perf_pmu_text, NULL, base); | ||
489 | if (errno) | ||
490 | return PP_ERROR; | ||
491 | |||
492 | perf_pmu_lval.num = num; | ||
493 | return PP_VALUE; | ||
494 | } | ||
495 | |||
496 | #line 497 "<stdout>" | ||
497 | |||
498 | #define INITIAL 0 | ||
499 | |||
500 | #ifndef YY_NO_UNISTD_H | ||
501 | /* Special case for "unistd.h", since it is non-ANSI. We include it way | ||
502 | * down here because we want the user's section 1 to have been scanned first. | ||
503 | * The user has a chance to override it with an option. | ||
504 | */ | ||
505 | #include <unistd.h> | ||
506 | #endif | ||
507 | |||
508 | #ifndef YY_EXTRA_TYPE | ||
509 | #define YY_EXTRA_TYPE void * | ||
510 | #endif | ||
511 | |||
512 | static int yy_init_globals (void ); | ||
513 | |||
514 | /* Accessor methods to globals. | ||
515 | These are made visible to non-reentrant scanners for convenience. */ | ||
516 | |||
517 | int perf_pmu_lex_destroy (void ); | ||
518 | |||
519 | int perf_pmu_get_debug (void ); | ||
520 | |||
521 | void perf_pmu_set_debug (int debug_flag ); | ||
522 | |||
523 | YY_EXTRA_TYPE perf_pmu_get_extra (void ); | ||
524 | |||
525 | void perf_pmu_set_extra (YY_EXTRA_TYPE user_defined ); | ||
526 | |||
527 | FILE *perf_pmu_get_in (void ); | ||
528 | |||
529 | void perf_pmu_set_in (FILE * in_str ); | ||
530 | |||
531 | FILE *perf_pmu_get_out (void ); | ||
532 | |||
533 | void perf_pmu_set_out (FILE * out_str ); | ||
534 | |||
535 | int perf_pmu_get_leng (void ); | ||
536 | |||
537 | char *perf_pmu_get_text (void ); | ||
538 | |||
539 | int perf_pmu_get_lineno (void ); | ||
540 | |||
541 | void perf_pmu_set_lineno (int line_number ); | ||
542 | |||
543 | /* Macros after this point can all be overridden by user definitions in | ||
544 | * section 1. | ||
545 | */ | ||
546 | |||
547 | #ifndef YY_SKIP_YYWRAP | ||
548 | #ifdef __cplusplus | ||
549 | extern "C" int perf_pmu_wrap (void ); | ||
550 | #else | ||
551 | extern int perf_pmu_wrap (void ); | ||
552 | #endif | ||
553 | #endif | ||
554 | |||
555 | static void yyunput (int c,char *buf_ptr ); | ||
556 | |||
557 | #ifndef yytext_ptr | ||
558 | static void yy_flex_strncpy (char *,yyconst char *,int ); | ||
559 | #endif | ||
560 | |||
561 | #ifdef YY_NEED_STRLEN | ||
562 | static int yy_flex_strlen (yyconst char * ); | ||
563 | #endif | ||
564 | |||
565 | #ifndef YY_NO_INPUT | ||
566 | |||
567 | #ifdef __cplusplus | ||
568 | static int yyinput (void ); | ||
569 | #else | ||
570 | static int input (void ); | ||
571 | #endif | ||
572 | |||
573 | #endif | ||
574 | |||
575 | /* Amount of stuff to slurp up with each read. */ | ||
576 | #ifndef YY_READ_BUF_SIZE | ||
577 | #define YY_READ_BUF_SIZE 8192 | ||
578 | #endif | ||
579 | |||
580 | /* Copy whatever the last rule matched to the standard output. */ | ||
581 | #ifndef ECHO | ||
582 | /* This used to be an fputs(), but since the string might contain NUL's, | ||
583 | * we now use fwrite(). | ||
584 | */ | ||
585 | #define ECHO do { if (fwrite( perf_pmu_text, perf_pmu_leng, 1, perf_pmu_out )) {} } while (0) | ||
586 | #endif | ||
587 | |||
588 | /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, | ||
589 | * is returned in "result". | ||
590 | */ | ||
591 | #ifndef YY_INPUT | ||
592 | #define YY_INPUT(buf,result,max_size) \ | ||
593 | if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ | ||
594 | { \ | ||
595 | int c = '*'; \ | ||
596 | unsigned n; \ | ||
597 | for ( n = 0; n < max_size && \ | ||
598 | (c = getc( perf_pmu_in )) != EOF && c != '\n'; ++n ) \ | ||
599 | buf[n] = (char) c; \ | ||
600 | if ( c == '\n' ) \ | ||
601 | buf[n++] = (char) c; \ | ||
602 | if ( c == EOF && ferror( perf_pmu_in ) ) \ | ||
603 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ | ||
604 | result = n; \ | ||
605 | } \ | ||
606 | else \ | ||
607 | { \ | ||
608 | errno=0; \ | ||
609 | while ( (result = fread(buf, 1, max_size, perf_pmu_in))==0 && ferror(perf_pmu_in)) \ | ||
610 | { \ | ||
611 | if( errno != EINTR) \ | ||
612 | { \ | ||
613 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ | ||
614 | break; \ | ||
615 | } \ | ||
616 | errno=0; \ | ||
617 | clearerr(perf_pmu_in); \ | ||
618 | } \ | ||
619 | }\ | ||
620 | \ | ||
621 | |||
622 | #endif | ||
623 | |||
624 | /* No semi-colon after return; correct usage is to write "yyterminate();" - | ||
625 | * we don't want an extra ';' after the "return" because that will cause | ||
626 | * some compilers to complain about unreachable statements. | ||
627 | */ | ||
628 | #ifndef yyterminate | ||
629 | #define yyterminate() return YY_NULL | ||
630 | #endif | ||
631 | |||
632 | /* Number of entries by which start-condition stack grows. */ | ||
633 | #ifndef YY_START_STACK_INCR | ||
634 | #define YY_START_STACK_INCR 25 | ||
635 | #endif | ||
636 | |||
637 | /* Report a fatal error. */ | ||
638 | #ifndef YY_FATAL_ERROR | ||
639 | #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) | ||
640 | #endif | ||
641 | |||
642 | /* end tables serialization structures and prototypes */ | ||
643 | |||
644 | /* Default declaration of generated scanner - a define so the user can | ||
645 | * easily add parameters. | ||
646 | */ | ||
647 | #ifndef YY_DECL | ||
648 | #define YY_DECL_IS_OURS 1 | ||
649 | |||
650 | extern int perf_pmu_lex (void); | ||
651 | |||
652 | #define YY_DECL int perf_pmu_lex (void) | ||
653 | #endif /* !YY_DECL */ | ||
654 | |||
655 | /* Code executed at the beginning of each rule, after perf_pmu_text and perf_pmu_leng | ||
656 | * have been set up. | ||
657 | */ | ||
658 | #ifndef YY_USER_ACTION | ||
659 | #define YY_USER_ACTION | ||
660 | #endif | ||
661 | |||
662 | /* Code executed at the end of each rule. */ | ||
663 | #ifndef YY_BREAK | ||
664 | #define YY_BREAK break; | ||
665 | #endif | ||
666 | |||
667 | #define YY_RULE_SETUP \ | ||
668 | YY_USER_ACTION | ||
669 | |||
670 | /** The main scanner function which does all the work. | ||
671 | */ | ||
672 | YY_DECL | ||
673 | { | ||
674 | register yy_state_type yy_current_state; | ||
675 | register char *yy_cp, *yy_bp; | ||
676 | register int yy_act; | ||
677 | |||
678 | #line 26 "util/pmu.l" | ||
679 | |||
680 | |||
681 | #line 682 "<stdout>" | ||
682 | |||
683 | if ( !(yy_init) ) | ||
684 | { | ||
685 | (yy_init) = 1; | ||
686 | |||
687 | #ifdef YY_USER_INIT | ||
688 | YY_USER_INIT; | ||
689 | #endif | ||
690 | |||
691 | if ( ! (yy_start) ) | ||
692 | (yy_start) = 1; /* first start state */ | ||
693 | |||
694 | if ( ! perf_pmu_in ) | ||
695 | perf_pmu_in = stdin; | ||
696 | |||
697 | if ( ! perf_pmu_out ) | ||
698 | perf_pmu_out = stdout; | ||
699 | |||
700 | if ( ! YY_CURRENT_BUFFER ) { | ||
701 | perf_pmu_ensure_buffer_stack (); | ||
702 | YY_CURRENT_BUFFER_LVALUE = | ||
703 | perf_pmu__create_buffer(perf_pmu_in,YY_BUF_SIZE ); | ||
704 | } | ||
705 | |||
706 | perf_pmu__load_buffer_state( ); | ||
707 | } | ||
708 | |||
709 | while ( 1 ) /* loops until end-of-file is reached */ | ||
710 | { | ||
711 | yy_cp = (yy_c_buf_p); | ||
712 | |||
713 | /* Support of perf_pmu_text. */ | ||
714 | *yy_cp = (yy_hold_char); | ||
715 | |||
716 | /* yy_bp points to the position in yy_ch_buf of the start of | ||
717 | * the current run. | ||
718 | */ | ||
719 | yy_bp = yy_cp; | ||
720 | |||
721 | yy_current_state = (yy_start); | ||
722 | yy_match: | ||
723 | do | ||
724 | { | ||
725 | register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; | ||
726 | if ( yy_accept[yy_current_state] ) | ||
727 | { | ||
728 | (yy_last_accepting_state) = yy_current_state; | ||
729 | (yy_last_accepting_cpos) = yy_cp; | ||
730 | } | ||
731 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | ||
732 | { | ||
733 | yy_current_state = (int) yy_def[yy_current_state]; | ||
734 | if ( yy_current_state >= 20 ) | ||
735 | yy_c = yy_meta[(unsigned int) yy_c]; | ||
736 | } | ||
737 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | ||
738 | ++yy_cp; | ||
739 | } | ||
740 | while ( yy_base[yy_current_state] != 24 ); | ||
741 | |||
742 | yy_find_action: | ||
743 | yy_act = yy_accept[yy_current_state]; | ||
744 | if ( yy_act == 0 ) | ||
745 | { /* have to back up */ | ||
746 | yy_cp = (yy_last_accepting_cpos); | ||
747 | yy_current_state = (yy_last_accepting_state); | ||
748 | yy_act = yy_accept[yy_current_state]; | ||
749 | } | ||
750 | |||
751 | YY_DO_BEFORE_ACTION; | ||
752 | |||
753 | do_action: /* This label is used only to access EOF actions. */ | ||
754 | |||
755 | switch ( yy_act ) | ||
756 | { /* beginning of action switch */ | ||
757 | case 0: /* must back up */ | ||
758 | /* undo the effects of YY_DO_BEFORE_ACTION */ | ||
759 | *yy_cp = (yy_hold_char); | ||
760 | yy_cp = (yy_last_accepting_cpos); | ||
761 | yy_current_state = (yy_last_accepting_state); | ||
762 | goto yy_find_action; | ||
763 | |||
764 | case 1: | ||
765 | YY_RULE_SETUP | ||
766 | #line 28 "util/pmu.l" | ||
767 | { return value(10); } | ||
768 | YY_BREAK | ||
769 | case 2: | ||
770 | YY_RULE_SETUP | ||
771 | #line 29 "util/pmu.l" | ||
772 | { return PP_CONFIG; } | ||
773 | YY_BREAK | ||
774 | case 3: | ||
775 | YY_RULE_SETUP | ||
776 | #line 30 "util/pmu.l" | ||
777 | { return PP_CONFIG1; } | ||
778 | YY_BREAK | ||
779 | case 4: | ||
780 | YY_RULE_SETUP | ||
781 | #line 31 "util/pmu.l" | ||
782 | { return PP_CONFIG2; } | ||
783 | YY_BREAK | ||
784 | case 5: | ||
785 | YY_RULE_SETUP | ||
786 | #line 32 "util/pmu.l" | ||
787 | { return '-'; } | ||
788 | YY_BREAK | ||
789 | case 6: | ||
790 | YY_RULE_SETUP | ||
791 | #line 33 "util/pmu.l" | ||
792 | { return ':'; } | ||
793 | YY_BREAK | ||
794 | case 7: | ||
795 | YY_RULE_SETUP | ||
796 | #line 34 "util/pmu.l" | ||
797 | { return ','; } | ||
798 | YY_BREAK | ||
799 | case 8: | ||
800 | YY_RULE_SETUP | ||
801 | #line 35 "util/pmu.l" | ||
802 | { ; } | ||
803 | YY_BREAK | ||
804 | case 9: | ||
805 | /* rule 9 can match eol */ | ||
806 | YY_RULE_SETUP | ||
807 | #line 36 "util/pmu.l" | ||
808 | { ; } | ||
809 | YY_BREAK | ||
810 | case 10: | ||
811 | YY_RULE_SETUP | ||
812 | #line 38 "util/pmu.l" | ||
813 | ECHO; | ||
814 | YY_BREAK | ||
815 | #line 816 "<stdout>" | ||
816 | case YY_STATE_EOF(INITIAL): | ||
817 | yyterminate(); | ||
818 | |||
819 | case YY_END_OF_BUFFER: | ||
820 | { | ||
821 | /* Amount of text matched not including the EOB char. */ | ||
822 | int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; | ||
823 | |||
824 | /* Undo the effects of YY_DO_BEFORE_ACTION. */ | ||
825 | *yy_cp = (yy_hold_char); | ||
826 | YY_RESTORE_YY_MORE_OFFSET | ||
827 | |||
828 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) | ||
829 | { | ||
830 | /* We're scanning a new file or input source. It's | ||
831 | * possible that this happened because the user | ||
832 | * just pointed perf_pmu_in at a new source and called | ||
833 | * perf_pmu_lex(). If so, then we have to assure | ||
834 | * consistency between YY_CURRENT_BUFFER and our | ||
835 | * globals. Here is the right place to do so, because | ||
836 | * this is the first action (other than possibly a | ||
837 | * back-up) that will match for the new input source. | ||
838 | */ | ||
839 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; | ||
840 | YY_CURRENT_BUFFER_LVALUE->yy_input_file = perf_pmu_in; | ||
841 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; | ||
842 | } | ||
843 | |||
844 | /* Note that here we test for yy_c_buf_p "<=" to the position | ||
845 | * of the first EOB in the buffer, since yy_c_buf_p will | ||
846 | * already have been incremented past the NUL character | ||
847 | * (since all states make transitions on EOB to the | ||
848 | * end-of-buffer state). Contrast this with the test | ||
849 | * in input(). | ||
850 | */ | ||
851 | if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) | ||
852 | { /* This was really a NUL. */ | ||
853 | yy_state_type yy_next_state; | ||
854 | |||
855 | (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; | ||
856 | |||
857 | yy_current_state = yy_get_previous_state( ); | ||
858 | |||
859 | /* Okay, we're now positioned to make the NUL | ||
860 | * transition. We couldn't have | ||
861 | * yy_get_previous_state() go ahead and do it | ||
862 | * for us because it doesn't know how to deal | ||
863 | * with the possibility of jamming (and we don't | ||
864 | * want to build jamming into it because then it | ||
865 | * will run more slowly). | ||
866 | */ | ||
867 | |||
868 | yy_next_state = yy_try_NUL_trans( yy_current_state ); | ||
869 | |||
870 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | ||
871 | |||
872 | if ( yy_next_state ) | ||
873 | { | ||
874 | /* Consume the NUL. */ | ||
875 | yy_cp = ++(yy_c_buf_p); | ||
876 | yy_current_state = yy_next_state; | ||
877 | goto yy_match; | ||
878 | } | ||
879 | |||
880 | else | ||
881 | { | ||
882 | yy_cp = (yy_c_buf_p); | ||
883 | goto yy_find_action; | ||
884 | } | ||
885 | } | ||
886 | |||
887 | else switch ( yy_get_next_buffer( ) ) | ||
888 | { | ||
889 | case EOB_ACT_END_OF_FILE: | ||
890 | { | ||
891 | (yy_did_buffer_switch_on_eof) = 0; | ||
892 | |||
893 | if ( perf_pmu_wrap( ) ) | ||
894 | { | ||
895 | /* Note: because we've taken care in | ||
896 | * yy_get_next_buffer() to have set up | ||
897 | * perf_pmu_text, we can now set up | ||
898 | * yy_c_buf_p so that if some total | ||
899 | * hoser (like flex itself) wants to | ||
900 | * call the scanner after we return the | ||
901 | * YY_NULL, it'll still work - another | ||
902 | * YY_NULL will get returned. | ||
903 | */ | ||
904 | (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; | ||
905 | |||
906 | yy_act = YY_STATE_EOF(YY_START); | ||
907 | goto do_action; | ||
908 | } | ||
909 | |||
910 | else | ||
911 | { | ||
912 | if ( ! (yy_did_buffer_switch_on_eof) ) | ||
913 | YY_NEW_FILE; | ||
914 | } | ||
915 | break; | ||
916 | } | ||
917 | |||
918 | case EOB_ACT_CONTINUE_SCAN: | ||
919 | (yy_c_buf_p) = | ||
920 | (yytext_ptr) + yy_amount_of_matched_text; | ||
921 | |||
922 | yy_current_state = yy_get_previous_state( ); | ||
923 | |||
924 | yy_cp = (yy_c_buf_p); | ||
925 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | ||
926 | goto yy_match; | ||
927 | |||
928 | case EOB_ACT_LAST_MATCH: | ||
929 | (yy_c_buf_p) = | ||
930 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; | ||
931 | |||
932 | yy_current_state = yy_get_previous_state( ); | ||
933 | |||
934 | yy_cp = (yy_c_buf_p); | ||
935 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | ||
936 | goto yy_find_action; | ||
937 | } | ||
938 | break; | ||
939 | } | ||
940 | |||
941 | default: | ||
942 | YY_FATAL_ERROR( | ||
943 | "fatal flex scanner internal error--no action found" ); | ||
944 | } /* end of action switch */ | ||
945 | } /* end of scanning one token */ | ||
946 | } /* end of perf_pmu_lex */ | ||
947 | |||
948 | /* yy_get_next_buffer - try to read in a new buffer | ||
949 | * | ||
950 | * Returns a code representing an action: | ||
951 | * EOB_ACT_LAST_MATCH - | ||
952 | * EOB_ACT_CONTINUE_SCAN - continue scanning from current position | ||
953 | * EOB_ACT_END_OF_FILE - end of file | ||
954 | */ | ||
955 | static int yy_get_next_buffer (void) | ||
956 | { | ||
957 | register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; | ||
958 | register char *source = (yytext_ptr); | ||
959 | register int number_to_move, i; | ||
960 | int ret_val; | ||
961 | |||
962 | if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) | ||
963 | YY_FATAL_ERROR( | ||
964 | "fatal flex scanner internal error--end of buffer missed" ); | ||
965 | |||
966 | if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) | ||
967 | { /* Don't try to fill the buffer, so this is an EOF. */ | ||
968 | if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) | ||
969 | { | ||
970 | /* We matched a single character, the EOB, so | ||
971 | * treat this as a final EOF. | ||
972 | */ | ||
973 | return EOB_ACT_END_OF_FILE; | ||
974 | } | ||
975 | |||
976 | else | ||
977 | { | ||
978 | /* We matched some text prior to the EOB, first | ||
979 | * process it. | ||
980 | */ | ||
981 | return EOB_ACT_LAST_MATCH; | ||
982 | } | ||
983 | } | ||
984 | |||
985 | /* Try to read more data. */ | ||
986 | |||
987 | /* First move last chars to start of buffer. */ | ||
988 | number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; | ||
989 | |||
990 | for ( i = 0; i < number_to_move; ++i ) | ||
991 | *(dest++) = *(source++); | ||
992 | |||
993 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) | ||
994 | /* don't do the read, it's not guaranteed to return an EOF, | ||
995 | * just force an EOF | ||
996 | */ | ||
997 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; | ||
998 | |||
999 | else | ||
1000 | { | ||
1001 | int num_to_read = | ||
1002 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; | ||
1003 | |||
1004 | while ( num_to_read <= 0 ) | ||
1005 | { /* Not enough room in the buffer - grow it. */ | ||
1006 | |||
1007 | /* just a shorter name for the current buffer */ | ||
1008 | YY_BUFFER_STATE b = YY_CURRENT_BUFFER; | ||
1009 | |||
1010 | int yy_c_buf_p_offset = | ||
1011 | (int) ((yy_c_buf_p) - b->yy_ch_buf); | ||
1012 | |||
1013 | if ( b->yy_is_our_buffer ) | ||
1014 | { | ||
1015 | int new_size = b->yy_buf_size * 2; | ||
1016 | |||
1017 | if ( new_size <= 0 ) | ||
1018 | b->yy_buf_size += b->yy_buf_size / 8; | ||
1019 | else | ||
1020 | b->yy_buf_size *= 2; | ||
1021 | |||
1022 | b->yy_ch_buf = (char *) | ||
1023 | /* Include room in for 2 EOB chars. */ | ||
1024 | perf_pmu_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); | ||
1025 | } | ||
1026 | else | ||
1027 | /* Can't grow it, we don't own it. */ | ||
1028 | b->yy_ch_buf = 0; | ||
1029 | |||
1030 | if ( ! b->yy_ch_buf ) | ||
1031 | YY_FATAL_ERROR( | ||
1032 | "fatal error - scanner input buffer overflow" ); | ||
1033 | |||
1034 | (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; | ||
1035 | |||
1036 | num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - | ||
1037 | number_to_move - 1; | ||
1038 | |||
1039 | } | ||
1040 | |||
1041 | if ( num_to_read > YY_READ_BUF_SIZE ) | ||
1042 | num_to_read = YY_READ_BUF_SIZE; | ||
1043 | |||
1044 | /* Read in more data. */ | ||
1045 | YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), | ||
1046 | (yy_n_chars), (size_t) num_to_read ); | ||
1047 | |||
1048 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | ||
1049 | } | ||
1050 | |||
1051 | if ( (yy_n_chars) == 0 ) | ||
1052 | { | ||
1053 | if ( number_to_move == YY_MORE_ADJ ) | ||
1054 | { | ||
1055 | ret_val = EOB_ACT_END_OF_FILE; | ||
1056 | perf_pmu_restart(perf_pmu_in ); | ||
1057 | } | ||
1058 | |||
1059 | else | ||
1060 | { | ||
1061 | ret_val = EOB_ACT_LAST_MATCH; | ||
1062 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = | ||
1063 | YY_BUFFER_EOF_PENDING; | ||
1064 | } | ||
1065 | } | ||
1066 | |||
1067 | else | ||
1068 | ret_val = EOB_ACT_CONTINUE_SCAN; | ||
1069 | |||
1070 | if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { | ||
1071 | /* Extend the array by 50%, plus the number we really need. */ | ||
1072 | yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); | ||
1073 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) perf_pmu_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); | ||
1074 | if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) | ||
1075 | YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); | ||
1076 | } | ||
1077 | |||
1078 | (yy_n_chars) += number_to_move; | ||
1079 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; | ||
1080 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; | ||
1081 | |||
1082 | (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; | ||
1083 | |||
1084 | return ret_val; | ||
1085 | } | ||
1086 | |||
1087 | /* yy_get_previous_state - get the state just before the EOB char was reached */ | ||
1088 | |||
1089 | static yy_state_type yy_get_previous_state (void) | ||
1090 | { | ||
1091 | register yy_state_type yy_current_state; | ||
1092 | register char *yy_cp; | ||
1093 | |||
1094 | yy_current_state = (yy_start); | ||
1095 | |||
1096 | for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) | ||
1097 | { | ||
1098 | register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); | ||
1099 | if ( yy_accept[yy_current_state] ) | ||
1100 | { | ||
1101 | (yy_last_accepting_state) = yy_current_state; | ||
1102 | (yy_last_accepting_cpos) = yy_cp; | ||
1103 | } | ||
1104 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | ||
1105 | { | ||
1106 | yy_current_state = (int) yy_def[yy_current_state]; | ||
1107 | if ( yy_current_state >= 20 ) | ||
1108 | yy_c = yy_meta[(unsigned int) yy_c]; | ||
1109 | } | ||
1110 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | ||
1111 | } | ||
1112 | |||
1113 | return yy_current_state; | ||
1114 | } | ||
1115 | |||
1116 | /* yy_try_NUL_trans - try to make a transition on the NUL character | ||
1117 | * | ||
1118 | * synopsis | ||
1119 | * next_state = yy_try_NUL_trans( current_state ); | ||
1120 | */ | ||
1121 | static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) | ||
1122 | { | ||
1123 | register int yy_is_jam; | ||
1124 | register char *yy_cp = (yy_c_buf_p); | ||
1125 | |||
1126 | register YY_CHAR yy_c = 1; | ||
1127 | if ( yy_accept[yy_current_state] ) | ||
1128 | { | ||
1129 | (yy_last_accepting_state) = yy_current_state; | ||
1130 | (yy_last_accepting_cpos) = yy_cp; | ||
1131 | } | ||
1132 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | ||
1133 | { | ||
1134 | yy_current_state = (int) yy_def[yy_current_state]; | ||
1135 | if ( yy_current_state >= 20 ) | ||
1136 | yy_c = yy_meta[(unsigned int) yy_c]; | ||
1137 | } | ||
1138 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | ||
1139 | yy_is_jam = (yy_current_state == 19); | ||
1140 | |||
1141 | return yy_is_jam ? 0 : yy_current_state; | ||
1142 | } | ||
1143 | |||
1144 | static void yyunput (int c, register char * yy_bp ) | ||
1145 | { | ||
1146 | register char *yy_cp; | ||
1147 | |||
1148 | yy_cp = (yy_c_buf_p); | ||
1149 | |||
1150 | /* undo effects of setting up perf_pmu_text */ | ||
1151 | *yy_cp = (yy_hold_char); | ||
1152 | |||
1153 | if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) | ||
1154 | { /* need to shift things up to make room */ | ||
1155 | /* +2 for EOB chars. */ | ||
1156 | register int number_to_move = (yy_n_chars) + 2; | ||
1157 | register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ | ||
1158 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; | ||
1159 | register char *source = | ||
1160 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; | ||
1161 | |||
1162 | while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) | ||
1163 | *--dest = *--source; | ||
1164 | |||
1165 | yy_cp += (int) (dest - source); | ||
1166 | yy_bp += (int) (dest - source); | ||
1167 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = | ||
1168 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; | ||
1169 | |||
1170 | if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) | ||
1171 | YY_FATAL_ERROR( "flex scanner push-back overflow" ); | ||
1172 | } | ||
1173 | |||
1174 | *--yy_cp = (char) c; | ||
1175 | |||
1176 | (yytext_ptr) = yy_bp; | ||
1177 | (yy_hold_char) = *yy_cp; | ||
1178 | (yy_c_buf_p) = yy_cp; | ||
1179 | } | ||
1180 | |||
1181 | #ifndef YY_NO_INPUT | ||
1182 | #ifdef __cplusplus | ||
1183 | static int yyinput (void) | ||
1184 | #else | ||
1185 | static int input (void) | ||
1186 | #endif | ||
1187 | |||
1188 | { | ||
1189 | int c; | ||
1190 | |||
1191 | *(yy_c_buf_p) = (yy_hold_char); | ||
1192 | |||
1193 | if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) | ||
1194 | { | ||
1195 | /* yy_c_buf_p now points to the character we want to return. | ||
1196 | * If this occurs *before* the EOB characters, then it's a | ||
1197 | * valid NUL; if not, then we've hit the end of the buffer. | ||
1198 | */ | ||
1199 | if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) | ||
1200 | /* This was really a NUL. */ | ||
1201 | *(yy_c_buf_p) = '\0'; | ||
1202 | |||
1203 | else | ||
1204 | { /* need more input */ | ||
1205 | int offset = (yy_c_buf_p) - (yytext_ptr); | ||
1206 | ++(yy_c_buf_p); | ||
1207 | |||
1208 | switch ( yy_get_next_buffer( ) ) | ||
1209 | { | ||
1210 | case EOB_ACT_LAST_MATCH: | ||
1211 | /* This happens because yy_g_n_b() | ||
1212 | * sees that we've accumulated a | ||
1213 | * token and flags that we need to | ||
1214 | * try matching the token before | ||
1215 | * proceeding. But for input(), | ||
1216 | * there's no matching to consider. | ||
1217 | * So convert the EOB_ACT_LAST_MATCH | ||
1218 | * to EOB_ACT_END_OF_FILE. | ||
1219 | */ | ||
1220 | |||
1221 | /* Reset buffer status. */ | ||
1222 | perf_pmu_restart(perf_pmu_in ); | ||
1223 | |||
1224 | /*FALLTHROUGH*/ | ||
1225 | |||
1226 | case EOB_ACT_END_OF_FILE: | ||
1227 | { | ||
1228 | if ( perf_pmu_wrap( ) ) | ||
1229 | return EOF; | ||
1230 | |||
1231 | if ( ! (yy_did_buffer_switch_on_eof) ) | ||
1232 | YY_NEW_FILE; | ||
1233 | #ifdef __cplusplus | ||
1234 | return yyinput(); | ||
1235 | #else | ||
1236 | return input(); | ||
1237 | #endif | ||
1238 | } | ||
1239 | |||
1240 | case EOB_ACT_CONTINUE_SCAN: | ||
1241 | (yy_c_buf_p) = (yytext_ptr) + offset; | ||
1242 | break; | ||
1243 | } | ||
1244 | } | ||
1245 | } | ||
1246 | |||
1247 | c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ | ||
1248 | *(yy_c_buf_p) = '\0'; /* preserve perf_pmu_text */ | ||
1249 | (yy_hold_char) = *++(yy_c_buf_p); | ||
1250 | |||
1251 | return c; | ||
1252 | } | ||
1253 | #endif /* ifndef YY_NO_INPUT */ | ||
1254 | |||
1255 | /** Immediately switch to a different input stream. | ||
1256 | * @param input_file A readable stream. | ||
1257 | * | ||
1258 | * @note This function does not reset the start condition to @c INITIAL . | ||
1259 | */ | ||
1260 | void perf_pmu_restart (FILE * input_file ) | ||
1261 | { | ||
1262 | |||
1263 | if ( ! YY_CURRENT_BUFFER ){ | ||
1264 | perf_pmu_ensure_buffer_stack (); | ||
1265 | YY_CURRENT_BUFFER_LVALUE = | ||
1266 | perf_pmu__create_buffer(perf_pmu_in,YY_BUF_SIZE ); | ||
1267 | } | ||
1268 | |||
1269 | perf_pmu__init_buffer(YY_CURRENT_BUFFER,input_file ); | ||
1270 | perf_pmu__load_buffer_state( ); | ||
1271 | } | ||
1272 | |||
1273 | /** Switch to a different input buffer. | ||
1274 | * @param new_buffer The new input buffer. | ||
1275 | * | ||
1276 | */ | ||
1277 | void perf_pmu__switch_to_buffer (YY_BUFFER_STATE new_buffer ) | ||
1278 | { | ||
1279 | |||
1280 | /* TODO. We should be able to replace this entire function body | ||
1281 | * with | ||
1282 | * perf_pmu_pop_buffer_state(); | ||
1283 | * perf_pmu_push_buffer_state(new_buffer); | ||
1284 | */ | ||
1285 | perf_pmu_ensure_buffer_stack (); | ||
1286 | if ( YY_CURRENT_BUFFER == new_buffer ) | ||
1287 | return; | ||
1288 | |||
1289 | if ( YY_CURRENT_BUFFER ) | ||
1290 | { | ||
1291 | /* Flush out information for old buffer. */ | ||
1292 | *(yy_c_buf_p) = (yy_hold_char); | ||
1293 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); | ||
1294 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | ||
1295 | } | ||
1296 | |||
1297 | YY_CURRENT_BUFFER_LVALUE = new_buffer; | ||
1298 | perf_pmu__load_buffer_state( ); | ||
1299 | |||
1300 | /* We don't actually know whether we did this switch during | ||
1301 | * EOF (perf_pmu_wrap()) processing, but the only time this flag | ||
1302 | * is looked at is after perf_pmu_wrap() is called, so it's safe | ||
1303 | * to go ahead and always set it. | ||
1304 | */ | ||
1305 | (yy_did_buffer_switch_on_eof) = 1; | ||
1306 | } | ||
1307 | |||
1308 | static void perf_pmu__load_buffer_state (void) | ||
1309 | { | ||
1310 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; | ||
1311 | (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; | ||
1312 | perf_pmu_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file; | ||
1313 | (yy_hold_char) = *(yy_c_buf_p); | ||
1314 | } | ||
1315 | |||
1316 | /** Allocate and initialize an input buffer state. | ||
1317 | * @param file A readable stream. | ||
1318 | * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. | ||
1319 | * | ||
1320 | * @return the allocated buffer state. | ||
1321 | */ | ||
1322 | YY_BUFFER_STATE perf_pmu__create_buffer (FILE * file, int size ) | ||
1323 | { | ||
1324 | YY_BUFFER_STATE b; | ||
1325 | |||
1326 | b = (YY_BUFFER_STATE) perf_pmu_alloc(sizeof( struct yy_buffer_state ) ); | ||
1327 | if ( ! b ) | ||
1328 | YY_FATAL_ERROR( "out of dynamic memory in perf_pmu__create_buffer()" ); | ||
1329 | |||
1330 | b->yy_buf_size = size; | ||
1331 | |||
1332 | /* yy_ch_buf has to be 2 characters longer than the size given because | ||
1333 | * we need to put in 2 end-of-buffer characters. | ||
1334 | */ | ||
1335 | b->yy_ch_buf = (char *) perf_pmu_alloc(b->yy_buf_size + 2 ); | ||
1336 | if ( ! b->yy_ch_buf ) | ||
1337 | YY_FATAL_ERROR( "out of dynamic memory in perf_pmu__create_buffer()" ); | ||
1338 | |||
1339 | b->yy_is_our_buffer = 1; | ||
1340 | |||
1341 | perf_pmu__init_buffer(b,file ); | ||
1342 | |||
1343 | return b; | ||
1344 | } | ||
1345 | |||
1346 | /** Destroy the buffer. | ||
1347 | * @param b a buffer created with perf_pmu__create_buffer() | ||
1348 | * | ||
1349 | */ | ||
1350 | void perf_pmu__delete_buffer (YY_BUFFER_STATE b ) | ||
1351 | { | ||
1352 | |||
1353 | if ( ! b ) | ||
1354 | return; | ||
1355 | |||
1356 | if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ | ||
1357 | YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; | ||
1358 | |||
1359 | if ( b->yy_is_our_buffer ) | ||
1360 | perf_pmu_free((void *) b->yy_ch_buf ); | ||
1361 | |||
1362 | perf_pmu_free((void *) b ); | ||
1363 | } | ||
1364 | |||
1365 | #ifndef __cplusplus | ||
1366 | extern int isatty (int ); | ||
1367 | #endif /* __cplusplus */ | ||
1368 | |||
1369 | /* Initializes or reinitializes a buffer. | ||
1370 | * This function is sometimes called more than once on the same buffer, | ||
1371 | * such as during a perf_pmu_restart() or at EOF. | ||
1372 | */ | ||
1373 | static void perf_pmu__init_buffer (YY_BUFFER_STATE b, FILE * file ) | ||
1374 | |||
1375 | { | ||
1376 | int oerrno = errno; | ||
1377 | |||
1378 | perf_pmu__flush_buffer(b ); | ||
1379 | |||
1380 | b->yy_input_file = file; | ||
1381 | b->yy_fill_buffer = 1; | ||
1382 | |||
1383 | /* If b is the current buffer, then perf_pmu__init_buffer was _probably_ | ||
1384 | * called from perf_pmu_restart() or through yy_get_next_buffer. | ||
1385 | * In that case, we don't want to reset the lineno or column. | ||
1386 | */ | ||
1387 | if (b != YY_CURRENT_BUFFER){ | ||
1388 | b->yy_bs_lineno = 1; | ||
1389 | b->yy_bs_column = 0; | ||
1390 | } | ||
1391 | |||
1392 | b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; | ||
1393 | |||
1394 | errno = oerrno; | ||
1395 | } | ||
1396 | |||
1397 | /** Discard all buffered characters. On the next scan, YY_INPUT will be called. | ||
1398 | * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. | ||
1399 | * | ||
1400 | */ | ||
1401 | void perf_pmu__flush_buffer (YY_BUFFER_STATE b ) | ||
1402 | { | ||
1403 | if ( ! b ) | ||
1404 | return; | ||
1405 | |||
1406 | b->yy_n_chars = 0; | ||
1407 | |||
1408 | /* We always need two end-of-buffer characters. The first causes | ||
1409 | * a transition to the end-of-buffer state. The second causes | ||
1410 | * a jam in that state. | ||
1411 | */ | ||
1412 | b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; | ||
1413 | b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; | ||
1414 | |||
1415 | b->yy_buf_pos = &b->yy_ch_buf[0]; | ||
1416 | |||
1417 | b->yy_at_bol = 1; | ||
1418 | b->yy_buffer_status = YY_BUFFER_NEW; | ||
1419 | |||
1420 | if ( b == YY_CURRENT_BUFFER ) | ||
1421 | perf_pmu__load_buffer_state( ); | ||
1422 | } | ||
1423 | |||
1424 | /** Pushes the new state onto the stack. The new state becomes | ||
1425 | * the current state. This function will allocate the stack | ||
1426 | * if necessary. | ||
1427 | * @param new_buffer The new state. | ||
1428 | * | ||
1429 | */ | ||
1430 | void perf_pmu_push_buffer_state (YY_BUFFER_STATE new_buffer ) | ||
1431 | { | ||
1432 | if (new_buffer == NULL) | ||
1433 | return; | ||
1434 | |||
1435 | perf_pmu_ensure_buffer_stack(); | ||
1436 | |||
1437 | /* This block is copied from perf_pmu__switch_to_buffer. */ | ||
1438 | if ( YY_CURRENT_BUFFER ) | ||
1439 | { | ||
1440 | /* Flush out information for old buffer. */ | ||
1441 | *(yy_c_buf_p) = (yy_hold_char); | ||
1442 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); | ||
1443 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | ||
1444 | } | ||
1445 | |||
1446 | /* Only push if top exists. Otherwise, replace top. */ | ||
1447 | if (YY_CURRENT_BUFFER) | ||
1448 | (yy_buffer_stack_top)++; | ||
1449 | YY_CURRENT_BUFFER_LVALUE = new_buffer; | ||
1450 | |||
1451 | /* copied from perf_pmu__switch_to_buffer. */ | ||
1452 | perf_pmu__load_buffer_state( ); | ||
1453 | (yy_did_buffer_switch_on_eof) = 1; | ||
1454 | } | ||
1455 | |||
1456 | /** Removes and deletes the top of the stack, if present. | ||
1457 | * The next element becomes the new top. | ||
1458 | * | ||
1459 | */ | ||
1460 | void perf_pmu_pop_buffer_state (void) | ||
1461 | { | ||
1462 | if (!YY_CURRENT_BUFFER) | ||
1463 | return; | ||
1464 | |||
1465 | perf_pmu__delete_buffer(YY_CURRENT_BUFFER ); | ||
1466 | YY_CURRENT_BUFFER_LVALUE = NULL; | ||
1467 | if ((yy_buffer_stack_top) > 0) | ||
1468 | --(yy_buffer_stack_top); | ||
1469 | |||
1470 | if (YY_CURRENT_BUFFER) { | ||
1471 | perf_pmu__load_buffer_state( ); | ||
1472 | (yy_did_buffer_switch_on_eof) = 1; | ||
1473 | } | ||
1474 | } | ||
1475 | |||
1476 | /* Allocates the stack if it does not exist. | ||
1477 | * Guarantees space for at least one push. | ||
1478 | */ | ||
1479 | static void perf_pmu_ensure_buffer_stack (void) | ||
1480 | { | ||
1481 | int num_to_alloc; | ||
1482 | |||
1483 | if (!(yy_buffer_stack)) { | ||
1484 | |||
1485 | /* First allocation is just for 2 elements, since we don't know if this | ||
1486 | * scanner will even need a stack. We use 2 instead of 1 to avoid an | ||
1487 | * immediate realloc on the next call. | ||
1488 | */ | ||
1489 | num_to_alloc = 1; | ||
1490 | (yy_buffer_stack) = (struct yy_buffer_state**)perf_pmu_alloc | ||
1491 | (num_to_alloc * sizeof(struct yy_buffer_state*) | ||
1492 | ); | ||
1493 | if ( ! (yy_buffer_stack) ) | ||
1494 | YY_FATAL_ERROR( "out of dynamic memory in perf_pmu_ensure_buffer_stack()" ); | ||
1495 | |||
1496 | memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); | ||
1497 | |||
1498 | (yy_buffer_stack_max) = num_to_alloc; | ||
1499 | (yy_buffer_stack_top) = 0; | ||
1500 | return; | ||
1501 | } | ||
1502 | |||
1503 | if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ | ||
1504 | |||
1505 | /* Increase the buffer to prepare for a possible push. */ | ||
1506 | int grow_size = 8 /* arbitrary grow size */; | ||
1507 | |||
1508 | num_to_alloc = (yy_buffer_stack_max) + grow_size; | ||
1509 | (yy_buffer_stack) = (struct yy_buffer_state**)perf_pmu_realloc | ||
1510 | ((yy_buffer_stack), | ||
1511 | num_to_alloc * sizeof(struct yy_buffer_state*) | ||
1512 | ); | ||
1513 | if ( ! (yy_buffer_stack) ) | ||
1514 | YY_FATAL_ERROR( "out of dynamic memory in perf_pmu_ensure_buffer_stack()" ); | ||
1515 | |||
1516 | /* zero only the new slots.*/ | ||
1517 | memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); | ||
1518 | (yy_buffer_stack_max) = num_to_alloc; | ||
1519 | } | ||
1520 | } | ||
1521 | |||
1522 | /** Setup the input buffer state to scan directly from a user-specified character buffer. | ||
1523 | * @param base the character buffer | ||
1524 | * @param size the size in bytes of the character buffer | ||
1525 | * | ||
1526 | * @return the newly allocated buffer state object. | ||
1527 | */ | ||
1528 | YY_BUFFER_STATE perf_pmu__scan_buffer (char * base, yy_size_t size ) | ||
1529 | { | ||
1530 | YY_BUFFER_STATE b; | ||
1531 | |||
1532 | if ( size < 2 || | ||
1533 | base[size-2] != YY_END_OF_BUFFER_CHAR || | ||
1534 | base[size-1] != YY_END_OF_BUFFER_CHAR ) | ||
1535 | /* They forgot to leave room for the EOB's. */ | ||
1536 | return 0; | ||
1537 | |||
1538 | b = (YY_BUFFER_STATE) perf_pmu_alloc(sizeof( struct yy_buffer_state ) ); | ||
1539 | if ( ! b ) | ||
1540 | YY_FATAL_ERROR( "out of dynamic memory in perf_pmu__scan_buffer()" ); | ||
1541 | |||
1542 | b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ | ||
1543 | b->yy_buf_pos = b->yy_ch_buf = base; | ||
1544 | b->yy_is_our_buffer = 0; | ||
1545 | b->yy_input_file = 0; | ||
1546 | b->yy_n_chars = b->yy_buf_size; | ||
1547 | b->yy_is_interactive = 0; | ||
1548 | b->yy_at_bol = 1; | ||
1549 | b->yy_fill_buffer = 0; | ||
1550 | b->yy_buffer_status = YY_BUFFER_NEW; | ||
1551 | |||
1552 | perf_pmu__switch_to_buffer(b ); | ||
1553 | |||
1554 | return b; | ||
1555 | } | ||
1556 | |||
1557 | /** Setup the input buffer state to scan a string. The next call to perf_pmu_lex() will | ||
1558 | * scan from a @e copy of @a str. | ||
1559 | * @param yystr a NUL-terminated string to scan | ||
1560 | * | ||
1561 | * @return the newly allocated buffer state object. | ||
1562 | * @note If you want to scan bytes that may contain NUL values, then use | ||
1563 | * perf_pmu__scan_bytes() instead. | ||
1564 | */ | ||
1565 | YY_BUFFER_STATE perf_pmu__scan_string (yyconst char * yystr ) | ||
1566 | { | ||
1567 | |||
1568 | return perf_pmu__scan_bytes(yystr,strlen(yystr) ); | ||
1569 | } | ||
1570 | |||
1571 | /** Setup the input buffer state to scan the given bytes. The next call to perf_pmu_lex() will | ||
1572 | * scan from a @e copy of @a bytes. | ||
1573 | * @param bytes the byte buffer to scan | ||
1574 | * @param len the number of bytes in the buffer pointed to by @a bytes. | ||
1575 | * | ||
1576 | * @return the newly allocated buffer state object. | ||
1577 | */ | ||
1578 | YY_BUFFER_STATE perf_pmu__scan_bytes (yyconst char * yybytes, int _yybytes_len ) | ||
1579 | { | ||
1580 | YY_BUFFER_STATE b; | ||
1581 | char *buf; | ||
1582 | yy_size_t n; | ||
1583 | int i; | ||
1584 | |||
1585 | /* Get memory for full buffer, including space for trailing EOB's. */ | ||
1586 | n = _yybytes_len + 2; | ||
1587 | buf = (char *) perf_pmu_alloc(n ); | ||
1588 | if ( ! buf ) | ||
1589 | YY_FATAL_ERROR( "out of dynamic memory in perf_pmu__scan_bytes()" ); | ||
1590 | |||
1591 | for ( i = 0; i < _yybytes_len; ++i ) | ||
1592 | buf[i] = yybytes[i]; | ||
1593 | |||
1594 | buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; | ||
1595 | |||
1596 | b = perf_pmu__scan_buffer(buf,n ); | ||
1597 | if ( ! b ) | ||
1598 | YY_FATAL_ERROR( "bad buffer in perf_pmu__scan_bytes()" ); | ||
1599 | |||
1600 | /* It's okay to grow etc. this buffer, and we should throw it | ||
1601 | * away when we're done. | ||
1602 | */ | ||
1603 | b->yy_is_our_buffer = 1; | ||
1604 | |||
1605 | return b; | ||
1606 | } | ||
1607 | |||
1608 | #ifndef YY_EXIT_FAILURE | ||
1609 | #define YY_EXIT_FAILURE 2 | ||
1610 | #endif | ||
1611 | |||
1612 | static void yy_fatal_error (yyconst char* msg ) | ||
1613 | { | ||
1614 | (void) fprintf( stderr, "%s\n", msg ); | ||
1615 | exit( YY_EXIT_FAILURE ); | ||
1616 | } | ||
1617 | |||
1618 | /* Redefine yyless() so it works in section 3 code. */ | ||
1619 | |||
1620 | #undef yyless | ||
1621 | #define yyless(n) \ | ||
1622 | do \ | ||
1623 | { \ | ||
1624 | /* Undo effects of setting up perf_pmu_text. */ \ | ||
1625 | int yyless_macro_arg = (n); \ | ||
1626 | YY_LESS_LINENO(yyless_macro_arg);\ | ||
1627 | perf_pmu_text[perf_pmu_leng] = (yy_hold_char); \ | ||
1628 | (yy_c_buf_p) = perf_pmu_text + yyless_macro_arg; \ | ||
1629 | (yy_hold_char) = *(yy_c_buf_p); \ | ||
1630 | *(yy_c_buf_p) = '\0'; \ | ||
1631 | perf_pmu_leng = yyless_macro_arg; \ | ||
1632 | } \ | ||
1633 | while ( 0 ) | ||
1634 | |||
1635 | /* Accessor methods (get/set functions) to struct members. */ | ||
1636 | |||
1637 | /** Get the current line number. | ||
1638 | * | ||
1639 | */ | ||
1640 | int perf_pmu_get_lineno (void) | ||
1641 | { | ||
1642 | |||
1643 | return perf_pmu_lineno; | ||
1644 | } | ||
1645 | |||
1646 | /** Get the input stream. | ||
1647 | * | ||
1648 | */ | ||
1649 | FILE *perf_pmu_get_in (void) | ||
1650 | { | ||
1651 | return perf_pmu_in; | ||
1652 | } | ||
1653 | |||
1654 | /** Get the output stream. | ||
1655 | * | ||
1656 | */ | ||
1657 | FILE *perf_pmu_get_out (void) | ||
1658 | { | ||
1659 | return perf_pmu_out; | ||
1660 | } | ||
1661 | |||
1662 | /** Get the length of the current token. | ||
1663 | * | ||
1664 | */ | ||
1665 | int perf_pmu_get_leng (void) | ||
1666 | { | ||
1667 | return perf_pmu_leng; | ||
1668 | } | ||
1669 | |||
1670 | /** Get the current token. | ||
1671 | * | ||
1672 | */ | ||
1673 | |||
1674 | char *perf_pmu_get_text (void) | ||
1675 | { | ||
1676 | return perf_pmu_text; | ||
1677 | } | ||
1678 | |||
1679 | /** Set the current line number. | ||
1680 | * @param line_number | ||
1681 | * | ||
1682 | */ | ||
1683 | void perf_pmu_set_lineno (int line_number ) | ||
1684 | { | ||
1685 | |||
1686 | perf_pmu_lineno = line_number; | ||
1687 | } | ||
1688 | |||
1689 | /** Set the input stream. This does not discard the current | ||
1690 | * input buffer. | ||
1691 | * @param in_str A readable stream. | ||
1692 | * | ||
1693 | * @see perf_pmu__switch_to_buffer | ||
1694 | */ | ||
1695 | void perf_pmu_set_in (FILE * in_str ) | ||
1696 | { | ||
1697 | perf_pmu_in = in_str ; | ||
1698 | } | ||
1699 | |||
1700 | void perf_pmu_set_out (FILE * out_str ) | ||
1701 | { | ||
1702 | perf_pmu_out = out_str ; | ||
1703 | } | ||
1704 | |||
1705 | int perf_pmu_get_debug (void) | ||
1706 | { | ||
1707 | return perf_pmu__flex_debug; | ||
1708 | } | ||
1709 | |||
1710 | void perf_pmu_set_debug (int bdebug ) | ||
1711 | { | ||
1712 | perf_pmu__flex_debug = bdebug ; | ||
1713 | } | ||
1714 | |||
1715 | static int yy_init_globals (void) | ||
1716 | { | ||
1717 | /* Initialization is the same as for the non-reentrant scanner. | ||
1718 | * This function is called from perf_pmu_lex_destroy(), so don't allocate here. | ||
1719 | */ | ||
1720 | |||
1721 | (yy_buffer_stack) = 0; | ||
1722 | (yy_buffer_stack_top) = 0; | ||
1723 | (yy_buffer_stack_max) = 0; | ||
1724 | (yy_c_buf_p) = (char *) 0; | ||
1725 | (yy_init) = 0; | ||
1726 | (yy_start) = 0; | ||
1727 | |||
1728 | /* Defined in main.c */ | ||
1729 | #ifdef YY_STDINIT | ||
1730 | perf_pmu_in = stdin; | ||
1731 | perf_pmu_out = stdout; | ||
1732 | #else | ||
1733 | perf_pmu_in = (FILE *) 0; | ||
1734 | perf_pmu_out = (FILE *) 0; | ||
1735 | #endif | ||
1736 | |||
1737 | /* For future reference: Set errno on error, since we are called by | ||
1738 | * perf_pmu_lex_init() | ||
1739 | */ | ||
1740 | return 0; | ||
1741 | } | ||
1742 | |||
1743 | /* perf_pmu_lex_destroy is for both reentrant and non-reentrant scanners. */ | ||
1744 | int perf_pmu_lex_destroy (void) | ||
1745 | { | ||
1746 | |||
1747 | /* Pop the buffer stack, destroying each element. */ | ||
1748 | while(YY_CURRENT_BUFFER){ | ||
1749 | perf_pmu__delete_buffer(YY_CURRENT_BUFFER ); | ||
1750 | YY_CURRENT_BUFFER_LVALUE = NULL; | ||
1751 | perf_pmu_pop_buffer_state(); | ||
1752 | } | ||
1753 | |||
1754 | /* Destroy the stack itself. */ | ||
1755 | perf_pmu_free((yy_buffer_stack) ); | ||
1756 | (yy_buffer_stack) = NULL; | ||
1757 | |||
1758 | /* Reset the globals. This is important in a non-reentrant scanner so the next time | ||
1759 | * perf_pmu_lex() is called, initialization will occur. */ | ||
1760 | yy_init_globals( ); | ||
1761 | |||
1762 | return 0; | ||
1763 | } | ||
1764 | |||
1765 | /* | ||
1766 | * Internal utility routines. | ||
1767 | */ | ||
1768 | |||
1769 | #ifndef yytext_ptr | ||
1770 | static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) | ||
1771 | { | ||
1772 | register int i; | ||
1773 | for ( i = 0; i < n; ++i ) | ||
1774 | s1[i] = s2[i]; | ||
1775 | } | ||
1776 | #endif | ||
1777 | |||
1778 | #ifdef YY_NEED_STRLEN | ||
1779 | static int yy_flex_strlen (yyconst char * s ) | ||
1780 | { | ||
1781 | register int n; | ||
1782 | for ( n = 0; s[n]; ++n ) | ||
1783 | ; | ||
1784 | |||
1785 | return n; | ||
1786 | } | ||
1787 | #endif | ||
1788 | |||
1789 | void *perf_pmu_alloc (yy_size_t size ) | ||
1790 | { | ||
1791 | return (void *) malloc( size ); | ||
1792 | } | ||
1793 | |||
1794 | void *perf_pmu_realloc (void * ptr, yy_size_t size ) | ||
1795 | { | ||
1796 | /* The cast to (char *) in the following accommodates both | ||
1797 | * implementations that use char* generic pointers, and those | ||
1798 | * that use void* generic pointers. It works with the latter | ||
1799 | * because both ANSI C and C++ allow castless assignment from | ||
1800 | * any pointer type to void*, and deal with argument conversions | ||
1801 | * as though doing an assignment. | ||
1802 | */ | ||
1803 | return (void *) realloc( (char *) ptr, size ); | ||
1804 | } | ||
1805 | |||
1806 | void perf_pmu_free (void * ptr ) | ||
1807 | { | ||
1808 | free( (char *) ptr ); /* see perf_pmu_realloc() for (char *) cast */ | ||
1809 | } | ||
1810 | |||
1811 | #define YYTABLES_NAME "yytables" | ||
1812 | |||
1813 | #line 38 "util/pmu.l" | ||
1814 | |||
1815 | |||
1816 | |||
1817 | int perf_pmu_wrap(void) | ||
1818 | { | ||
1819 | return 1; | ||
1820 | } | ||
1821 | |||
diff --git a/tools/perf/util/pmu-flex.h b/tools/perf/util/pmu-flex.h new file mode 100644 index 000000000000..0a29c8a0da4e --- /dev/null +++ b/tools/perf/util/pmu-flex.h | |||
@@ -0,0 +1,316 @@ | |||
1 | #ifndef perf_pmu_HEADER_H | ||
2 | #define perf_pmu_HEADER_H 1 | ||
3 | #define perf_pmu_IN_HEADER 1 | ||
4 | |||
5 | #line 6 "util/pmu-flex.h" | ||
6 | |||
7 | #define YY_INT_ALIGNED short int | ||
8 | |||
9 | /* A lexical scanner generated by flex */ | ||
10 | |||
11 | #define FLEX_SCANNER | ||
12 | #define YY_FLEX_MAJOR_VERSION 2 | ||
13 | #define YY_FLEX_MINOR_VERSION 5 | ||
14 | #define YY_FLEX_SUBMINOR_VERSION 35 | ||
15 | #if YY_FLEX_SUBMINOR_VERSION > 0 | ||
16 | #define FLEX_BETA | ||
17 | #endif | ||
18 | |||
19 | /* First, we deal with platform-specific or compiler-specific issues. */ | ||
20 | |||
21 | /* begin standard C headers. */ | ||
22 | #include <stdio.h> | ||
23 | #include <string.h> | ||
24 | #include <errno.h> | ||
25 | #include <stdlib.h> | ||
26 | |||
27 | /* end standard C headers. */ | ||
28 | |||
29 | /* flex integer type definitions */ | ||
30 | |||
31 | #ifndef FLEXINT_H | ||
32 | #define FLEXINT_H | ||
33 | |||
34 | /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ | ||
35 | |||
36 | #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L | ||
37 | |||
38 | /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, | ||
39 | * if you want the limit (max/min) macros for int types. | ||
40 | */ | ||
41 | #ifndef __STDC_LIMIT_MACROS | ||
42 | #define __STDC_LIMIT_MACROS 1 | ||
43 | #endif | ||
44 | |||
45 | #include <inttypes.h> | ||
46 | typedef int8_t flex_int8_t; | ||
47 | typedef uint8_t flex_uint8_t; | ||
48 | typedef int16_t flex_int16_t; | ||
49 | typedef uint16_t flex_uint16_t; | ||
50 | typedef int32_t flex_int32_t; | ||
51 | typedef uint32_t flex_uint32_t; | ||
52 | #else | ||
53 | typedef signed char flex_int8_t; | ||
54 | typedef short int flex_int16_t; | ||
55 | typedef int flex_int32_t; | ||
56 | typedef unsigned char flex_uint8_t; | ||
57 | typedef unsigned short int flex_uint16_t; | ||
58 | typedef unsigned int flex_uint32_t; | ||
59 | #endif /* ! C99 */ | ||
60 | |||
61 | /* Limits of integral types. */ | ||
62 | #ifndef INT8_MIN | ||
63 | #define INT8_MIN (-128) | ||
64 | #endif | ||
65 | #ifndef INT16_MIN | ||
66 | #define INT16_MIN (-32767-1) | ||
67 | #endif | ||
68 | #ifndef INT32_MIN | ||
69 | #define INT32_MIN (-2147483647-1) | ||
70 | #endif | ||
71 | #ifndef INT8_MAX | ||
72 | #define INT8_MAX (127) | ||
73 | #endif | ||
74 | #ifndef INT16_MAX | ||
75 | #define INT16_MAX (32767) | ||
76 | #endif | ||
77 | #ifndef INT32_MAX | ||
78 | #define INT32_MAX (2147483647) | ||
79 | #endif | ||
80 | #ifndef UINT8_MAX | ||
81 | #define UINT8_MAX (255U) | ||
82 | #endif | ||
83 | #ifndef UINT16_MAX | ||
84 | #define UINT16_MAX (65535U) | ||
85 | #endif | ||
86 | #ifndef UINT32_MAX | ||
87 | #define UINT32_MAX (4294967295U) | ||
88 | #endif | ||
89 | |||
90 | #endif /* ! FLEXINT_H */ | ||
91 | |||
92 | #ifdef __cplusplus | ||
93 | |||
94 | /* The "const" storage-class-modifier is valid. */ | ||
95 | #define YY_USE_CONST | ||
96 | |||
97 | #else /* ! __cplusplus */ | ||
98 | |||
99 | /* C99 requires __STDC__ to be defined as 1. */ | ||
100 | #if defined (__STDC__) | ||
101 | |||
102 | #define YY_USE_CONST | ||
103 | |||
104 | #endif /* defined (__STDC__) */ | ||
105 | #endif /* ! __cplusplus */ | ||
106 | |||
107 | #ifdef YY_USE_CONST | ||
108 | #define yyconst const | ||
109 | #else | ||
110 | #define yyconst | ||
111 | #endif | ||
112 | |||
113 | /* Size of default input buffer. */ | ||
114 | #ifndef YY_BUF_SIZE | ||
115 | #define YY_BUF_SIZE 16384 | ||
116 | #endif | ||
117 | |||
118 | #ifndef YY_TYPEDEF_YY_BUFFER_STATE | ||
119 | #define YY_TYPEDEF_YY_BUFFER_STATE | ||
120 | typedef struct yy_buffer_state *YY_BUFFER_STATE; | ||
121 | #endif | ||
122 | |||
123 | extern int perf_pmu_leng; | ||
124 | |||
125 | extern FILE *perf_pmu_in, *perf_pmu_out; | ||
126 | |||
127 | #ifndef YY_TYPEDEF_YY_SIZE_T | ||
128 | #define YY_TYPEDEF_YY_SIZE_T | ||
129 | typedef size_t yy_size_t; | ||
130 | #endif | ||
131 | |||
132 | #ifndef YY_STRUCT_YY_BUFFER_STATE | ||
133 | #define YY_STRUCT_YY_BUFFER_STATE | ||
134 | struct yy_buffer_state | ||
135 | { | ||
136 | FILE *yy_input_file; | ||
137 | |||
138 | char *yy_ch_buf; /* input buffer */ | ||
139 | char *yy_buf_pos; /* current position in input buffer */ | ||
140 | |||
141 | /* Size of input buffer in bytes, not including room for EOB | ||
142 | * characters. | ||
143 | */ | ||
144 | yy_size_t yy_buf_size; | ||
145 | |||
146 | /* Number of characters read into yy_ch_buf, not including EOB | ||
147 | * characters. | ||
148 | */ | ||
149 | int yy_n_chars; | ||
150 | |||
151 | /* Whether we "own" the buffer - i.e., we know we created it, | ||
152 | * and can realloc() it to grow it, and should free() it to | ||
153 | * delete it. | ||
154 | */ | ||
155 | int yy_is_our_buffer; | ||
156 | |||
157 | /* Whether this is an "interactive" input source; if so, and | ||
158 | * if we're using stdio for input, then we want to use getc() | ||
159 | * instead of fread(), to make sure we stop fetching input after | ||
160 | * each newline. | ||
161 | */ | ||
162 | int yy_is_interactive; | ||
163 | |||
164 | /* Whether we're considered to be at the beginning of a line. | ||
165 | * If so, '^' rules will be active on the next match, otherwise | ||
166 | * not. | ||
167 | */ | ||
168 | int yy_at_bol; | ||
169 | |||
170 | int yy_bs_lineno; /**< The line count. */ | ||
171 | int yy_bs_column; /**< The column count. */ | ||
172 | |||
173 | /* Whether to try to fill the input buffer when we reach the | ||
174 | * end of it. | ||
175 | */ | ||
176 | int yy_fill_buffer; | ||
177 | |||
178 | int yy_buffer_status; | ||
179 | |||
180 | }; | ||
181 | #endif /* !YY_STRUCT_YY_BUFFER_STATE */ | ||
182 | |||
183 | void perf_pmu_restart (FILE *input_file ); | ||
184 | void perf_pmu__switch_to_buffer (YY_BUFFER_STATE new_buffer ); | ||
185 | YY_BUFFER_STATE perf_pmu__create_buffer (FILE *file,int size ); | ||
186 | void perf_pmu__delete_buffer (YY_BUFFER_STATE b ); | ||
187 | void perf_pmu__flush_buffer (YY_BUFFER_STATE b ); | ||
188 | void perf_pmu_push_buffer_state (YY_BUFFER_STATE new_buffer ); | ||
189 | void perf_pmu_pop_buffer_state (void ); | ||
190 | |||
191 | YY_BUFFER_STATE perf_pmu__scan_buffer (char *base,yy_size_t size ); | ||
192 | YY_BUFFER_STATE perf_pmu__scan_string (yyconst char *yy_str ); | ||
193 | YY_BUFFER_STATE perf_pmu__scan_bytes (yyconst char *bytes,int len ); | ||
194 | |||
195 | void *perf_pmu_alloc (yy_size_t ); | ||
196 | void *perf_pmu_realloc (void *,yy_size_t ); | ||
197 | void perf_pmu_free (void * ); | ||
198 | |||
199 | /* Begin user sect3 */ | ||
200 | |||
201 | extern int perf_pmu_lineno; | ||
202 | |||
203 | extern char *perf_pmu_text; | ||
204 | #define yytext_ptr perf_pmu_text | ||
205 | |||
206 | #ifdef YY_HEADER_EXPORT_START_CONDITIONS | ||
207 | #define INITIAL 0 | ||
208 | |||
209 | #endif | ||
210 | |||
211 | #ifndef YY_NO_UNISTD_H | ||
212 | /* Special case for "unistd.h", since it is non-ANSI. We include it way | ||
213 | * down here because we want the user's section 1 to have been scanned first. | ||
214 | * The user has a chance to override it with an option. | ||
215 | */ | ||
216 | #include <unistd.h> | ||
217 | #endif | ||
218 | |||
219 | #ifndef YY_EXTRA_TYPE | ||
220 | #define YY_EXTRA_TYPE void * | ||
221 | #endif | ||
222 | |||
223 | /* Accessor methods to globals. | ||
224 | These are made visible to non-reentrant scanners for convenience. */ | ||
225 | |||
226 | int perf_pmu_lex_destroy (void ); | ||
227 | |||
228 | int perf_pmu_get_debug (void ); | ||
229 | |||
230 | void perf_pmu_set_debug (int debug_flag ); | ||
231 | |||
232 | YY_EXTRA_TYPE perf_pmu_get_extra (void ); | ||
233 | |||
234 | void perf_pmu_set_extra (YY_EXTRA_TYPE user_defined ); | ||
235 | |||
236 | FILE *perf_pmu_get_in (void ); | ||
237 | |||
238 | void perf_pmu_set_in (FILE * in_str ); | ||
239 | |||
240 | FILE *perf_pmu_get_out (void ); | ||
241 | |||
242 | void perf_pmu_set_out (FILE * out_str ); | ||
243 | |||
244 | int perf_pmu_get_leng (void ); | ||
245 | |||
246 | char *perf_pmu_get_text (void ); | ||
247 | |||
248 | int perf_pmu_get_lineno (void ); | ||
249 | |||
250 | void perf_pmu_set_lineno (int line_number ); | ||
251 | |||
252 | /* Macros after this point can all be overridden by user definitions in | ||
253 | * section 1. | ||
254 | */ | ||
255 | |||
256 | #ifndef YY_SKIP_YYWRAP | ||
257 | #ifdef __cplusplus | ||
258 | extern "C" int perf_pmu_wrap (void ); | ||
259 | #else | ||
260 | extern int perf_pmu_wrap (void ); | ||
261 | #endif | ||
262 | #endif | ||
263 | |||
264 | #ifndef yytext_ptr | ||
265 | static void yy_flex_strncpy (char *,yyconst char *,int ); | ||
266 | #endif | ||
267 | |||
268 | #ifdef YY_NEED_STRLEN | ||
269 | static int yy_flex_strlen (yyconst char * ); | ||
270 | #endif | ||
271 | |||
272 | #ifndef YY_NO_INPUT | ||
273 | |||
274 | #endif | ||
275 | |||
276 | /* Amount of stuff to slurp up with each read. */ | ||
277 | #ifndef YY_READ_BUF_SIZE | ||
278 | #define YY_READ_BUF_SIZE 8192 | ||
279 | #endif | ||
280 | |||
281 | /* Number of entries by which start-condition stack grows. */ | ||
282 | #ifndef YY_START_STACK_INCR | ||
283 | #define YY_START_STACK_INCR 25 | ||
284 | #endif | ||
285 | |||
286 | /* Default declaration of generated scanner - a define so the user can | ||
287 | * easily add parameters. | ||
288 | */ | ||
289 | #ifndef YY_DECL | ||
290 | #define YY_DECL_IS_OURS 1 | ||
291 | |||
292 | extern int perf_pmu_lex (void); | ||
293 | |||
294 | #define YY_DECL int perf_pmu_lex (void) | ||
295 | #endif /* !YY_DECL */ | ||
296 | |||
297 | /* yy_get_previous_state - get the state just before the EOB char was reached */ | ||
298 | |||
299 | #undef YY_NEW_FILE | ||
300 | #undef YY_FLUSH_BUFFER | ||
301 | #undef yy_set_bol | ||
302 | #undef yy_new_buffer | ||
303 | #undef yy_set_interactive | ||
304 | #undef YY_DO_BEFORE_ACTION | ||
305 | |||
306 | #ifdef YY_DECL_IS_OURS | ||
307 | #undef YY_DECL_IS_OURS | ||
308 | #undef YY_DECL | ||
309 | #endif | ||
310 | |||
311 | #line 38 "util/pmu.l" | ||
312 | |||
313 | |||
314 | #line 315 "util/pmu-flex.h" | ||
315 | #undef perf_pmu_IN_HEADER | ||
316 | #endif /* perf_pmu_HEADER_H */ | ||
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c new file mode 100644 index 000000000000..cb08a118e811 --- /dev/null +++ b/tools/perf/util/pmu.c | |||
@@ -0,0 +1,469 @@ | |||
1 | |||
2 | #include <linux/list.h> | ||
3 | #include <sys/types.h> | ||
4 | #include <sys/stat.h> | ||
5 | #include <unistd.h> | ||
6 | #include <stdio.h> | ||
7 | #include <dirent.h> | ||
8 | #include "sysfs.h" | ||
9 | #include "util.h" | ||
10 | #include "pmu.h" | ||
11 | #include "parse-events.h" | ||
12 | |||
13 | int perf_pmu_parse(struct list_head *list, char *name); | ||
14 | extern FILE *perf_pmu_in; | ||
15 | |||
16 | static LIST_HEAD(pmus); | ||
17 | |||
18 | /* | ||
19 | * Parse & process all the sysfs attributes located under | ||
20 | * the directory specified in 'dir' parameter. | ||
21 | */ | ||
22 | static int pmu_format_parse(char *dir, struct list_head *head) | ||
23 | { | ||
24 | struct dirent *evt_ent; | ||
25 | DIR *format_dir; | ||
26 | int ret = 0; | ||
27 | |||
28 | format_dir = opendir(dir); | ||
29 | if (!format_dir) | ||
30 | return -EINVAL; | ||
31 | |||
32 | while (!ret && (evt_ent = readdir(format_dir))) { | ||
33 | char path[PATH_MAX]; | ||
34 | char *name = evt_ent->d_name; | ||
35 | FILE *file; | ||
36 | |||
37 | if (!strcmp(name, ".") || !strcmp(name, "..")) | ||
38 | continue; | ||
39 | |||
40 | snprintf(path, PATH_MAX, "%s/%s", dir, name); | ||
41 | |||
42 | ret = -EINVAL; | ||
43 | file = fopen(path, "r"); | ||
44 | if (!file) | ||
45 | break; | ||
46 | |||
47 | perf_pmu_in = file; | ||
48 | ret = perf_pmu_parse(head, name); | ||
49 | fclose(file); | ||
50 | } | ||
51 | |||
52 | closedir(format_dir); | ||
53 | return ret; | ||
54 | } | ||
55 | |||
56 | /* | ||
57 | * Reading/parsing the default pmu format definition, which should be | ||
58 | * located at: | ||
59 | * /sys/bus/event_source/devices/<dev>/format as sysfs group attributes. | ||
60 | */ | ||
61 | static int pmu_format(char *name, struct list_head *format) | ||
62 | { | ||
63 | struct stat st; | ||
64 | char path[PATH_MAX]; | ||
65 | const char *sysfs; | ||
66 | |||
67 | sysfs = sysfs_find_mountpoint(); | ||
68 | if (!sysfs) | ||
69 | return -1; | ||
70 | |||
71 | snprintf(path, PATH_MAX, | ||
72 | "%s/bus/event_source/devices/%s/format", sysfs, name); | ||
73 | |||
74 | if (stat(path, &st) < 0) | ||
75 | return -1; | ||
76 | |||
77 | if (pmu_format_parse(path, format)) | ||
78 | return -1; | ||
79 | |||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | /* | ||
84 | * Reading/parsing the default pmu type value, which should be | ||
85 | * located at: | ||
86 | * /sys/bus/event_source/devices/<dev>/type as sysfs attribute. | ||
87 | */ | ||
88 | static int pmu_type(char *name, __u32 *type) | ||
89 | { | ||
90 | struct stat st; | ||
91 | char path[PATH_MAX]; | ||
92 | const char *sysfs; | ||
93 | FILE *file; | ||
94 | int ret = 0; | ||
95 | |||
96 | sysfs = sysfs_find_mountpoint(); | ||
97 | if (!sysfs) | ||
98 | return -1; | ||
99 | |||
100 | snprintf(path, PATH_MAX, | ||
101 | "%s/bus/event_source/devices/%s/type", sysfs, name); | ||
102 | |||
103 | if (stat(path, &st) < 0) | ||
104 | return -1; | ||
105 | |||
106 | file = fopen(path, "r"); | ||
107 | if (!file) | ||
108 | return -EINVAL; | ||
109 | |||
110 | if (1 != fscanf(file, "%u", type)) | ||
111 | ret = -1; | ||
112 | |||
113 | fclose(file); | ||
114 | return ret; | ||
115 | } | ||
116 | |||
117 | static struct perf_pmu *pmu_lookup(char *name) | ||
118 | { | ||
119 | struct perf_pmu *pmu; | ||
120 | LIST_HEAD(format); | ||
121 | __u32 type; | ||
122 | |||
123 | /* | ||
124 | * The pmu data we store & need consists of the pmu | ||
125 | * type value and format definitions. Load both right | ||
126 | * now. | ||
127 | */ | ||
128 | if (pmu_format(name, &format)) | ||
129 | return NULL; | ||
130 | |||
131 | if (pmu_type(name, &type)) | ||
132 | return NULL; | ||
133 | |||
134 | pmu = zalloc(sizeof(*pmu)); | ||
135 | if (!pmu) | ||
136 | return NULL; | ||
137 | |||
138 | INIT_LIST_HEAD(&pmu->format); | ||
139 | list_splice(&format, &pmu->format); | ||
140 | pmu->name = strdup(name); | ||
141 | pmu->type = type; | ||
142 | return pmu; | ||
143 | } | ||
144 | |||
145 | static struct perf_pmu *pmu_find(char *name) | ||
146 | { | ||
147 | struct perf_pmu *pmu; | ||
148 | |||
149 | list_for_each_entry(pmu, &pmus, list) | ||
150 | if (!strcmp(pmu->name, name)) | ||
151 | return pmu; | ||
152 | |||
153 | return NULL; | ||
154 | } | ||
155 | |||
156 | struct perf_pmu *perf_pmu__find(char *name) | ||
157 | { | ||
158 | struct perf_pmu *pmu; | ||
159 | |||
160 | /* | ||
161 | * Once PMU is loaded it stays in the list, | ||
162 | * so we keep us from multiple reading/parsing | ||
163 | * the pmu format definitions. | ||
164 | */ | ||
165 | pmu = pmu_find(name); | ||
166 | if (pmu) | ||
167 | return pmu; | ||
168 | |||
169 | return pmu_lookup(name); | ||
170 | } | ||
171 | |||
172 | static struct perf_pmu__format* | ||
173 | pmu_find_format(struct list_head *formats, char *name) | ||
174 | { | ||
175 | struct perf_pmu__format *format; | ||
176 | |||
177 | list_for_each_entry(format, formats, list) | ||
178 | if (!strcmp(format->name, name)) | ||
179 | return format; | ||
180 | |||
181 | return NULL; | ||
182 | } | ||
183 | |||
184 | /* | ||
185 | * Returns value based on the format definition (format parameter) | ||
186 | * and unformated value (value parameter). | ||
187 | * | ||
188 | * TODO maybe optimize a little ;) | ||
189 | */ | ||
190 | static __u64 pmu_format_value(unsigned long *format, __u64 value) | ||
191 | { | ||
192 | unsigned long fbit, vbit; | ||
193 | __u64 v = 0; | ||
194 | |||
195 | for (fbit = 0, vbit = 0; fbit < PERF_PMU_FORMAT_BITS; fbit++) { | ||
196 | |||
197 | if (!test_bit(fbit, format)) | ||
198 | continue; | ||
199 | |||
200 | if (!(value & (1llu << vbit++))) | ||
201 | continue; | ||
202 | |||
203 | v |= (1llu << fbit); | ||
204 | } | ||
205 | |||
206 | return v; | ||
207 | } | ||
208 | |||
209 | /* | ||
210 | * Setup one of config[12] attr members based on the | ||
211 | * user input data - temr parameter. | ||
212 | */ | ||
213 | static int pmu_config_term(struct list_head *formats, | ||
214 | struct perf_event_attr *attr, | ||
215 | struct parse_events__term *term) | ||
216 | { | ||
217 | struct perf_pmu__format *format; | ||
218 | __u64 *vp; | ||
219 | |||
220 | /* | ||
221 | * Support only for hardcoded and numnerial terms. | ||
222 | * Hardcoded terms should be already in, so nothing | ||
223 | * to be done for them. | ||
224 | */ | ||
225 | if (parse_events__is_hardcoded_term(term)) | ||
226 | return 0; | ||
227 | |||
228 | if (term->type != PARSE_EVENTS__TERM_TYPE_NUM) | ||
229 | return -EINVAL; | ||
230 | |||
231 | format = pmu_find_format(formats, term->config); | ||
232 | if (!format) | ||
233 | return -EINVAL; | ||
234 | |||
235 | switch (format->value) { | ||
236 | case PERF_PMU_FORMAT_VALUE_CONFIG: | ||
237 | vp = &attr->config; | ||
238 | break; | ||
239 | case PERF_PMU_FORMAT_VALUE_CONFIG1: | ||
240 | vp = &attr->config1; | ||
241 | break; | ||
242 | case PERF_PMU_FORMAT_VALUE_CONFIG2: | ||
243 | vp = &attr->config2; | ||
244 | break; | ||
245 | default: | ||
246 | return -EINVAL; | ||
247 | } | ||
248 | |||
249 | *vp |= pmu_format_value(format->bits, term->val.num); | ||
250 | return 0; | ||
251 | } | ||
252 | |||
253 | static int pmu_config(struct list_head *formats, struct perf_event_attr *attr, | ||
254 | struct list_head *head_terms) | ||
255 | { | ||
256 | struct parse_events__term *term, *h; | ||
257 | |||
258 | list_for_each_entry_safe(term, h, head_terms, list) | ||
259 | if (pmu_config_term(formats, attr, term)) | ||
260 | return -EINVAL; | ||
261 | |||
262 | return 0; | ||
263 | } | ||
264 | |||
265 | /* | ||
266 | * Configures event's 'attr' parameter based on the: | ||
267 | * 1) users input - specified in terms parameter | ||
268 | * 2) pmu format definitions - specified by pmu parameter | ||
269 | */ | ||
270 | int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr, | ||
271 | struct list_head *head_terms) | ||
272 | { | ||
273 | attr->type = pmu->type; | ||
274 | return pmu_config(&pmu->format, attr, head_terms); | ||
275 | } | ||
276 | |||
277 | int perf_pmu__new_format(struct list_head *list, char *name, | ||
278 | int config, unsigned long *bits) | ||
279 | { | ||
280 | struct perf_pmu__format *format; | ||
281 | |||
282 | format = zalloc(sizeof(*format)); | ||
283 | if (!format) | ||
284 | return -ENOMEM; | ||
285 | |||
286 | format->name = strdup(name); | ||
287 | format->value = config; | ||
288 | memcpy(format->bits, bits, sizeof(format->bits)); | ||
289 | |||
290 | list_add_tail(&format->list, list); | ||
291 | return 0; | ||
292 | } | ||
293 | |||
294 | void perf_pmu__set_format(unsigned long *bits, long from, long to) | ||
295 | { | ||
296 | long b; | ||
297 | |||
298 | if (!to) | ||
299 | to = from; | ||
300 | |||
301 | memset(bits, 0, BITS_TO_LONGS(PERF_PMU_FORMAT_BITS)); | ||
302 | for (b = from; b <= to; b++) | ||
303 | set_bit(b, bits); | ||
304 | } | ||
305 | |||
306 | /* Simulated format definitions. */ | ||
307 | static struct test_format { | ||
308 | const char *name; | ||
309 | const char *value; | ||
310 | } test_formats[] = { | ||
311 | { "krava01", "config:0-1,62-63\n", }, | ||
312 | { "krava02", "config:10-17\n", }, | ||
313 | { "krava03", "config:5\n", }, | ||
314 | { "krava11", "config1:0,2,4,6,8,20-28\n", }, | ||
315 | { "krava12", "config1:63\n", }, | ||
316 | { "krava13", "config1:45-47\n", }, | ||
317 | { "krava21", "config2:0-3,10-13,20-23,30-33,40-43,50-53,60-63\n", }, | ||
318 | { "krava22", "config2:8,18,48,58\n", }, | ||
319 | { "krava23", "config2:28-29,38\n", }, | ||
320 | }; | ||
321 | |||
322 | #define TEST_FORMATS_CNT (sizeof(test_formats) / sizeof(struct test_format)) | ||
323 | |||
324 | /* Simulated users input. */ | ||
325 | static struct parse_events__term test_terms[] = { | ||
326 | { | ||
327 | .config = (char *) "krava01", | ||
328 | .val.num = 15, | ||
329 | .type = PARSE_EVENTS__TERM_TYPE_NUM, | ||
330 | }, | ||
331 | { | ||
332 | .config = (char *) "krava02", | ||
333 | .val.num = 170, | ||
334 | .type = PARSE_EVENTS__TERM_TYPE_NUM, | ||
335 | }, | ||
336 | { | ||
337 | .config = (char *) "krava03", | ||
338 | .val.num = 1, | ||
339 | .type = PARSE_EVENTS__TERM_TYPE_NUM, | ||
340 | }, | ||
341 | { | ||
342 | .config = (char *) "krava11", | ||
343 | .val.num = 27, | ||
344 | .type = PARSE_EVENTS__TERM_TYPE_NUM, | ||
345 | }, | ||
346 | { | ||
347 | .config = (char *) "krava12", | ||
348 | .val.num = 1, | ||
349 | .type = PARSE_EVENTS__TERM_TYPE_NUM, | ||
350 | }, | ||
351 | { | ||
352 | .config = (char *) "krava13", | ||
353 | .val.num = 2, | ||
354 | .type = PARSE_EVENTS__TERM_TYPE_NUM, | ||
355 | }, | ||
356 | { | ||
357 | .config = (char *) "krava21", | ||
358 | .val.num = 119, | ||
359 | .type = PARSE_EVENTS__TERM_TYPE_NUM, | ||
360 | }, | ||
361 | { | ||
362 | .config = (char *) "krava22", | ||
363 | .val.num = 11, | ||
364 | .type = PARSE_EVENTS__TERM_TYPE_NUM, | ||
365 | }, | ||
366 | { | ||
367 | .config = (char *) "krava23", | ||
368 | .val.num = 2, | ||
369 | .type = PARSE_EVENTS__TERM_TYPE_NUM, | ||
370 | }, | ||
371 | }; | ||
372 | #define TERMS_CNT (sizeof(test_terms) / sizeof(struct parse_events__term)) | ||
373 | |||
374 | /* | ||
375 | * Prepare format directory data, exported by kernel | ||
376 | * at /sys/bus/event_source/devices/<dev>/format. | ||
377 | */ | ||
378 | static char *test_format_dir_get(void) | ||
379 | { | ||
380 | static char dir[PATH_MAX]; | ||
381 | unsigned int i; | ||
382 | |||
383 | snprintf(dir, PATH_MAX, "/tmp/perf-pmu-test-format-XXXXXX"); | ||
384 | if (!mkdtemp(dir)) | ||
385 | return NULL; | ||
386 | |||
387 | for (i = 0; i < TEST_FORMATS_CNT; i++) { | ||
388 | static char name[PATH_MAX]; | ||
389 | struct test_format *format = &test_formats[i]; | ||
390 | FILE *file; | ||
391 | |||
392 | snprintf(name, PATH_MAX, "%s/%s", dir, format->name); | ||
393 | |||
394 | file = fopen(name, "w"); | ||
395 | if (!file) | ||
396 | return NULL; | ||
397 | |||
398 | if (1 != fwrite(format->value, strlen(format->value), 1, file)) | ||
399 | break; | ||
400 | |||
401 | fclose(file); | ||
402 | } | ||
403 | |||
404 | return dir; | ||
405 | } | ||
406 | |||
407 | /* Cleanup format directory. */ | ||
408 | static int test_format_dir_put(char *dir) | ||
409 | { | ||
410 | char buf[PATH_MAX]; | ||
411 | snprintf(buf, PATH_MAX, "rm -f %s/*\n", dir); | ||
412 | if (system(buf)) | ||
413 | return -1; | ||
414 | |||
415 | snprintf(buf, PATH_MAX, "rmdir %s\n", dir); | ||
416 | return system(buf); | ||
417 | } | ||
418 | |||
419 | static struct list_head *test_terms_list(void) | ||
420 | { | ||
421 | static LIST_HEAD(terms); | ||
422 | unsigned int i; | ||
423 | |||
424 | for (i = 0; i < TERMS_CNT; i++) | ||
425 | list_add_tail(&test_terms[i].list, &terms); | ||
426 | |||
427 | return &terms; | ||
428 | } | ||
429 | |||
430 | #undef TERMS_CNT | ||
431 | |||
432 | int perf_pmu__test(void) | ||
433 | { | ||
434 | char *format = test_format_dir_get(); | ||
435 | LIST_HEAD(formats); | ||
436 | struct list_head *terms = test_terms_list(); | ||
437 | int ret; | ||
438 | |||
439 | if (!format) | ||
440 | return -EINVAL; | ||
441 | |||
442 | do { | ||
443 | struct perf_event_attr attr; | ||
444 | |||
445 | memset(&attr, 0, sizeof(attr)); | ||
446 | |||
447 | ret = pmu_format_parse(format, &formats); | ||
448 | if (ret) | ||
449 | break; | ||
450 | |||
451 | ret = pmu_config(&formats, &attr, terms); | ||
452 | if (ret) | ||
453 | break; | ||
454 | |||
455 | ret = -EINVAL; | ||
456 | |||
457 | if (attr.config != 0xc00000000002a823) | ||
458 | break; | ||
459 | if (attr.config1 != 0x8000400000000145) | ||
460 | break; | ||
461 | if (attr.config2 != 0x0400000020041d07) | ||
462 | break; | ||
463 | |||
464 | ret = 0; | ||
465 | } while (0); | ||
466 | |||
467 | test_format_dir_put(format); | ||
468 | return ret; | ||
469 | } | ||
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h new file mode 100644 index 000000000000..68c0db965e1f --- /dev/null +++ b/tools/perf/util/pmu.h | |||
@@ -0,0 +1,41 @@ | |||
1 | #ifndef __PMU_H | ||
2 | #define __PMU_H | ||
3 | |||
4 | #include <linux/bitops.h> | ||
5 | #include "../../../include/linux/perf_event.h" | ||
6 | |||
7 | enum { | ||
8 | PERF_PMU_FORMAT_VALUE_CONFIG, | ||
9 | PERF_PMU_FORMAT_VALUE_CONFIG1, | ||
10 | PERF_PMU_FORMAT_VALUE_CONFIG2, | ||
11 | }; | ||
12 | |||
13 | #define PERF_PMU_FORMAT_BITS 64 | ||
14 | |||
15 | struct perf_pmu__format { | ||
16 | char *name; | ||
17 | int value; | ||
18 | DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS); | ||
19 | struct list_head list; | ||
20 | }; | ||
21 | |||
22 | struct perf_pmu { | ||
23 | char *name; | ||
24 | __u32 type; | ||
25 | struct list_head format; | ||
26 | struct list_head list; | ||
27 | }; | ||
28 | |||
29 | struct perf_pmu *perf_pmu__find(char *name); | ||
30 | int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr, | ||
31 | struct list_head *head_terms); | ||
32 | |||
33 | int perf_pmu_wrap(void); | ||
34 | void perf_pmu_error(struct list_head *list, char *name, char const *msg); | ||
35 | |||
36 | int perf_pmu__new_format(struct list_head *list, char *name, | ||
37 | int config, unsigned long *bits); | ||
38 | void perf_pmu__set_format(unsigned long *bits, long from, long to); | ||
39 | |||
40 | int perf_pmu__test(void); | ||
41 | #endif /* __PMU_H */ | ||
diff --git a/tools/perf/util/pmu.l b/tools/perf/util/pmu.l new file mode 100644 index 000000000000..a15d9fbd7c0e --- /dev/null +++ b/tools/perf/util/pmu.l | |||
@@ -0,0 +1,43 @@ | |||
1 | %option prefix="perf_pmu_" | ||
2 | |||
3 | %{ | ||
4 | #include <stdlib.h> | ||
5 | #include <linux/bitops.h> | ||
6 | #include "pmu.h" | ||
7 | #include "pmu-bison.h" | ||
8 | |||
9 | static int value(int base) | ||
10 | { | ||
11 | long num; | ||
12 | |||
13 | errno = 0; | ||
14 | num = strtoul(perf_pmu_text, NULL, base); | ||
15 | if (errno) | ||
16 | return PP_ERROR; | ||
17 | |||
18 | perf_pmu_lval.num = num; | ||
19 | return PP_VALUE; | ||
20 | } | ||
21 | |||
22 | %} | ||
23 | |||
24 | num_dec [0-9]+ | ||
25 | |||
26 | %% | ||
27 | |||
28 | {num_dec} { return value(10); } | ||
29 | config { return PP_CONFIG; } | ||
30 | config1 { return PP_CONFIG1; } | ||
31 | config2 { return PP_CONFIG2; } | ||
32 | - { return '-'; } | ||
33 | : { return ':'; } | ||
34 | , { return ','; } | ||
35 | . { ; } | ||
36 | \n { ; } | ||
37 | |||
38 | %% | ||
39 | |||
40 | int perf_pmu_wrap(void) | ||
41 | { | ||
42 | return 1; | ||
43 | } | ||
diff --git a/tools/perf/util/pmu.y b/tools/perf/util/pmu.y new file mode 100644 index 000000000000..20ea77e93169 --- /dev/null +++ b/tools/perf/util/pmu.y | |||
@@ -0,0 +1,93 @@ | |||
1 | |||
2 | %name-prefix "perf_pmu_" | ||
3 | %parse-param {struct list_head *format} | ||
4 | %parse-param {char *name} | ||
5 | |||
6 | %{ | ||
7 | |||
8 | #include <linux/compiler.h> | ||
9 | #include <linux/list.h> | ||
10 | #include <linux/bitmap.h> | ||
11 | #include <string.h> | ||
12 | #include "pmu.h" | ||
13 | |||
14 | extern int perf_pmu_lex (void); | ||
15 | |||
16 | #define ABORT_ON(val) \ | ||
17 | do { \ | ||
18 | if (val) \ | ||
19 | YYABORT; \ | ||
20 | } while (0) | ||
21 | |||
22 | %} | ||
23 | |||
24 | %token PP_CONFIG PP_CONFIG1 PP_CONFIG2 | ||
25 | %token PP_VALUE PP_ERROR | ||
26 | %type <num> PP_VALUE | ||
27 | %type <bits> bit_term | ||
28 | %type <bits> bits | ||
29 | |||
30 | %union | ||
31 | { | ||
32 | unsigned long num; | ||
33 | DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS); | ||
34 | } | ||
35 | |||
36 | %% | ||
37 | |||
38 | format: | ||
39 | format format_term | ||
40 | | | ||
41 | format_term | ||
42 | |||
43 | format_term: | ||
44 | PP_CONFIG ':' bits | ||
45 | { | ||
46 | ABORT_ON(perf_pmu__new_format(format, name, | ||
47 | PERF_PMU_FORMAT_VALUE_CONFIG, | ||
48 | $3)); | ||
49 | } | ||
50 | | | ||
51 | PP_CONFIG1 ':' bits | ||
52 | { | ||
53 | ABORT_ON(perf_pmu__new_format(format, name, | ||
54 | PERF_PMU_FORMAT_VALUE_CONFIG1, | ||
55 | $3)); | ||
56 | } | ||
57 | | | ||
58 | PP_CONFIG2 ':' bits | ||
59 | { | ||
60 | ABORT_ON(perf_pmu__new_format(format, name, | ||
61 | PERF_PMU_FORMAT_VALUE_CONFIG2, | ||
62 | $3)); | ||
63 | } | ||
64 | |||
65 | bits: | ||
66 | bits ',' bit_term | ||
67 | { | ||
68 | bitmap_or($$, $1, $3, 64); | ||
69 | } | ||
70 | | | ||
71 | bit_term | ||
72 | { | ||
73 | memcpy($$, $1, sizeof($1)); | ||
74 | } | ||
75 | |||
76 | bit_term: | ||
77 | PP_VALUE '-' PP_VALUE | ||
78 | { | ||
79 | perf_pmu__set_format($$, $1, $3); | ||
80 | } | ||
81 | | | ||
82 | PP_VALUE | ||
83 | { | ||
84 | perf_pmu__set_format($$, $1, 0); | ||
85 | } | ||
86 | |||
87 | %% | ||
88 | |||
89 | void perf_pmu_error(struct list_head *list __used, | ||
90 | char *name __used, | ||
91 | char const *msg __used) | ||
92 | { | ||
93 | } | ||