1 | dnl |
---|
2 | dnl $Id$ |
---|
3 | dnl |
---|
4 | dnl Check for System V IPC calls used by Unix simulators |
---|
5 | dnl |
---|
6 | dnl 98/07/17 Dario Alcocer alcocer@netcom.com |
---|
7 | dnl Ralf Corsepius corsepiu@faw.uni-ulm.de |
---|
8 | dnl |
---|
9 | dnl Note: $host_os should probably *not* ever be used here to |
---|
10 | dnl determine if host supports System V IPC calls, since some |
---|
11 | dnl (e.g. FreeBSD 2.x) are configured by default to include only |
---|
12 | dnl a subset of the System V IPC calls. Therefore, to make sure |
---|
13 | dnl all of the required calls are found, test for each call explicitly. |
---|
14 | dnl |
---|
15 | dnl All of the calls use IPC_PRIVATE, so tests will not unintentionally |
---|
16 | dnl modify any existing key sets. See the man pages for semget, shmget, |
---|
17 | dnl msgget, semctl, shmctl and msgctl for details. |
---|
18 | |
---|
19 | AC_DEFUN([RTEMS_UNION_SEMUN], |
---|
20 | [ |
---|
21 | AC_CACHE_CHECK([whether $host defines union semun], |
---|
22 | rtems_cv_HAS_UNION_SEMUN, |
---|
23 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
---|
24 | #include <sys/types.h> |
---|
25 | #include <sys/ipc.h> |
---|
26 | #include <sys/sem.h>]], [[union semun arg ;]])],[rtems_cv_HAS_UNION_SEMUN="yes"],[rtems_cv_HAS_UNION_SEMUN="no"]) |
---|
27 | ]) |
---|
28 | if test "$rtems_cv_HAS_UNION_SEMUN" = "yes"; then |
---|
29 | AC_DEFINE(HAS_UNION_SEMUN,[1],[if having union semum]) |
---|
30 | fi |
---|
31 | ]) |
---|
32 | |
---|
33 | AC_DEFUN([RTEMS_SYSV_SEM], |
---|
34 | [AC_REQUIRE([AC_PROG_CC]) |
---|
35 | AC_CACHE_CHECK(whether $host supports System V semaphores, |
---|
36 | rtems_cv_sysv_sem, |
---|
37 | [ |
---|
38 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
---|
39 | #include <sys/types.h> |
---|
40 | #include <sys/ipc.h> |
---|
41 | #include <sys/sem.h> |
---|
42 | #if !HAS_UNION_SEMUN |
---|
43 | union semun { |
---|
44 | int val; |
---|
45 | struct semid_ds *buf; |
---|
46 | ushort *array; |
---|
47 | } ; |
---|
48 | #endif |
---|
49 | int main () { |
---|
50 | union semun arg ; |
---|
51 | |
---|
52 | int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400); |
---|
53 | if (id == -1) |
---|
54 | exit(1); |
---|
55 | arg.val = 0; /* avoid implicit type cast to union */ |
---|
56 | if (semctl(id, 0, IPC_RMID, arg) == -1) |
---|
57 | exit(1); |
---|
58 | exit(0); |
---|
59 | } |
---|
60 | ]])],[rtems_cv_sysv_sem="yes"],[rtems_cv_sysv_sem="no"],[:]) |
---|
61 | ]) |
---|
62 | ]) |
---|
63 | |
---|
64 | AC_DEFUN([RTEMS_SYSV_SHM], |
---|
65 | [AC_REQUIRE([AC_PROG_CC]) |
---|
66 | # AC_REQUIRE([RTEMS_CANONICAL_HOST]) |
---|
67 | AC_CACHE_CHECK(whether $host supports System V shared memory, |
---|
68 | rtems_cv_sysv_shm, |
---|
69 | [ |
---|
70 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
---|
71 | #include <sys/types.h> |
---|
72 | #include <sys/ipc.h> |
---|
73 | #include <sys/shm.h> |
---|
74 | int main () { |
---|
75 | int id=shmget(IPC_PRIVATE,1,IPC_CREAT|0400); |
---|
76 | if (id == -1) |
---|
77 | exit(1); |
---|
78 | if (shmctl(id, IPC_RMID, 0) == -1) |
---|
79 | exit(1); |
---|
80 | exit(0); |
---|
81 | } |
---|
82 | ]])],[rtems_cv_sysv_shm="yes"],[rtems_cv_sysv_shm="no"],[:]) |
---|
83 | ]) |
---|
84 | ]) |
---|
85 | |
---|
86 | AC_DEFUN([RTEMS_SYSV_MSG], |
---|
87 | [AC_REQUIRE([AC_PROG_CC]) |
---|
88 | # AC_REQUIRE([RTEMS_CANONICAL_HOST]) |
---|
89 | AC_CACHE_CHECK(whether $host supports System V messages, |
---|
90 | rtems_cv_sysv_msg, |
---|
91 | [ |
---|
92 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
---|
93 | #include <sys/types.h> |
---|
94 | #include <sys/ipc.h> |
---|
95 | #include <sys/msg.h> |
---|
96 | int main () { |
---|
97 | int id=msgget(IPC_PRIVATE,IPC_CREAT|0400); |
---|
98 | if (id == -1) |
---|
99 | exit(1); |
---|
100 | if (msgctl(id, IPC_RMID, 0) == -1) |
---|
101 | exit(1); |
---|
102 | exit(0); |
---|
103 | } |
---|
104 | ]])],[rtems_cv_sysv_msg="yes"],[rtems_cv_sysv_msg="no"],[:]) |
---|
105 | ]) |
---|
106 | ]) |
---|
107 | |
---|
108 | AC_DEFUN([RTEMS_CHECK_SYSV_UNIX], |
---|
109 | [# AC_REQUIRE([RTEMS_CANONICAL_HOST]) |
---|
110 | if test "$RTEMS_CPU" = "unix" ; then |
---|
111 | RTEMS_UNION_SEMUN |
---|
112 | RTEMS_SYSV_SEM |
---|
113 | if test "$rtems_cv_sysv_sem" != "yes" ; then |
---|
114 | AC_MSG_ERROR([System V semaphores don't work, required by simulator]) |
---|
115 | fi |
---|
116 | RTEMS_SYSV_SHM |
---|
117 | if test "$rtems_cv_sysv_shm" != "yes" ; then |
---|
118 | AC_MSG_ERROR([System V shared memory doesn't work, required by simulator]) |
---|
119 | fi |
---|
120 | RTEMS_SYSV_MSG |
---|
121 | if test "$rtems_cv_sysv_msg" != "yes" ; then |
---|
122 | AC_MSG_ERROR([System V messages don't work, required by simulator]) |
---|
123 | fi |
---|
124 | fi |
---|
125 | ]) |
---|