[613ab62] | 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 | |
---|
[ea562ee9] | 19 | AC_DEFUN(RTEMS_UNION_SEMUN, |
---|
| 20 | [ |
---|
[a0ea6f1] | 21 | AC_CACHE_CHECK([whether $host defines union semun], |
---|
[ea562ee9] | 22 | rtems_cv_HAS_UNION_SEMUN, |
---|
| 23 | [AC_TRY_COMPILE([ |
---|
| 24 | #include <sys/types.h> |
---|
| 25 | #include <sys/ipc.h> |
---|
| 26 | #include <sys/sem.h>], |
---|
| 27 | [union semun arg ;], |
---|
| 28 | [rtems_cv_HAS_UNION_SEMUN="yes"], |
---|
| 29 | [rtems_cv_HAS_UNION_SEMUN="no"]) |
---|
[5913d94] | 30 | ]) |
---|
[ea562ee9] | 31 | if test "$rtems_cv_HAS_UNION_SEMUN" = "yes"; then |
---|
| 32 | AC_DEFINE(HAS_UNION_SEMUN) |
---|
[5913d94] | 33 | fi |
---|
[ea562ee9] | 34 | ]) |
---|
| 35 | |
---|
[613ab62] | 36 | AC_DEFUN(RTEMS_SYSV_SEM, |
---|
[6693a68] | 37 | [AC_REQUIRE([AC_PROG_CC]) |
---|
[a0ea6f1] | 38 | # AC_REQUIRE([RTEMS_CANONICAL_HOST]) |
---|
| 39 | AC_CACHE_CHECK(whether $host supports System V semaphores, |
---|
[613ab62] | 40 | rtems_cv_sysv_sem, |
---|
| 41 | [ |
---|
[ea562ee9] | 42 | AC_TRY_RUN( |
---|
| 43 | [ |
---|
[613ab62] | 44 | #include <sys/types.h> |
---|
| 45 | #include <sys/ipc.h> |
---|
| 46 | #include <sys/sem.h> |
---|
[ea562ee9] | 47 | #if !HAS_UNION_SEMUN |
---|
[06fa582] | 48 | union semun { |
---|
| 49 | int val; |
---|
| 50 | struct semid_ds *buf; |
---|
| 51 | ushort *array; |
---|
[ea562ee9] | 52 | } ; |
---|
[06fa582] | 53 | #endif |
---|
[ea562ee9] | 54 | int main () { |
---|
| 55 | union semun arg ; |
---|
| 56 | |
---|
[613ab62] | 57 | int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400); |
---|
| 58 | if (id == -1) |
---|
| 59 | exit(1); |
---|
| 60 | arg.val = 0; /* avoid implicit type cast to union */ |
---|
| 61 | if (semctl(id, 0, IPC_RMID, arg) == -1) |
---|
| 62 | exit(1); |
---|
| 63 | exit(0); |
---|
| 64 | } |
---|
| 65 | ], |
---|
| 66 | rtems_cv_sysv_sem="yes", rtems_cv_sysv_sem="no", :) |
---|
| 67 | ]) |
---|
| 68 | ]) |
---|
| 69 | |
---|
| 70 | AC_DEFUN(RTEMS_SYSV_SHM, |
---|
[6693a68] | 71 | [AC_REQUIRE([AC_PROG_CC]) |
---|
[a0ea6f1] | 72 | # AC_REQUIRE([RTEMS_CANONICAL_HOST]) |
---|
| 73 | AC_CACHE_CHECK(whether $host supports System V shared memory, |
---|
[613ab62] | 74 | rtems_cv_sysv_shm, |
---|
| 75 | [ |
---|
| 76 | AC_TRY_RUN([ |
---|
| 77 | #include <sys/types.h> |
---|
| 78 | #include <sys/ipc.h> |
---|
| 79 | #include <sys/shm.h> |
---|
| 80 | int main () { |
---|
| 81 | int id=shmget(IPC_PRIVATE,1,IPC_CREAT|0400); |
---|
| 82 | if (id == -1) |
---|
| 83 | exit(1); |
---|
| 84 | if (shmctl(id, IPC_RMID, 0) == -1) |
---|
| 85 | exit(1); |
---|
| 86 | exit(0); |
---|
| 87 | } |
---|
| 88 | ], |
---|
| 89 | rtems_cv_sysv_shm="yes", rtems_cv_sysv_shm="no", :) |
---|
| 90 | ]) |
---|
| 91 | ]) |
---|
| 92 | |
---|
| 93 | AC_DEFUN(RTEMS_SYSV_MSG, |
---|
[6693a68] | 94 | [AC_REQUIRE([AC_PROG_CC]) |
---|
[a0ea6f1] | 95 | # AC_REQUIRE([RTEMS_CANONICAL_HOST]) |
---|
| 96 | AC_CACHE_CHECK(whether $host supports System V messages, |
---|
[613ab62] | 97 | rtems_cv_sysv_msg, |
---|
| 98 | [ |
---|
| 99 | AC_TRY_RUN([ |
---|
| 100 | #include <sys/types.h> |
---|
| 101 | #include <sys/ipc.h> |
---|
| 102 | #include <sys/msg.h> |
---|
| 103 | int main () { |
---|
| 104 | int id=msgget(IPC_PRIVATE,IPC_CREAT|0400); |
---|
| 105 | if (id == -1) |
---|
| 106 | exit(1); |
---|
| 107 | if (msgctl(id, IPC_RMID, 0) == -1) |
---|
| 108 | exit(1); |
---|
| 109 | exit(0); |
---|
| 110 | } |
---|
| 111 | ], |
---|
| 112 | rtems_cv_sysv_msg="yes", rtems_cv_sysv_msg="no", :) |
---|
| 113 | ]) |
---|
| 114 | ]) |
---|
[6693a68] | 115 | |
---|
| 116 | AC_DEFUN(RTEMS_CHECK_SYSV_UNIX, |
---|
[a0ea6f1] | 117 | [# AC_REQUIRE([RTEMS_CANONICAL_HOST]) |
---|
[6693a68] | 118 | if test "$RTEMS_CPU" = "unix" ; then |
---|
[ea562ee9] | 119 | RTEMS_UNION_SEMUN |
---|
[6693a68] | 120 | RTEMS_SYSV_SEM |
---|
| 121 | if test "$rtems_cv_sysv_sem" != "yes" ; then |
---|
| 122 | AC_MSG_ERROR([System V semaphores don't work, required by simulator]) |
---|
| 123 | fi |
---|
| 124 | RTEMS_SYSV_SHM |
---|
| 125 | if test "$rtems_cv_sysv_shm" != "yes" ; then |
---|
| 126 | AC_MSG_ERROR([System V shared memory doesn't work, required by simulator]) |
---|
| 127 | fi |
---|
| 128 | RTEMS_SYSV_MSG |
---|
| 129 | if test "$rtems_cv_sysv_msg" != "yes" ; then |
---|
| 130 | AC_MSG_ERROR([System V messages don't work, required by simulator]) |
---|
| 131 | fi |
---|
| 132 | fi |
---|
| 133 | ]) |
---|