mtd: print out the page size and oob size after parsing out the nand
[linux/fpc-iii.git] / tools / perf / util / trace-event-scripting.c
blob18ae6c1831d3896263c5a7c3ff58f264bcefbfa5
1 /*
2 * trace-event-scripting. Scripting engine common and initialization code.
4 * Copyright (C) 2009-2010 Tom Zanussi <tzanussi@gmail.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <errno.h>
27 #include "../perf.h"
28 #include "util.h"
29 #include "trace-event.h"
31 struct scripting_context *scripting_context;
33 static int stop_script_unsupported(void)
35 return 0;
38 static void process_event_unsupported(union perf_event *event __unused,
39 struct perf_sample *sample __unused,
40 struct perf_evsel *evsel __unused,
41 struct machine *machine __unused,
42 struct thread *thread __unused)
46 static void print_python_unsupported_msg(void)
48 fprintf(stderr, "Python scripting not supported."
49 " Install libpython and rebuild perf to enable it.\n"
50 "For example:\n # apt-get install python-dev (ubuntu)"
51 "\n # yum install python-devel (Fedora)"
52 "\n etc.\n");
55 static int python_start_script_unsupported(const char *script __unused,
56 int argc __unused,
57 const char **argv __unused)
59 print_python_unsupported_msg();
61 return -1;
64 static int python_generate_script_unsupported(const char *outfile __unused)
66 print_python_unsupported_msg();
68 return -1;
71 struct scripting_ops python_scripting_unsupported_ops = {
72 .name = "Python",
73 .start_script = python_start_script_unsupported,
74 .stop_script = stop_script_unsupported,
75 .process_event = process_event_unsupported,
76 .generate_script = python_generate_script_unsupported,
79 static void register_python_scripting(struct scripting_ops *scripting_ops)
81 int err;
82 err = script_spec_register("Python", scripting_ops);
83 if (err)
84 die("error registering Python script extension");
86 err = script_spec_register("py", scripting_ops);
87 if (err)
88 die("error registering py script extension");
90 scripting_context = malloc(sizeof(struct scripting_context));
93 #ifdef NO_LIBPYTHON
94 void setup_python_scripting(void)
96 register_python_scripting(&python_scripting_unsupported_ops);
98 #else
99 extern struct scripting_ops python_scripting_ops;
101 void setup_python_scripting(void)
103 register_python_scripting(&python_scripting_ops);
105 #endif
107 static void print_perl_unsupported_msg(void)
109 fprintf(stderr, "Perl scripting not supported."
110 " Install libperl and rebuild perf to enable it.\n"
111 "For example:\n # apt-get install libperl-dev (ubuntu)"
112 "\n # yum install 'perl(ExtUtils::Embed)' (Fedora)"
113 "\n etc.\n");
116 static int perl_start_script_unsupported(const char *script __unused,
117 int argc __unused,
118 const char **argv __unused)
120 print_perl_unsupported_msg();
122 return -1;
125 static int perl_generate_script_unsupported(const char *outfile __unused)
127 print_perl_unsupported_msg();
129 return -1;
132 struct scripting_ops perl_scripting_unsupported_ops = {
133 .name = "Perl",
134 .start_script = perl_start_script_unsupported,
135 .stop_script = stop_script_unsupported,
136 .process_event = process_event_unsupported,
137 .generate_script = perl_generate_script_unsupported,
140 static void register_perl_scripting(struct scripting_ops *scripting_ops)
142 int err;
143 err = script_spec_register("Perl", scripting_ops);
144 if (err)
145 die("error registering Perl script extension");
147 err = script_spec_register("pl", scripting_ops);
148 if (err)
149 die("error registering pl script extension");
151 scripting_context = malloc(sizeof(struct scripting_context));
154 #ifdef NO_LIBPERL
155 void setup_perl_scripting(void)
157 register_perl_scripting(&perl_scripting_unsupported_ops);
159 #else
160 extern struct scripting_ops perl_scripting_ops;
162 void setup_perl_scripting(void)
164 register_perl_scripting(&perl_scripting_ops);
166 #endif