From 26ee263b6f8b5a1a52e09c2f2a223bac191f7cc9 Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Thu, 23 Jun 2005 16:23:31 +0000 Subject: [PATCH] Don't fake the TVECT value on non-BeOS native systems. This is important for systems that use a global r2 as the TLS register, e.g. Linux/ppc with newer glibc. Also remove the syscall junk which were simply workarounds for this bug. Remove a duplicate r2 restoration in EmulOp. BTW, it's possible to get SheepShaver running on Linux/ppc systems with NPTL rather than SheepThreads. --- SheepShaver/src/Unix/main_unix.cpp | 4 +-- SheepShaver/src/Unix/ppc_asm.S | 55 ------------------------------ SheepShaver/src/thunks.cpp | 2 +- 3 files changed, 3 insertions(+), 58 deletions(-) diff --git a/SheepShaver/src/Unix/main_unix.cpp b/SheepShaver/src/Unix/main_unix.cpp index f6d6d605..5074096a 100644 --- a/SheepShaver/src/Unix/main_unix.cpp +++ b/SheepShaver/src/Unix/main_unix.cpp @@ -286,8 +286,8 @@ static inline int sig_stack_release(void) // Global variables (exported) #if !EMULATED_PPC -void *TOC; // Pointer to Thread Local Storage (r2) -void *R13; // Pointer to .sdata section (r13 under Linux) +void *TOC = NULL; // Pointer to Thread Local Storage (r2) +void *R13 = NULL; // Pointer to .sdata section (r13 under Linux) #endif uint32 RAMBase; // Base address of Mac RAM uint32 RAMSize; // Size of Mac RAM diff --git a/SheepShaver/src/Unix/ppc_asm.S b/SheepShaver/src/Unix/ppc_asm.S index 16829a02..b6847c71 100644 --- a/SheepShaver/src/Unix/ppc_asm.S +++ b/SheepShaver/src/Unix/ppc_asm.S @@ -381,7 +381,6 @@ C_SYMBOL_NAME(jump_to_rom): stw r0,16(r1) stw r2,12(r1) stwu r1,-(24+16*4+15*8)(r1) - RESTORE_SYSTEM_R2 // Save 68k registers (M68kRegisters) stw r8,24+0*4(r1) // d[0]..d[7] @@ -916,57 +915,3 @@ C_SYMBOL_NAME(ppc_interrupt): // Enter nanokernel mtlr r3 blr - - -/* - * Glue for glibc with TLS support which clobbers r2 - * - * The following is derived from dietlibc and only provides - * pass-through to kernel syscalls. You also lose asynchronous - * cancellation support. - */ - -#if defined(__linux__) -#define __NR_getpid 20 -#define __NR__newselect 142 - -#define syscall_weak(name,wsym,sym) \ -.text; \ -.type wsym,@function; \ -.weak wsym; \ -wsym: ; \ -.type sym,@function; \ -.global sym; \ -sym: \ - li 0,__NR_##name; \ - b __unified_syscall - -#define syscall(name,sym) \ -.text; \ -.type sym,@function; \ -.global sym; \ -sym: \ - li 0,__NR_##name; \ - b __unified_syscall - - - .type __unified_syscall,@function -__unified_syscall: - sc - bnslr+ - stwu 1,-16(1) - mflr 0 - stw 0,20(1) - stw 3,12(1) - bl __errno_location - lwz 0,12(1) - stw 0,0(3) - lwz 0,20(1) - mtlr 0 - addi 1,1,16 - blr - -/* name weak symbol symbol */ -syscall( getpid, getpid) -syscall_weak( _newselect, select, __select) -#endif diff --git a/SheepShaver/src/thunks.cpp b/SheepShaver/src/thunks.cpp index 83b7e17a..9dbb2ca7 100644 --- a/SheepShaver/src/thunks.cpp +++ b/SheepShaver/src/thunks.cpp @@ -219,7 +219,7 @@ bool ThunksInit(void) #define DEFINE_NATIVE_OP(ID, FUNC) do { \ uintptr base = SheepMem::Reserve(8); \ WriteMacInt32(base + 0, (uint32)FUNC); \ - WriteMacInt32(base + 4, 0); /*Fake TVECT*/ \ + WriteMacInt32(base + 4, (uint32)TOC); \ native_op[ID].tvect = base; \ native_op[ID].func = (uint32)FUNC; \ } while (0)