int thread_attr_set(thread_attr_t attr, int field, ...) { va_list ap; int rc = TRUE; if(attr == NULL) return EINVAL; va_start(ap, field); switch (field) { case THREAD_ATTR_JOINABLE: { int val = va_arg(ap, int); if(attr->thread == NULL) { if( val == THREAD_CREATE_JOINABLE ) attr->joinable = TRUE; else attr->joinable = FALSE; } else { if( val == THREAD_CREATE_JOINABLE ) attr->thread->joinable = 1; else attr->thread->joinable = 0; } break; } default: notimplemented(thread_attr_set); } va_end(ap); return rc; }
int pthread_setcanceltype(int type, int *oldtype) { (void) type; (void) oldtype; /* int t, ot; if (oldtype != NULL) { thread_cancel_state(0, &ot); if (ot & THREAD_CANCEL_DEFERRED) *oldtype = PTHREAD_CANCEL_DEFERRED; else *oldtype = PTHREAD_CANCEL_ASYNCHRONOUS; } if (type != 0) { thread_cancel_state(0, &t); if (type == PTHREAD_CANCEL_DEFERRED) { t |= THREAD_CANCEL_DEFERRED; t &= ~(THREAD_CANCEL_ASYNCHRONOUS); } else { t |= THREAD_CANCEL_ASYNCHRONOUS; t &= ~(THREAD_CANCEL_DEFERRED); } thread_cancel_state(t, NULL); } */ notimplemented(pthread_setcanceltype); return OK; }
void pthread_cleanup_pop(int execute) { (void) execute; // thread_cleanup_pop(execute); notimplemented(pthread_cleanup_pop); return; }
int pthread_setcancelstate(int state, int *oldstate) { (void) state; (void) oldstate; /* int s, os; if (oldstate != NULL) { thread_cancel_state(0, &os); if (os & THREAD_CANCEL_ENABLE) *oldstate = PTHREAD_CANCEL_ENABLE; else *oldstate = PTHREAD_CANCEL_DISABLE; } if (state != 0) { thread_cancel_state(0, &s); if (state == PTHREAD_CANCEL_ENABLE) { s |= THREAD_CANCEL_ENABLE; s &= ~(THREAD_CANCEL_DISABLE); } else { s |= THREAD_CANCEL_DISABLE; s &= ~(THREAD_CANCEL_ENABLE); } thread_cancel_state(s, NULL); } */ notimplemented(pthread_setcancelstate); return OK; }
int pthread_cancel(pthread_t thread) { (void) thread; // if (!thread_cancel((thread_t)thread)) // return errno; notimplemented(pthread_cancel); return OK; }
void pthread_cleanup_push(void (*routine)(void *), void *arg) { (void) routine; (void) arg; pthread_initialize(); // thread_cleanup_push(routine, arg); notimplemented(pthread_cleanup_push); return; }
int pthread_attr_setname_np(pthread_attr_t *attr, char *name) { if (attr == NULL || name == NULL) return_errno(EINVAL, EINVAL); notimplemented(pthread_attr_setname_np); // if (!thread_attr_set((thread_attr_t)(*attr), THREAD_ATTR_NAME, name)) // return errno; return OK; }
int thread_attr_get(thread_attr_t attr, int field, ...) { va_list ap; int rc = TRUE; va_start(ap, field); switch (field) { case THREAD_ATTR_JOINABLE: { int *val = va_arg(ap, int *); int joinable = (attr->thread == NULL) ? attr->joinable : attr->thread->joinable; *val = joinable ? THREAD_CREATE_JOINABLE : THREAD_CREATE_DETACHED; } default: notimplemented(thread_attr_get); } va_end(ap); return rc; }
void pthread_testcancel(void) { // thread_cancel_point(); notimplemented(pthread_testcancel); return; }