diff options
author | Jakub Jelinek <jakub@redhat.com> | 2008-01-11 07:45:15 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2008-01-11 07:45:15 +0000 |
commit | 07b7d301cc62d3f4ff1bbaf668ddc2510f7a55d8 (patch) | |
tree | b7a82272de69e03b1850cb2cf93e25f258769fa2 /nptl/sysdeps/unix/sysv/linux/sem_post.c | |
parent | 1e44f485d223b0f2f7b194935a0109cb7b713cc3 (diff) |
Updated to fedora-glibc-20080111T0737
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/sem_post.c')
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/sem_post.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/sem_post.c b/nptl/sysdeps/unix/sysv/linux/sem_post.c index 25b676fcd2..58b226f63d 100644 --- a/nptl/sysdeps/unix/sysv/linux/sem_post.c +++ b/nptl/sysdeps/unix/sysv/linux/sem_post.c @@ -1,5 +1,5 @@ /* sem_post -- post to a POSIX semaphore. Generic futex-using version. - Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. @@ -31,7 +31,18 @@ __new_sem_post (sem_t *sem) { struct new_sem *isem = (struct new_sem *) sem; - int nr = atomic_increment_val (&isem->value); + __typeof (isem->value) cur; + do + { + cur = isem->value; + if (isem->value == SEM_VALUE_MAX) + { + __set_errno (EOVERFLOW); + return -1; + } + } + while (atomic_compare_and_exchange_bool_acq (&isem->value, cur + 1, cur)); + atomic_full_barrier (); if (isem->nwaiters > 0) { |