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: releng/11.0/include/semaphore.h 277983 2015-01-31 16:39:26Z jilles $ 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 39277983Sjilles#include <machine/_limits.h> 40277983Sjilles 41201546Sdavidxustruct _sem { 42201546Sdavidxu __uint32_t _magic; 43273604Sjhb struct _usem2 _kern; 44273604Sjhb __uint32_t _padding; /* Preserve structure size */ 45201546Sdavidxu}; 46201546Sdavidxu 47201546Sdavidxutypedef struct _sem sem_t; 48201546Sdavidxu 49201546Sdavidxu#define SEM_FAILED ((sem_t *)0) 50201546Sdavidxu#define SEM_VALUE_MAX __INT_MAX 51201546Sdavidxu 52201546Sdavidxustruct timespec; 53201546Sdavidxu 54201546Sdavidxu__BEGIN_DECLS 55201546Sdavidxuint sem_close(sem_t *); 56201546Sdavidxuint sem_destroy(sem_t *); 57201546Sdavidxuint sem_getvalue(sem_t * __restrict, int * __restrict); 58201546Sdavidxuint sem_init(sem_t *, int, unsigned int); 59201546Sdavidxusem_t *sem_open(const char *, int, ...); 60201546Sdavidxuint sem_post(sem_t *); 61201546Sdavidxuint sem_timedwait(sem_t * __restrict, const struct timespec * __restrict); 62201546Sdavidxuint sem_trywait(sem_t *); 63201546Sdavidxuint sem_unlink(const char *); 64201546Sdavidxuint sem_wait(sem_t *); 65201546Sdavidxu__END_DECLS 66201546Sdavidxu 67201546Sdavidxu#endif /* !_SEMAPHORE_H_ */ 68