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

Side by Side Diff: sandbox/linux/seccomp-bpf/syscall_iterator.h

Issue 11096012: Add a platform-specific syscall number iterator. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Assume MIN_SYSCALL == 0, remove X32 support, address comments. Created 8 years, 2 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 (c) 2012 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 #ifndef SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_ITERATOR_H__
6 #define SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_ITERATOR_H__
7
8 #include <stdint.h>
9
10 #include <base/logging.h>
11
12 namespace playground2 {
13
14 // Iterates over the entire system call range from 0..0xFFFFFFFFu. This
15 // iterator is aware of how system calls look like and will skip quickly
16 // over ranges that can't contain system calls. It iterates more slowly
17 // whenever it reaches a range that is potentially problematic. And it
18 // iterates over individual values whenever it is in the normal range for
19 // system calls (typically MIN_SYSCALL..MAX_SYSCALL).
20 // If |invalid_only| is true, the iterator will only return invalid
21 // syscall numbers, but will still skip quickly over invalid ranges.
22 //
23 // Example usage:
24 // for (SyscallIterator iter(false); !iter.Done(); ) {
25 // uint32_t sysnum = iter.Next();
26 // // Do something with sysnum.
27 // }
28 //
29 // TODO(markus): Make this a classic C++ iterator.
30 class SyscallIterator {
31 public:
32 explicit SyscallIterator(bool invalid_only)
33 : invalid_only_(invalid_only),
jln (very slow on Chromium) 2012/10/13 02:44:22 Style: You misread my previous comment. Colon shou
Jorge Lucangeli Obes 2012/10/13 04:45:42 I'm not sure what's wrong in this case. The colon
34 done_(false),
35 num_(MIN_SYSCALL) {
36 CHECK_EQ(MIN_SYSCALL, 0u);
jln (very slow on Chromium) 2012/10/13 02:44:22 This needs to be localized where you are actually
Jorge Lucangeli Obes 2012/10/13 04:45:42 Done.
37 }
38
39 bool Done() const { return done_; }
40 uint32_t Next();
41 static bool IsValid(uint32_t num);
42
43 private:
44 static bool IsArmPrivate(uint32_t num);
45
46 bool invalid_only_;
47 bool done_;
48 uint32_t num_;
49
50 DISALLOW_COPY_AND_ASSIGN(SyscallIterator);
51 };
52
53 } // namespace
jln (very slow on Chromium) 2012/10/13 02:44:22 Style: namespace playground2
Jorge Lucangeli Obes 2012/10/13 04:45:42 Done.
54
55 #endif // SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_ITERATOR_H__
56
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698