1 : // Copyright 2015 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : #ifndef SYZYGY_REFINERY_CORE_ADDRESS_H_
16 : #define SYZYGY_REFINERY_CORE_ADDRESS_H_
17 :
18 : #include <stdint.h>
19 :
20 : #include "syzygy/core/address_range.h"
21 :
22 : namespace refinery {
23 :
24 : // TODO(manzagop): consider making Address a class for stricter control on
25 : // conversions. In particular, we've hit an issue where an int* being
26 : // reinterpret_cast'ed to an Address triggered sign extension in the pointer.
27 : typedef uint64_t Address;
28 : typedef uint32_t Size;
29 :
30 : // AddressRange represents a range of memory with an address and a size.
31 : // TODO(manzagop): incorporate a notion of validity wrt the process (eg 32 vs
32 : // 64 bits).
33 : class AddressRange : public core::AddressRange<Address, Size> {
34 : public:
35 : using Super = core::AddressRange<Address, Size>;
36 :
37 E : AddressRange(Address addr, Size size) : Super(addr, size) {}
38 E : AddressRange() {}
39 :
40 : // Determines the validity of the address range. All users of |AddressRange|
41 : // expect a valid range.
42 : // @returns true if the range is valid, false otherwise (empty range or
43 : // overflow).
44 : bool IsValid() const;
45 : };
46 :
47 : } // namespace refinery
48 :
49 : #endif // SYZYGY_REFINERY_CORE_ADDRESS_H_
|