Back to index

plt-scheme  4.2.1
mzsj86.c
Go to the documentation of this file.
00001 /*
00002   MzScheme
00003   Copyright (c) 2004-2009 PLT Scheme Inc.
00004   Copyright (c) 1995 Matthew Flatt
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public
00017     License along with this library; if not, write to the Free
00018     Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301 USA.
00020 */
00021 
00022 /* Re-implementation of i386 setjmp to avoid Windows-specific work,
00023    which messes up MzScheme's (MrEd's, really) threads. */
00024 
00025 #include "schpriv.h"
00026 
00027 int __declspec(naked) scheme_mz_setjmp(mz_jmp_buf b)
00028 {
00029   __asm {
00030     mov ECX, [ESP]
00031        mov EAX, [ESP+4]
00032        mov [EAX], EBP
00033        mov [EAX+4], EBX
00034        mov [EAX+8], EDI
00035        mov [EAX+12], ESI
00036        mov [EAX+16], ESP
00037        mov [EAX+20], ECX
00038        mov EAX, 0
00039        ret
00040   }
00041 }
00042 
00043 void __declspec(naked) scheme_mz_longjmp(mz_jmp_buf b, int v)
00044 {
00045   __asm {
00046     mov EAX, [ESP+8]
00047        mov ECX, [ESP+4]
00048        mov ESP, [ECX+16]
00049        mov EBP, [ECX]
00050        mov EBX, [ECX+4]
00051        mov EDI, [ECX+8]
00052        mov ESI, [ECX+12]
00053        mov ECX, [ECX+20]
00054        mov [ESP], ECX
00055        ret
00056   }
00057 }