Cygwin: make check_invalid_virtual_addr a static inline function

move it to mm/mmap.cc which uses it exclusively.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2022-08-10 18:03:05 +02:00
parent 9fbfccff71
commit 56b7fd620f
3 changed files with 13 additions and 16 deletions

View File

@ -101,9 +101,6 @@ PWCHAR transform_chars_af_unix (PWCHAR, const char *, __socklen_t);
/* Get handle count of an object. */
ULONG get_obj_handle_count (HANDLE h);
/* Memory checking */
int check_invalid_virtual_addr (const void *s, unsigned sz);
ssize_t check_iovec (const struct iovec *, int, bool);
#define check_iovec_for_read(a, b) check_iovec ((a), (b), false)
#define check_iovec_for_write(a, b) check_iovec ((a), (b), true)

View File

@ -37,19 +37,6 @@ get_obj_handle_count (HANDLE h)
return hdl_cnt;
}
int
check_invalid_virtual_addr (const void *s, unsigned sz)
{
MEMORY_BASIC_INFORMATION mbuf;
const void *end;
for (end = (char *) s + sz; s < end;
s = (char *) mbuf.BaseAddress + mbuf.RegionSize)
if (!VirtualQuery (s, &mbuf, sizeof mbuf))
return EINVAL;
return 0;
}
static char __attribute__ ((noinline))
dummytest (volatile char *p)
{

View File

@ -1112,6 +1112,19 @@ out:
/* munmap () removes all mmapped pages between addr and addr+len. */
static inline int
check_invalid_virtual_addr (const void *s, unsigned sz)
{
MEMORY_BASIC_INFORMATION mbuf;
const void *end;
for (end = (char *) s + sz; s < end;
s = (char *) mbuf.BaseAddress + mbuf.RegionSize)
if (!VirtualQuery (s, &mbuf, sizeof mbuf))
return EINVAL;
return 0;
}
extern "C" int
munmap (void *addr, size_t len)
{