1*521eaa49Sdholland /* $NetBSD: semaphore.h,v 1.5 2016/04/24 19:48:29 dholland Exp $ */ 23f4a1907Schristos 33f4a1907Schristos /*- 43f4a1907Schristos * Copyright (c) 2003 The NetBSD Foundation, Inc. 53f4a1907Schristos * All rights reserved. 63f4a1907Schristos * 73f4a1907Schristos * This code is derived from software contributed to The NetBSD Foundation 83f4a1907Schristos * by Christos Zoulas. 93f4a1907Schristos * 103f4a1907Schristos * Redistribution and use in source and binary forms, with or without 113f4a1907Schristos * modification, are permitted provided that the following conditions 123f4a1907Schristos * are met: 133f4a1907Schristos * 1. Redistributions of source code must retain the above copyright 143f4a1907Schristos * notice, this list of conditions and the following disclaimer. 153f4a1907Schristos * 2. Redistributions in binary form must reproduce the above copyright 163f4a1907Schristos * notice, this list of conditions and the following disclaimer in the 173f4a1907Schristos * documentation and/or other materials provided with the distribution. 183f4a1907Schristos * 193f4a1907Schristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 203f4a1907Schristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 213f4a1907Schristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 223f4a1907Schristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 233f4a1907Schristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 243f4a1907Schristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 253f4a1907Schristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 263f4a1907Schristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 273f4a1907Schristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 283f4a1907Schristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 293f4a1907Schristos * POSSIBILITY OF SUCH DAMAGE. 303f4a1907Schristos */ 3195893cccSkleink 323f4a1907Schristos #ifndef _SEMAPHORE_H_ 333f4a1907Schristos #define _SEMAPHORE_H_ 343f4a1907Schristos 353f4a1907Schristos /* POSIX 1003.1b semaphores */ 363f4a1907Schristos 373f4a1907Schristos struct _sem_st; 383f4a1907Schristos typedef struct _sem_st *sem_t; 393f4a1907Schristos 403f4a1907Schristos #define SEM_FAILED ((sem_t *)0) 413f4a1907Schristos 42*521eaa49Sdholland #include <sys/semaphore.h> /* some kernel-only bits */ 434acff4c0Sjoerg #include <sys/time.h> 4495893cccSkleink 453f4a1907Schristos __BEGIN_DECLS 463f4a1907Schristos int sem_close(sem_t *); 473f4a1907Schristos int sem_destroy(sem_t *); 483f4a1907Schristos int sem_getvalue(sem_t * __restrict, int * __restrict); 493f4a1907Schristos int sem_init(sem_t *, int, unsigned int); 503f4a1907Schristos int sem_post(sem_t *); 514acff4c0Sjoerg int sem_timedwait(sem_t *, const struct timespec * __restrict); 523f4a1907Schristos int sem_trywait(sem_t *); 533f4a1907Schristos int sem_unlink(const char *); 543f4a1907Schristos int sem_wait(sem_t *); 553f4a1907Schristos sem_t *sem_open(const char *, int, ...); 563f4a1907Schristos __END_DECLS 573f4a1907Schristos 583f4a1907Schristos #endif /* !_SEMAPHORE_H_ */ 59