2 * Copyright (c) 2008 Yahoo!, Inc.
4 * Written by: John Baldwin <jhb@FreeBSD.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the author nor the names of any co-contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 #include <semaphore.h>
42 #include <sys/param.h>
43 #include <sys/types.h>
46 #define ELAPSED(elapsed, limit) (abs((elapsed) - (limit)) < 100)
48 #define TEST_PATH "/posixsem_regression_test"
50 extern sem_t *alarm_id;
51 extern int alarm_errno;
52 extern int alarm_handler_installed;
54 /* Macros for passing child status to parent over a pipe. */
55 #define CSTAT(class, error) ((class) << 16 | (error))
56 #define CSTAT_CLASS(stat) ((stat) >> 16)
57 #define CSTAT_ERROR(stat) ((stat) & 0xffff)
59 int checkvalue(sem_t *, int);
60 sem_t *construct_shared_unnamed_sem(unsigned int);
61 void destruct_shared_unnamed_sem(sem_t *);
62 int testwait(sem_t *, u_int *);
63 int timedwait(sem_t *, u_int, u_int *, int);
64 int schedule_post(sem_t *, u_int);
66 int child_worker(int (*)(void *), void *, int *);
67 int wait_twoproc_child(void *);
68 int sem_open_should_fail(const char *, int, mode_t, unsigned int, int);
69 int sem_init_should_fail(unsigned int, int);
70 int sem_unlink_should_fail(const char *, int);
71 int sem_destroy_should_fail(sem_t *, int);
72 int sem_close_should_fail(sem_t *, int);