diff options
author | Mike Frysinger <vapier@gentoo.org> | 2024-01-01 20:03:26 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2024-01-02 00:29:28 -0500 |
commit | d237a93af39a489c86ec0142fa05b2af17505d13 (patch) | |
tree | 1ef3608ff7bb5760e9527791738692d62d3dee96 /sim | |
parent | 4d4952a63dd231110cd91d2e88c75ad56aa2726f (diff) | |
download | binutils-d237a93af39a489c86ec0142fa05b2af17505d13.zip binutils-d237a93af39a489c86ec0142fa05b2af17505d13.tar.gz binutils-d237a93af39a489c86ec0142fa05b2af17505d13.tar.bz2 |
sim: ppc: merge System V semaphores checks
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.
Diffstat (limited to 'sim')
-rwxr-xr-x | sim/ppc/configure | 54 | ||||
-rw-r--r-- | sim/ppc/configure.ac | 42 |
2 files changed, 13 insertions, 83 deletions
diff --git a/sim/ppc/configure b/sim/ppc/configure index 7915721..3288650 100755 --- a/sim/ppc/configure +++ b/sim/ppc/configure @@ -3170,52 +3170,14 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_has_union_semun" >&5 $as_echo "$ac_cv_has_union_semun" >&6; } +if test x"$ac_cv_has_union_semun" = x"yes"; then : +$as_echo "#define HAVE_UNION_SEMUN 1" >>confdefs.h -if test "$ac_cv_has_union_semun" = "yes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether System V semaphores are supported" >&5 -$as_echo_n "checking whether System V semaphores are supported... " >&6; } -if ${ac_cv_sysv_sem+:} false; then : - $as_echo_n "(cached) " >&6 -else - - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #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); - } -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_sysv_sem="yes" -else - ac_cv_sysv_sem="no" -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sysv_sem" >&5 -$as_echo "$ac_cv_sysv_sem" >&6; } -else # semun is not defined - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether System V semaphores are supported" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether System V semaphores are supported" >&5 $as_echo_n "checking whether System V semaphores are supported... " >&6; } if ${ac_cv_sysv_sem+:} false; then : $as_echo_n "(cached) " >&6 @@ -3230,11 +3192,13 @@ else #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 ; @@ -3261,7 +3225,6 @@ fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sysv_sem" >&5 $as_echo "$ac_cv_sysv_sem" >&6; } -fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether System V shared memory is supported" >&5 $as_echo_n "checking whether System V shared memory is supported... " >&6; } @@ -3308,13 +3271,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 - -$as_echo "#define HAVE_UNION_SEMUN 1" >>confdefs.h - -fi - - # Check whether --enable-sim-hardware was given. if test "${enable_sim_hardware+set}" = set; then : enableval=$enable_sim_hardware; hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide${sim_sysv_ipc_hw}" diff --git a/sim/ppc/configure.ac b/sim/ppc/configure.ac index 1f61ff1..50afce7 100644 --- a/sim/ppc/configure.ac +++ b/sim/ppc/configure.ac @@ -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}" |