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_SYSV_SEM, |
---|
20 | [AC_REQUIRE([RTEMS_PROG_CC]) |
---|
21 | AC_REQUIRE([AC_CANONICAL_HOST]) |
---|
22 | AC_CACHE_CHECK(whether $RTEMS_HOST supports System V semaphores, |
---|
23 | rtems_cv_sysv_sem, |
---|
24 | [ |
---|
25 | AC_TRY_RUN([ |
---|
26 | #include <sys/types.h> |
---|
27 | #include <sys/ipc.h> |
---|
28 | #include <sys/sem.h> |
---|
29 | int main () { |
---|
30 | #if !defined(sun) |
---|
31 | union semun arg ; |
---|
32 | #else |
---|
33 | union semun { |
---|
34 | int val; |
---|
35 | struct semid_ds *buf; |
---|
36 | ushort *array; |
---|
37 | } arg; |
---|
38 | #endif |
---|
39 | int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400); |
---|
40 | if (id == -1) |
---|
41 | exit(1); |
---|
42 | arg.val = 0; /* avoid implicit type cast to union */ |
---|
43 | if (semctl(id, 0, IPC_RMID, arg) == -1) |
---|
44 | exit(1); |
---|
45 | exit(0); |
---|
46 | } |
---|
47 | ], |
---|
48 | rtems_cv_sysv_sem="yes", rtems_cv_sysv_sem="no", :) |
---|
49 | ]) |
---|
50 | ]) |
---|
51 | |
---|
52 | AC_DEFUN(RTEMS_SYSV_SHM, |
---|
53 | [AC_REQUIRE([RTEMS_PROG_CC]) |
---|
54 | AC_REQUIRE([AC_CANONICAL_HOST]) |
---|
55 | AC_CACHE_CHECK(whether $RTEMS_HOST supports System V shared memory, |
---|
56 | rtems_cv_sysv_shm, |
---|
57 | [ |
---|
58 | AC_TRY_RUN([ |
---|
59 | #include <sys/types.h> |
---|
60 | #include <sys/ipc.h> |
---|
61 | #include <sys/shm.h> |
---|
62 | int main () { |
---|
63 | int id=shmget(IPC_PRIVATE,1,IPC_CREAT|0400); |
---|
64 | if (id == -1) |
---|
65 | exit(1); |
---|
66 | if (shmctl(id, IPC_RMID, 0) == -1) |
---|
67 | exit(1); |
---|
68 | exit(0); |
---|
69 | } |
---|
70 | ], |
---|
71 | rtems_cv_sysv_shm="yes", rtems_cv_sysv_shm="no", :) |
---|
72 | ]) |
---|
73 | ]) |
---|
74 | |
---|
75 | AC_DEFUN(RTEMS_SYSV_MSG, |
---|
76 | [AC_REQUIRE([RTEMS_PROG_CC]) |
---|
77 | AC_REQUIRE([AC_CANONICAL_HOST]) |
---|
78 | AC_CACHE_CHECK(whether $RTEMS_HOST supports System V messages, |
---|
79 | rtems_cv_sysv_msg, |
---|
80 | [ |
---|
81 | AC_TRY_RUN([ |
---|
82 | #include <sys/types.h> |
---|
83 | #include <sys/ipc.h> |
---|
84 | #include <sys/msg.h> |
---|
85 | int main () { |
---|
86 | int id=msgget(IPC_PRIVATE,IPC_CREAT|0400); |
---|
87 | if (id == -1) |
---|
88 | exit(1); |
---|
89 | if (msgctl(id, IPC_RMID, 0) == -1) |
---|
90 | exit(1); |
---|
91 | exit(0); |
---|
92 | } |
---|
93 | ], |
---|
94 | rtems_cv_sysv_msg="yes", rtems_cv_sysv_msg="no", :) |
---|
95 | ]) |
---|
96 | ]) |
---|