mirror of
https://git.freebsd.org/ports.git
synced 2025-07-18 01:39:16 -04:00
Correct retrieval of stack address and size when getting the current
thread attributes for the main thread. Add emulation of native threads (libc_r) method of getting the current thread attributes (pthread_attr_get_np()) and adjust emulation of native threads pthread_attr_getstackaddr() to return bottom of stack instead of top of stack. Correct emulation of native threads pthread_mutexattr_settype() when selecting recursive mutexes. Previously, the argument conversion before calling the linuxthreads version of pthread_mutexattr_setattr() ended up selecting errorcheck mutexes instead of recursive mutexes.
This commit is contained in:
parent
3a0ccf7858
commit
18eb964d17
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=187943
2 changed files with 39 additions and 3 deletions
|
@ -311,6 +311,26 @@ diff -ru ../../work/linuxthreads-2.2.3/attr.c ./attr.c
|
||||||
attr->__inheritsched = PTHREAD_EXPLICIT_SCHED;
|
attr->__inheritsched = PTHREAD_EXPLICIT_SCHED;
|
||||||
attr->__scope = PTHREAD_SCOPE_SYSTEM;
|
attr->__scope = PTHREAD_SCOPE_SYSTEM;
|
||||||
attr->__guardsize = ps;
|
attr->__guardsize = ps;
|
||||||
|
@@ -283,6 +286,9 @@
|
||||||
|
|
||||||
|
attr->__inheritsched = descr->p_inheritsched;
|
||||||
|
attr->__scope = PTHREAD_SCOPE_SYSTEM;
|
||||||
|
+ if (descr == &__pthread_initial_thread)
|
||||||
|
+ attr->__stacksize = 3 * STACK_SIZE;
|
||||||
|
+ else
|
||||||
|
attr->__stacksize = (char *)(descr + 1) - (char *)descr->p_guardaddr
|
||||||
|
- descr->p_guardsize;
|
||||||
|
attr->__guardsize = descr->p_guardsize;
|
||||||
|
@@ -295,6 +301,9 @@
|
||||||
|
otherwise the range of the stack area cannot be computed. */
|
||||||
|
attr->__stacksize += attr->__guardsize;
|
||||||
|
#endif
|
||||||
|
+ if (descr == &__pthread_initial_thread)
|
||||||
|
+ attr->__stackaddr = __pthread_initial_thread_bos + 3 * STACK_SIZE;
|
||||||
|
+ else
|
||||||
|
#ifndef _STACK_GROWS_UP
|
||||||
|
attr->__stackaddr = (char *)(descr + 1);
|
||||||
|
#else
|
||||||
diff -ru ../../work/linuxthreads-2.2.3/cancel.c ./cancel.c
|
diff -ru ../../work/linuxthreads-2.2.3/cancel.c ./cancel.c
|
||||||
--- ../../work/linuxthreads-2.2.3/cancel.c Thu Apr 12 23:10:53 2001
|
--- ../../work/linuxthreads-2.2.3/cancel.c Thu Apr 12 23:10:53 2001
|
||||||
+++ ./cancel.c Thu Jun 7 22:59:29 2001
|
+++ ./cancel.c Thu Jun 7 22:59:29 2001
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $FreeBSD: /tmp/pcvs/ports/devel/linuxthreads/files/wraputhread.c,v 1.4 2005-07-22 22:20:21 tegge Exp $
|
* $FreeBSD: /tmp/pcvs/ports/devel/linuxthreads/files/wraputhread.c,v 1.5 2007-03-21 21:40:24 tegge Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LINUXTHREADS_WRAP_API
|
#ifdef LINUXTHREADS_WRAP_API
|
||||||
|
@ -69,6 +69,7 @@
|
||||||
#define __pthread_detach linuxthreads_pthread_detach
|
#define __pthread_detach linuxthreads_pthread_detach
|
||||||
#define __pthread_equal linuxthreads_pthread_equal
|
#define __pthread_equal linuxthreads_pthread_equal
|
||||||
#define __pthread_exit linuxthreads_pthread_exit
|
#define __pthread_exit linuxthreads_pthread_exit
|
||||||
|
#define __pthread_getattr_np linuxthreads_pthread_getattr_np
|
||||||
#define __pthread_getcpuclockid linuxthreads_pthread_getcpuclockid
|
#define __pthread_getcpuclockid linuxthreads_pthread_getcpuclockid
|
||||||
#define __pthread_getschedparam linuxthreads_pthread_getschedparam
|
#define __pthread_getschedparam linuxthreads_pthread_getschedparam
|
||||||
#define __pthread_join linuxthreads_pthread_join
|
#define __pthread_join linuxthreads_pthread_join
|
||||||
|
@ -118,6 +119,7 @@
|
||||||
#define __pthread_detach pthread_detach
|
#define __pthread_detach pthread_detach
|
||||||
#define __pthread_equal pthread_equal
|
#define __pthread_equal pthread_equal
|
||||||
#define __pthread_exit pthread_exit
|
#define __pthread_exit pthread_exit
|
||||||
|
#define __pthread_getattr_np pthread_getattr_np
|
||||||
#define __pthread_getschedparam pthread_getschedparam
|
#define __pthread_getschedparam pthread_getschedparam
|
||||||
#define __pthread_join pthread_join
|
#define __pthread_join pthread_join
|
||||||
#define __pthread_key_delete pthread_key_delete
|
#define __pthread_key_delete pthread_key_delete
|
||||||
|
@ -186,6 +188,7 @@ int __pthread_create(pthread_t *,
|
||||||
int __pthread_detach(pthread_t);
|
int __pthread_detach(pthread_t);
|
||||||
int __pthread_equal(pthread_t, pthread_t);
|
int __pthread_equal(pthread_t, pthread_t);
|
||||||
void __pthread_exit(void *);
|
void __pthread_exit(void *);
|
||||||
|
int __pthread_getattr_np(pthread_t, pthread_attr_t *);
|
||||||
int __pthread_getconcurrency(void);
|
int __pthread_getconcurrency(void);
|
||||||
int __pthread_getschedparam(pthread_t, int *, struct sched_param *);
|
int __pthread_getschedparam(pthread_t, int *, struct sched_param *);
|
||||||
void *__pthread_getspecific(pthread_key_t);
|
void *__pthread_getspecific(pthread_key_t);
|
||||||
|
@ -230,6 +233,10 @@ int __pthread_setspecific(pthread_key_t, const void *);
|
||||||
int __pthread_sigmask(int, const sigset_t *, sigset_t *);
|
int __pthread_sigmask(int, const sigset_t *, sigset_t *);
|
||||||
void __pthread_testcancel(void);
|
void __pthread_testcancel(void);
|
||||||
|
|
||||||
|
extern int pthread_attr_get_np(pthread_t, pthread_attr_t *)
|
||||||
|
__attribute__ ((weak, alias("_pthread_attr_get_np")));
|
||||||
|
|
||||||
|
|
||||||
static pthread_mutex_t allocmutexlock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t allocmutexlock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
enum uthread_mutextype {
|
enum uthread_mutextype {
|
||||||
UTHREAD_PTHREAD_MUTEX_ERRORCHECK = 1, /* Default POSIX mutex */
|
UTHREAD_PTHREAD_MUTEX_ERRORCHECK = 1, /* Default POSIX mutex */
|
||||||
|
@ -537,9 +544,10 @@ int
|
||||||
_pthread_attr_getstackaddr(const pthread_attr_t **attr,
|
_pthread_attr_getstackaddr(const pthread_attr_t **attr,
|
||||||
void **stackaddr)
|
void **stackaddr)
|
||||||
{
|
{
|
||||||
|
size_t stacksize;
|
||||||
if (attr == NULL || *attr == NULL || stackaddr == NULL)
|
if (attr == NULL || *attr == NULL || stackaddr == NULL)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
return __pthread_attr_getstackaddr(*attr, stackaddr);
|
return __pthread_attr_getstack(*attr, stackaddr, &stacksize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -551,6 +559,14 @@ _pthread_attr_getstacksize(const pthread_attr_t **attr,
|
||||||
return __pthread_attr_getstacksize(*attr, stacksize);
|
return __pthread_attr_getstacksize(*attr, stacksize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_pthread_attr_get_np(pthread_t tid, pthread_attr_t **dst)
|
||||||
|
{
|
||||||
|
if (dst == NULL || *dst == NULL)
|
||||||
|
return EINVAL;
|
||||||
|
return __pthread_getattr_np(tid, *dst);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_pthread_attr_init(pthread_attr_t **attr)
|
_pthread_attr_init(pthread_attr_t **attr)
|
||||||
{
|
{
|
||||||
|
@ -1275,7 +1291,7 @@ _pthread_mutexattr_settype(pthread_mutexattr_t **mattr, int type)
|
||||||
PTHREAD_MUTEX_ERRORCHECK);
|
PTHREAD_MUTEX_ERRORCHECK);
|
||||||
case UTHREAD_PTHREAD_MUTEX_RECURSIVE:
|
case UTHREAD_PTHREAD_MUTEX_RECURSIVE:
|
||||||
return __pthread_mutexattr_settype(*mattr,
|
return __pthread_mutexattr_settype(*mattr,
|
||||||
PTHREAD_MUTEX_ERRORCHECK);
|
PTHREAD_MUTEX_RECURSIVE);
|
||||||
case UTHREAD_PTHREAD_MUTEX_NORMAL:
|
case UTHREAD_PTHREAD_MUTEX_NORMAL:
|
||||||
return __pthread_mutexattr_settype(*mattr,
|
return __pthread_mutexattr_settype(*mattr,
|
||||||
PTHREAD_MUTEX_NORMAL);
|
PTHREAD_MUTEX_NORMAL);
|
||||||
|
|
Loading…
Add table
Reference in a new issue