Module Name: src
Committed By: jruoho
Date: Thu May 20 04:40:23 UTC 2010
Modified Files:
src/lib/libpthread: pthread_cond_init.3 pthread_mutex_init.3
pthread_rwlock_init.3
Log Message:
Note the initializer macros.
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libpthread/pthread_cond_init.3
cvs rdiff -u -r1.5 -r1.6 src/lib/libpthread/pthread_mutex_init.3
cvs rdiff -u -r1.8 -r1.9 src/lib/libpthread/pthread_rwlock_init.3
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libpthread/pthread_cond_init.3
diff -u src/lib/libpthread/pthread_cond_init.3:1.9 src/lib/libpthread/pthread_cond_init.3:1.10
--- src/lib/libpthread/pthread_cond_init.3:1.9 Mon May 26 08:43:57 2008
+++ src/lib/libpthread/pthread_cond_init.3 Thu May 20 04:40:23 2010
@@ -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
Index: src/lib/libpthread/pthread_mutex_init.3
diff -u src/lib/libpthread/pthread_mutex_init.3:1.5 src/lib/libpthread/pthread_mutex_init.3:1.6
--- src/lib/libpthread/pthread_mutex_init.3:1.5 Mon May 26 08:43:57 2008
+++ src/lib/libpthread/pthread_mutex_init.3 Thu May 20 04:40:23 2010
@@ -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
Index: src/lib/libpthread/pthread_rwlock_init.3
diff -u src/lib/libpthread/pthread_rwlock_init.3:1.8 src/lib/libpthread/pthread_rwlock_init.3:1.9
--- src/lib/libpthread/pthread_rwlock_init.3:1.8 Sun May 4 19:43:05 2008
+++ src/lib/libpthread/pthread_rwlock_init.3 Thu May 20 04:40:23 2010
@@ -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