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

Unified Diff: sandbox/linux/seccomp-bpf/syscall_iterator.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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/linux/seccomp-bpf/syscall.cc ('k') | sandbox/linux/seccomp-bpf/syscall_iterator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/seccomp-bpf/syscall_iterator.cc
diff --git a/sandbox/linux/seccomp-bpf/syscall_iterator.cc b/sandbox/linux/seccomp-bpf/syscall_iterator.cc
index 89cc1cb473cc911cd0c1254129624f13d422174c..d1c383b470f48b7fa35431c0dbf7fb219a353bd2 100644
--- a/sandbox/linux/seccomp-bpf/syscall_iterator.cc
+++ b/sandbox/linux/seccomp-bpf/syscall_iterator.cc
@@ -16,14 +16,25 @@ uint32_t SyscallIterator::Next() {
uint32_t val;
do {
+#if defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_ABI32)
+ // |num_| has been initialized to 4000, which we assume is also MIN_SYSCALL.
+ // This is true for Mips O32 ABI.
+ COMPILE_ASSERT(MIN_SYSCALL == __NR_Linux, min_syscall_should_be_4000);
+#else
// |num_| has been initialized to 0, which we assume is also MIN_SYSCALL.
// This true for supported architectures (Intel and ARM EABI).
COMPILE_ASSERT(MIN_SYSCALL == 0u, min_syscall_should_always_be_zero);
+#endif
val = num_;
+ // The syscall iterator always starts at zero.
+ // If zero is not a valid system call, iterator first returns MIN_SYSCALL -1
+ // before continuing to iterate.
+ if (num_ == 0 && MIN_SYSCALL != num_) {
+ num_ = MIN_SYSCALL - 1;
// First we iterate up to MAX_PUBLIC_SYSCALL, which is equal to MAX_SYSCALL
// on Intel architectures, but leaves room for private syscalls on ARM.
- if (num_ <= MAX_PUBLIC_SYSCALL) {
+ } else if (num_ <= MAX_PUBLIC_SYSCALL) {
if (invalid_only_ && num_ < MAX_PUBLIC_SYSCALL) {
num_ = MAX_PUBLIC_SYSCALL;
} else {
« no previous file with comments | « sandbox/linux/seccomp-bpf/syscall.cc ('k') | sandbox/linux/seccomp-bpf/syscall_iterator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698