mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-15 23:14:31 +08:00
3d88aec0d4
By default bison uses global state for compatibility with yacc. Make the parser reentrant so that it may be used in asynchronous and multithreaded situations. Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Gaosheng Cui <cuigaosheng1@huawei.com> Cc: German Gomez <german.gomez@arm.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jing Zhang <renyu.zj@linux.alibaba.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Rob Herring <robh@kernel.org> Cc: Sean Christopherson <seanjc@google.com> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20230406065224.2553640-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
49 lines
767 B
Plaintext
49 lines
767 B
Plaintext
%option prefix="perf_pmu_"
|
|
%option reentrant
|
|
%option bison-bridge
|
|
|
|
%{
|
|
#include <stdlib.h>
|
|
#include <linux/bitops.h>
|
|
#include "pmu.h"
|
|
#include "pmu-bison.h"
|
|
|
|
char *perf_pmu_get_text(yyscan_t yyscanner);
|
|
YYSTYPE *perf_pmu_get_lval(yyscan_t yyscanner);
|
|
|
|
static int value(yyscan_t scanner, int base)
|
|
{
|
|
YYSTYPE *yylval = perf_pmu_get_lval(scanner);
|
|
char *text = perf_pmu_get_text(scanner);
|
|
long num;
|
|
|
|
errno = 0;
|
|
num = strtoul(text, NULL, base);
|
|
if (errno)
|
|
return PP_ERROR;
|
|
|
|
yylval->num = num;
|
|
return PP_VALUE;
|
|
}
|
|
|
|
%}
|
|
|
|
num_dec [0-9]+
|
|
|
|
%%
|
|
|
|
{num_dec} { return value(yyscanner, 10); }
|
|
config { return PP_CONFIG; }
|
|
- { return '-'; }
|
|
: { return ':'; }
|
|
, { return ','; }
|
|
. { ; }
|
|
\n { ; }
|
|
|
|
%%
|
|
|
|
int perf_pmu_wrap(void *scanner __maybe_unused)
|
|
{
|
|
return 1;
|
|
}
|