spi-topcliff-pch: supports a spi mode setup and bit order setup by IO control
[zen-stable.git] / tools / perf / util / trace-event-scripting.c
bloba3fdf55f317bb851e4990b2c73e11e670a92aac7
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 <ctype.h>
26 #include <errno.h>
28 #include "../perf.h"
29 #include "util.h"
30 #include "trace-event.h"
32 struct scripting_context *scripting_context;
34 static int stop_script_unsupported(void)
36 return 0;
39 static void process_event_unsupported(union perf_event *event __unused,
40 struct perf_sample *sample __unused,
41 struct perf_evsel *evsel __unused,
42 struct machine *machine __unused,
43 struct thread *thread __unused)
47 static void print_python_unsupported_msg(void)
49 fprintf(stderr, "Python scripting not supported."
50 " Install libpython and rebuild perf to enable it.\n"
51 "For example:\n # apt-get install python-dev (ubuntu)"
52 "\n # yum install python-devel (Fedora)"
53 "\n etc.\n");
56 static int python_start_script_unsupported(const char *script __unused,
57 int argc __unused,
58 const char **argv __unused)
60 print_python_unsupported_msg();
62 return -1;
65 static int python_generate_script_unsupported(const char *outfile __unused)
67 print_python_unsupported_msg();
69 return -1;
72 struct scripting_ops python_scripting_unsupported_ops = {
73 .name = "Python",
74 .start_script = python_start_script_unsupported,
75 .stop_script = stop_script_unsupported,
76 .process_event = process_event_unsupported,
77 .generate_script = python_generate_script_unsupported,
80 static void register_python_scripting(struct scripting_ops *scripting_ops)
82 int err;
83 err = script_spec_register("Python", scripting_ops);
84 if (err)
85 die("error registering Python script extension");
87 err = script_spec_register("py", scripting_ops);
88 if (err)
89 die("error registering py script extension");
91 scripting_context = malloc(sizeof(struct scripting_context));
94 #ifdef NO_LIBPYTHON
95 void setup_python_scripting(void)
97 register_python_scripting(&python_scripting_unsupported_ops);
99 #else
100 extern struct scripting_ops python_scripting_ops;
102 void setup_python_scripting(void)
104 register_python_scripting(&python_scripting_ops);
106 #endif
108 static void print_perl_unsupported_msg(void)
110 fprintf(stderr, "Perl scripting not supported."
111 " Install libperl and rebuild perf to enable it.\n"
112 "For example:\n # apt-get install libperl-dev (ubuntu)"
113 "\n # yum install 'perl(ExtUtils::Embed)' (Fedora)"
114 "\n etc.\n");
117 static int perl_start_script_unsupported(const char *script __unused,
118 int argc __unused,
119 const char **argv __unused)
121 print_perl_unsupported_msg();
123 return -1;
126 static int perl_generate_script_unsupported(const char *outfile __unused)
128 print_perl_unsupported_msg();
130 return -1;
133 struct scripting_ops perl_scripting_unsupported_ops = {
134 .name = "Perl",
135 .start_script = perl_start_script_unsupported,
136 .stop_script = stop_script_unsupported,
137 .process_event = process_event_unsupported,
138 .generate_script = perl_generate_script_unsupported,
141 static void register_perl_scripting(struct scripting_ops *scripting_ops)
143 int err;
144 err = script_spec_register("Perl", scripting_ops);
145 if (err)
146 die("error registering Perl script extension");
148 err = script_spec_register("pl", scripting_ops);
149 if (err)
150 die("error registering pl script extension");
152 scripting_context = malloc(sizeof(struct scripting_context));
155 #ifdef NO_LIBPERL
156 void setup_perl_scripting(void)
158 register_perl_scripting(&perl_scripting_unsupported_ops);
160 #else
161 extern struct scripting_ops perl_scripting_ops;
163 void setup_perl_scripting(void)
165 register_perl_scripting(&perl_scripting_ops);
167 #endif