source: rtems/cpukit/aclocal/sysv-ipc.m4 @ d8befba2

4.104.114.84.95
Last change on this file since d8befba2 was ed8ec1c, checked in by Ralf Corsepius <ralf.corsepius@…>, on 06/17/02 at 08:52:47

2002-06-17 Ralf Corsepius <corsepiu@…>

  • copied over from aclocal/.
  • Property mode set to 100644
File size: 3.2 KB
Line 
1dnl
2dnl $Id$
3dnl
4dnl Check for System V IPC calls used by Unix simulators
5dnl
6dnl 98/07/17 Dario Alcocer     alcocer@netcom.com
7dnl          Ralf Corsepius    corsepiu@faw.uni-ulm.de
8dnl
9dnl Note: $host_os should probably *not* ever be used here to
10dnl determine if host supports System V IPC calls, since some
11dnl (e.g. FreeBSD 2.x) are configured by default to include only
12dnl a subset of the System V IPC calls.  Therefore, to make sure
13dnl all of the required calls are found, test for each call explicitly.
14dnl
15dnl All of the calls use IPC_PRIVATE, so tests will not unintentionally
16dnl modify any existing key sets.  See the man pages for semget, shmget,
17dnl msgget, semctl, shmctl and msgctl for details.
18
19AC_DEFUN(RTEMS_UNION_SEMUN,
20[
21AC_CACHE_CHECK([whether $host defines union semun],
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"])
30])
31if test "$rtems_cv_HAS_UNION_SEMUN" = "yes"; then
32    AC_DEFINE(HAS_UNION_SEMUN,[1],[if having union semum])
33fi
34])
35
36AC_DEFUN(RTEMS_SYSV_SEM,
37[AC_REQUIRE([AC_PROG_CC])
38# AC_REQUIRE([RTEMS_CANONICAL_HOST])
39AC_CACHE_CHECK(whether $host supports System V semaphores,
40rtems_cv_sysv_sem,
41[
42AC_TRY_RUN(
43[
44#include <sys/types.h>
45#include <sys/ipc.h>
46#include <sys/sem.h>
47#if !HAS_UNION_SEMUN
48  union semun {
49    int val;
50    struct semid_ds *buf;
51    ushort *array;
52  } ;
53#endif
54int main () {
55  union semun arg ;
56
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],
66rtems_cv_sysv_sem="yes", rtems_cv_sysv_sem="no", :)
67])
68])
69
70AC_DEFUN(RTEMS_SYSV_SHM,
71[AC_REQUIRE([AC_PROG_CC])
72# AC_REQUIRE([RTEMS_CANONICAL_HOST])
73AC_CACHE_CHECK(whether $host supports System V shared memory,
74rtems_cv_sysv_shm,
75[
76AC_TRY_RUN([
77#include <sys/types.h>
78#include <sys/ipc.h>
79#include <sys/shm.h>
80int 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],
89rtems_cv_sysv_shm="yes", rtems_cv_sysv_shm="no", :)
90])
91])
92
93AC_DEFUN(RTEMS_SYSV_MSG,
94[AC_REQUIRE([AC_PROG_CC])
95# AC_REQUIRE([RTEMS_CANONICAL_HOST])
96AC_CACHE_CHECK(whether $host supports System V messages,
97rtems_cv_sysv_msg,
98[
99AC_TRY_RUN([
100#include <sys/types.h>
101#include <sys/ipc.h>
102#include <sys/msg.h>
103int 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],
112rtems_cv_sysv_msg="yes", rtems_cv_sysv_msg="no", :)
113])
114])
115
116AC_DEFUN(RTEMS_CHECK_SYSV_UNIX,
117[# AC_REQUIRE([RTEMS_CANONICAL_HOST])
118if test "$RTEMS_CPU" = "unix" ; then
119  RTEMS_UNION_SEMUN
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
132fi
133])
Note: See TracBrowser for help on using the repository browser.