* [PATCH/submitted 1/5] sim: ppc: fix bad AC_CACHE_CHECK call with semun
@ 2024-01-02 5:30 Mike Frysinger
2024-01-02 5:30 ` [PATCH/submitted 2/5] sim: ppc: merge System V semaphores checks Mike Frysinger
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Mike Frysinger @ 2024-01-02 5:30 UTC (permalink / raw)
To: gdb-patches
The first arg is the cache var name, and this one was typoed relative
to what the call actually set. We also don't need the manual call to
AC_MSG_RESULT as the AC_CACHE_CHECK takes care of it for us.
---
sim/ppc/configure | 7 ++-----
sim/ppc/configure.ac | 6 ++----
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/sim/ppc/configure.ac b/sim/ppc/configure.ac
index adb4fc00a01d..1f61ff1bacef 100644
--- a/sim/ppc/configure.ac
+++ b/sim/ppc/configure.ac
@@ -97,16 +97,14 @@ esac
])dnl
AC_CACHE_CHECK([if union semun defined],
- ac_cv_HAS_UNION_SEMUN,
+ [ac_cv_has_union_semun],
[AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>],
[union semun arg ;],
[ac_cv_has_union_semun="yes"],
-[ac_cv_has_union_semun="no"])
-AC_MSG_RESULT($ac_cv_has_union_semun)
-])
+[ac_cv_has_union_semun="no"])])
if test "$ac_cv_has_union_semun" = "yes"; then
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH/submitted 2/5] sim: ppc: merge System V semaphores checks
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
2024-01-02 5:30 ` [PATCH/submitted 3/5] sim: ppc: change SysV sem & shm tests to compile-time Mike Frysinger
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2024-01-02 5:30 UTC (permalink / raw)
To: gdb-patches
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH/submitted 3/5] sim: ppc: change SysV sem & shm tests to compile-time
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 ` [PATCH/submitted 2/5] sim: ppc: merge System V semaphores checks Mike Frysinger
@ 2024-01-02 5:30 ` 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
3 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2024-01-02 5:30 UTC (permalink / raw)
To: gdb-patches
Instead of executing code to see if SysV semaphores & shared memory
are available, switch to just a compile-time test. The system used
to compile might not match the system used to run the code wrt the
current kernel & OS settings, but the library APIs should. So move
the failures from compile-time to runtime so the program is more
portable, and works correctly even when cross-compiling.
---
sim/ppc/configure | 149 ++++++++++++++++++++-----------------------
sim/ppc/configure.ac | 48 +++++---------
2 files changed, 87 insertions(+), 110 deletions(-)
diff --git a/sim/ppc/configure.ac b/sim/ppc/configure.ac
index 50afce74303d..b78a09d9b587 100644
--- a/sim/ppc/configure.ac
+++ b/sim/ppc/configure.ac
@@ -111,10 +111,8 @@ AS_IF([test x"$ac_cv_has_union_semun" = x"yes"], [dnl
])
AC_CACHE_CHECK([whether System V semaphores are supported],
- ac_cv_sysv_sem,
- [
- AC_TRY_RUN(
- [
+ [ac_cv_sysv_sem],
+ [AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
@@ -124,40 +122,28 @@ AC_CACHE_CHECK([whether System V semaphores are supported],
struct semid_ds *buf;
ushort *array;
};
-#endif
- 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", :)
-])
+#endif], [
+ union semun arg;
+ int id = semget(IPC_PRIVATE, 1, IPC_CREAT|0400);
+ if (id == -1)
+ return 1;
+ arg.val = 0; /* avoid implicit type cast to union */
+ if (semctl(id, 0, IPC_RMID, arg) == -1)
+ return 1;
+], [ac_cv_sysv_sem="yes"], [ac_cv_sysv_sem="no"])])
AC_CACHE_CHECK(whether System V shared memory is supported,
ac_cv_sysv_shm,
-[
-AC_TRY_RUN([
+[AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/ipc.h>
-#include <sys/shm.h>
-int main () {
- int id=shmget(IPC_PRIVATE,1,IPC_CREAT|0400);
+#include <sys/shm.h>], [
+ int id = shmget(IPC_PRIVATE, 1, IPC_CREAT|0400);
if (id == -1)
- exit(1);
+ return 1;
if (shmctl(id, IPC_RMID, 0) == -1)
- exit(1);
- exit(0);
-}
-],
-ac_cv_sysv_shm="yes", ac_cv_sysv_shm="no", :)
-])
+ return 1;
+], [ac_cv_sysv_shm="yes"], [ac_cv_sysv_shm="no"])])
if test x"$ac_cv_sysv_shm" = x"yes" -a x"$ac_cv_sysv_sem" = x"yes" ; then
sim_sysv_ipc_hw=",sem,shm";
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH/submitted 4/5] sim: ppc: always compile in the sysv sem & shm device files
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 ` [PATCH/submitted 2/5] sim: ppc: merge System V semaphores checks Mike Frysinger
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 ` Mike Frysinger
2024-01-02 5:30 ` [PATCH/submitted 5/5] sim: ppc: hoist sysv tests to top-level Mike Frysinger
3 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2024-01-02 5:30 UTC (permalink / raw)
To: gdb-patches
Move the stub logic to the device files themselves. This makes the
configure & build logic more static which will make it easier to move
to the top-level build, and matches what we did with the common/ hw
tree already.
This also decouples the logic from the two -- in the past, you needed
both sem & shm in order to enable the device models, but now each one
is tied to its own independent knob. Practically speaking, this will
probably not make a difference, but it simplifies the build a bit.
---
sim/ppc/config.in | 6 ++++++
sim/ppc/configure | 18 ++++++++++++------
sim/ppc/configure.ac | 16 ++++++++--------
sim/ppc/hw_sem.c | 10 ++++++++++
sim/ppc/hw_shm.c | 10 ++++++++++
5 files changed, 46 insertions(+), 14 deletions(-)
diff --git a/sim/ppc/configure.ac b/sim/ppc/configure.ac
index b78a09d9b587..9b01aede82cd 100644
--- a/sim/ppc/configure.ac
+++ b/sim/ppc/configure.ac
@@ -131,6 +131,9 @@ AC_CACHE_CHECK([whether System V semaphores are supported],
if (semctl(id, 0, IPC_RMID, arg) == -1)
return 1;
], [ac_cv_sysv_sem="yes"], [ac_cv_sysv_sem="no"])])
+AS_IF([test x"$ac_cv_sysv_sem" = x"yes"], [dnl
+ AC_DEFINE(HAVE_SYSV_SEM, 1, [Define if System V semaphores are supported])
+])
AC_CACHE_CHECK(whether System V shared memory is supported,
ac_cv_sysv_shm,
@@ -144,16 +147,13 @@ ac_cv_sysv_shm,
if (shmctl(id, IPC_RMID, 0) == -1)
return 1;
], [ac_cv_sysv_shm="yes"], [ac_cv_sysv_shm="no"])])
-
-if test x"$ac_cv_sysv_shm" = x"yes" -a x"$ac_cv_sysv_sem" = x"yes" ; then
- sim_sysv_ipc_hw=",sem,shm";
-else
- sim_sysv_ipc_hw="";
-fi
+AS_IF([test x"$ac_cv_sysv_shm" = x"yes"], [dnl
+ AC_DEFINE(HAVE_SYSV_SHM, 1, [Define if System V shared memory is supported])
+])
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}"
+[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide,sem,shm"
case "${enableval}" in
yes) ;;
no) AC_MSG_ERROR("List of hardware must be specified for --enable-sim-hardware"); hardware="";;
@@ -165,7 +165,7 @@ sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
if test x"$silent" != x"yes" && test x"$hardware" != x""; then
echo "Setting hardware to $sim_hw_src, $sim_hw_obj"
-fi],[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide${sim_sysv_ipc_hw}"
+fi],[hardware="cpu,memory,nvram,iobus,htab,disk,trace,register,vm,init,core,pal,com,eeprom,opic,glue,phb,ide,sem,shm"
sim_hw_src=`echo $hardware | sed -e 's/,/.c hw_/g' -e 's/^/hw_/' -e s'/$/.c/'`
sim_hw_obj=`echo $sim_hw_src | sed -e 's/\.c/.o/g'`
if test x"$silent" != x"yes"; then
diff --git a/sim/ppc/hw_sem.c b/sim/ppc/hw_sem.c
index 937e2ad6f812..c43af3b1d9ed 100644
--- a/sim/ppc/hw_sem.c
+++ b/sim/ppc/hw_sem.c
@@ -84,6 +84,8 @@
*/
+#ifdef HAVE_SYSV_SEM
+
typedef struct _hw_sem_device {
unsigned_word physical_address;
key_t key;
@@ -278,4 +280,12 @@ const device_descriptor hw_sem_device_descriptor[] = {
{ NULL },
};
+#else
+
+const device_descriptor hw_sem_device_descriptor[] = {
+ { NULL },
+};
+
+#endif /* HAVE_SYSV_SEM */
+
#endif /* _HW_SEM_C_ */
diff --git a/sim/ppc/hw_shm.c b/sim/ppc/hw_shm.c
index c4d5cae83453..0f78ae8c4a9a 100644
--- a/sim/ppc/hw_shm.c
+++ b/sim/ppc/hw_shm.c
@@ -77,6 +77,8 @@
*/
+#ifdef HAVE_SYSV_SHM
+
typedef struct _hw_shm_device {
unsigned_word physical_address;
char *shm_address;
@@ -222,4 +224,12 @@ const device_descriptor hw_shm_device_descriptor[] = {
{ NULL },
};
+#else
+
+const device_descriptor hw_shm_device_descriptor[] = {
+ { NULL },
+};
+
+#endif /* HAVE_SYSV_SHM */
+
#endif /* _HW_SHM_C_ */
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH/submitted 5/5] sim: ppc: hoist sysv tests to top-level
2024-01-02 5:30 [PATCH/submitted 1/5] sim: ppc: fix bad AC_CACHE_CHECK call with semun Mike Frysinger
` (2 preceding siblings ...)
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 ` Mike Frysinger
3 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2024-01-02 5:30 UTC (permalink / raw)
To: gdb-patches
Now that the sysv tests turn into config.h defines and everything
checks that, we can move the tests to the top-level and out of the
ppc subdir.
---
sim/config.h.in | 9 +++
sim/configure | 132 +++++++++++++++++++++++++++++++++++++-
sim/m4/sim_ac_platform.m4 | 55 ++++++++++++++++
sim/ppc/config.in | 9 ---
sim/ppc/configure | 127 +-----------------------------------
sim/ppc/configure.ac | 54 ----------------
6 files changed, 195 insertions(+), 191 deletions(-)
diff --git a/sim/m4/sim_ac_platform.m4 b/sim/m4/sim_ac_platform.m4
index f45321763fa7..dcab5b2862d9 100644
--- a/sim/m4/sim_ac_platform.m4
+++ b/sim/m4/sim_ac_platform.m4
@@ -133,6 +133,61 @@ AC_CHECK_TYPES(socklen_t, [], [],
#include <sys/socket.h>
])
+dnl Some System V related checks.
+AC_CACHE_CHECK([if union semun defined],
+ [sim_cv_has_union_semun],
+ [AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>], [
+ union semun arg;
+], [sim_cv_has_union_semun="yes"], [sim_cv_has_union_semun="no"])])
+AS_IF([test x"$sim_cv_has_union_semun" = x"yes"], [dnl
+ AC_DEFINE(HAVE_UNION_SEMUN, 1,
+ [Define if union semun is defined in <sys/sem.h>])
+])
+
+AC_CACHE_CHECK([whether System V semaphores are supported],
+ [sim_cv_sysv_sem],
+ [AC_TRY_COMPILE([
+ #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], [
+ union semun arg;
+ int id = semget(IPC_PRIVATE, 1, IPC_CREAT|0400);
+ if (id == -1)
+ return 1;
+ arg.val = 0; /* avoid implicit type cast to union */
+ if (semctl(id, 0, IPC_RMID, arg) == -1)
+ return 1;
+], [sim_cv_sysv_sem="yes"], [sim_cv_sysv_sem="no"])])
+AS_IF([test x"$sim_cv_sysv_sem" = x"yes"], [dnl
+ AC_DEFINE(HAVE_SYSV_SEM, 1, [Define if System V semaphores are supported])
+])
+
+AC_CACHE_CHECK([whether System V shared memory is supported],
+ [sim_cv_sysv_shm],
+ [AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>], [
+ int id = shmget(IPC_PRIVATE, 1, IPC_CREAT|0400);
+ if (id == -1)
+ return 1;
+ if (shmctl(id, IPC_RMID, 0) == -1)
+ return 1;
+], [sim_cv_sysv_shm="yes"], [sim_cv_sysv_shm="no"])])
+AS_IF([test x"$sim_cv_sysv_shm" = x"yes"], [dnl
+ AC_DEFINE(HAVE_SYSV_SHM, 1, [Define if System V shared memory is supported])
+])
+
dnl Types used by common code
AC_TYPE_GETGROUPS
AC_TYPE_MODE_T
diff --git a/sim/ppc/configure.ac b/sim/ppc/configure.ac
index 9b01aede82cd..06be2c960768 100644
--- a/sim/ppc/configure.ac
+++ b/sim/ppc/configure.ac
@@ -96,60 +96,6 @@ case "${target}" in
esac
])dnl
-AC_CACHE_CHECK([if union semun defined],
- [ac_cv_has_union_semun],
- [AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>],
-[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>])
-])
-
-AC_CACHE_CHECK([whether System V semaphores are supported],
- [ac_cv_sysv_sem],
- [AC_TRY_COMPILE([
- #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], [
- union semun arg;
- int id = semget(IPC_PRIVATE, 1, IPC_CREAT|0400);
- if (id == -1)
- return 1;
- arg.val = 0; /* avoid implicit type cast to union */
- if (semctl(id, 0, IPC_RMID, arg) == -1)
- return 1;
-], [ac_cv_sysv_sem="yes"], [ac_cv_sysv_sem="no"])])
-AS_IF([test x"$ac_cv_sysv_sem" = x"yes"], [dnl
- AC_DEFINE(HAVE_SYSV_SEM, 1, [Define if System V semaphores are supported])
-])
-
-AC_CACHE_CHECK(whether System V shared memory is supported,
-ac_cv_sysv_shm,
-[AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>], [
- int id = shmget(IPC_PRIVATE, 1, IPC_CREAT|0400);
- if (id == -1)
- return 1;
- if (shmctl(id, IPC_RMID, 0) == -1)
- return 1;
-], [ac_cv_sysv_shm="yes"], [ac_cv_sysv_shm="no"])])
-AS_IF([test x"$ac_cv_sysv_shm" = x"yes"], [dnl
- AC_DEFINE(HAVE_SYSV_SHM, 1, [Define if System V shared memory is supported])
-])
AC_ARG_ENABLE(sim-hardware,
[ --enable-sim-hardware=list Specify the hardware to be included in the build.],
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-02 6:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH/submitted 2/5] sim: ppc: merge System V semaphores checks Mike Frysinger
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
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).