+int
+pthread_workqueue_setdispatch_np(void (*worker_func)(int, int, void *))
+{
+ int error = 0;
+
+ if (__workqueue_oldspis != 0)
+ return(EPERM);
+
+ __workqueue_newspis = 1;
+
+ if (__libdispatch_workerfunction == NULL) {
+ __libdispatch_workerfunction = worker_func;
+ /* check whether the kernel supports new SPIs */
+ error = __workq_kernreturn(WQOPS_QUEUE_NEWSPISUPP, NULL, 0, 0);
+ if (error == -1){
+ __libdispatch_workerfunction = NULL;
+ error = ENOTSUP;
+ __workqueue_newspis = 0;
+ } else {
+ /* prepare the kernel for workq action */
+ (void)__workq_open();
+ kernel_workq_setup = 1;
+ if (__is_threaded == 0)
+ __is_threaded = 1;
+ __workqueue_newspis = 1;
+ }
+ } else {
+ error = EBUSY;
+ }
+
+ return(error);
+}
+
+int
+pthread_workqueue_addthreads_np(int queue_priority, int options, int numthreads)
+{
+ int priority = queue_priority & WQ_FLAG_THREAD_PRIOMASK;
+ int error = 0;
+
+ /* new spi not inited yet?? */
+ if (__workqueue_newspis == 0)
+ return(EPERM);
+
+
+ if ((options & WORKQ_ADDTHREADS_OPTION_OVERCOMMIT) != 0)
+ priority |= WORKQUEUE_OVERCOMMIT;
+
+ error = __workq_kernreturn(WQOPS_QUEUE_REQTHREADS, NULL, numthreads, priority);
+
+ if (error == -1)
+ return(errno);
+ else
+ return(0);
+}
+