mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 03:16:10 +00:00
e3e070d094
* remove cutter_win32 * build without compile errors * temporary workaround for sdb problems (now compiles again at least) * totally not a hack to get sdb working seriously, don't do this but it works
57 lines
2.0 KiB
C
57 lines
2.0 KiB
C
#ifndef R_ADDR_INTERVAL_H
|
|
#define R_ADDR_INTERVAL_H
|
|
|
|
#pragma message("r_addr_interval_msvc.h(4): warning C1337: hacky implementation of r_addr_interval, be wary!")
|
|
//MSVC (C++) implementation of radare2/include/libr/r_util/r_addr_interval.h
|
|
//DO NOT REMOVE THE WARNING BEFORE R2 IS FIXED!
|
|
|
|
#include <r_types.h>
|
|
|
|
// An interval in 64-bit address space which is aware of address space wraparound
|
|
// Precondition: 0 <= size < 2**64 and addr + size <= 2**64
|
|
typedef struct r_addr_interval_t {
|
|
// public:
|
|
ut64 addr;
|
|
ut64 size;
|
|
} RAddrInterval;
|
|
|
|
static inline ut64 r_itv_begin(RAddrInterval itv) {
|
|
return itv.addr;
|
|
}
|
|
|
|
// Returns the right endpoint address (not included)
|
|
static inline ut64 r_itv_end(RAddrInterval itv) {
|
|
return itv.addr + itv.size;
|
|
}
|
|
|
|
// Returns true if itv contained addr
|
|
static inline bool r_itv_contain(RAddrInterval itv, ut64 addr) {
|
|
ut64 end = itv.addr + itv.size;
|
|
return itv.addr <= addr && (!end || addr < end);
|
|
}
|
|
|
|
// Returns true if x is a subset of itv
|
|
static inline bool r_itv_include(RAddrInterval itv, RAddrInterval x) {
|
|
ut64 end = itv.addr + itv.size;
|
|
return itv.addr <= x.addr && (!end || (x.addr + x.size && x.addr + x.size <= end));
|
|
}
|
|
|
|
// Returns true if itv and x overlap (implying they are non-empty)
|
|
static inline bool r_itv_overlap(RAddrInterval itv, RAddrInterval x) {
|
|
ut64 end = itv.addr + itv.size, end1 = x.addr + x.size;
|
|
return (!end1 || itv.addr < end1) && (!end || x.addr < end);
|
|
}
|
|
|
|
static inline bool r_itv_overlap2(RAddrInterval itv, ut64 addr, ut64 size) {
|
|
return r_itv_overlap (itv, RAddrInterval{addr, size});
|
|
}
|
|
|
|
// Precondition: itv and x overlap
|
|
// Returns the intersection of itv and x
|
|
static inline RAddrInterval r_itv_intersect(RAddrInterval itv, RAddrInterval x) {
|
|
ut64 addr = R_MAX (itv.addr, x.addr),
|
|
end = R_MIN (itv.addr + itv.size - 1, x.addr + x.size - 1) + 1;
|
|
return RAddrInterval{addr, end - addr};
|
|
}
|
|
|
|
#endif // R_ADDR_INTERVAL_H
|