From c7757f181f0bd52206059f2685a5197113aca76f Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 8 Oct 2003 18:15:50 +0000 Subject: Patch from George Thanos adding support for the "e1" architecture. --- libc/sysdeps/linux/e1/longjmp.c | 72 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 libc/sysdeps/linux/e1/longjmp.c (limited to 'libc/sysdeps/linux/e1/longjmp.c') diff --git a/libc/sysdeps/linux/e1/longjmp.c b/libc/sysdeps/linux/e1/longjmp.c new file mode 100644 index 000000000..5770d4997 --- /dev/null +++ b/libc/sysdeps/linux/e1/longjmp.c @@ -0,0 +1,72 @@ +/* This file is lisenced under LGPL + * Copyright (C) 2002-2003, George Thanos + * Yannis Mitsos + */ + +#include +#include +#include +#include + +#define __NR_e1newSP 224 +static inline _syscall1(int, e1newSP, unsigned long, SavedSP ) + +unsigned long jmpbuf_ptr; + +void longjmp(jmp_buf state, int value ) +{ + if(!value) + state->__jmpbuf->ReturnValue = 1; + else + state->__jmpbuf->ReturnValue = value; + + jmpbuf_ptr = (unsigned long)state; + e1newSP(state->__jmpbuf->SavedSP); + +#define _state_ ((struct __jmp_buf_tag*)jmpbuf_ptr) + asm volatile("mov L0, %0\n\t" + "mov L1, %1\n\t" + "mov L2, %2\n\t" + "mov G3, %3\n\t" + "mov G4, %4\n\t" + "ret PC, L1\n\t" + :/*no output*/ + :"l"(_state_->__jmpbuf->ReturnValue), + "l"(_state_->__jmpbuf->SavedPC), + "l"(_state_->__jmpbuf->SavedSR), + "l"(_state_->__jmpbuf->G3), + "l"(_state_->__jmpbuf->G4) + :"%G3", "%G4", "%L0", "%L1" ); +#undef _state_ +} + +void siglongjmp(sigjmp_buf state, int value ) +{ + if( state->__mask_was_saved ) + sigprocmask(SIG_SETMASK, &state->__saved_mask, NULL); + + if(!value) + state->__jmpbuf->ReturnValue = 1; + else + state->__jmpbuf->ReturnValue = value; + + jmpbuf_ptr = (unsigned long)state; + e1newSP(state->__jmpbuf->SavedSP); + + +#define _state_ ((struct __jmp_buf_tag*)jmpbuf_ptr) + asm volatile("mov L0, %0\n\t" + "mov L1, %1\n\t" + "mov L2, %2\n\t" + "mov G3, %3\n\t" + "mov G4, %4\n\t" + "ret PC, L1\n\t" + :/*no output*/ + :"l"(_state_->__jmpbuf->ReturnValue), + "l"(_state_->__jmpbuf->SavedPC), + "l"(_state_->__jmpbuf->SavedSR), + "l"(_state_->__jmpbuf->G3), + "l"(_state_->__jmpbuf->G4) + :"%G3", "%G4", "%L0", "%L1" ); +#undef _state_ +} -- cgit v1.2.3