f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow/*
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow * This file and its contents are supplied under the terms of the
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow * Common Development and Distribution License ("CDDL"), version 1.0.
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow * You may only use this file in accordance with the terms of version
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow * 1.0 of the CDDL.
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow *
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow * A full copy of the text of the CDDL should have accompanied this
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow * source. A copy of the CDDL is also available via the Internet at
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow * http://www.illumos.org/license/CDDL.
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow */
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow/*
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow * Copyright 2012 (c), Joyent, Inc. All rights reserved.
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow */
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow#include <sys/sdt.h>
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow#include "usdt.h"
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow#define FMT "{" \
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow " \"sizes\": [ \"first\", 2, %f ]," \
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow " \"index\": %d," \
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow " \"facts\": {" \
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow " \"odd\": \"%s\"," \
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow " \"even\": \"%s\"" \
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow " }," \
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow " \"action\": \"%s\"" \
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow "}\n"
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulowint
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulowwaiting(volatile int *a)
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow{
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow return (*a);
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow}
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulowint
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulowmain(int argc, char **argv)
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow{
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow volatile int a = 0;
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow int idx;
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow double size = 250.5;
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow while (waiting(&a) == 0)
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow continue;
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow for (idx = 0; idx < 10; idx++) {
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow char *odd, *even, *json, *action;
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow size *= 1.78;
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow odd = idx % 2 == 1 ? "true" : "false";
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow even = idx % 2 == 0 ? "true" : "false";
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow action = idx == 7 ? "ignore" : "print";
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow asprintf(&json, FMT, size, idx, odd, even, action);
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow BUNYAN_FAKE_LOG_DEBUG(json);
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow free(json);
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow }
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow BUNYAN_FAKE_LOG_DEBUG("{\"finished\": true}");
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow return (0);
f497f9fe231e0e400f339c84a7d80c4aae2ac4d5Joshua M. Clulow}