-/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <fcntl.h>
void *__sem_mappings attribute_hidden;
/* Lock to protect the search tree. */
-lll_lock_t __sem_mappings_lock attribute_hidden = LLL_LOCK_INITIALIZER;
+int __sem_mappings_lock attribute_hidden = LLL_LOCK_INITIALIZER;
/* Search for existing mapping and if possible add the one provided. */
if (__fxstat64 (_STAT_VER, fd, &st) == 0)
{
/* Get the lock. */
- lll_lock (__sem_mappings_lock);
+ lll_lock (__sem_mappings_lock, LLL_PRIVATE);
/* Search for an existing mapping given the information we have. */
struct inuse_sem *fake;
}
/* Release the lock. */
- lll_unlock (__sem_mappings_lock);
+ lll_unlock (__sem_mappings_lock, LLL_PRIVATE);
}
if (result != existing && existing != SEM_FAILED && existing != MAP_FAILED)
int fd;
/* Determine where the shmfs is mounted. */
- INTUSE(__pthread_once) (&__namedsem_once, __where_is_shmfs);
+ __pthread_once (&__namedsem_once, __where_is_shmfs);
/* If we don't know the mount points there is nothing we can do. Ever. */
if (mountpoint.dir == NULL)
}
/* Create the initial file content. */
- sem_t initsem;
+ union
+ {
+ sem_t initsem;
+ struct new_sem newsem;
+ } sem;
- struct sem *iinitsem = (struct sem *) &initsem;
- iinitsem->count = value;
+ sem.newsem.value = value;
+ sem.newsem.private = 0;
+ sem.newsem.nwaiters = 0;
/* Initialize the remaining bytes as well. */
- memset ((char *) &initsem + sizeof (struct sem), '\0',
- sizeof (sem_t) - sizeof (struct sem));
+ memset ((char *) &sem.initsem + sizeof (struct new_sem), '\0',
+ sizeof (sem_t) - sizeof (struct new_sem));
tmpfname = (char *) alloca (mountpoint.dirlen + 6 + 1);
char *xxxxxx = __mempcpy (tmpfname, mountpoint.dir, mountpoint.dirlen);
break;
}
- if (TEMP_FAILURE_RETRY (__libc_write (fd, &initsem, sizeof (sem_t)))
+ if (TEMP_FAILURE_RETRY (__libc_write (fd, &sem.initsem, sizeof (sem_t)))
== sizeof (sem_t)
/* Map the sem_t structure from the file. */
&& (result = (sem_t *) mmap (NULL, sizeof (sem_t),