1 //===-- sanitizer_range.h ---------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Contais Range and related utilities.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef SANITIZER_RANGE_H
14 #define SANITIZER_RANGE_H
15 
16 #include "sanitizer_common.h"
17 #include "sanitizer_common/sanitizer_array_ref.h"
18 
19 namespace __sanitizer {
20 
21 struct Range {
22   uptr begin;
23   uptr end;
24 };
25 
26 inline bool operator==(const Range &lhs, const Range &rhs) {
27   return lhs.begin == rhs.begin && lhs.end == rhs.end;
28 }
29 
30 inline bool operator!=(const Range &lhs, const Range &rhs) {
31   return !(lhs == rhs);
32 }
33 
34 // Calculates intersection of two sets of regions in O(N log N) time.
35 void Intersect(ArrayRef<Range> a, ArrayRef<Range> b,
36                InternalMmapVectorNoCtor<Range> &output);
37 
38 }  // namespace __sanitizer
39 
40 #endif  // SANITIZER_RANGE_H
41