1201546Sdavidxu/* 2201546Sdavidxu * Copyright (c) 2010 David Xu <davidxu@freebsd.org> 3201546Sdavidxu * 4201546Sdavidxu * All rights reserved. 5201546Sdavidxu * 6201546Sdavidxu * Redistribution and use in source and binary forms, with or without 7201546Sdavidxu * modification, are permitted provided that the following conditions 8201546Sdavidxu * are met: 9201546Sdavidxu * 1. Redistributions of source code must retain the above copyright 10201546Sdavidxu * notice unmodified, this list of conditions, and the following 11201546Sdavidxu * disclaimer. 12201546Sdavidxu * 2. Redistributions in binary form must reproduce the above copyright 13201546Sdavidxu * notice, this list of conditions and the following disclaimer in the 14201546Sdavidxu * documentation and/or other materials provided with the distribution. 15201546Sdavidxu * 16201546Sdavidxu * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17201546Sdavidxu * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18201546Sdavidxu * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19201546Sdavidxu * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20201546Sdavidxu * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21201546Sdavidxu * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22201546Sdavidxu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23201546Sdavidxu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24201546Sdavidxu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25201546Sdavidxu * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26201546Sdavidxu * 27201546Sdavidxu * $FreeBSD$ 28201546Sdavidxu */ 29201546Sdavidxu 30201546Sdavidxu/* semaphore.h: POSIX 1003.1b semaphores */ 31201546Sdavidxu 32201546Sdavidxu#ifndef _SEMAPHORE_H_ 33201546Sdavidxu#define _SEMAPHORE_H_ 34201546Sdavidxu 35201546Sdavidxu#include <sys/cdefs.h> 36201546Sdavidxu#include <sys/_types.h> 37201546Sdavidxu#include <sys/_umtx.h> 38201546Sdavidxu 39201546Sdavidxustruct _sem { 40201546Sdavidxu __uint32_t _magic; 41201546Sdavidxu struct _usem _kern; 42201546Sdavidxu}; 43201546Sdavidxu 44201546Sdavidxutypedef struct _sem sem_t; 45201546Sdavidxu 46201546Sdavidxu#define SEM_FAILED ((sem_t *)0) 47201546Sdavidxu#define SEM_VALUE_MAX __INT_MAX 48201546Sdavidxu 49201546Sdavidxustruct timespec; 50201546Sdavidxu 51201546Sdavidxu__BEGIN_DECLS 52201546Sdavidxuint sem_close(sem_t *); 53201546Sdavidxuint sem_destroy(sem_t *); 54201546Sdavidxuint sem_getvalue(sem_t * __restrict, int * __restrict); 55201546Sdavidxuint sem_init(sem_t *, int, unsigned int); 56201546Sdavidxusem_t *sem_open(const char *, int, ...); 57201546Sdavidxuint sem_post(sem_t *); 58201546Sdavidxuint sem_timedwait(sem_t * __restrict, const struct timespec * __restrict); 59201546Sdavidxuint sem_trywait(sem_t *); 60201546Sdavidxuint sem_unlink(const char *); 61201546Sdavidxuint sem_wait(sem_t *); 62201546Sdavidxu__END_DECLS 63201546Sdavidxu 64201546Sdavidxu#endif /* !_SEMAPHORE_H_ */ 65