Define _LGPL_SOURCE in test applications
[lttng-tools.git] / tests / utils / testapp / gen-ust-nevents / gen-ust-nevents.c
1 /*
2 * Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
3 *
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by the
6 * Free Software Foundation; version 2.1 of the License.
7 *
8 * This library is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 * for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18 #define _LGPL_SOURCE
19 #include <arpa/inet.h>
20 #include <stdarg.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <sys/mman.h>
25 #include <sys/stat.h>
26 #include <sys/types.h>
27 #include <unistd.h>
28
29 #define TRACEPOINT_DEFINE
30 #include "tp.h"
31
32 int main(int argc, char **argv)
33 {
34 int i, netint;
35 long values[] = { 1, 2, 3 };
36 char text[10] = "test";
37 double dbl = 2.0;
38 float flt = 2222.0;
39 unsigned int nr_iter = 100;
40 useconds_t nr_usec = 0;
41
42 if (argc >= 2) {
43 nr_iter = atoi(argv[1]);
44 }
45
46 if (argc == 3) {
47 /* By default, don't wait unless user specifies. */
48 nr_usec = atoi(argv[2]);
49 }
50
51 for (i = 0; i < nr_iter; i++) {
52 netint = htonl(i);
53 tracepoint(tp, tptest1, i, netint, values, text, strlen(text),
54 dbl, flt);
55 tracepoint(tp, tptest2, i, netint, values, text, strlen(text),
56 dbl, flt);
57 tracepoint(tp, tptest3, i, netint, values, text, strlen(text),
58 dbl, flt);
59 tracepoint(tp, tptest4, i, netint, values, text, strlen(text),
60 dbl, flt);
61 tracepoint(tp, tptest5, i, netint, values, text, strlen(text),
62 dbl, flt);
63 usleep(nr_usec);
64 }
65
66 return 0;
67 }
This page took 0.030673 seconds and 5 git commands to generate.