OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_ITERATOR_H__ | 5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_ITERATOR_H__ |
6 #define SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_ITERATOR_H__ | 6 #define SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_ITERATOR_H__ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 namespace playground2 { | 10 namespace playground2 { |
(...skipping 14 matching lines...) Expand all Loading... |
25 // Example usage: | 25 // Example usage: |
26 // for (SyscallIterator iter(false); !iter.Done(); ) { | 26 // for (SyscallIterator iter(false); !iter.Done(); ) { |
27 // uint32_t sysnum = iter.Next(); | 27 // uint32_t sysnum = iter.Next(); |
28 // // Do something with sysnum. | 28 // // Do something with sysnum. |
29 // } | 29 // } |
30 // | 30 // |
31 // TODO(markus): Make this a classic C++ iterator. | 31 // TODO(markus): Make this a classic C++ iterator. |
32 class SyscallIterator { | 32 class SyscallIterator { |
33 public: | 33 public: |
34 explicit SyscallIterator(bool invalid_only) | 34 explicit SyscallIterator(bool invalid_only) |
35 : invalid_only_(invalid_only), | 35 : invalid_only_(invalid_only), done_(false), num_(0) {} |
36 done_(false), | |
37 num_(0) {} | |
38 | 36 |
39 bool Done() const { return done_; } | 37 bool Done() const { return done_; } |
40 uint32_t Next(); | 38 uint32_t Next(); |
41 static bool IsValid(uint32_t num); | 39 static bool IsValid(uint32_t num); |
42 | 40 |
43 private: | 41 private: |
44 static bool IsArmPrivate(uint32_t num); | 42 static bool IsArmPrivate(uint32_t num); |
45 | 43 |
46 bool invalid_only_; | 44 bool invalid_only_; |
47 bool done_; | 45 bool done_; |
48 uint32_t num_; | 46 uint32_t num_; |
49 | 47 |
50 DISALLOW_IMPLICIT_CONSTRUCTORS(SyscallIterator); | 48 DISALLOW_IMPLICIT_CONSTRUCTORS(SyscallIterator); |
51 }; | 49 }; |
52 | 50 |
53 } // namespace playground2 | 51 } // namespace playground2 |
54 | 52 |
55 #endif // SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_ITERATOR_H__ | 53 #endif // SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_ITERATOR_H__ |
56 | |
OLD | NEW |