1331722Seadler/* 2144518Sdavidxu * Copyright (C) 2005 David Xu <davidxu@freebsd.org>. 3112918Sjeff * Copyright (C) 2000 Jason Evans <jasone@freebsd.org>. 4112918Sjeff * All rights reserved. 5112918Sjeff * 6112918Sjeff * Redistribution and use in source and binary forms, with or without 7112918Sjeff * modification, are permitted provided that the following conditions 8112918Sjeff * are met: 9112918Sjeff * 1. Redistributions of source code must retain the above copyright 10112918Sjeff * notice(s), this list of conditions and the following disclaimer as 11112918Sjeff * the first lines of this file unmodified other than the possible 12112918Sjeff * addition of one or more copyright notices. 13112918Sjeff * 2. Redistributions in binary form must reproduce the above copyright 14112918Sjeff * notice(s), this list of conditions and the following disclaimer in 15112918Sjeff * the documentation and/or other materials provided with the 16112918Sjeff * distribution. 17112918Sjeff * 18112918Sjeff * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 19112918Sjeff * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20112918Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21112918Sjeff * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE 22112918Sjeff * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23112918Sjeff * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24112918Sjeff * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25112918Sjeff * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26112918Sjeff * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27112918Sjeff * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 28112918Sjeff * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29112918Sjeff */ 30112918Sjeff 31297706Skib#include <sys/cdefs.h> 32297706Skib__FBSDID("$FreeBSD$"); 33297706Skib 34144518Sdavidxu#include "namespace.h" 35149691Sstefanf#include <sys/types.h> 36144518Sdavidxu#include <sys/queue.h> 37112918Sjeff#include <errno.h> 38144518Sdavidxu#include <fcntl.h> 39144518Sdavidxu#include <pthread.h> 40144518Sdavidxu#include <stdlib.h> 41144518Sdavidxu#include <time.h> 42144518Sdavidxu#include <_semaphore.h> 43144518Sdavidxu#include "un-namespace.h" 44144518Sdavidxu 45112918Sjeff#include "thr_private.h" 46112918Sjeff 47201546SdavidxuFB10_COMPAT(_sem_init_compat, sem_init); 48201546SdavidxuFB10_COMPAT(_sem_destroy_compat, sem_destroy); 49201546SdavidxuFB10_COMPAT(_sem_getvalue_compat, sem_getvalue); 50201546SdavidxuFB10_COMPAT(_sem_trywait_compat, sem_trywait); 51201546SdavidxuFB10_COMPAT(_sem_wait_compat, sem_wait); 52201546SdavidxuFB10_COMPAT(_sem_timedwait_compat, sem_timedwait); 53201546SdavidxuFB10_COMPAT(_sem_post_compat, sem_post); 54112918Sjeff 55201546Sdavidxutypedef struct sem *sem_t; 56112918Sjeff 57201546Sdavidxuextern int _libc_sem_init_compat(sem_t *sem, int pshared, unsigned int value); 58201546Sdavidxuextern int _libc_sem_destroy_compat(sem_t *sem); 59201546Sdavidxuextern int _libc_sem_getvalue_compat(sem_t * __restrict sem, int * __restrict sval); 60201546Sdavidxuextern int _libc_sem_trywait_compat(sem_t *sem); 61201546Sdavidxuextern int _libc_sem_wait_compat(sem_t *sem); 62201546Sdavidxuextern int _libc_sem_timedwait_compat(sem_t * __restrict sem, 63201546Sdavidxu const struct timespec * __restrict abstime); 64201546Sdavidxuextern int _libc_sem_post_compat(sem_t *sem); 65112918Sjeff 66201546Sdavidxuint _sem_init_compat(sem_t *sem, int pshared, unsigned int value); 67201546Sdavidxuint _sem_destroy_compat(sem_t *sem); 68201546Sdavidxuint _sem_getvalue_compat(sem_t * __restrict sem, int * __restrict sval); 69201546Sdavidxuint _sem_trywait_compat(sem_t *sem); 70201546Sdavidxuint _sem_wait_compat(sem_t *sem); 71201546Sdavidxuint _sem_timedwait_compat(sem_t * __restrict sem, 72201546Sdavidxu const struct timespec * __restrict abstime); 73201546Sdavidxuint _sem_post_compat(sem_t *sem); 74112918Sjeff 75144518Sdavidxuint 76201546Sdavidxu_sem_init_compat(sem_t *sem, int pshared, unsigned int value) 77144518Sdavidxu{ 78201546Sdavidxu return _libc_sem_init_compat(sem, pshared, value); 79112918Sjeff} 80112918Sjeff 81112918Sjeffint 82201546Sdavidxu_sem_destroy_compat(sem_t *sem) 83112918Sjeff{ 84201546Sdavidxu return _libc_sem_destroy_compat(sem); 85112918Sjeff} 86112918Sjeff 87112918Sjeffint 88201546Sdavidxu_sem_getvalue_compat(sem_t * __restrict sem, int * __restrict sval) 89112918Sjeff{ 90201546Sdavidxu return _libc_sem_getvalue_compat(sem, sval); 91112918Sjeff} 92112918Sjeff 93112918Sjeffint 94201546Sdavidxu_sem_trywait_compat(sem_t *sem) 95112918Sjeff{ 96201546Sdavidxu return _libc_sem_trywait_compat(sem); 97112918Sjeff} 98112918Sjeff 99112918Sjeffint 100201546Sdavidxu_sem_wait_compat(sem_t *sem) 101112918Sjeff{ 102201546Sdavidxu return _libc_sem_wait_compat(sem); 103112918Sjeff} 104112918Sjeff 105112918Sjeffint 106201546Sdavidxu_sem_timedwait_compat(sem_t * __restrict sem, 107157234Sdes const struct timespec * __restrict abstime) 108112918Sjeff{ 109201546Sdavidxu return _libc_sem_timedwait_compat(sem, abstime); 110112918Sjeff} 111112918Sjeff 112112918Sjeffint 113201546Sdavidxu_sem_post_compat(sem_t *sem) 114112918Sjeff{ 115201546Sdavidxu return _libc_sem_post_compat(sem); 116112918Sjeff} 117