diff options
author | Mike Frysinger <vapier@gentoo.org> | 2024-01-01 20:11:52 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2024-01-02 00:29:28 -0500 |
commit | d961049a26b7e19da19198e3908b6823d4c462d7 (patch) | |
tree | a3edac107912ed6e24658af328b06e9febe731a7 /sim | |
parent | d237a93af39a489c86ec0142fa05b2af17505d13 (diff) | |
download | gdb-d961049a26b7e19da19198e3908b6823d4c462d7.zip gdb-d961049a26b7e19da19198e3908b6823d4c462d7.tar.gz gdb-d961049a26b7e19da19198e3908b6823d4c462d7.tar.bz2 |
sim: ppc: change SysV sem & shm tests to compile-time
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.
Diffstat (limited to 'sim')
-rwxr-xr-x | sim/ppc/configure | 149 | ||||
-rw-r--r-- | sim/ppc/configure.ac | 48 |
2 files changed, 87 insertions, 110 deletions
diff --git a/sim/ppc/configure b/sim/ppc/configure index 3288650..7104a99 100755 --- a/sim/ppc/configure +++ b/sim/ppc/configure @@ -1495,48 +1495,6 @@ fi } # ac_fn_c_try_compile -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache @@ -1628,6 +1586,48 @@ fi } # ac_fn_c_try_cpp +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in @@ -3182,10 +3182,6 @@ $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. */ @@ -3199,29 +3195,28 @@ else 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); - } +int +main () +{ + + 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; + ; + return 0; +} _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_c_try_compile "$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 - - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sysv_sem" >&5 $as_echo "$ac_cv_sysv_sem" >&6; } @@ -3231,36 +3226,32 @@ $as_echo_n "checking whether System V shared memory is supported... " >&6; } if ${ac_cv_sysv_shm+:} 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/shm.h> -int main () { - int id=shmget(IPC_PRIVATE,1,IPC_CREAT|0400); +int +main () +{ + + 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); -} + return 1; + ; + return 0; +} _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sysv_shm="yes" else ac_cv_sysv_shm="no" fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sysv_shm" >&5 $as_echo "$ac_cv_sysv_shm" >&6; } diff --git a/sim/ppc/configure.ac b/sim/ppc/configure.ac index 50afce7..b78a09d 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"; |