public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH/submitted 2/5] sim: ppc: merge System V semaphores checks
Date: Tue,  2 Jan 2024 00:30:23 -0500	[thread overview]
Message-ID: <20240102053026.20425-2-vapier@gentoo.org> (raw)
In-Reply-To: <20240102053026.20425-1-vapier@gentoo.org>

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(-)

diff --git a/sim/ppc/configure.ac b/sim/ppc/configure.ac
index 1f61ff1bacef..50afce74303d 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}"
-- 
2.43.0


  reply	other threads:[~2024-01-02  6:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-02  5:30 [PATCH/submitted 1/5] sim: ppc: fix bad AC_CACHE_CHECK call with semun Mike Frysinger
2024-01-02  5:30 ` Mike Frysinger [this message]
2024-01-02  5:30 ` [PATCH/submitted 3/5] sim: ppc: change SysV sem & shm tests to compile-time Mike Frysinger
2024-01-02  5:30 ` [PATCH/submitted 4/5] sim: ppc: always compile in the sysv sem & shm device files Mike Frysinger
2024-01-02  5:30 ` [PATCH/submitted 5/5] sim: ppc: hoist sysv tests to top-level Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240102053026.20425-2-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).