1266987Smarkj/*
2266987Smarkj * This file and its contents are supplied under the terms of the
3266987Smarkj * Common Development and Distribution License ("CDDL"), version 1.0.
4266987Smarkj * You may only use this file in accordance with the terms of version
5266987Smarkj * 1.0 of the CDDL.
6266987Smarkj *
7266987Smarkj * A full copy of the text of the CDDL should have accompanied this
8266987Smarkj * source.  A copy of the CDDL is also available via the Internet at
9266987Smarkj * http://www.illumos.org/license/CDDL.
10266987Smarkj */
11266987Smarkj
12266987Smarkj/*
13266987Smarkj * Copyright 2012 (c), Joyent, Inc.  All rights reserved.
14266987Smarkj */
15266987Smarkj
16266987Smarkj#include <sys/sdt.h>
17313485Sngie#include <stdio.h>
18313485Sngie#include <stdlib.h>
19266987Smarkj#include "usdt.h"
20266987Smarkj
21266987Smarkj#define	FMT	"{" \
22266987Smarkj		"  \"sizes\": [ \"first\", 2, %f ]," \
23266987Smarkj		"  \"index\": %d," \
24266987Smarkj		"  \"facts\": {" \
25266987Smarkj		"    \"odd\": \"%s\"," \
26266987Smarkj		"    \"even\": \"%s\"" \
27266987Smarkj		"  }," \
28266987Smarkj		"  \"action\": \"%s\"" \
29266987Smarkj		"}\n"
30266987Smarkj
31266987Smarkjint
32266987Smarkjwaiting(volatile int *a)
33266987Smarkj{
34266987Smarkj	return (*a);
35266987Smarkj}
36266987Smarkj
37266987Smarkjint
38266987Smarkjmain(int argc, char **argv)
39266987Smarkj{
40266987Smarkj	volatile int a = 0;
41266987Smarkj	int idx;
42266987Smarkj	double size = 250.5;
43266987Smarkj
44266987Smarkj	while (waiting(&a) == 0)
45266987Smarkj		continue;
46266987Smarkj
47266987Smarkj	for (idx = 0; idx < 10; idx++) {
48266987Smarkj		char *odd, *even, *json, *action;
49266987Smarkj
50266987Smarkj		size *= 1.78;
51266987Smarkj		odd = idx % 2 == 1 ? "true" : "false";
52266987Smarkj		even = idx % 2 == 0 ? "true" : "false";
53266987Smarkj		action = idx == 7 ? "ignore" : "print";
54266987Smarkj
55266987Smarkj		asprintf(&json, FMT, size, idx, odd, even, action);
56266987Smarkj		BUNYAN_FAKE_LOG_DEBUG(json);
57266987Smarkj		free(json);
58266987Smarkj	}
59266987Smarkj
60266987Smarkj	BUNYAN_FAKE_LOG_DEBUG("{\"finished\": true}");
61266987Smarkj
62266987Smarkj	return (0);
63266987Smarkj}
64