semaphore.h revision 201546
1239281Sgonzo/*
2239281Sgonzo * Copyright (c) 2010 David Xu <davidxu@freebsd.org>
3239281Sgonzo *
4239281Sgonzo * All rights reserved.
5239281Sgonzo *
6239281Sgonzo * Redistribution and use in source and binary forms, with or without
7239281Sgonzo * modification, are permitted provided that the following conditions
8239281Sgonzo * are met:
9239281Sgonzo * 1. Redistributions of source code must retain the above copyright
10239281Sgonzo *    notice unmodified, this list of conditions, and the following
11239281Sgonzo *    disclaimer.
12239281Sgonzo * 2. Redistributions in binary form must reproduce the above copyright
13239281Sgonzo *    notice, this list of conditions and the following disclaimer in the
14239281Sgonzo *    documentation and/or other materials provided with the distribution.
15239281Sgonzo *
16239281Sgonzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17239281Sgonzo * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18239281Sgonzo * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19239281Sgonzo * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20239281Sgonzo * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21239281Sgonzo * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22239281Sgonzo * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23239281Sgonzo * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24239281Sgonzo * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25239281Sgonzo * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26239281Sgonzo *
27239281Sgonzo * $FreeBSD: head/include/semaphore.h 201546 2010-01-05 02:37:59Z davidxu $
28239281Sgonzo */
29239281Sgonzo
30239281Sgonzo/* semaphore.h: POSIX 1003.1b semaphores */
31239281Sgonzo
32239281Sgonzo#ifndef _SEMAPHORE_H_
33239281Sgonzo#define _SEMAPHORE_H_
34239281Sgonzo
35239281Sgonzo#include <sys/cdefs.h>
36239281Sgonzo#include <sys/_types.h>
37239281Sgonzo#include <sys/_umtx.h>
38239281Sgonzo
39239281Sgonzostruct _sem {
40239281Sgonzo	__uint32_t	_magic;
41239281Sgonzo	struct _usem	_kern;
42239281Sgonzo};
43239281Sgonzo
44239281Sgonzotypedef	struct _sem	sem_t;
45239281Sgonzo
46239281Sgonzo#define	SEM_FAILED	((sem_t *)0)
47239281Sgonzo#define	SEM_VALUE_MAX	__INT_MAX
48239281Sgonzo
49239281Sgonzostruct timespec;
50239281Sgonzo
51239281Sgonzo__BEGIN_DECLS
52239281Sgonzoint	 sem_close(sem_t *);
53239281Sgonzoint	 sem_destroy(sem_t *);
54239281Sgonzoint	 sem_getvalue(sem_t * __restrict, int * __restrict);
55239281Sgonzoint	 sem_init(sem_t *, int, unsigned int);
56239281Sgonzosem_t	*sem_open(const char *, int, ...);
57239281Sgonzoint	 sem_post(sem_t *);
58239281Sgonzoint	 sem_timedwait(sem_t * __restrict, const struct timespec * __restrict);
59239281Sgonzoint	 sem_trywait(sem_t *);
60239281Sgonzoint	 sem_unlink(const char *);
61239281Sgonzoint	 sem_wait(sem_t *);
62239281Sgonzo__END_DECLS
63239281Sgonzo
64239281Sgonzo#endif /* !_SEMAPHORE_H_ */
65239281Sgonzo