Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linux/linux_mmap.c
Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | #endif | ||||
/* | /* | ||||
* FreeBSD is free to ignore the address hint if MAP_FIXED wasn't | * FreeBSD is free to ignore the address hint if MAP_FIXED wasn't | ||||
* passed. However, some Linux applications, like the ART runtime, | * passed. However, some Linux applications, like the ART runtime, | ||||
* depend on the hint. If the MAP_FIXED wasn't passed, but the | * depend on the hint. If the MAP_FIXED wasn't passed, but the | ||||
* address is not zero, try with MAP_FIXED and MAP_EXCL first, | * address is not zero, try with MAP_FIXED and MAP_EXCL first, | ||||
* and fall back to the normal behaviour if that fails. | * and fall back to the normal behaviour if that fails. | ||||
*/ | */ | ||||
struct mmap_req mr = { | |||||
brooks: We could alternatively do the declaration above and assign with a compound literal here. Style… | |||||
.mr_hint = addr, | |||||
.mr_len = len, | |||||
.mr_prot = prot, | |||||
.mr_flags = bsd_flags, | |||||
.mr_fd = fd, | |||||
.mr_pos = pos, | |||||
.mr_check_fp_fn = linux_mmap_check_fp | |||||
Done Inline Actionsend line with comma, as we usually do ? kib: end line with comma, as we usually do ? | |||||
}; | |||||
if (addr != 0 && (bsd_flags & MAP_FIXED) == 0 && | if (addr != 0 && (bsd_flags & MAP_FIXED) == 0 && | ||||
(bsd_flags & MAP_EXCL) == 0) { | (bsd_flags & MAP_EXCL) == 0) { | ||||
error = kern_mmap_fpcheck(td, addr, len, prot, | struct mmap_req mr_fixed = mr; | ||||
kibUnsubmitted Done Inline ActionsI do not see why mr_fixed needs to be defined there and not at the start of the function. kib: I do not see why mr_fixed needs to be defined there and not at the start of the function.
If… | |||||
kibUnsubmitted Done Inline ActionsThis comment is still relevant. kib: This comment is still relevant. | |||||
bsd_flags | MAP_FIXED | MAP_EXCL, fd, pos, | mr_fixed.mr_flags |= MAP_FIXED | MAP_EXCL; | ||||
linux_mmap_check_fp); | error = kern_mmap_req(td, &mr_fixed); | ||||
if (error == 0) | if (error == 0) | ||||
goto out; | goto out; | ||||
} | } | ||||
error = kern_mmap_fpcheck(td, addr, len, prot, bsd_flags, fd, pos, | error = kern_mmap_req(td, &mr); | ||||
linux_mmap_check_fp); | |||||
out: | out: | ||||
LINUX_CTR2(mmap2, "return: %d (%p)", error, td->td_retval[0]); | LINUX_CTR2(mmap2, "return: %d (%p)", error, td->td_retval[0]); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
linux_mprotect_common(struct thread *td, uintptr_t addr, size_t len, int prot) | linux_mprotect_common(struct thread *td, uintptr_t addr, size_t len, int prot) | ||||
Show All 27 Lines |
We could alternatively do the declaration above and assign with a compound literal here. Style(9) doesn't really have an opinion.