Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: sandbox/linux/seccomp-bpf/kernel_return_value_helpers.cc

Issue 260793003: [MIPS] Add seccomp bpf support (Closed) Base URL: https://git.chromium.org/git/chromium/src.git@master
Patch Set: Update per code review Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sandbox/linux/seccomp-bpf/kernel_return_value_helpers.h"
6 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h"
7
8 namespace sandbox {
9 int ErrnoToKernelRet(int kernel_ret) {
10 #if defined(__mips__)
11 // On MIPS, kernel returns kernel_ret (instead of -kernel_ret)
12 return kernel_ret;
13 #else
14 return -kernel_ret;
15 #endif
16 }
17
18 void PutValueInUcontext(int ret_val, ucontext_t* ctx) {
19 #if defined(__mips__)
20 // Mips ABI states that on error a3 CPU register should be set to one
21 // and if there is no error, it should be zero.
22 if (ret_val < 0) {
23 // On MIPS, kernel returns errno (instead of -errno)
24 ret_val = -ret_val;
25 SECCOMP_PARM4(ctx) = 1;
26 } else
27 SECCOMP_PARM4(ctx) = 0;
28 #endif
29 SECCOMP_RESULT(ctx) = static_cast<greg_t>(ret_val);
30 }
31
32 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698