mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-02 19:22:47 +00:00
rtld_malloc.c: cleanup morepages().
Use roundup2() and rounddown2() instead of inlining them. Get rid of the fd local variable, use literal -1 for the mmap argument. Use MAP_FAILED as mmap(2) failure indicator. After that, apply some style. Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
37f0b7f1d7
commit
3cac4083ef
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=347693
@ -345,12 +345,11 @@ findbucket(union overhead *freep, int srchlen)
|
||||
static int
|
||||
morepages(int n)
|
||||
{
|
||||
int fd = -1;
|
||||
int offset;
|
||||
caddr_t addr;
|
||||
int offset;
|
||||
|
||||
if (pagepool_end - pagepool_start > pagesz) {
|
||||
caddr_t addr = (caddr_t)
|
||||
(((long)pagepool_start + pagesz - 1) & ~(pagesz - 1));
|
||||
addr = (caddr_t)roundup2((long)pagepool_start, pagesz);
|
||||
if (munmap(addr, pagepool_end - addr) != 0) {
|
||||
#ifdef IN_RTLD
|
||||
rtld_fdprintf(STDERR_FILENO, _BASENAME_RTLD ": "
|
||||
@ -360,20 +359,21 @@ morepages(int n)
|
||||
}
|
||||
}
|
||||
|
||||
offset = (long)pagepool_start - ((long)pagepool_start & ~(pagesz - 1));
|
||||
offset = (long)pagepool_start - rounddown2((long)pagepool_start,
|
||||
pagesz);
|
||||
|
||||
if ((pagepool_start = mmap(0, n * pagesz,
|
||||
PROT_READ|PROT_WRITE,
|
||||
MAP_ANON|MAP_PRIVATE, fd, 0)) == (caddr_t)-1) {
|
||||
pagepool_start = mmap(0, n * pagesz, PROT_READ | PROT_WRITE,
|
||||
MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
if (pagepool_start == MAP_FAILED) {
|
||||
#ifdef IN_RTLD
|
||||
rtld_fdprintf(STDERR_FILENO, _BASENAME_RTLD ": morepages: "
|
||||
"cannot mmap anonymous memory: %s\n",
|
||||
rtld_strerror(errno));
|
||||
#endif
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
pagepool_end = pagepool_start + n * pagesz;
|
||||
pagepool_start += offset;
|
||||
|
||||
return n;
|
||||
return (n);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user