Blame doc/examples/demo/demo.c

Packit c04fcb
/*
Packit c04fcb
 * Copyright (C) 2009  Pierre-Marc Fournier
Packit c04fcb
 * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Packit c04fcb
 *
Packit c04fcb
 * This library is free software; you can redistribute it and/or
Packit c04fcb
 * modify it under the terms of the GNU Lesser General Public
Packit c04fcb
 * License as published by the Free Software Foundation; version 2.1 of
Packit c04fcb
 * the License.
Packit c04fcb
 *
Packit c04fcb
 * This library is distributed in the hope that it will be useful,
Packit c04fcb
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit c04fcb
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit c04fcb
 * Lesser General Public License for more details.
Packit c04fcb
 *
Packit c04fcb
 * You should have received a copy of the GNU Lesser General Public
Packit c04fcb
 * License along with this library; if not, write to the Free Software
Packit c04fcb
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
Packit c04fcb
 */
Packit c04fcb
Packit c04fcb
#include <stdio.h>
Packit c04fcb
#include <unistd.h>
Packit c04fcb
#include <sys/mman.h>
Packit c04fcb
#include <stdarg.h>
Packit c04fcb
#include <sys/types.h>
Packit c04fcb
#include <sys/stat.h>
Packit c04fcb
#include <fcntl.h>
Packit c04fcb
#include <signal.h>
Packit c04fcb
#include <string.h>
Packit c04fcb
#include <arpa/inet.h>
Packit c04fcb
#include <stdlib.h>
Packit c04fcb
Packit c04fcb
#define TRACEPOINT_DEFINE
Packit c04fcb
#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
Packit c04fcb
#include "ust_tests_demo.h"
Packit c04fcb
#include "ust_tests_demo2.h"
Packit c04fcb
#include "ust_tests_demo3.h"
Packit c04fcb
Packit c04fcb
int main(int argc, char **argv)
Packit c04fcb
{
Packit c04fcb
	int i, netint;
Packit c04fcb
	long values[] = { 1, 2, 3 };
Packit c04fcb
	char text[10] = "test";
Packit c04fcb
	double dbl = 2.0;
Packit c04fcb
	float flt = 2222.0;
Packit c04fcb
	int delay = 0;
Packit c04fcb
Packit c04fcb
	if (argc == 2)
Packit c04fcb
		delay = atoi(argv[1]);
Packit c04fcb
Packit c04fcb
	fprintf(stderr, "Demo program starting.\n");
Packit c04fcb
Packit c04fcb
	sleep(delay);
Packit c04fcb
Packit c04fcb
	fprintf(stderr, "Tracing... ");
Packit c04fcb
	tracepoint(ust_tests_demo, starting, 123);
Packit c04fcb
	for (i = 0; i < 5; i++) {
Packit c04fcb
		netint = htonl(i);
Packit c04fcb
		tracepoint(ust_tests_demo2, loop, i, netint, values,
Packit c04fcb
			   text, strlen(text), dbl, flt);
Packit c04fcb
	}
Packit c04fcb
	tracepoint(ust_tests_demo, done, 456);
Packit c04fcb
	tracepoint(ust_tests_demo3, done, 42);
Packit c04fcb
	fprintf(stderr, " done.\n");
Packit c04fcb
	return 0;
Packit c04fcb
}