fix: namespacing of 'tp_rcu_read_lock'
[lttng-ust.git] / tests / compile / hello.cxx / hello.cpp
CommitLineData
6b79f035 1/*
c0c0989a 2 * SPDX-License-Identifier: LGPL-2.1-only
6b79f035 3 *
c0c0989a
MJ
4 * Copyright (C) 2009 Pierre-Marc Fournier
5 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6b79f035
MD
6 */
7
8#include <stdio.h>
9#include <unistd.h>
10#include <sys/mman.h>
11#include <stdarg.h>
12#include <sys/types.h>
13#include <sys/stat.h>
14#include <fcntl.h>
15#include <signal.h>
16#include <string.h>
17#include <arpa/inet.h>
40b2b5a4 18#include <stdlib.h>
6b79f035 19
88c7c4ea 20#define LTTNG_UST_TRACEPOINT_DEFINE
6b79f035
MD
21#include "ust_tests_hello.h"
22
4b4a1337 23static
2208d8b5 24void inthandler(int sig __attribute__((unused)))
6b79f035
MD
25{
26 printf("in SIGUSR1 handler\n");
27 tracepoint(ust_tests_hello, tptest_sighandler);
28}
29
4b4a1337 30static
6b79f035
MD
31int init_int_handler(void)
32{
33 int result;
34 struct sigaction act;
35
36 memset(&act, 0, sizeof(act));
37 result = sigemptyset(&act.sa_mask);
38 if (result == -1) {
39 perror("sigemptyset");
40 return -1;
41 }
42
43 act.sa_handler = inthandler;
44 act.sa_flags = SA_RESTART;
45
46 /* Only defer ourselves. Also, try to restart interrupted
47 * syscalls to disturb the traced program as little as possible.
48 */
49 result = sigaction(SIGUSR1, &act, NULL);
50 if (result == -1) {
51 perror("sigaction");
52 return -1;
53 }
54
55 return 0;
56}
57
58int main(int argc, char **argv)
59{
60 int i, netint;
61 long values[] = { 1, 2, 3 };
62 char text[10] = "test";
63 double dbl = 2.0;
64 float flt = 2222.0;
65 int delay = 0;
66
67 init_int_handler();
68
69 if (argc == 2)
70 delay = atoi(argv[1]);
71
72 fprintf(stderr, "Hello, World!\n");
73
74 sleep(delay);
75
76 fprintf(stderr, "Tracing... ");
77 for (i = 0; i < 1000000; i++) {
78 netint = htonl(i);
79 tracepoint(ust_tests_hello, tptest, i, netint, values,
95526f2d 80 text, strlen(text), dbl, flt, 15);
6b79f035
MD
81 //usleep(100000);
82 }
83 fprintf(stderr, " done.\n");
84 return 0;
85}
This page took 0.033109 seconds and 4 git commands to generate.