mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
Added _setjmp3() and __p__iob()
svn path=/trunk/; revision=4508
This commit is contained in:
parent
e6af1b07da
commit
3fe2b722fd
7 changed files with 123 additions and 152 deletions
|
@ -1,4 +1,4 @@
|
||||||
# $Id: Makefile,v 1.31 2002/12/10 19:09:26 hbirr Exp $
|
# $Id: Makefile,v 1.32 2003/04/06 12:40:55 gvg Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../..
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ TARGET_CLEAN = \
|
||||||
process/*.o \
|
process/*.o \
|
||||||
search/*.o \
|
search/*.o \
|
||||||
setjmp/*.o \
|
setjmp/*.o \
|
||||||
|
setjmp/i386/*.o \
|
||||||
signal/*.o \
|
signal/*.o \
|
||||||
stdio/*.o \
|
stdio/*.o \
|
||||||
stdlib/*.o \
|
stdlib/*.o \
|
||||||
|
@ -273,7 +274,7 @@ SEARCH_OBJECTS = \
|
||||||
search/lsearch.o
|
search/lsearch.o
|
||||||
|
|
||||||
SETJMP_OBJECTS = \
|
SETJMP_OBJECTS = \
|
||||||
setjmp/setjmp.o
|
setjmp/i386/setjmp.o
|
||||||
|
|
||||||
SIGNAL_OBJECTS = \
|
SIGNAL_OBJECTS = \
|
||||||
signal/signal.o
|
signal/signal.o
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: msvcrt.def,v 1.18 2003/02/21 21:50:04 jfilby Exp $
|
; $Id: msvcrt.def,v 1.19 2003/04/06 12:40:55 gvg Exp $
|
||||||
;
|
;
|
||||||
; ReactOS MSVCRT Compatibility Library
|
; ReactOS MSVCRT Compatibility Library
|
||||||
;
|
;
|
||||||
|
@ -124,7 +124,7 @@ __p__commode
|
||||||
__p__environ
|
__p__environ
|
||||||
; __p__fileinfo
|
; __p__fileinfo
|
||||||
__p__fmode
|
__p__fmode
|
||||||
; __p__iob
|
__p__iob
|
||||||
; __p__mbcasemap
|
; __p__mbcasemap
|
||||||
; __p__mbctype
|
; __p__mbctype
|
||||||
__p__osver
|
__p__osver
|
||||||
|
@ -436,7 +436,7 @@ _searchenv
|
||||||
; _set_sbh_threshold
|
; _set_sbh_threshold
|
||||||
_seterrormode
|
_seterrormode
|
||||||
_setjmp
|
_setjmp
|
||||||
; _setjmp3
|
_setjmp3
|
||||||
; _setmaxstdio
|
; _setmaxstdio
|
||||||
; _setmbcp
|
; _setmbcp
|
||||||
_setmode
|
_setmode
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
*.d
|
|
||||||
*.o
|
|
||||||
*.sym
|
|
2
reactos/lib/msvcrt/setjmp/i386/.cvsignore
Normal file
2
reactos/lib/msvcrt/setjmp/i386/.cvsignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
.*.d
|
||||||
|
*.o
|
111
reactos/lib/msvcrt/setjmp/i386/setjmp.s
Normal file
111
reactos/lib/msvcrt/setjmp/i386/setjmp.s
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
/* $Id: setjmp.s,v 1.1 2003/04/06 12:40:55 gvg Exp $
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* PURPOSE: Implementation of _setjmp/longjmp
|
||||||
|
* FILE: lib/msvcrt/i386/setjmp.s
|
||||||
|
* PROGRAMMER: Ge van Geldorp (ge@gse.nl)
|
||||||
|
* NOTES: Implementation is not complete, see Wine source for a more
|
||||||
|
* complete implementation
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define JB_BP 0
|
||||||
|
#define JB_BX 1
|
||||||
|
#define JB_DI 2
|
||||||
|
#define JB_SI 3
|
||||||
|
#define JB_SP 4
|
||||||
|
#define JB_IP 5
|
||||||
|
|
||||||
|
#define PCOFF 0
|
||||||
|
|
||||||
|
#define JMPBUF 4
|
||||||
|
|
||||||
|
/*
|
||||||
|
* int
|
||||||
|
* _setjmp(jmp_buf env);
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* [ESP+04h] - jmp_buf env
|
||||||
|
* Registers:
|
||||||
|
* None
|
||||||
|
* Returns:
|
||||||
|
* 0
|
||||||
|
* Notes:
|
||||||
|
* Sets up the jmp_buf
|
||||||
|
*/
|
||||||
|
.globl __setjmp
|
||||||
|
__setjmp:
|
||||||
|
xorl %eax, %eax
|
||||||
|
movl JMPBUF(%esp), %edx
|
||||||
|
|
||||||
|
/* Save registers. */
|
||||||
|
movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */
|
||||||
|
movl %ebx, (JB_BX*4)(%edx)
|
||||||
|
movl %edi, (JB_DI*4)(%edx)
|
||||||
|
movl %esi, (JB_SI*4)(%edx)
|
||||||
|
leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */
|
||||||
|
movl %ecx, (JB_SP*4)(%edx)
|
||||||
|
movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
|
||||||
|
movl %ecx, (JB_IP*4)(%edx)
|
||||||
|
ret
|
||||||
|
|
||||||
|
/*
|
||||||
|
* int
|
||||||
|
* _setjmp3(jmp_buf env, int nb_args, ...);
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* [ESP+04h] - jmp_buf env
|
||||||
|
* Registers:
|
||||||
|
* None
|
||||||
|
* Returns:
|
||||||
|
* 0
|
||||||
|
* Notes:
|
||||||
|
* Sets up the jmp_buf
|
||||||
|
*/
|
||||||
|
.globl __setjmp3
|
||||||
|
__setjmp3:
|
||||||
|
xorl %eax, %eax
|
||||||
|
movl JMPBUF(%esp), %edx
|
||||||
|
|
||||||
|
/* Save registers. */
|
||||||
|
movl %ebp, (JB_BP*4)(%edx) /* Save caller's frame pointer. */
|
||||||
|
movl %ebx, (JB_BX*4)(%edx)
|
||||||
|
movl %edi, (JB_DI*4)(%edx)
|
||||||
|
movl %esi, (JB_SI*4)(%edx)
|
||||||
|
leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */
|
||||||
|
movl %ecx, (JB_SP*4)(%edx)
|
||||||
|
movl PCOFF(%esp), %ecx /* Save PC we are returning to now. */
|
||||||
|
movl %ecx, (JB_IP*4)(%edx)
|
||||||
|
ret
|
||||||
|
|
||||||
|
#define VAL 8
|
||||||
|
|
||||||
|
/*
|
||||||
|
* void
|
||||||
|
* longjmp(jmp_buf env, int value);
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* [ESP+04h] - jmp_buf setup by _setjmp
|
||||||
|
* [ESP+08h] - int value to return
|
||||||
|
* Registers:
|
||||||
|
* None
|
||||||
|
* Returns:
|
||||||
|
* Doesn't return
|
||||||
|
* Notes:
|
||||||
|
* Non-local goto
|
||||||
|
*/
|
||||||
|
.globl _longjmp
|
||||||
|
_longjmp:
|
||||||
|
movl JMPBUF(%esp), %ecx /* User's jmp_buf in %ecx. */
|
||||||
|
|
||||||
|
movl VAL(%esp), %eax /* Second argument is return value. */
|
||||||
|
/* Save the return address now. */
|
||||||
|
movl (JB_IP*4)(%ecx), %edx
|
||||||
|
/* Restore registers. */
|
||||||
|
movl (JB_BP*4)(%ecx), %ebp
|
||||||
|
movl (JB_BX*4)(%ecx), %ebx
|
||||||
|
movl (JB_DI*4)(%ecx), %edi
|
||||||
|
movl (JB_SI*4)(%ecx), %esi
|
||||||
|
movl (JB_SP*4)(%ecx), %esp
|
||||||
|
/* Jump to saved PC. */
|
||||||
|
jmp *%edx
|
|
@ -1,142 +0,0 @@
|
||||||
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
|
||||||
/* modified by Boudewijn Dekker */
|
|
||||||
/* ms uses a smaller jmp_buf structure */
|
|
||||||
/* might do a realloc in setjmp */
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned int __eax, __ebx, __ecx, __edx, __esi;
|
|
||||||
unsigned int __edi, __ebp, __esp, __eip, __eflags;
|
|
||||||
unsigned short __cs, __ds, __es, __fs, __gs, __ss;
|
|
||||||
unsigned long __sigmask; /* for POSIX signals only */
|
|
||||||
unsigned long __signum; /* for expansion */
|
|
||||||
unsigned long __exception_ptr; /* pointer to previous exception */
|
|
||||||
unsigned char __fpu_state[108]; /* for future use */
|
|
||||||
} jmp_buf[1];
|
|
||||||
|
|
||||||
|
|
||||||
/* jumps back to position specified in jmp_buf */
|
|
||||||
|
|
||||||
int longjmp( jmp_buf env, int value )
|
|
||||||
{
|
|
||||||
//push ebp generated by the compiler
|
|
||||||
//mov ebp, esp
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
"movl 8(%ebp),%edi\n\t" /* get jmp_buf */
|
|
||||||
"movl 12(%ebp),%eax\n\t" /* store retval in j->eax */
|
|
||||||
"movl %eax,0(%edi)\n\t"
|
|
||||||
|
|
||||||
"movw 46(%edi),%fs\n\t"
|
|
||||||
"movw 48(%edi),%gs\n\t"
|
|
||||||
"movl 4(%edi),%ebx\n\t"
|
|
||||||
"movl 8(%edi),%ecx\n\t"
|
|
||||||
"movl 12(%edi),%edx\n\t"
|
|
||||||
"movl 24(%edi),%ebp\n\t"
|
|
||||||
|
|
||||||
/* Now for some uglyness. The jmp_buf structure may be ABOVE the
|
|
||||||
point on the new SS:ESP we are moving to. We don't allow overlap,
|
|
||||||
but do force that it always be valid. We will use ES:ESI for
|
|
||||||
our new stack before swapping to it. */
|
|
||||||
|
|
||||||
"movw 50(%edi),%es\n\t"
|
|
||||||
"movl 28(%edi),%esi\n\t"
|
|
||||||
"subl $28,%esi\n\t" /* We need 7 working longwords on stack */
|
|
||||||
|
|
||||||
"movl 60(%edi),%eax\n\t"
|
|
||||||
"es\n\t"
|
|
||||||
"movl %eax,(%esi)\n\t" /* Exception pointer */
|
|
||||||
|
|
||||||
"movzwl 42(%edi),%eax\n\t"
|
|
||||||
"es\n\t"
|
|
||||||
"movl %eax,4(%esi)\n\t" /* DS */
|
|
||||||
|
|
||||||
"movl 20(%edi),%eax\n\t"
|
|
||||||
"es\n\t"
|
|
||||||
"movl %eax,8(%esi)\n\t" /* EDI */
|
|
||||||
|
|
||||||
"movl 16(%edi),%eax\n\t"
|
|
||||||
"es\n\t"
|
|
||||||
"movl %eax,12(%esi)\n\t" /* ESI */
|
|
||||||
|
|
||||||
"movl 32(%edi),%eax\n\t"
|
|
||||||
"es\n\t"
|
|
||||||
"movl %eax,16(%esi)\n\t" /* EIP - start of IRET frame */
|
|
||||||
|
|
||||||
"movl 40(%edi),%eax\n\t"
|
|
||||||
"es\n\t"
|
|
||||||
"movl %eax,20(%esi)\n\t" /* CS */
|
|
||||||
|
|
||||||
"movl 36(%edi),%eax\n\t"
|
|
||||||
"es\n\t"
|
|
||||||
"movl %eax,24(%esi)\n\t" /* EFLAGS */
|
|
||||||
|
|
||||||
"movl 0(%edi),%eax\n\t"
|
|
||||||
"movw 44(%edi),%es\n\t"
|
|
||||||
|
|
||||||
"movw 50(%edi),%ss\n\t"
|
|
||||||
"movl %esi,%esp\n\t"
|
|
||||||
|
|
||||||
//"popl ___djgpp_exception_state_ptr\n\t"
|
|
||||||
"popl %edi\n\t" // dummy popl instead of djgpp_exception_state_ptr
|
|
||||||
"popl %ds\n\t"
|
|
||||||
"popl %edi\n\t"
|
|
||||||
"popl %esi\n\t"
|
|
||||||
|
|
||||||
"iret\n\t" /* actually jump to new cs:eip loading flags */
|
|
||||||
);
|
|
||||||
|
|
||||||
#else
|
|
||||||
#endif /*__GNUC__*/
|
|
||||||
return value; // dummy return never reached
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
|
|
||||||
int _setjmp( jmp_buf env )
|
|
||||||
{
|
|
||||||
//push ebp generated by the compiler
|
|
||||||
//mov ebp, esp
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
"pushl %edi\n\t"
|
|
||||||
"movl 8(%ebp),%edi\n\t"
|
|
||||||
|
|
||||||
"movl %eax, (%edi)\n\t"
|
|
||||||
"movl %ebx,4(%edi)\n\t"
|
|
||||||
"movl %ecx,8(%edi)\n\t"
|
|
||||||
"movl %edx,12(%edi)\n\t"
|
|
||||||
"movl %esi,16(%edi)\n\t"
|
|
||||||
|
|
||||||
"movl -4(%ebp),%eax\n\t"
|
|
||||||
"movl %eax,20(%edi)\n\t"
|
|
||||||
|
|
||||||
"movl (%ebp),%eax\n\t"
|
|
||||||
"movl %eax,24(%edi)\n\t"
|
|
||||||
|
|
||||||
"movl %esp,%eax\n\t"
|
|
||||||
"addl $12,%eax\n\t"
|
|
||||||
"movl %eax,28(%edi)\n\t"
|
|
||||||
|
|
||||||
"movl 4(%ebp),%eax\n\t"
|
|
||||||
"movl %eax,32(%edi)\n\t"
|
|
||||||
|
|
||||||
"pushfl\n\t"
|
|
||||||
"popl 36(%edi)\n\t"
|
|
||||||
|
|
||||||
"movw %cs, 40(%edi)\n\t"
|
|
||||||
"movw %ds, 42(%edi)\n\t"
|
|
||||||
"movw %es, 44(%edi)\n\t"
|
|
||||||
"movw %fs, 46(%edi)\n\t"
|
|
||||||
"movw %gs, 48(%edi)\n\t"
|
|
||||||
"movw %ss, 50(%edi)\n\t"
|
|
||||||
|
|
||||||
//movl ___djgpp_exception_state_ptr, %eax
|
|
||||||
//movl %eax, 60(%edi)
|
|
||||||
|
|
||||||
"popl %edi\n\t"
|
|
||||||
);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#endif /*__GNUC__*/
|
|
|
@ -36,5 +36,7 @@ FILE _iob[5] =
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FILE *__p__iob(void)
|
||||||
|
{
|
||||||
|
return &_iob[0];
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue