diff options
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_thr.c | 29 | ||||
-rw-r--r-- | sys/kern/kern_umtx.c | 8 | ||||
-rw-r--r-- | sys/kern/syscalls.master | 8 |
3 files changed, 25 insertions, 20 deletions
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index 50fed6e..d1b5d3f 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -118,11 +118,12 @@ thr_exit1(void) */ int thr_create(struct thread *td, struct thr_create_args *uap) - /* ucontext_t *ctx, thr_id_t *id, int flags */ + /* ucontext_t *ctx, long *id, int flags */ { struct kse *ke0; struct thread *td0; ucontext_t ctx; + long id; int error; if ((error = copyin(uap->ctx, &ctx, sizeof(ctx)))) @@ -135,7 +136,8 @@ thr_create(struct thread *td, struct thr_create_args *uap) * Try the copyout as soon as we allocate the td so we don't have to * tear things down in a failure case below. */ - if ((error = copyout(&td0, uap->id, sizeof(thr_id_t)))) { + id = td0->td_tid; + if ((error = copyout(&id, uap->id, sizeof(long)))) { thread_free(td0); return (error); } @@ -163,7 +165,7 @@ thr_create(struct thread *td, struct thr_create_args *uap) kse_free(ke0); thread_free(td0); goto out; - } + } /* Link the thread and kse into the ksegrp and make it runnable. */ mtx_lock_spin(&sched_lock); @@ -190,11 +192,13 @@ out: int thr_self(struct thread *td, struct thr_self_args *uap) - /* thr_id_t *id */ + /* long *id */ { + long id; int error; - if ((error = copyout(&td, uap->id, sizeof(thr_id_t)))) + id = td->td_tid; + if ((error = copyout(&id, uap->id, sizeof(long)))) return (error); return (0); @@ -223,7 +227,7 @@ thr_exit(struct thread *td, struct thr_exit_args *uap) int thr_kill(struct thread *td, struct thr_kill_args *uap) - /* thr_id_t id, int sig */ + /* long id, int sig */ { struct thread *ttd; struct proc *p; @@ -233,7 +237,7 @@ thr_kill(struct thread *td, struct thr_kill_args *uap) error = 0; PROC_LOCK(p); FOREACH_THREAD_IN_PROC(p, ttd) { - if (ttd == uap->id) + if (ttd->td_tid == uap->id) break; } if (ttd == NULL) { @@ -291,14 +295,13 @@ thr_suspend(struct thread *td, struct thr_suspend_args *uap) int thr_wake(struct thread *td, struct thr_wake_args *uap) - /* thr_id_t id */ + /* long id */ { - struct thread *tdsleeper, *ttd; + struct thread *ttd; - tdsleeper = ((struct thread *)uap->id); PROC_LOCK(td->td_proc); FOREACH_THREAD_IN_PROC(td->td_proc, ttd) { - if (ttd == tdsleeper) + if (ttd->td_tid == uap->id) break; } if (ttd == NULL) { @@ -306,9 +309,9 @@ thr_wake(struct thread *td, struct thr_wake_args *uap) return (ESRCH); } mtx_lock_spin(&sched_lock); - tdsleeper->td_flags |= TDF_THRWAKEUP; + ttd->td_flags |= TDF_THRWAKEUP; mtx_unlock_spin(&sched_lock); - wakeup_one((void *)tdsleeper); + wakeup_one((void *)ttd); PROC_UNLOCK(td->td_proc); return (0); } diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index e767ec8..e1ae68d 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/kernel.h> +#include <sys/limits.h> #include <sys/lock.h> #include <sys/malloc.h> #include <sys/mutex.h> @@ -62,6 +63,7 @@ MTX_SYSINIT(umtx, &umtx_lock, "umtx", MTX_DEF); #define UMTX_LOCK() mtx_lock(&umtx_lock); #define UMTX_UNLOCK() mtx_unlock(&umtx_lock); +#define UMTX_CONTESTED LONG_MIN static struct umtx_q *umtx_lookup(struct thread *, struct umtx *umtx); static struct umtx_q *umtx_insert(struct thread *, struct umtx *umtx); @@ -161,7 +163,7 @@ _umtx_lock(struct thread *td, struct _umtx_lock_args *uap) * Try the uncontested case. This should be done in userland. */ owner = casuptr((intptr_t *)&umtx->u_owner, - UMTX_UNOWNED, (intptr_t)td); + UMTX_UNOWNED, td->td_tid); /* The address was invalid. */ if (owner == -1) @@ -174,7 +176,7 @@ _umtx_lock(struct thread *td, struct _umtx_lock_args *uap) /* If no one owns it but it is contested try to acquire it. */ if (owner == UMTX_CONTESTED) { owner = casuptr((intptr_t *)&umtx->u_owner, - UMTX_CONTESTED, ((intptr_t)td | UMTX_CONTESTED)); + UMTX_CONTESTED, td->td_tid | UMTX_CONTESTED); /* The address was invalid. */ if (owner == -1) @@ -263,7 +265,7 @@ _umtx_unlock(struct thread *td, struct _umtx_unlock_args *uap) if ((owner = fuword(&umtx->u_owner)) == -1) return (EFAULT); - if ((struct thread *)(owner & ~UMTX_CONTESTED) != td) + if ((owner & ~UMTX_CONTESTED) != td->td_tid) return (EPERM); /* We should only ever be in here for contested locks */ diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 8d18d5a..acab8e0 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -613,10 +613,10 @@ 428 MSTD { int __acl_aclcheck_link(const char *path, \ acl_type_t type, struct acl *aclp); } 429 MSTD { int sigwait(const sigset_t *set, int *sig); } -430 MSTD { int thr_create(ucontext_t *ctx, thr_id_t *id, int flags); } +430 MSTD { int thr_create(ucontext_t *ctx, long *id, int flags); } 431 MSTD { void thr_exit(void); } -432 MSTD { int thr_self(thr_id_t *id); } -433 MSTD { int thr_kill(thr_id_t id, int sig); } +432 MSTD { int thr_self(long *id); } +433 MSTD { int thr_kill(long id, int sig); } 434 MSTD { int _umtx_lock(struct umtx *umtx); } 435 MSTD { int _umtx_unlock(struct umtx *umtx); } 436 MSTD { int jail_attach(int jid); } @@ -630,6 +630,6 @@ long val, long *loc); } 441 MNOSTD { int ksem_timedwait(semid_t id, struct timespec *abstime); } 442 MSTD { int thr_suspend(const struct timespec *timeout); } -443 MSTD { int thr_wake(thr_id_t id); } +443 MSTD { int thr_wake(long id); } ; Please copy any additions and changes to the following compatability tables: ; sys/compat/freebsd32/syscalls.master |