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>
17266987Smarkj#include "usdt.h"
18266987Smarkj
19266987Smarkj#define	FMT	"{" \
20266987Smarkj		"  \"sizes\": [ \"first\", 2, %f ]," \
21266987Smarkj		"  \"index\": %d," \
22266987Smarkj		"  \"facts\": {" \
23266987Smarkj		"    \"odd\": \"%s\"," \
24266987Smarkj		"    \"even\": \"%s\"" \
25266987Smarkj		"  }," \
26266987Smarkj		"  \"action\": \"%s\"" \
27266987Smarkj		"}\n"
28266987Smarkj
29266987Smarkjint
30266987Smarkjwaiting(volatile int *a)
31266987Smarkj{
32266987Smarkj	return (*a);
33266987Smarkj}
34266987Smarkj
35266987Smarkjint
36266987Smarkjmain(int argc, char **argv)
37266987Smarkj{
38266987Smarkj	volatile int a = 0;
39266987Smarkj	int idx;
40266987Smarkj	double size = 250.5;
41266987Smarkj
42266987Smarkj	while (waiting(&a) == 0)
43266987Smarkj		continue;
44266987Smarkj
45266987Smarkj	for (idx = 0; idx < 10; idx++) {
46266987Smarkj		char *odd, *even, *json, *action;
47266987Smarkj
48266987Smarkj		size *= 1.78;
49266987Smarkj		odd = idx % 2 == 1 ? "true" : "false";
50266987Smarkj		even = idx % 2 == 0 ? "true" : "false";
51266987Smarkj		action = idx == 7 ? "ignore" : "print";
52266987Smarkj
53266987Smarkj		asprintf(&json, FMT, size, idx, odd, even, action);
54266987Smarkj		BUNYAN_FAKE_LOG_DEBUG(json);
55266987Smarkj		free(json);
56266987Smarkj	}
57266987Smarkj
58266987Smarkj	BUNYAN_FAKE_LOG_DEBUG("{\"finished\": true}");
59266987Smarkj
60266987Smarkj	return (0);
61266987Smarkj}
62