OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
jln (very slow on Chromium)
2014/05/16 19:30:17
- Please, add a _unittest.cc file for this with a
nedeljko
2014/05/19 17:37:23
These are pretty basic functions.
Since functions
jln (very slow on Chromium)
2014/05/20 01:57:47
What should be tested is what these function do.
nedeljko
2014/05/20 14:36:41
I was thinking to move this (implementation of fun
nedeljko
2014/05/22 17:38:55
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SANDBOX_LINUX_SERVICES_KERNEL_TO_ERRNO_H | |
6 #define SANDBOX_LINUX_SERVICES_KERNEL_TO_ERRNO_H | |
7 | |
8 namespace { | |
jln (very slow on Chromium)
2014/05/16 19:30:17
This should be "namespace sandbox".
nedeljko
2014/05/22 17:38:55
Done.
| |
9 | |
10 inline int KernelRetToErrno(int kernel_ret) { | |
jln (very slow on Chromium)
2014/05/16 19:30:17
In practice I've only seen this used taking an err
nedeljko
2014/05/22 17:38:55
Done.
| |
11 #if defined(__mips__) | |
12 // On MIPS, kernel returns kernel_ret (instead of -kernel_ret) | |
13 return kernel_ret; | |
14 #else | |
15 return -kernel_ret; | |
16 #endif | |
17 } | |
18 | |
19 inline int RetValToKernelRet(int ret_val, ucontext_t* ctx) { | |
jln (very slow on Chromium)
2014/05/16 19:30:17
Please add valid #include for ucontext_t.
jln (very slow on Chromium)
2014/05/16 19:30:17
Let's make this a function that returns void inste
jln (very slow on Chromium)
2014/05/16 21:27:10
Let's have the implementation hidden in a .cc file
nedeljko
2014/05/22 17:38:55
Done.
nedeljko
2014/05/22 17:38:55
Done.
nedeljko
2014/05/22 17:38:55
Done.
| |
20 #if defined(__mips__) | |
21 // Mips ABI states that on error a3 CPU register should be set to one | |
22 // and if there is no error, it should be zero. | |
23 if (ret_val < 0) { | |
24 // On MIPS, kernel returns errno (instead of -errno) | |
25 ret_val = -ret_val; | |
26 (ctx)->uc_mcontext.gregs[7] = 1; | |
27 } else | |
28 (ctx)->uc_mcontext.gregs[7] = 0; | |
29 return ret_val; | |
30 #else | |
31 return ret_val; | |
32 #endif | |
33 } | |
34 | |
35 } // namespace | |
36 | |
37 #endif // SANDBOX_LINUX_SERVICES_KERNEL_TO_ERRNO_H | |
OLD | NEW |