Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 13c06be3 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds
Browse files

[PATCH] uml: Use klibc setjmp/longjmp



This patch adds an implementation of setjmp and longjmp to UML, allowing
access to the inside of a jmpbuf without needing the access macros formerly
provided by libc.

The implementation is stolen from klibc.  I copy the relevant files into
arch/um.  I have another patch which avoids the copying, but requires klibc be
in the tree.

setjmp and longjmp users required some tweaking.  Includes of <setjmp.h> were
removed and includes of the UML longjmp.h were added where necessary.  There
are also replacements of siglongjmp with UML_LONGJMP which I somehow missed
earlier.

Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c5c6ba4e
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
#ifndef __UML_LONGJMP_H
#define __UML_LONGJMP_H

#include <setjmp.h>
#include "sysdep/archsetjmp.h"
#include "os.h"

extern int setjmp(jmp_buf);
extern void longjmp(jmp_buf, int);

#define UML_LONGJMP(buf, val) do { \
	longjmp(*buf, val);	\
} while(0)
+19 −0
Original line number Diff line number Diff line
/*
 * arch/i386/include/klibc/archsetjmp.h
 */

#ifndef _KLIBC_ARCHSETJMP_H
#define _KLIBC_ARCHSETJMP_H

struct __jmp_buf {
	unsigned int __ebx;
	unsigned int __esp;
	unsigned int __ebp;
	unsigned int __esi;
	unsigned int __edi;
	unsigned int __eip;
};

typedef struct __jmp_buf jmp_buf[1];

#endif				/* _SETJMP_H */
+21 −0
Original line number Diff line number Diff line
/*
 * arch/x86_64/include/klibc/archsetjmp.h
 */

#ifndef _KLIBC_ARCHSETJMP_H
#define _KLIBC_ARCHSETJMP_H

struct __jmp_buf {
	unsigned long __rbx;
	unsigned long __rsp;
	unsigned long __rbp;
	unsigned long __r12;
	unsigned long __r13;
	unsigned long __r14;
	unsigned long __r15;
	unsigned long __rip;
};

typedef struct __jmp_buf jmp_buf[1];

#endif				/* _SETJMP_H */
+0 −1
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include <setjmp.h>
#include <linux/unistd.h>
#include <sys/mman.h>
#include <sys/wait.h>
+1 −2
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <setjmp.h>
#include <sched.h>
#include "ptrace_user.h"
#include <sys/wait.h>
@@ -470,7 +469,7 @@ void thread_wait(void *sw, void *fb)
	*switch_buf = &buf;
	fork_buf = fb;
	if(UML_SETJMP(&buf) == 0)
		siglongjmp(*fork_buf, INIT_JMP_REMOVE_SIGSTACK);
		UML_LONGJMP(fork_buf, INIT_JMP_REMOVE_SIGSTACK);
}

void switch_threads(void *me, void *next)
Loading