Commit | Line | Data |
---|---|---|
bb578426 GS |
1 | /* |
2 | * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk) | |
5134d8fe | 3 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
bb578426 GS |
4 | * Licensed under the GPL |
5 | */ | |
6 | ||
13c06be3 | 7 | #include <stddef.h> |
1d7173ba | 8 | #include "longjmp.h" |
bb578426 GS |
9 | |
10 | unsigned long __do_user_copy(void *to, const void *from, int n, | |
fab95c55 | 11 | void **fault_addr, jmp_buf **fault_catcher, |
bb578426 GS |
12 | void (*op)(void *to, const void *from, |
13 | int n), int *faulted_out) | |
14 | { | |
15 | unsigned long *faddrp = (unsigned long *) fault_addr, ret; | |
16 | ||
ad28e029 | 17 | jmp_buf jbuf; |
bb578426 | 18 | *fault_catcher = &jbuf; |
5134d8fe | 19 | if (UML_SETJMP(&jbuf) == 0) { |
bb578426 GS |
20 | (*op)(to, from, n); |
21 | ret = 0; | |
22 | *faulted_out = 0; | |
23 | } | |
24 | else { | |
25 | ret = *faddrp; | |
26 | *faulted_out = 1; | |
27 | } | |
28 | *fault_addr = NULL; | |
29 | *fault_catcher = NULL; | |
30 | return ret; | |
31 | } | |
32 |