From f4da14d6e415a271a7f52de0cc37eb35c2050960 Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Sat, 9 Nov 2024 20:02:01 +0300 Subject: [PATCH] Remove where-is-mcontext.c That's pretty old. Using the same code for ppc32/ppc64 appears to work. --- .gitignore | 1 - clean.sh | 1 - make-config.sh | 14 +------- src/runtime/ppc-linux-os.c | 48 +++------------------------ src/runtime/ppc-linux-os.h | 9 +---- tools-for-build/where-is-mcontext.c | 51 ----------------------------- 6 files changed, 7 insertions(+), 117 deletions(-) delete mode 100644 tools-for-build/where-is-mcontext.c diff --git a/.gitignore b/.gitignore index 64eb2641b..42c75d384 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,6 @@ src/runtime/target-arch-os.h src/runtime/target-arch.h src/runtime/target-lispregs.h src/runtime/target-os.h -src/runtime/ppc-linux-mcontext.h tests/test-status.lisp-expr tests/test.log tests/*.so diff --git a/clean.sh b/clean.sh index 6645a2d39..42ef25fee 100755 --- a/clean.sh +++ b/clean.sh @@ -110,7 +110,6 @@ find . \( \ -name 'test.log' -o \ -name 'a.out' -o \ -name 'sbcl' -o \ - -name 'ppc-linux-mcontext.h' -o \ -name 'depend' -o \ -name 'TAGS' -o \ -name 'tags' -o \ diff --git a/make-config.sh b/make-config.sh index c19bda449..dfd2b6125 100755 --- a/make-config.sh +++ b/make-config.sh @@ -724,15 +724,7 @@ case "$sbcl_arch" in esac ;; ppc) - if [ "$sbcl_os" = "linux" ]; then - # Use a C program to detect which kind of glibc we're building on, - # to bandage across the break in source compatibility between - # versions 2.3.1 and 2.3.2 - # - # FIXME: integrate to grovel-features, mayhaps - $GNUMAKE -C tools-for-build where-is-mcontext -I ../src/runtime - tools-for-build/where-is-mcontext > src/runtime/ppc-linux-mcontext.h || (echo "error running where-is-mcontext"; exit 1) - elif [ "$sbcl_os" = "darwin" ]; then + if [ "$sbcl_os" = "darwin" ]; then # We provide a dlopen shim, so a little lie won't hurt printf ' :os-provides-dlopen' >> $ltf # The default stack ulimit under darwin is too small to run PURIFY. @@ -745,10 +737,6 @@ case "$sbcl_arch" in fi ;; ppc64) - # there is no glibc bug that requires the 'where-is-mcontext' hack. - # (Sufficiently new glibc uses the correct definition, which is the same as - # 2.3.1, so define our constant for that) - echo '#define GLIBC231_STYLE_UCONTEXT 1' > src/runtime/ppc-linux-mcontext.h ;; riscv) if [ "$xlen" = "64" ]; then diff --git a/src/runtime/ppc-linux-os.c b/src/runtime/ppc-linux-os.c index 857d299dc..90a4eef59 100644 --- a/src/runtime/ppc-linux-os.c +++ b/src/runtime/ppc-linux-os.c @@ -34,7 +34,6 @@ #include #include "validate.h" -#include "ppc-linux-mcontext.h" int arch_os_thread_init(struct thread *thread) { /* For some reason, PPC Linux appears to default to not generating @@ -62,74 +61,37 @@ int arch_os_thread_cleanup(struct thread *thread) { os_context_register_t * os_context_register_addr(os_context_t *context, int offset) { -#if defined(GLIBC231_STYLE_UCONTEXT) - return &((context->uc_mcontext.regs)->gpr[offset]); -#elif defined(GLIBC232_STYLE_UCONTEXT) - return &((context->uc_mcontext.uc_regs->gregs)[offset]); -#endif + return &context->uc_mcontext.regs->gpr[offset]; } os_context_register_t * os_context_lr_addr(os_context_t *context) { -#if defined(GLIBC231_STYLE_UCONTEXT) - return &((context->uc_mcontext.regs)->link); -#elif defined(GLIBC232_STYLE_UCONTEXT) - return &((context->uc_mcontext.uc_regs->gregs)[PT_LNK]); -#endif + return &context->uc_mcontext.regs->link; } os_context_register_t * os_context_ctr_addr(os_context_t *context) { - /* Like os_context_fp_control() and os_context_lr_addr(), this - * uses an index beyond the declared end of the array in order to - * find the correct register value in the context. */ -#if defined(GLIBC231_STYLE_UCONTEXT) - /* FIXME: This probably should be ->ctr instead of ->gpr[PT_CTR]. */ - return &((context->uc_mcontext.regs)->gpr[PT_CTR]); -#elif defined(GLIBC232_STYLE_UCONTEXT) - return &((context->uc_mcontext.uc_regs)->gregs[PT_CTR]); -#endif + return &context->uc_mcontext.regs->ctr; } os_context_register_t * os_context_cr_addr(os_context_t *context) { - /* Like os_context_fp_control() and os_context_lr_addr(), this - * uses an index beyond the declared end of the array in order to - * find the correct register value in the context. */ -#if defined(GLIBC231_STYLE_UCONTEXT) - /* FIXME: This probably should be ->ccr instead of ->gpr[PT_CCR]. */ - return &((context->uc_mcontext.regs)->gpr[PT_CCR]); -#elif defined(GLIBC232_STYLE_UCONTEXT) - return &((context->uc_mcontext.uc_regs)->gregs[PT_CCR]); -#endif + return &context->uc_mcontext.regs->ccr; } sigset_t * os_context_sigmask_addr(os_context_t *context) { -#if defined(GLIBC231_STYLE_UCONTEXT) return &context->uc_sigmask; -#elif defined(GLIBC232_STYLE_UCONTEXT) - return &context->uc_sigmask; -#endif } unsigned long os_context_fp_control(os_context_t *context) { - /* So this may look like nice, well behaved code. However, closer - inspection reveals that gpr is simply the general purpose - registers, and PT_FPSCR is an offset that is larger than 32 - (the number of ppc registers), but that happens to get the - right answer. -- CSR, 2002-07-11 */ -#if defined(GLIBC231_STYLE_UCONTEXT) - return context->uc_mcontext.regs->gpr[PT_FPSCR]; -#elif defined(GLIBC232_STYLE_UCONTEXT) - return context->uc_mcontext.uc_regs->gregs[PT_FPSCR]; -#endif + return ((unsigned long*)context->uc_mcontext.regs)[PT_FPSCR]; } void diff --git a/src/runtime/ppc-linux-os.h b/src/runtime/ppc-linux-os.h index 691764095..8418a5aa0 100644 --- a/src/runtime/ppc-linux-os.h +++ b/src/runtime/ppc-linux-os.h @@ -8,13 +8,6 @@ unsigned long os_context_fp_control(os_context_t *context); #define RESTORE_FP_CONTROL_FROM_CONTEXT void os_restore_fp_control(os_context_t *context); -#include "ppc-linux-mcontext.h" // Selects one of these two definitions -#ifdef GLIBC231_STYLE_UCONTEXT -# define OS_CONTEXT_PC(context) (context->uc_mcontext.regs)->nip -#elif defined GLIBC232_STYLE_UCONTEXT -# define OS_CONTEXT_PC(context) (context->uc_mcontext.uc_regs->gregs)[PT_NIP] -#else -# error "Need a definition of OS_CONTEXT_PC" -#endif +#define OS_CONTEXT_PC(context) (context->uc_mcontext.regs)->nip #endif /* _PPC_LINUX_OS_H */ diff --git a/tools-for-build/where-is-mcontext.c b/tools-for-build/where-is-mcontext.c deleted file mode 100644 index 6c579b1dc..000000000 --- a/tools-for-build/where-is-mcontext.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Find the offset of uc_mcontext in a ucontext structure, to enable - * building on both (glibc-2.3.1 and earlier) and (glibc-2.3.2 and - * later), after the glibc developers broke source code compatibility. - * (see also Debian bugs #207806 and #209074) - */ - -/* - * This software is part of the SBCL system. See the README file for - * more information. - * - * While most of SBCL is derived from the CMU CL system, many - * utilities for the build process (like this one) were written from - * scratch after the fork from CMU CL. - * - * This software is in the public domain and is provided with - * absolutely no warranty. See the COPYING and CREDITS files for - * more information. - */ - -#include -#include -#include -#include - -int main (int argc, char *argv[]) { - - if(argc != 1) { - fprintf(stderr,"%s: command line arguments provided. Don't do that.\n", argv[0]); - exit(1); - } - - printf("\ -/* This is an automatically-generated file; please do not edit it.\n\ - See the program tools-for-build/where-is-mcontext.c.\n\ - */\n\n"); - - printf("\ -#ifndef PPC_LINUX_MCONTEXT_H\n\ -#define PPC_LINUX_MCONTEXT_H\n\n"); - - if (offsetof(ucontext_t,uc_mcontext) > 40) { - printf("#define GLIBC232_STYLE_UCONTEXT\n\n"); - } else { - printf("#define GLIBC231_STYLE_UCONTEXT\n\n"); - } - printf("\ -#endif /* PPC_LINUX_MCONTEXT_H */\n"); - exit(0); -} -