<sys/time.h>: Add 3rd arg to timespecadd()/sub() and make them public.
[dragonfly.git] / test / testcases / posixipc / common / common.h
1 /*-
2  * Copyright (c) 2008 Yahoo!, Inc.
3  * All rights reserved.
4  * Written by: John Baldwin <jhb@FreeBSD.org>
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
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.
17  *
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
28  * SUCH DAMAGE.
29  */
30
31 #ifndef _COMMON_H_
32 #define _COMMON_H_
33
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <errno.h>
37 #include <fcntl.h>
38 #include <semaphore.h>
39 #include <string.h>
40 #include <unistd.h>
41
42 #include <sys/param.h>
43 #include <sys/types.h>
44 #include <sys/stat.h>
45
46 #define ELAPSED(elapsed, limit)         (abs((elapsed) - (limit)) < 100)
47
48 #define TEST_PATH       "/posixsem_regression_test"
49
50 extern sem_t *alarm_id;
51 extern int alarm_errno;
52 extern int alarm_handler_installed;
53
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)
58
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);
65 int check_alarm(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);
73
74 #endif