sem.c revision e8031f0a8ed0e45c6d8847c5e09424e66fd34a4b
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "c_synonyms.h"
#include <semaphore.h>
#include <synch.h>
#include <errno.h>
#include <stdarg.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <thread.h>
#include "pos4obj.h"
#include "pos4.h"
typedef struct semaddr {
} semaddr_t;
sem_t *
{
int fd = 0;
int error = 0;
int cr_flag = 0;
return (SEM_FAILED);
/* acquire semaphore lock to have atomic operation */
return (SEM_FAILED);
/* modify oflag to have RDWR and filter CREATE mode only */
/* check value < the max for a named semaphore */
if ((_lsemvaluemax == -1L) ||
((unsigned long)value > (unsigned long)_lsemvaluemax)) {
goto out;
}
}
errno = 0;
goto out;
if (cr_flag)
else
/* find out inode # for the opened file */
goto out;
/* if created, acquire total_size in the file */
if ((cr_flag & DFILE_CREATE) != 0) {
goto out;
} else {
(void) mutex_lock(&semlock);
/*
* if this semaphore has already been opened, inode
* will indicate then return the same semaphore address
*/
(void) __close_nc(fd);
(void) mutex_unlock(&semlock);
}
}
(void) mutex_unlock(&semlock);
}
/* new sem descriptor to be allocated and new address to be mapped */
goto out;
}
/* LINTED */
(void) __close_nc(fd);
cr_flag &= ~DFILE_OPEN;
if (sem == MAP_FAILED)
goto out;
cr_flag |= DFILE_MMAP;
/* add to the list pointed by semheadp */
/* initialize it by jumping through the jump table */
if ((cr_flag & DFILE_CREATE) != 0) {
!= 0) {
goto out;
}
}
return (SEM_FAILED);
return (sem);
out:
if ((cr_flag & DFILE_OPEN) != 0)
(void) __close_nc(fd);
if ((cr_flag & DFILE_CREATE) != 0)
if ((cr_flag & DFILE_MMAP) != 0)
return (SEM_FAILED);
}
int
{
(void) mutex_lock(&semlock);
(void) mutex_unlock(&semlock);
}
}
(void) mutex_unlock(&semlock);
return (-1);
}
int
_sem_unlink(const char *path)
{
int error;
int oerrno;
if (__pos4obj_check(path) < 0)
return (-1);
return (-1);
return (error);
}
/*
* SUSV3 requires ("shall fail") an EINVAL failure for operations
* on invalid semaphores, including uninitialized unnamed semaphores.
* The best we can do is check that the magic number is correct.
* This is not perfect, but it allows the test suite to pass.
* (Standards bodies are filled with fools and idiots.)
*/
static int
{
return (-1);
}
return (0);
}
int
{
int error;
return (-1);
}
return (0);
}
int
{
int error;
if (sem_invalid(sem))
return (-1);
return (-1);
}
return (0);
}
int
{
int error;
if (sem_invalid(sem))
return (-1);
return (-1);
}
return (0);
}
int
{
int error;
if (sem_invalid(sem))
return (-1);
return (-1);
}
return (0);
}
int
{
int error;
if (sem_invalid(sem))
return (-1);
return (-1);
}
return (0);
}
int
{
int error;
if (sem_invalid(sem))
return (-1);
return (-1);
}
return (0);
}
int
{
int error;
if (sem_invalid(sem))
return (-1);
return (-1);
}
return (0);
}
int
{
if (sem_invalid(sem))
return (-1);
return (0);
}