1112918Sjeff/* 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 * $FreeBSD: releng/10.3/lib/libthr/thread/thr_sem.c 201546 2010-01-05 02:37:59Z davidxu $ 31112918Sjeff */ 32112918Sjeff 33144518Sdavidxu#include "namespace.h" 34149691Sstefanf#include <sys/types.h> 35144518Sdavidxu#include <sys/queue.h> 36112918Sjeff#include <errno.h> 37144518Sdavidxu#include <fcntl.h> 38144518Sdavidxu#include <pthread.h> 39144518Sdavidxu#include <stdlib.h> 40144518Sdavidxu#include <time.h> 41144518Sdavidxu#include <_semaphore.h> 42144518Sdavidxu#include "un-namespace.h" 43144518Sdavidxu 44112918Sjeff#include "thr_private.h" 45112918Sjeff 46201546SdavidxuFB10_COMPAT(_sem_init_compat, sem_init); 47201546SdavidxuFB10_COMPAT(_sem_destroy_compat, sem_destroy); 48201546SdavidxuFB10_COMPAT(_sem_getvalue_compat, sem_getvalue); 49201546SdavidxuFB10_COMPAT(_sem_trywait_compat, sem_trywait); 50201546SdavidxuFB10_COMPAT(_sem_wait_compat, sem_wait); 51201546SdavidxuFB10_COMPAT(_sem_timedwait_compat, sem_timedwait); 52201546SdavidxuFB10_COMPAT(_sem_post_compat, sem_post); 53112918Sjeff 54201546Sdavidxutypedef struct sem *sem_t; 55112918Sjeff 56201546Sdavidxuextern int _libc_sem_init_compat(sem_t *sem, int pshared, unsigned int value); 57201546Sdavidxuextern int _libc_sem_destroy_compat(sem_t *sem); 58201546Sdavidxuextern int _libc_sem_getvalue_compat(sem_t * __restrict sem, int * __restrict sval); 59201546Sdavidxuextern int _libc_sem_trywait_compat(sem_t *sem); 60201546Sdavidxuextern int _libc_sem_wait_compat(sem_t *sem); 61201546Sdavidxuextern int _libc_sem_timedwait_compat(sem_t * __restrict sem, 62201546Sdavidxu const struct timespec * __restrict abstime); 63201546Sdavidxuextern int _libc_sem_post_compat(sem_t *sem); 64112918Sjeff 65201546Sdavidxuint _sem_init_compat(sem_t *sem, int pshared, unsigned int value); 66201546Sdavidxuint _sem_destroy_compat(sem_t *sem); 67201546Sdavidxuint _sem_getvalue_compat(sem_t * __restrict sem, int * __restrict sval); 68201546Sdavidxuint _sem_trywait_compat(sem_t *sem); 69201546Sdavidxuint _sem_wait_compat(sem_t *sem); 70201546Sdavidxuint _sem_timedwait_compat(sem_t * __restrict sem, 71201546Sdavidxu const struct timespec * __restrict abstime); 72201546Sdavidxuint _sem_post_compat(sem_t *sem); 73112918Sjeff 74144518Sdavidxuint 75201546Sdavidxu_sem_init_compat(sem_t *sem, int pshared, unsigned int value) 76144518Sdavidxu{ 77201546Sdavidxu return _libc_sem_init_compat(sem, pshared, value); 78112918Sjeff} 79112918Sjeff 80112918Sjeffint 81201546Sdavidxu_sem_destroy_compat(sem_t *sem) 82112918Sjeff{ 83201546Sdavidxu return _libc_sem_destroy_compat(sem); 84112918Sjeff} 85112918Sjeff 86112918Sjeffint 87201546Sdavidxu_sem_getvalue_compat(sem_t * __restrict sem, int * __restrict sval) 88112918Sjeff{ 89201546Sdavidxu return _libc_sem_getvalue_compat(sem, sval); 90112918Sjeff} 91112918Sjeff 92112918Sjeffint 93201546Sdavidxu_sem_trywait_compat(sem_t *sem) 94112918Sjeff{ 95201546Sdavidxu return _libc_sem_trywait_compat(sem); 96112918Sjeff} 97112918Sjeff 98112918Sjeffint 99201546Sdavidxu_sem_wait_compat(sem_t *sem) 100112918Sjeff{ 101201546Sdavidxu return _libc_sem_wait_compat(sem); 102112918Sjeff} 103112918Sjeff 104112918Sjeffint 105201546Sdavidxu_sem_timedwait_compat(sem_t * __restrict sem, 106157234Sdes const struct timespec * __restrict abstime) 107112918Sjeff{ 108201546Sdavidxu return _libc_sem_timedwait_compat(sem, abstime); 109112918Sjeff} 110112918Sjeff 111112918Sjeffint 112201546Sdavidxu_sem_post_compat(sem_t *sem) 113112918Sjeff{ 114201546Sdavidxu return _libc_sem_post_compat(sem); 115112918Sjeff} 116