source: rtems/aclocal/sysv-ipc.m4 @ b62a92c

4.104.114.84.95
Last change on this file since b62a92c was ea562ee9, checked in by Joel Sherrill <joel.sherrill@…>, on 08/12/99 at 18:22:17

Patch from Ralf Corsepius <corsepiu@…>:

After upgrading my linux box to the brand new SuSE 6.2 release, which is
glibc-2.1 based, I came across a bug in RTEMS - IIRC, I even warned you
about it about 1/2 a year ago, but nothing has been done since then :-.

The *.m4 macros to check for SYSV/IPC are broken for linux/glibc2.1,
because they assume that linux always defines union semun, which isn't
true anymore for glibc2.1 (the manpage for semctl states _X_OPEN
specifies it this way). Therefore I have tried to implement a more
general approach for handling SYSV for unix/posix which checks for
presence of struct semun, instead of trying to evaluate OS specific
preprocessor symbols.

This approach is a bit adventureous, because I only tested it with
linux/glibc2.1 and linux/libc5, but not under other Unix variants RTEMS
supports. I am quite confident it will work on other hosts, too, but who
knows :-.

[FYI: I think this might also is the cause of some problems with RedHat?
6.X / Mandrake linux recently reported on the rtems list -- rtems-4.0.0
can not be build for posix on any glibc2.1 based host]

Furthermore the patch below contains a couple of minor fixes and
configuration cleanups, which IMO should be applied before releasing a
new snapshot.

To apply this patch:

cd <source-tree>
patch -p1 < rtems-rc-19990709-8.diff
./autogen

  • 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 $RTEMS_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)
33fi])
34])
35
36AC_DEFUN(RTEMS_SYSV_SEM,
37[AC_REQUIRE([AC_PROG_CC])
38AC_REQUIRE([RTEMS_CANONICAL_HOST])
39AC_CACHE_CHECK(whether $RTEMS_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])
72AC_REQUIRE([RTEMS_CANONICAL_HOST])
73AC_CACHE_CHECK(whether $RTEMS_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])
95AC_REQUIRE([RTEMS_CANONICAL_HOST])
96AC_CACHE_CHECK(whether $RTEMS_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.