1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2012 (c), Joyent, Inc.  All rights reserved.
14  */
15 
16 #include <sys/sdt.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include "usdt.h"
20 
21 #define	FMT	"{" \
22 		"  \"sizes\": [ \"first\", 2, %f ]," \
23 		"  \"index\": %d," \
24 		"  \"facts\": {" \
25 		"    \"odd\": \"%s\"," \
26 		"    \"even\": \"%s\"" \
27 		"  }," \
28 		"  \"action\": \"%s\"" \
29 		"}\n"
30 
31 int waiting(volatile int *);
32 
33 int
34 waiting(volatile int *a)
35 {
36 	return (*a);
37 }
38 
39 int
40 main(void)
41 {
42 	volatile int a = 0;
43 	int idx;
44 	double size = 250.5;
45 
46 	while (waiting(&a) == 0)
47 		continue;
48 
49 	for (idx = 0; idx < 10; idx++) {
50 		const char *odd, *even, *action;
51 		char *json;
52 
53 		size *= 1.78;
54 		odd = idx % 2 == 1 ? "true" : "false";
55 		even = idx % 2 == 0 ? "true" : "false";
56 		action = idx == 7 ? "ignore" : "print";
57 
58 		asprintf(&json, FMT, size, idx, odd, even, action);
59 		BUNYAN_FAKE_LOG_DEBUG(json);
60 		free(json);
61 	}
62 
63 	BUNYAN_FAKE_LOG_DEBUG(__DECONST(char *, "{\"finished\": true}"));
64 
65 	return (0);
66 }
67