⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setjmp.h

📁 一个微型操作系统源码
💻 H
字号:
/* * OSV * Copyright (C) 2002 Ciprian DOSOFTEI <rocksoul@mail.com> * All rights reserved. *  * http://backster.free.fr/osv * * This file is part of the OSV project. OSV is free software, also known as * "open source"; you can redistribute it and/or modify it under the terms  * of the GNU General Public License (GPL), version 2, as published by the Free * Software Foundation (FSF). To explore alternate licensing terms, contact  * the author at rocksoul@mail.com or +40740649907. *  * OSV is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE.  See the GPL for more details.  You should have * received a copy of the GPL along with OSV; see the file COPYING.  If * not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA. */typedef struct {    ulong eip;    ulong edi;    ulong esi;    ulong ebp;    ulong esp;    ulong ebx;    ulong edx;    ulong ecx;    ulong eax;} jmp_buf[1];inline static int setjmp(jmp_buf regs) {    register int retcode;        __asm__ __volatile__ (    	"movl $1f,(%%edi)\n\t"	"movl %%esi,8(%%edi)\n\t"	"movl %%esp,%%eax\n\t"	"movl %%ebp,12(%%edi)\n\t"	"subl $4,%%eax\n\t"	"movl %%eax,16(%%edi)\n\t"	"xorl %%eax,%%eax\n\t"	"movl %%ebx,20(%%edi)\n\t"	"movl %%edx,24(%%edi)\n\t"	"movl %%ecx,28(%%edi)\n"	"1:\n\t"	: "=a" (retcode)	: "D" (regs));    return(retcode);}inline static void longjmp(jmp_buf regs, int retval) {    __asm__ __volatile__ (	"movl 16(%%edi),%%esp\n\t"	"movl 12(%%edi),%%ebp\n\t"	"movl 8(%%edi),%%esi\n\t"	"movl (%%edi),%%edx\n\t"	"movl %%edx,(%%esp)\n\t"	"movl 20(%%edi),%%ebx\n\t"	"movl 24(%%edi),%%edx\n\t"	"movl 28(%%edi),%%ecx\n\t"	"ret\n\t"	: /* No output */	: "D" (regs), "a" (retval));}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -