| 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 #include "sandbox/linux/bpf_dsl/codegen.h" | 5 #include "sandbox/linux/bpf_dsl/codegen.h" |
| 6 | 6 |
| 7 #include <linux/filter.h> | |
| 8 | |
| 9 #include <limits> | 7 #include <limits> |
| 10 #include <utility> | 8 #include <utility> |
| 11 | 9 |
| 12 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "sandbox/linux/system_headers/linux_filter.h" |
| 13 | 12 |
| 14 // This CodeGen implementation strives for simplicity while still | 13 // This CodeGen implementation strives for simplicity while still |
| 15 // generating acceptable BPF programs under typical usage patterns | 14 // generating acceptable BPF programs under typical usage patterns |
| 16 // (e.g., by PolicyCompiler). | 15 // (e.g., by PolicyCompiler). |
| 17 // | 16 // |
| 18 // The key to its simplicity is that BPF programs only support forward | 17 // The key to its simplicity is that BPF programs only support forward |
| 19 // jumps/branches, which allows constraining the DAG construction API | 18 // jumps/branches, which allows constraining the DAG construction API |
| 20 // to make instruction nodes immutable. Immutable nodes admits a | 19 // to make instruction nodes immutable. Immutable nodes admits a |
| 21 // simple greedy approach of emitting new instructions as needed and | 20 // simple greedy approach of emitting new instructions as needed and |
| 22 // then reusing existing ones that have already been emitted. This | 21 // then reusing existing ones that have already been emitted. This |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 if (get<1>(lhs) != get<1>(rhs)) | 149 if (get<1>(lhs) != get<1>(rhs)) |
| 151 return get<1>(lhs) < get<1>(rhs); | 150 return get<1>(lhs) < get<1>(rhs); |
| 152 if (get<2>(lhs) != get<2>(rhs)) | 151 if (get<2>(lhs) != get<2>(rhs)) |
| 153 return get<2>(lhs) < get<2>(rhs); | 152 return get<2>(lhs) < get<2>(rhs); |
| 154 if (get<3>(lhs) != get<3>(rhs)) | 153 if (get<3>(lhs) != get<3>(rhs)) |
| 155 return get<3>(lhs) < get<3>(rhs); | 154 return get<3>(lhs) < get<3>(rhs); |
| 156 return false; | 155 return false; |
| 157 } | 156 } |
| 158 | 157 |
| 159 } // namespace sandbox | 158 } // namespace sandbox |
| OLD | NEW |