-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
int fd;
/* Determine where the shmfs is mounted. */
- pthread_once (&__namedsem_once, __where_is_shmfs);
+ INTUSE(__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)
/* If the semaphore object has to exist simply open it. */
if ((oflag & O_CREAT) == 0)
{
- fd = open (finalname, oflag | O_NOFOLLOW);
+ fd = __libc_open (finalname, oflag | O_NOFOLLOW);
if (fd == -1)
/* Return. errno is already set. */
/* Map the sem_t structure from the file. */
result = (sem_t *) mmap (NULL, sizeof (sem_t), PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
+ if (MAP_FAILED != (void *) SEM_FAILED && result == MAP_FAILED)
+ result = SEM_FAILED;
}
else
{
memset ((char *) &initsem + sizeof (struct sem), '\0',
sizeof (sem_t) - sizeof (struct sem));
- if (TEMP_FAILURE_RETRY (write (fd, &initsem, sizeof (sem_t)))
+ if (TEMP_FAILURE_RETRY (__libc_write (fd, &initsem, sizeof (sem_t)))
!= sizeof (sem_t)
/* Adjust the permission. */
|| fchmod (fd, mode) != 0)
}
/* We don't need the file descriptor anymore. */
- close (fd);
+ __libc_close (fd);
return result;
}