fix: namespacing of 'tp_rcu_read_lock'
[lttng-ust.git] / tests / compile / hello / hello.c
CommitLineData
81614639 1/*
c0c0989a 2 * SPDX-License-Identifier: LGPL-2.1-only
a09dac63 3 *
c0c0989a
MJ
4 * Copyright (C) 2009 Pierre-Marc Fournier
5 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
a09dac63
PMF
6 */
7
68c1021b
PMF
8#include <stdio.h>
9#include <unistd.h>
b6bf28ec 10#include <sys/mman.h>
9c67dc50
PMF
11#include <stdarg.h>
12#include <sys/types.h>
13#include <sys/stat.h>
14#include <fcntl.h>
4486e566 15#include <signal.h>
5dba5937 16#include <string.h>
3e4e9902
MD
17/*
18 * Work-around inet.h missing struct mmsghdr forward declaration, with
19 * triggers a warning when system files warnings are enabled.
20 */
21struct mmsghdr;
9a396c3c 22#include <arpa/inet.h>
40b2b5a4 23#include <stdlib.h>
f121009f 24#include <stdbool.h>
68c1021b 25
88c7c4ea 26#define LTTNG_UST_TRACEPOINT_DEFINE
41aaf8a5 27#include "ust_tests_hello.h"
59b161cd 28
4b4a1337 29static
2208d8b5 30void inthandler(int sig __attribute__((unused)))
8d938dbd 31{
8d8a24c8 32 printf("in SIGUSR1 handler\n");
cbc06a3b 33 lttng_ust_tracepoint(ust_tests_hello, tptest_sighandler);
8d938dbd
PMF
34}
35
4b4a1337 36static
8d938dbd
PMF
37int init_int_handler(void)
38{
39 int result;
40 struct sigaction act;
41
1ea11eab 42 memset(&act, 0, sizeof(act));
8d938dbd 43 result = sigemptyset(&act.sa_mask);
81614639 44 if (result == -1) {
41aaf8a5 45 perror("sigemptyset");
8d938dbd
PMF
46 return -1;
47 }
48
49 act.sa_handler = inthandler;
50 act.sa_flags = SA_RESTART;
51
52 /* Only defer ourselves. Also, try to restart interrupted
53 * syscalls to disturb the traced program as little as possible.
54 */
8d8a24c8 55 result = sigaction(SIGUSR1, &act, NULL);
81614639 56 if (result == -1) {
41aaf8a5 57 perror("sigaction");
8d938dbd
PMF
58 return -1;
59 }
60
61 return 0;
62}
63
8d8a24c8 64int main(int argc, char **argv)
b6bf28ec 65{
9a396c3c 66 int i, netint;
775e7fd8 67 long values[] = { 1, 2, 3 };
5dba5937 68 char text[10] = "test";
513fc97e
MD
69 double dbl = 2.0;
70 float flt = 2222.0;
ff927bae 71 int delay = 0;
f121009f 72 bool mybool = 123; /* should print "1" */
5f54827b 73
8d938dbd
PMF
74 init_int_handler();
75
ff927bae
MD
76 if (argc == 2)
77 delay = atoi(argv[1]);
59b161cd 78
ff927bae 79 fprintf(stderr, "Hello, World!\n");
8d8a24c8 80
ff927bae
MD
81 sleep(delay);
82
83 fprintf(stderr, "Tracing... ");
c95f3a3a 84 for (i = 0; i < 1000000; i++) {
9a396c3c 85 netint = htonl(i);
cbc06a3b 86 lttng_ust_tracepoint(ust_tests_hello, tptest, i, netint, values,
f121009f 87 text, strlen(text), dbl, flt, mybool);
c95f3a3a 88 //usleep(100000);
8d938dbd 89 }
ff927bae 90 fprintf(stderr, " done.\n");
68c1021b
PMF
91 return 0;
92}
This page took 0.039526 seconds and 4 git commands to generate.