+static kern_return_t chud_null_syscall(uint64_t code __unused,
+ uint64_t arg0 __unused, uint64_t arg1 __unused, uint64_t arg2 __unused,
+ uint64_t arg3 __unused, uint64_t arg4 __unused) {
+ return (kern_return_t)EINVAL;
+}
+
+/*
+ * chud
+ *
+ * Performs performance-related tasks. A private interface registers a handler for this
+ * system call. The implementation is in the CHUDProf kernel extension.
+ *
+ * chud() is a callback style system call used by the CHUD Tools suite of performance tools. If the CHUD
+ * kexts are not loaded, this system call will always return EINVAL. The CHUD kexts contain the
+ * implementation of the system call.
+ *
+ * The current behavior of the chud() system call is as follows:
+ *
+ * Parameters: p (ignored)
+ * uap User argument descriptor (see below)
+ * retval return value of fn (the function returned by syscall_callback_fn)
+ *
+ * Indirect parameters: uap->code Selects the operation to do. This is broken down into a
+ * 16-bit facility and a 16-bit action.
+ *
+ * The rest of the indirect parameters depend on the facility and the action that is selected:
+ *
+ * Facility: 1 Amber instruction tracer
+ * Action: 1 Indicate that a new thread has been created. No arguments are used.
+ *
+ * Action: 2 Indicate that a thread is about to exit. No arguments are used.
+ *
+ * Facility: 2 Not Supported for this system call
+ *
+ * Facility: 3 CHUD Trace facility
+ * Action: 1 Record a backtrace of the calling process into the CHUD Trace facility sample
+ * buffer.
+ *
+ * uap->arg1 Number of frames to skip
+ * uap->arg2 Pointer to a uint64_t containing a timestamp for the
+ * beginning of the sample. NULL uses the current time.
+ * uap->arg3 Pointer to a uint64_t containing a timestamp for the end
+ * of the sample. NULL uses the current time.
+ * uap->arg4 Pointer to auxiliary data to be recorded with the sample
+ * uap->arg5 Size of the auxiliary data pointed to by arg4.
+ *
+ * Returns: EINVAL If syscall_callback_fn returns an invalid function
+ * KERN_SUCCESS Success
+ * KERN_FAILURE Generic failure
+ * KERN_NO_SPACE Auxiliary data is too large (only used by Facility: 3)
+ *
+ * Implicit returns: retval return value of fn (the function returned by syscall_callback_fn)
+ */
+int
+chud(__unused proc_t p, struct chud_args *uap, int32_t *retval)