bus-message: add macro for calculation of offset from the page

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2020-06-22 17:18:35 +02:00
parent b17af3e503
commit b98f393d88
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -13,6 +13,7 @@
size_t page_size(void) _pure_;
#define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
#define PAGE_ALIGN_DOWN(l) ((l) & ~(page_size() - 1))
#define PAGE_OFFSET(l) ((l) & (page_size() - 1))
/* Normal memcpy requires src to be nonnull. We do nothing if n is 0. */
static inline void memcpy_safe(void *dst, const void *src, size_t n) {
+1 -1
View File
@@ -3022,7 +3022,7 @@ int bus_body_part_map(struct bus_body_part *part) {
return 0;
}
shift = part->memfd_offset - ((part->memfd_offset / page_size()) * page_size());
shift = PAGE_OFFSET(part->memfd_offset);
psz = PAGE_ALIGN(part->size + shift);
if (part->memfd >= 0)