]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: ppc: merge System V semaphores checks
authorMike Frysinger <vapier@gentoo.org>
Tue, 2 Jan 2024 01:03:26 +0000 (20:03 -0500)
committerMike Frysinger <vapier@gentoo.org>
Tue, 2 Jan 2024 05:29:28 +0000 (00:29 -0500)
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
sim/ppc/configure.ac

index 791572150054e6009fe0ad2f19ae678981cd16aa..32886507185c96cb42e9d3a39c71eeb4549df896 100755 (executable)
@@ -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}"
index 1f61ff1bacefe35dacf153a843ddcafc5d1e1a18..50afce74303dee8060227259216f20a762065017 100644 (file)
@@ -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}"