From owner-svn-src-user@FreeBSD.ORG Sun Nov 7 02:16:08 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE687106564A; Sun, 7 Nov 2010 02:16:07 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CBEA08FC0A; Sun, 7 Nov 2010 02:16:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA72G7l9008178; Sun, 7 Nov 2010 02:16:07 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA72G7Sv008170; Sun, 7 Nov 2010 02:16:07 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011070216.oA72G7Sv008170@svn.freebsd.org> From: David Xu Date: Sun, 7 Nov 2010 02:16:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214901 - in user/davidxu/libthr: include lib/libc/include lib/libthr lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Nov 2010 02:16:08 -0000 Author: davidxu Date: Sun Nov 7 02:16:07 2010 New Revision: 214901 URL: http://svn.freebsd.org/changeset/base/214901 Log: Add POSIX functions pthread_mutexattr_setrobust and pthread_mutexattr_getrobust, these functions are required to support POSIX robust mutex. Modified: user/davidxu/libthr/include/pthread.h user/davidxu/libthr/lib/libc/include/namespace.h user/davidxu/libthr/lib/libc/include/un-namespace.h user/davidxu/libthr/lib/libthr/pthread.map user/davidxu/libthr/lib/libthr/thread/thr_init.c user/davidxu/libthr/lib/libthr/thread/thr_mutexattr.c user/davidxu/libthr/lib/libthr/thread/thr_private.h Modified: user/davidxu/libthr/include/pthread.h ============================================================================== --- user/davidxu/libthr/include/pthread.h Sun Nov 7 01:19:40 2010 (r214900) +++ user/davidxu/libthr/include/pthread.h Sun Nov 7 02:16:07 2010 (r214901) @@ -135,6 +135,9 @@ enum pthread_mutextype { #define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_ERRORCHECK +#define PTHREAD_MUTEX_STALLED 0 +#define PTHREAD_MUTEX_ROBUST 1 + enum pthread_rwlocktype_np { PTHREAD_RWLOCK_PREFER_READER_NP, @@ -214,13 +217,17 @@ int pthread_join(pthread_t, void **); int pthread_key_create(pthread_key_t *, void (*) (void *)); int pthread_key_delete(pthread_key_t); -int pthread_mutexattr_init(pthread_mutexattr_t *); int pthread_mutexattr_destroy(pthread_mutexattr_t *); +int pthread_mutexattr_getrobust(const pthread_mutexattr_t *__restrict, + int *__restrict); int pthread_mutexattr_getpshared(const pthread_mutexattr_t *, int *); int pthread_mutexattr_gettype(pthread_mutexattr_t *, int *); +int pthread_mutexattr_init(pthread_mutexattr_t *); int pthread_mutexattr_settype(pthread_mutexattr_t *, int); int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int); +int pthread_mutexattr_setrobust(pthread_mutexattr_t *, + int); int pthread_mutex_destroy(pthread_mutex_t *); int pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *); Modified: user/davidxu/libthr/lib/libc/include/namespace.h ============================================================================== --- user/davidxu/libthr/lib/libc/include/namespace.h Sun Nov 7 01:19:40 2010 (r214900) +++ user/davidxu/libthr/lib/libc/include/namespace.h Sun Nov 7 02:16:07 2010 (r214901) @@ -157,12 +157,14 @@ #define pthread_mutexattr_getprioceiling _pthread_mutexattr_getprioceiling #define pthread_mutexattr_getprotocol _pthread_mutexattr_getprotocol #define pthread_mutexattr_getpshared _pthread_mutexattr_getpshared +#define pthread_mutexattr_getrobust _pthread_mutexattr_getrobust #define pthread_mutexattr_gettype _pthread_mutexattr_gettype #define pthread_mutexattr_init _pthread_mutexattr_init #define pthread_mutexattr_setkind_np _pthread_mutexattr_setkind_np #define pthread_mutexattr_setprioceiling _pthread_mutexattr_setprioceiling #define pthread_mutexattr_setprotocol _pthread_mutexattr_setprotocol #define pthread_mutexattr_setpshared _pthread_mutexattr_setpshared +#define pthread_mutexattr_setrobust _pthread_mutexattr_setrobust #define pthread_mutexattr_settype _pthread_mutexattr_settype #define pthread_once _pthread_once #define pthread_resume_all_np _pthread_resume_all_np Modified: user/davidxu/libthr/lib/libc/include/un-namespace.h ============================================================================== --- user/davidxu/libthr/lib/libc/include/un-namespace.h Sun Nov 7 01:19:40 2010 (r214900) +++ user/davidxu/libthr/lib/libc/include/un-namespace.h Sun Nov 7 02:16:07 2010 (r214901) @@ -138,12 +138,14 @@ #undef pthread_mutexattr_getprioceiling #undef pthread_mutexattr_getprotocol #undef pthread_mutexattr_getpshared +#undef pthread_mutexattr_getrobust #undef pthread_mutexattr_gettype #undef pthread_mutexattr_init #undef pthread_mutexattr_setkind_np #undef pthread_mutexattr_setprioceiling #undef pthread_mutexattr_setprotocol #undef pthread_mutexattr_setpshared +#undef pthread_mutexattr_setrobust #undef pthread_mutexattr_settype #undef pthread_once #undef pthread_resume_all_np Modified: user/davidxu/libthr/lib/libthr/pthread.map ============================================================================== --- user/davidxu/libthr/lib/libthr/pthread.map Sun Nov 7 01:19:40 2010 (r214900) +++ user/davidxu/libthr/lib/libthr/pthread.map Sun Nov 7 02:16:07 2010 (r214901) @@ -297,12 +297,14 @@ FBSDprivate_1.0 { _pthread_mutexattr_getprioceiling; _pthread_mutexattr_getprotocol; _pthread_mutexattr_getpshared; + _pthread_mutexattr_getrobust; _pthread_mutexattr_gettype; _pthread_mutexattr_init; _pthread_mutexattr_setkind_np; _pthread_mutexattr_setprioceiling; _pthread_mutexattr_setprotocol; _pthread_mutexattr_setpshared; + _pthread_mutexattr_setrobust; _pthread_mutexattr_settype; _pthread_once; _pthread_resume_all_np; @@ -403,4 +405,6 @@ FBSD_1.2 { openat; setcontext; swapcontext; + pthread_mutexattr_getrobust; + pthread_mutexattr_setrobust; }; Modified: user/davidxu/libthr/lib/libthr/thread/thr_init.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_init.c Sun Nov 7 01:19:40 2010 (r214900) +++ user/davidxu/libthr/lib/libthr/thread/thr_init.c Sun Nov 7 02:16:07 2010 (r214901) @@ -90,7 +90,8 @@ struct pthread_mutex_attr _pthread_mutex .m_type = PTHREAD_MUTEX_DEFAULT, .m_protocol = PTHREAD_PRIO_NONE, .m_ceiling = 0, - .m_pshared = 0 + .m_pshared = 0, + .m_robust = PTHREAD_MUTEX_STALLED }; struct pthread_mutex_attr _pthread_mutexattr_adaptive_default = { Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutexattr.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_mutexattr.c Sun Nov 7 01:19:40 2010 (r214900) +++ user/davidxu/libthr/lib/libthr/thread/thr_mutexattr.c Sun Nov 7 02:16:07 2010 (r214901) @@ -81,6 +81,8 @@ __weak_reference(_pthread_mutexattr_getp __weak_reference(_pthread_mutexattr_setprotocol, pthread_mutexattr_setprotocol); __weak_reference(_pthread_mutexattr_getprioceiling, pthread_mutexattr_getprioceiling); __weak_reference(_pthread_mutexattr_setprioceiling, pthread_mutexattr_setprioceiling); +__weak_reference(_pthread_mutexattr_getrobust, pthread_mutexattr_getrobust); +__weak_reference(_pthread_mutexattr_setrobust, pthread_mutexattr_setrobust); int _pthread_mutexattr_init(pthread_mutexattr_t *attr) @@ -253,3 +255,35 @@ _pthread_mutexattr_setprioceiling(pthrea return(ret); } +int +_pthread_mutexattr_getrobust(const pthread_mutexattr_t *mattr, + int *robust) +{ + int error; + + if ((mattr == NULL) || (*mattr == NULL)) + error = EINVAL; + else { + *robust =(*mattr)->m_robust; + error = 0; + } + return (error); +} + +int +_pthread_mutexattr_setrobust(pthread_mutexattr_t *mattr, + int robust) +{ + int error; + + if ((mattr == NULL) || (*mattr == NULL)) + error = EINVAL; + else if (robust == PTHREAD_MUTEX_STALLED || + robust == PTHREAD_MUTEX_ROBUST) { + (*mattr)->m_robust = robust; + error = 0; + } else{ + error = EINVAL; + } + return (error); +} Modified: user/davidxu/libthr/lib/libthr/thread/thr_private.h ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_private.h Sun Nov 7 01:19:40 2010 (r214900) +++ user/davidxu/libthr/lib/libthr/thread/thr_private.h Sun Nov 7 02:16:07 2010 (r214901) @@ -156,6 +156,7 @@ struct pthread_mutex_attr { int m_protocol; int m_ceiling; int m_pshared; + int m_robust; }; struct pthread_cond {