diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-12-09 12:45:44 -0500 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-12-09 12:45:44 -0500 |
commit | ce2538d74ca5b9650ca6d18203032e47edd36c60 (patch) | |
tree | 7ea79ab8ad03afa74210e2f9d7e352a81259c297 /src | |
parent | a1842e14f55a3230ae076aada09b56e6d6096b47 (diff) |
timestamp.h: rip out old unneeded definitions
Diffstat (limited to 'src')
-rw-r--r-- | src/ftcat.c | 20 | ||||
-rw-r--r-- | src/timestamp.c | 29 |
2 files changed, 19 insertions, 30 deletions
diff --git a/src/ftcat.c b/src/ftcat.c index 28f1924..f0a1c5f 100644 --- a/src/ftcat.c +++ b/src/ftcat.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <string.h> | 21 | #include <string.h> |
22 | #include <signal.h> | 22 | #include <signal.h> |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <unistd.h> | ||
25 | #include <errno.h> | ||
24 | 26 | ||
25 | #include "timestamp.h" | 27 | #include "timestamp.h" |
26 | 28 | ||
@@ -44,14 +46,16 @@ static int disable_all(int fd) | |||
44 | return size == ret; | 46 | return size == ret; |
45 | } | 47 | } |
46 | 48 | ||
47 | static int enable_events(int fd, char* str) | 49 | static int enable_event(int fd, char* str) |
48 | { | 50 | { |
49 | cmd_t *id; | 51 | cmd_t *id; |
50 | cmd_t cmd[2]; | 52 | cmd_t cmd[2]; |
51 | 53 | ||
52 | id = ids + event_count; | 54 | id = ids + event_count; |
53 | if (!str2event(str, id)) | 55 | if (!str2event(str, id)) { |
56 | errno = EINVAL; | ||
54 | return 0; | 57 | return 0; |
58 | } | ||
55 | 59 | ||
56 | event_count += 1; | 60 | event_count += 1; |
57 | cmd[0] = ENABLE_CMD; | 61 | cmd[0] = ENABLE_CMD; |
@@ -60,7 +64,7 @@ static int enable_events(int fd, char* str) | |||
60 | } | 64 | } |
61 | 65 | ||
62 | 66 | ||
63 | static void cat2stdout(int fd) | 67 | static void cat2stdout(int fd) |
64 | { | 68 | { |
65 | static char buf[4096]; | 69 | static char buf[4096]; |
66 | int rd; | 70 | int rd; |
@@ -73,7 +77,7 @@ static void cat2stdout(int fd) | |||
73 | 77 | ||
74 | static void usage(void) | 78 | static void usage(void) |
75 | { | 79 | { |
76 | fprintf(stderr, | 80 | fprintf(stderr, |
77 | "Usage: ftcat <ft device> TS1 TS2 ...." | 81 | "Usage: ftcat <ft device> TS1 TS2 ...." |
78 | "\n"); | 82 | "\n"); |
79 | exit(1); | 83 | exit(1); |
@@ -94,12 +98,12 @@ static void shutdown(int sig) | |||
94 | fprintf(stderr, "disable_all: %m\n"); | 98 | fprintf(stderr, "disable_all: %m\n"); |
95 | } | 99 | } |
96 | 100 | ||
97 | int main(int argc, char** argv) | 101 | int main(int argc, char** argv) |
98 | { | 102 | { |
99 | const char* trace_file; | 103 | const char* trace_file; |
100 | if (argc < 3) | 104 | if (argc < 3) |
101 | usage(); | 105 | usage(); |
102 | 106 | ||
103 | trace_file = argv[1]; | 107 | trace_file = argv[1]; |
104 | fd = open(trace_file, O_RDWR); | 108 | fd = open(trace_file, O_RDWR); |
105 | if (fd < 0) { | 109 | if (fd < 0) { |
@@ -112,7 +116,7 @@ int main(int argc, char** argv) | |||
112 | signal(SIGUSR1, shutdown); | 116 | signal(SIGUSR1, shutdown); |
113 | signal(SIGTERM, shutdown); | 117 | signal(SIGTERM, shutdown); |
114 | while (argc--) { | 118 | while (argc--) { |
115 | if (!enable_events(fd, *argv)) { | 119 | if (!enable_event(fd, *argv)) { |
116 | fprintf(stderr, "Enabling %s failed: %m\n", *argv); | 120 | fprintf(stderr, "Enabling %s failed: %m\n", *argv); |
117 | return 2; | 121 | return 2; |
118 | } | 122 | } |
diff --git a/src/timestamp.c b/src/timestamp.c index f3f7861..9ad43f1 100644 --- a/src/timestamp.c +++ b/src/timestamp.c | |||
@@ -8,9 +8,11 @@ struct event_name { | |||
8 | cmd_t id; | 8 | cmd_t id; |
9 | }; | 9 | }; |
10 | 10 | ||
11 | #define EVENT(name) {#name, TS_ ## name ## _START} | 11 | #define EVENT(name) \ |
12 | {#name "_START", TS_ ## name ## _START}, \ | ||
13 | {#name "_END", TS_ ## name ## _END} | ||
12 | 14 | ||
13 | static struct event_name event_table[] = | 15 | static struct event_name event_table[] = |
14 | { | 16 | { |
15 | EVENT(SCHED), | 17 | EVENT(SCHED), |
16 | EVENT(SCHED2), | 18 | EVENT(SCHED2), |
@@ -19,28 +21,11 @@ static struct event_name event_table[] = | |||
19 | EVENT(PLUGIN_SCHED), | 21 | EVENT(PLUGIN_SCHED), |
20 | EVENT(PLUGIN_TICK), | 22 | EVENT(PLUGIN_TICK), |
21 | EVENT(CXS), | 23 | EVENT(CXS), |
22 | EVENT(ENTER_NP), | ||
23 | EVENT(EXIT_NP), | ||
24 | EVENT(SRP_UP), | ||
25 | EVENT(SRP_DOWN), | ||
26 | EVENT(PI_UP), | ||
27 | EVENT(PI_DOWN), | ||
28 | EVENT(FIFO_UP), | ||
29 | EVENT(FIFO_DOWN), | ||
30 | EVENT(PCP_UP), | ||
31 | EVENT(PCP1_DOWN), | ||
32 | EVENT(PCP2_DOWN), | ||
33 | EVENT(DPCP_INVOKE), | ||
34 | EVENT(DPCP_AGENT1), | ||
35 | EVENT(DPCP_AGENT2), | ||
36 | EVENT(MPCP_UP), | ||
37 | EVENT(MPCP_DOWN), | ||
38 | EVENT(SRPT) | ||
39 | }; | 24 | }; |
40 | 25 | ||
41 | int str2event(const char* str, cmd_t *id) | 26 | int str2event(const char* str, cmd_t *id) |
42 | { | 27 | { |
43 | int i; | 28 | int i; |
44 | 29 | ||
45 | for (i = 0; i < sizeof(event_table) / sizeof(event_table[0]); i++) | 30 | for (i = 0; i < sizeof(event_table) / sizeof(event_table[0]); i++) |
46 | if (!strcmp(str, event_table[i].name)) { | 31 | if (!strcmp(str, event_table[i].name)) { |
@@ -53,11 +38,11 @@ int str2event(const char* str, cmd_t *id) | |||
53 | 38 | ||
54 | const char* event2str(cmd_t id) | 39 | const char* event2str(cmd_t id) |
55 | { | 40 | { |
56 | int i; | 41 | int i; |
57 | 42 | ||
58 | for (i = 0; i < sizeof(event_table) / sizeof(event_table[0]); i++) | 43 | for (i = 0; i < sizeof(event_table) / sizeof(event_table[0]); i++) |
59 | if (event_table[i].id == id) | 44 | if (event_table[i].id == id) |
60 | return event_table[i].name; | 45 | return event_table[i].name; |
61 | 46 | ||
62 | return NULL; | 47 | return NULL; |
63 | } | 48 | } |