Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread Note the initializer macros.



details:   https://anonhg.NetBSD.org/src/rev/297a3dd8590c
branches:  trunk
changeset: 755018:297a3dd8590c
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Thu May 20 04:40:23 2010 +0000

description:
Note the initializer macros.

diffstat:

 lib/libpthread/pthread_cond_init.3   |  18 ++++++++++++++++--
 lib/libpthread/pthread_mutex_init.3  |  18 ++++++++++++++++--
 lib/libpthread/pthread_rwlock_init.3 |  18 ++++++++++++++++--
 3 files changed, 48 insertions(+), 6 deletions(-)

diffs (138 lines):

diff -r 0945b834c5eb -r 297a3dd8590c lib/libpthread/pthread_cond_init.3
--- a/lib/libpthread/pthread_cond_init.3        Thu May 20 00:36:31 2010 +0000
+++ b/lib/libpthread/pthread_cond_init.3        Thu May 20 04:40:23 2010 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pthread_cond_init.3,v 1.9 2008/05/26 08:43:57 wiz Exp $
+.\" $NetBSD: pthread_cond_init.3,v 1.10 2010/05/20 04:40:23 jruoho Exp $
 .\"
 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -51,7 +51,7 @@
 .\"
 .\" $FreeBSD: src/lib/libpthread/man/pthread_cond_init.3,v 1.13 2002/09/16 19:29:28 mini Exp $
 .\"
-.Dd January 30, 2003
+.Dd May 20, 2010
 .Dt PTHREAD_COND_INIT 3
 .Os
 .Sh NAME
@@ -63,6 +63,8 @@
 .In pthread.h
 .Ft int
 .Fn pthread_cond_init "pthread_cond_t * restrict cond" "const pthread_condattr_t * restrict attr"
+.Pp
+.Va pthread_cond_t cond = Dv PTHREAD_COND_INITIALIZER;
 .Sh DESCRIPTION
 The
 .Fn pthread_cond_init
@@ -80,6 +82,18 @@
 condition variable.
 The predicate should identify a state of the
 shared data that must be true before the thread proceeds.
+.Pp
+The macro
+.Dv PTHREAD_COND_INITIALIZER
+can be used to initialize a condition variable when it can be statically
+allocated and the default attributes are appropriate.
+The effect is similar to calling
+.Fn pthread_cond_init
+with
+.Fa attr
+specified as
+.Dv NULL ,
+except that no error checking is done.
 .Sh RETURN VALUES
 If successful, the
 .Fn pthread_cond_init
diff -r 0945b834c5eb -r 297a3dd8590c lib/libpthread/pthread_mutex_init.3
--- a/lib/libpthread/pthread_mutex_init.3       Thu May 20 00:36:31 2010 +0000
+++ b/lib/libpthread/pthread_mutex_init.3       Thu May 20 04:40:23 2010 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pthread_mutex_init.3,v 1.5 2008/05/26 08:43:57 wiz Exp $
+.\" $NetBSD: pthread_mutex_init.3,v 1.6 2010/05/20 04:40:23 jruoho Exp $
 .\"
 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -51,7 +51,7 @@
 .\"
 .\" $FreeBSD: src/lib/libpthread/man/pthread_mutex_init.3,v 1.12 2002/09/16 19:29:29 mini Exp $
 .\"
-.Dd January 30, 2003
+.Dd May 20, 2010
 .Dt PTHREAD_MUTEX_INIT 3
 .Os
 .Sh NAME
@@ -63,6 +63,8 @@
 .In pthread.h
 .Ft int
 .Fn pthread_mutex_init "pthread_mutex_t * restrict mutex" "const pthread_mutexattr_t * restrict attr"
+.Pp
+.Va pthread_mutex_t mutex = Dv PTHREAD_MUTEX_INITIALIZER;
 .Sh DESCRIPTION
 The
 .Fn pthread_mutex_init
@@ -71,6 +73,18 @@
 If
 .Fa attr
 is NULL the default attributes are used.
+.Pp
+The macro
+.Dv PTHREAD_MUTEX_INITIALIZER
+can be used to initialize a mutex when the default attributes are
+appropriate and the mutex can be statically allocated.
+The behavior is similar to
+.Fn pthread_mutex_init
+with
+.Fa attr
+specified as
+.Dv NULL ,
+except that no error checking is done.
 .Sh RETURN VALUES
 If successful,
 .Fn pthread_mutex_init
diff -r 0945b834c5eb -r 297a3dd8590c lib/libpthread/pthread_rwlock_init.3
--- a/lib/libpthread/pthread_rwlock_init.3      Thu May 20 00:36:31 2010 +0000
+++ b/lib/libpthread/pthread_rwlock_init.3      Thu May 20 04:40:23 2010 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pthread_rwlock_init.3,v 1.8 2008/05/04 19:43:05 martin Exp $
+.\" $NetBSD: pthread_rwlock_init.3,v 1.9 2010/05/20 04:40:23 jruoho Exp $
 .\"
 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -48,7 +48,7 @@
 .\"
 .\" $FreeBSD: src/lib/libpthread/man/pthread_rwlock_init.3,v 1.6 2002/09/16 19:29:29 mini Exp $
 .\"
-.Dd January 30, 2003
+.Dd May 20, 2010
 .Dt PTHREAD_RWLOCK_INIT 3
 .Os
 .Sh NAME
@@ -60,6 +60,8 @@
 .In pthread.h
 .Ft int
 .Fn pthread_rwlock_init "pthread_rwlock_t * restrict lock" "const pthread_rwlockattr_t * restrict attr"
+.Pp
+.Va pthread_rwlock_t lock = Dv PTHREAD_RWLOCK_INITIALIZER;
 .Sh DESCRIPTION
 The
 .Fn pthread_rwlock_init
@@ -73,6 +75,18 @@
 The results of calling
 .Fn pthread_rwlock_init
 with an already initialized lock are undefined.
+.Pp
+The macro
+.Dv PTHREAD_RWLOCK_INITIALIZER
+can be used to initialize a read/write lock when the allocation can be done
+statically, no error checking is required, and the default attributes are
+appropriate.
+The behavior is similar to calling
+.Fn pthread_rwlock_init
+with
+.Fa attr
+specified as
+.Dv NULL .
 .Sh RETURN VALUES
 If successful, the
 .Fn pthread_rwlock_init



Home | Main Index | Thread Index | Old Index