Remove where-is-mcontext.c

That's pretty old. Using the same code for ppc32/ppc64 appears to
work.
This commit is contained in:
Stas Boukarev 2024-11-09 20:02:01 +03:00
parent 8f5bf0919a
commit f4da14d6e4
6 changed files with 7 additions and 117 deletions

1
.gitignore vendored
View file

@ -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

View file

@ -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 \

View file

@ -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

View file

@ -34,7 +34,6 @@
#include <sys/prctl.h>
#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

View file

@ -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 */

View file

@ -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 <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <sys/ucontext.h>
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);
}