From b44473af978aa2f178bc5b165a044dec0489a86d Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Wed, 11 Mar 2015 18:10:55 +0100 Subject: [PATCH] : Rename struct lwp_params member names. This is mainly to better "protect" them against 3rd party software doing silly things like lvm2 which has a "#define stack ..." that conflicted with the struct's 'stack' member, for example. It's a lame reason to rename the struct members, but, given that it is a public struct, it's a good thing to do so generally. Also, because it is a public structure, bump __DragonFly_version so it can be dealt with in code. I didn't find any usage of our lwp_* code in dports but it might be used in someone's own code still. --- lib/libthread_xu/thread/thr_create.c | 9 ++++----- sys/kern/kern_fork.c | 8 ++++---- sys/platform/pc64/x86_64/vm_machdep.c | 6 +++--- sys/platform/vkernel64/x86_64/vm_machdep.c | 6 +++--- sys/sys/param.h | 3 ++- sys/sys/unistd.h | 11 +++++------ 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/lib/libthread_xu/thread/thr_create.c b/lib/libthread_xu/thread/thr_create.c index d67fd5284b..658688c1af 100644 --- a/lib/libthread_xu/thread/thr_create.c +++ b/lib/libthread_xu/thread/thr_create.c @@ -32,7 +32,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libpthread/thread/thr_create.c,v 1.58 2004/10/23 23:28:36 davidxu Exp $ - * $DragonFly: src/lib/libthread_xu/thread/thr_create.c,v 1.12 2008/05/09 11:24:08 corecode Exp $ */ #include "namespace.h" @@ -165,10 +164,10 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr, stack = (char *)new_thread->attr.stackaddr_attr + new_thread->attr.stacksize_attr; bzero(&create_params, sizeof(create_params)); - create_params.func = thread_start; - create_params.arg = new_thread; - create_params.stack = stack; - create_params.tid1 = &new_thread->tid; + create_params.lwp_func = thread_start; + create_params.lwp_arg = new_thread; + create_params.lwp_stack = stack; + create_params.lwp_tid1 = &new_thread->tid; /* * Thread created by thr_create() inherits currrent thread * sigmask, however, before new thread setup itself correctly, diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 842f3e94e4..3bd4bd12bd 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -201,11 +201,11 @@ sys_lwp_create(struct lwp_create_args *uap) error = cpu_prepare_lwp(lp, ¶ms); if (error) goto fail; - if (params.tid1 != NULL && - (error = copyout(&lp->lwp_tid, params.tid1, sizeof(lp->lwp_tid)))) + if (params.lwp_tid1 != NULL && + (error = copyout(&lp->lwp_tid, params.lwp_tid1, sizeof(lp->lwp_tid)))) goto fail; - if (params.tid2 != NULL && - (error = copyout(&lp->lwp_tid, params.tid2, sizeof(lp->lwp_tid)))) + if (params.lwp_tid2 != NULL && + (error = copyout(&lp->lwp_tid, params.lwp_tid2, sizeof(lp->lwp_tid)))) goto fail; /* diff --git a/sys/platform/pc64/x86_64/vm_machdep.c b/sys/platform/pc64/x86_64/vm_machdep.c index 42ba8b940d..4ffc3fcbae 100644 --- a/sys/platform/pc64/x86_64/vm_machdep.c +++ b/sys/platform/pc64/x86_64/vm_machdep.c @@ -199,10 +199,10 @@ cpu_prepare_lwp(struct lwp *lp, struct lwp_params *params) void *bad_return = NULL; int error; - regs->tf_rip = (long)params->func; - regs->tf_rsp = (long)params->stack; + regs->tf_rip = (long)params->lwp_func; + regs->tf_rsp = (long)params->lwp_stack; /* Set up argument for function call */ - regs->tf_rdi = (long)params->arg; + regs->tf_rdi = (long)params->lwp_arg; /* * Set up fake return address. As the lwp function may never return, diff --git a/sys/platform/vkernel64/x86_64/vm_machdep.c b/sys/platform/vkernel64/x86_64/vm_machdep.c index 95929dadaf..61bea284e8 100644 --- a/sys/platform/vkernel64/x86_64/vm_machdep.c +++ b/sys/platform/vkernel64/x86_64/vm_machdep.c @@ -199,10 +199,10 @@ cpu_prepare_lwp(struct lwp *lp, struct lwp_params *params) void *bad_return = NULL; int error; - regs->tf_rip = (long)params->func; - regs->tf_rsp = (long)params->stack; + regs->tf_rip = (long)params->lwp_func; + regs->tf_rsp = (long)params->lwp_stack; /* Set up argument for function call */ - regs->tf_rdi = (long)params->arg; /* JG Can this be in userspace addresses? */ + regs->tf_rdi = (long)params->lwp_arg; /* JG Can this be in userspace addresses? */ /* * Set up fake return address. As the lwp function may never return, * we simply copy out a NULL pointer and force the lwp to receive diff --git a/sys/sys/param.h b/sys/sys/param.h index 3e79d23372..f48ebef19a 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -117,9 +117,10 @@ * 400101 - Removal of SCTP support. * 400102 - Sound system update from FreeBSD * 400103 - Milestone - availability of gcc50 in base + * 400104 - struct lwp_params (a public struct) members renaming */ #undef __DragonFly_version -#define __DragonFly_version 400103 /* propagated to newvers */ +#define __DragonFly_version 400104 /* propagated to newvers */ #include diff --git a/sys/sys/unistd.h b/sys/sys/unistd.h index 5be7eeef17..e27917c6f6 100644 --- a/sys/sys/unistd.h +++ b/sys/sys/unistd.h @@ -28,7 +28,6 @@ * * @(#)unistd.h 8.2 (Berkeley) 1/7/94 * $FreeBSD: src/sys/sys/unistd.h,v 1.50 2009/01/31 10:04:36 trhodes Exp $ - * $DragonFly: src/sys/sys/unistd.h,v 1.10 2008/09/22 09:13:21 hasso Exp $ */ #ifndef _SYS_UNISTD_H_ @@ -204,11 +203,11 @@ * Parameters for the creation of a new lwp. */ struct lwp_params { - void (*func)(void *); /* Function to start execution */ - void *arg; /* Parameter to this function */ - void *stack; /* Stack address to use */ - lwpid_t *tid1; /* Address to copy out new tid */ - lwpid_t *tid2; /* Same */ + void (*lwp_func)(void *); /* Function to start execution */ + void *lwp_arg; /* Parameter to this function */ + void *lwp_stack; /* Stack address to use */ + lwpid_t *lwp_tid1; /* Address to copy out new tid */ + lwpid_t *lwp_tid2; /* Same */ }; #endif /* __BSD_VISIBLE */ -- 2.41.0