Compile tests can use earlier defines, so hoist the HAVE_UNION_SEMUN
define to before the semaphore check, and use it in the test so that
we can merge the 2 versions into one.
This also defines HAVE_UNION_SEMUN even when ac_cv_sysv_sem is not
set, but that's OK as this define is only about a type existing, not
about whether the overall code is usable.
---
sim/ppc/configure | 54 ++++----------------------------------------
sim/ppc/configure.ac | 42 +++++++---------------------------
2 files changed, 13 insertions(+), 83 deletions(-)
@@ -105,33 +105,12 @@ AC_CACHE_CHECK([if union semun defined],
[union semun arg ;],
[ac_cv_has_union_semun="yes"],
[ac_cv_has_union_semun="no"])])
+AS_IF([test x"$ac_cv_has_union_semun" = x"yes"], [dnl
+ AC_DEFINE(HAVE_UNION_SEMUN, 1,
+ [Define if union semun is defined in <sys/sem.h>])
+])
-
-if test "$ac_cv_has_union_semun" = "yes"; then
- AC_CACHE_CHECK(whether System V semaphores are supported,
- ac_cv_sysv_sem,
- [
- AC_TRY_RUN(
- [
- #include <sys/types.h>
- #include <sys/ipc.h>
- #include <sys/sem.h>
- int main () {
- union semun arg ;
-
- int id=semget(IPC_PRIVATE,1,IPC_CREAT|0400);
- if (id == -1)
- exit(1);
- arg.val = 0; /* avoid implicit type cast to union */
- if (semctl(id, 0, IPC_RMID, arg) == -1)
- exit(1);
- exit(0);
- }
- ],
- ac_cv_sysv_sem="yes", ac_cv_sysv_sem="no", :)
- ])
-else # semun is not defined
- AC_CACHE_CHECK(whether System V semaphores are supported,
+AC_CACHE_CHECK([whether System V semaphores are supported],
ac_cv_sysv_sem,
[
AC_TRY_RUN(
@@ -139,11 +118,13 @@ else # semun is not defined
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
+#ifndef HAVE_UNION_SEMUN
union semun {
int val;
struct semid_ds *buf;
ushort *array;
};
+#endif
int main () {
union semun arg ;
@@ -157,8 +138,7 @@ else # semun is not defined
}
],
ac_cv_sysv_sem="yes", ac_cv_sysv_sem="no", :)
- ])
-fi
+])
AC_CACHE_CHECK(whether System V shared memory is supported,
ac_cv_sysv_shm,
@@ -185,12 +165,6 @@ else
sim_sysv_ipc_hw="";
fi
-if test x"$ac_cv_has_union_semun" = x"yes" -a x"$ac_cv_sysv_sem" = x"yes" ; then
- AC_DEFINE(HAVE_UNION_SEMUN, 1,
- [Define if union semun is defined in <sys/sem.h>])
-fi
-
-
AC_ARG_ENABLE(sim-hardware,
[ --enable-sim-hardware=list Specify the hardware to be included in the build.],
[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide${sim_sysv_ipc_hw}"