SoW-2019-0002: Dynamic Snapshot
[lttng-tools.git] / tests / regression / ust / high-throughput / main.c
... / ...
CommitLineData
1/*
2 * Copyright (C) 2009 Pierre-Marc Fournier
3 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 *
5 * SPDX-License-Identifier: LGPL-2.1-only
6 *
7 */
8
9#include <stdio.h>
10#include <unistd.h>
11#include <sys/mman.h>
12#include <stdarg.h>
13#include <sys/types.h>
14#include <sys/stat.h>
15#include <fcntl.h>
16#include <signal.h>
17#include <string.h>
18#include <arpa/inet.h>
19#include <stdlib.h>
20
21#define TRACEPOINT_DEFINE
22#include "tp.h"
23
24static void inthandler(int sig)
25{
26}
27
28static int init_int_handler(void)
29{
30 int result;
31 struct sigaction act;
32
33 memset(&act, 0, sizeof(act));
34 result = sigemptyset(&act.sa_mask);
35 if (result == -1) {
36 perror("sigemptyset");
37 return -1;
38 }
39
40 act.sa_handler = inthandler;
41 act.sa_flags = SA_RESTART;
42
43 /* Only defer ourselves. Also, try to restart interrupted
44 * syscalls to disturb the traced program as little as possible.
45 */
46 result = sigaction(SIGUSR1, &act, NULL);
47 if (result == -1) {
48 perror("sigaction");
49 return -1;
50 }
51
52 return 0;
53}
54
55int main(int argc, char **argv)
56{
57 int i, netint;
58 long values[] = { 1, 2, 3 };
59 char text[10] = "test";
60 double dbl = 2.0;
61 float flt = 2222.0;
62 int delay = 0;
63
64 init_int_handler();
65
66 if (argc == 2)
67 delay = atoi(argv[1]);
68
69 sleep(delay);
70
71 for (i = 0; i < 1000000; i++) {
72 netint = htonl(i);
73 tracepoint(tp, tptest, i, netint, values, text,
74 strlen(text), dbl, flt);
75 }
76
77 return 0;
78}
This page took 0.023854 seconds and 5 git commands to generate.