Throughout use wincap.allocation_granularity instead of getpagesize.

Throughout use wincap.page_size instead of getsystempagesize.
	Throughout use "status" as variable name to hold NTSTATUS values.
	* fhandler_mem.cc: Check for NT_SUCCESS rather than for STATUS_SUCCESS.
	Fix debug_printf output.  Rectify long statements.  Fix comment
	formatting.
	* fhandler_proc.cc: Ditto.
	(format_proc_swaps): Drop useless test for ERROR_PROC_NOT_FOUND.
	* fhandler_process.cc: Ditto as in fhandler_mem.cc.
	(get_process_state): Rearrange allocation loop.  Use malloc/realloc.
	(get_mem_values): Fix potential NULL pointer usage.  Drop unused
	variable.
	* pinfo.cc (winpids::enum_processes): Handle low memory gracefully.
	* sec_auth.cc (get_priv_list): Drop local variable ret.
	* shared.cc (memory_init): Drop outdated call to getpagesize.
	* syscalls.cc (getsystempagesize): Remove.
	* sysconf.cc: Check for NT_SUCCESS rather than for STATUS_SUCCESS.
	(sysinfo): Constify sizeof_stodi.  Drop useless test for
	ERROR_PROC_NOT_FOUND.
	* thread.cc (pthread_getattr_np): Cast pointers to uintptr_t rather
	than to int for pointer arithmetic.
	* winsup.h (getsystempagesize): Drop declaration.
This commit is contained in:
Corinna Vinschen 2011-12-22 11:02:36 +00:00
parent 8176232ddc
commit 177dc6c7f6
14 changed files with 337 additions and 314 deletions

View File

@ -1,9 +1,34 @@
2011-12-22 Corinna Vinschen <vinschen@redhat.com>
Throughout use wincap.allocation_granularity instead of getpagesize.
Throughout use wincap.page_size instead of getsystempagesize.
Throughout use "status" as variable name to hold NTSTATUS values.
* fhandler_mem.cc: Check for NT_SUCCESS rather than for STATUS_SUCCESS.
Fix debug_printf output. Rectify long statements. Fix comment
formatting.
* fhandler_proc.cc: Ditto.
(format_proc_swaps): Drop useless test for ERROR_PROC_NOT_FOUND.
* fhandler_process.cc: Ditto as in fhandler_mem.cc.
(get_process_state): Rearrange allocation loop. Use malloc/realloc.
(get_mem_values): Fix potential NULL pointer usage. Drop unused
variable.
* pinfo.cc (winpids::enum_processes): Handle low memory gracefully.
* sec_auth.cc (get_priv_list): Drop local variable ret.
* shared.cc (memory_init): Drop outdated call to getpagesize.
* syscalls.cc (getsystempagesize): Remove.
* sysconf.cc: Check for NT_SUCCESS rather than for STATUS_SUCCESS.
(sysinfo): Constify sizeof_stodi. Drop useless test for
ERROR_PROC_NOT_FOUND.
* thread.cc (pthread_getattr_np): Cast pointers to uintptr_t rather
than to int for pointer arithmetic.
* winsup.h (getsystempagesize): Drop declaration.
2011-12-21 Christopher Faylor <me.cygwin2011@cgf.cx> 2011-12-21 Christopher Faylor <me.cygwin2011@cgf.cx>
* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use correct * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use correct
value in switch statement. value in switch statement.
2011-12-11 Corinna Vinschen <vinschen@redhat.com> 2011-12-21 Corinna Vinschen <vinschen@redhat.com>
* dcrt0.cc (_dll_crt0): Rephrase comments. Set $ebp to NULL, as in * dcrt0.cc (_dll_crt0): Rephrase comments. Set $ebp to NULL, as in
the pthread stack setup. the pthread stack setup.

View File

@ -126,7 +126,7 @@ static void *__stdcall
_csbrk (int sbs) _csbrk (int sbs)
{ {
void *prebrk = cygheap_max; void *prebrk = cygheap_max;
size_t granmask = getpagesize () - 1; size_t granmask = wincap.allocation_granularity () - 1;
char *newbase = nextpage (prebrk); char *newbase = nextpage (prebrk);
cygheap_max = (char *) cygheap_max + sbs; cygheap_max = (char *) cygheap_max + sbs;
if (!sbs || (newbase >= cygheap_max) || (cygheap_max <= _cygheap_end)) if (!sbs || (newbase >= cygheap_max) || (cygheap_max <= _cygheap_end))

View File

@ -371,7 +371,7 @@ cygwin_internal (cygwin_getinfo_types t, ...)
break; break;
case CW_GET_SHMLBA: case CW_GET_SHMLBA:
{ {
res = getpagesize (); res = wincap.allocation_granularity ();
} }
break; break;
case CW_GET_UID_FROM_SID: case CW_GET_UID_FROM_SID:

View File

@ -32,6 +32,8 @@ fhandler_dev_mem::~fhandler_dev_mem ()
int int
fhandler_dev_mem::open (int flags, mode_t) fhandler_dev_mem::open (int flags, mode_t)
{ {
NTSTATUS status;
if (!wincap.has_physical_mem_access ()) if (!wincap.has_physical_mem_access ())
{ {
set_errno (ENOENT); set_errno (ENOENT);
@ -41,13 +43,13 @@ fhandler_dev_mem::open (int flags, mode_t)
if (dev () == FH_MEM) /* /dev/mem */ if (dev () == FH_MEM) /* /dev/mem */
{ {
NTSTATUS ret;
SYSTEM_BASIC_INFORMATION sbi; SYSTEM_BASIC_INFORMATION sbi;
if ((ret = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi, status = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi,
sizeof sbi, NULL)) != STATUS_SUCCESS) sizeof sbi, NULL);
if (NT_SUCCESS (status))
{ {
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
debug_printf("NtQuerySystemInformation: ret %d, Dos(ret) %E", ret); debug_printf("NtQuerySystemInformation: status %p, %E", status);
mem_size = 0; mem_size = 0;
} }
else else
@ -67,7 +69,7 @@ fhandler_dev_mem::open (int flags, mode_t)
else else
{ {
mem_size = 0; mem_size = 0;
debug_printf ("Illegal minor number!!!"); debug_printf ("Illegal minor number");
} }
/* Check for illegal flags. */ /* Check for illegal flags. */
@ -101,10 +103,10 @@ fhandler_dev_mem::open (int flags, mode_t)
} }
HANDLE mem; HANDLE mem;
NTSTATUS ret = NtOpenSection (&mem, section_access, &attr); status = NtOpenSection (&mem, section_access, &attr);
if (!NT_SUCCESS (ret)) if (!NT_SUCCESS (status))
{ {
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
set_io_handle (NULL); set_io_handle (NULL);
return 0; return 0;
} }
@ -130,31 +132,26 @@ fhandler_dev_mem::write (const void *ptr, size_t ulen)
ulen = mem_size - pos; ulen = mem_size - pos;
PHYSICAL_ADDRESS phys; PHYSICAL_ADDRESS phys;
NTSTATUS ret; NTSTATUS status;
void *viewmem = NULL; void *viewmem = NULL;
DWORD len = ulen + getsystempagesize () - 1; DWORD len = ulen + wincap.page_size () - 1;
phys.QuadPart = (ULONGLONG) pos; phys.QuadPart = (ULONGLONG) pos;
if ((ret = NtMapViewOfSection (get_handle (), status = NtMapViewOfSection (get_handle (), INVALID_HANDLE_VALUE, &viewmem,
INVALID_HANDLE_VALUE, 0L, len, &phys, &len, ViewShare, 0,
&viewmem, PAGE_READONLY);
0L, if (!NT_SUCCESS (status))
len,
&phys,
&len,
ViewShare,
0,
PAGE_READONLY)) != STATUS_SUCCESS)
{ {
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
return -1; return -1;
} }
memcpy ((char *) viewmem + (pos - phys.QuadPart), ptr, ulen); memcpy ((char *) viewmem + (pos - phys.QuadPart), ptr, ulen);
if (!NT_SUCCESS (ret = NtUnmapViewOfSection (INVALID_HANDLE_VALUE, viewmem))) status = NtUnmapViewOfSection (INVALID_HANDLE_VALUE, viewmem);
if (!NT_SUCCESS (status))
{ {
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
return -1; return -1;
} }
@ -182,32 +179,27 @@ fhandler_dev_mem::read (void *ptr, size_t& ulen)
ulen = mem_size - pos; ulen = mem_size - pos;
PHYSICAL_ADDRESS phys; PHYSICAL_ADDRESS phys;
NTSTATUS ret; NTSTATUS status;
void *viewmem = NULL; void *viewmem = NULL;
DWORD len = ulen + getsystempagesize () - 1; DWORD len = ulen + wincap.page_size () - 1;
phys.QuadPart = (ULONGLONG) pos; phys.QuadPart = (ULONGLONG) pos;
if ((ret = NtMapViewOfSection (get_handle (), status = NtMapViewOfSection (get_handle (), INVALID_HANDLE_VALUE, &viewmem,
INVALID_HANDLE_VALUE, 0L, len, &phys, &len, ViewShare, 0,
&viewmem, PAGE_READONLY);
0L, if (!NT_SUCCESS (status))
len,
&phys,
&len,
ViewShare,
0,
PAGE_READONLY)) != STATUS_SUCCESS)
{ {
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
ulen = (size_t) -1; ulen = (size_t) -1;
return; return;
} }
memcpy (ptr, (char *) viewmem + (pos - phys.QuadPart), ulen); memcpy (ptr, (char *) viewmem + (pos - phys.QuadPart), ulen);
if (!NT_SUCCESS (ret = NtUnmapViewOfSection (INVALID_HANDLE_VALUE, viewmem))) status = NtUnmapViewOfSection (INVALID_HANDLE_VALUE, viewmem);
if (!NT_SUCCESS (status))
{ {
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
ulen = (size_t) -1; ulen = (size_t) -1;
return; return;
} }
@ -251,7 +243,7 @@ int
fhandler_dev_mem::fstat (struct __stat64 *buf) fhandler_dev_mem::fstat (struct __stat64 *buf)
{ {
fhandler_base::fstat (buf); fhandler_base::fstat (buf);
buf->st_blksize = getsystempagesize (); buf->st_blksize = wincap.page_size ();
if (is_auto_device ()) if (is_auto_device ())
{ {
buf->st_mode = S_IFCHR; buf->st_mode = S_IFCHR;

View File

@ -460,7 +460,7 @@ static _off64_t
format_proc_uptime (void *, char *&destbuf) format_proc_uptime (void *, char *&destbuf)
{ {
unsigned long long uptime = 0ULL, idle_time = 0ULL; unsigned long long uptime = 0ULL, idle_time = 0ULL;
NTSTATUS ret; NTSTATUS status;
SYSTEM_TIME_OF_DAY_INFORMATION stodi; SYSTEM_TIME_OF_DAY_INFORMATION stodi;
/* Sizeof SYSTEM_PERFORMANCE_INFORMATION on 64 bit systems. It /* Sizeof SYSTEM_PERFORMANCE_INFORMATION on 64 bit systems. It
appears to contain some trailing additional information from appears to contain some trailing additional information from
@ -470,13 +470,13 @@ format_proc_uptime (void *, char *&destbuf)
PSYSTEM_PERFORMANCE_INFORMATION spi = (PSYSTEM_PERFORMANCE_INFORMATION) PSYSTEM_PERFORMANCE_INFORMATION spi = (PSYSTEM_PERFORMANCE_INFORMATION)
alloca (sizeof_spi); alloca (sizeof_spi);
ret = NtQuerySystemInformation (SystemTimeOfDayInformation, &stodi, status = NtQuerySystemInformation (SystemTimeOfDayInformation, &stodi,
sizeof stodi, NULL); sizeof stodi, NULL);
if (NT_SUCCESS (ret)) if (NT_SUCCESS (status))
uptime = (stodi.CurrentTime.QuadPart - stodi.BootTime.QuadPart) / 100000ULL; uptime = (stodi.CurrentTime.QuadPart - stodi.BootTime.QuadPart) / 100000ULL;
else else
debug_printf ("NtQuerySystemInformation(SystemTimeOfDayInformation), " debug_printf ("NtQuerySystemInformation(SystemTimeOfDayInformation), "
"status %p", ret); "status %p", status);
if (NT_SUCCESS (NtQuerySystemInformation (SystemPerformanceInformation, if (NT_SUCCESS (NtQuerySystemInformation (SystemPerformanceInformation,
spi, sizeof_spi, NULL))) spi, sizeof_spi, NULL)))
@ -495,7 +495,7 @@ format_proc_stat (void *, char *&destbuf)
unsigned long pages_in = 0UL, pages_out = 0UL, interrupt_count = 0UL, unsigned long pages_in = 0UL, pages_out = 0UL, interrupt_count = 0UL,
context_switches = 0UL, swap_in = 0UL, swap_out = 0UL; context_switches = 0UL, swap_in = 0UL, swap_out = 0UL;
time_t boot_time = 0; time_t boot_time = 0;
NTSTATUS ret; NTSTATUS status;
/* Sizeof SYSTEM_PERFORMANCE_INFORMATION on 64 bit systems. It /* Sizeof SYSTEM_PERFORMANCE_INFORMATION on 64 bit systems. It
appears to contain some trailing additional information from appears to contain some trailing additional information from
what I can tell after examining the content. what I can tell after examining the content.
@ -510,11 +510,11 @@ format_proc_stat (void *, char *&destbuf)
char *eobuf = buf; char *eobuf = buf;
SYSTEM_PROCESSOR_TIMES spt[wincap.cpu_count ()]; SYSTEM_PROCESSOR_TIMES spt[wincap.cpu_count ()];
ret = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) spt, status = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) spt,
sizeof spt[0] * wincap.cpu_count (), NULL); sizeof spt[0] * wincap.cpu_count (), NULL);
if (!NT_SUCCESS (ret)) if (!NT_SUCCESS (status))
debug_printf ("NtQuerySystemInformation(SystemProcessorTimes), " debug_printf ("NtQuerySystemInformation(SystemProcessorTimes), "
"status %p", ret); "status %p", status);
else else
{ {
unsigned long long user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL; unsigned long long user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL;
@ -539,36 +539,32 @@ format_proc_stat (void *, char *&destbuf)
user_time, 0ULL, kernel_time, idle_time); user_time, 0ULL, kernel_time, idle_time);
} }
ret = NtQuerySystemInformation (SystemPerformanceInformation, status = NtQuerySystemInformation (SystemPerformanceInformation,
(PVOID) spi, sizeof_spi, NULL); (PVOID) spi, sizeof_spi, NULL);
if (!NT_SUCCESS (ret)) if (!NT_SUCCESS (status))
{ {
debug_printf ("NtQuerySystemInformation(SystemPerformanceInformation)" debug_printf ("NtQuerySystemInformation(SystemPerformanceInformation)"
", status %p", ret); ", status %p", status);
memset (spi, 0, sizeof_spi); memset (spi, 0, sizeof_spi);
} }
ret = NtQuerySystemInformation (SystemTimeOfDayInformation, status = NtQuerySystemInformation (SystemTimeOfDayInformation,
(PVOID) &stodi, (PVOID) &stodi, sizeof stodi, NULL);
sizeof stodi, NULL); if (!NT_SUCCESS (status))
if (!NT_SUCCESS (ret))
debug_printf ("NtQuerySystemInformation(SystemTimeOfDayInformation), " debug_printf ("NtQuerySystemInformation(SystemTimeOfDayInformation), "
"status %p", ret); "status %p", status);
} }
if (!NT_SUCCESS (ret)) if (!NT_SUCCESS (status))
{ {
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
return 0; return 0;
} }
pages_in = spi->PagesRead; pages_in = spi->PagesRead;
pages_out = spi->PagefilePagesWritten + spi->MappedFilePagesWritten; pages_out = spi->PagefilePagesWritten + spi->MappedFilePagesWritten;
/* /* Note: there is no distinction made in this structure between pages read
* Note: there is no distinction made in this structure between pages from the page file and pages read from mapped files, but there is such
* read from the page file and pages read from mapped files, but there a distinction made when it comes to writing. Goodness knows why. The
* is such a distinction made when it comes to writing. Goodness knows value of swap_in, then, will obviously be wrong but its our best guess. */
* why. The value of swap_in, then, will obviously be wrong but its our
* best guess.
*/
swap_in = spi->PagesRead; swap_in = spi->PagesRead;
swap_out = spi->PagefilePagesWritten; swap_out = spi->PagefilePagesWritten;
context_switches = spi->ContextSwitches; context_switches = spi->ContextSwitches;
@ -705,7 +701,7 @@ format_proc_cpuinfo (void *, char *&destbuf)
maxf &= 0xffff; maxf &= 0xffff;
vendor_id[3] = 0; vendor_id[3] = 0;
// vendor identification /* Vendor identification. */
bool is_amd = false, is_intel = false; bool is_amd = false, is_intel = false;
if (!strcmp ((char*)vendor_id, "AuthenticAMD")) if (!strcmp ((char*)vendor_id, "AuthenticAMD"))
is_amd = true; is_amd = true;
@ -746,18 +742,18 @@ format_proc_cpuinfo (void *, char *&destbuf)
} }
else else
{ {
// could implement a lookup table here if someone needs it /* Could implement a lookup table here if someone needs it. */
strcpy (in_buf.s, "unknown"); strcpy (in_buf.s, "unknown");
} }
int cache_size = -1, int cache_size = -1,
tlb_size = -1, tlb_size = -1,
clflush = 64, clflush = 64,
cache_alignment = 64; cache_alignment = 64;
if (features1 & (1 << 19)) // CLFSH if (features1 & (1 << 19)) /* CLFSH */
clflush = ((extra_info >> 8) & 0xff) << 3; clflush = ((extra_info >> 8) & 0xff) << 3;
if (is_intel && family == 15) if (is_intel && family == 15)
cache_alignment = clflush * 2; cache_alignment = clflush * 2;
if (maxe >= 0x80000005) // L1 Cache and TLB Identifiers if (maxe >= 0x80000005) /* L1 Cache and TLB Identifiers. */
{ {
unsigned data_cache, inst_cache; unsigned data_cache, inst_cache;
cpuid (&unused, &unused, &data_cache, &inst_cache, cpuid (&unused, &unused, &data_cache, &inst_cache,
@ -766,7 +762,7 @@ format_proc_cpuinfo (void *, char *&destbuf)
cache_size = (inst_cache >> 24) + (data_cache >> 24); cache_size = (inst_cache >> 24) + (data_cache >> 24);
tlb_size = 0; tlb_size = 0;
} }
if (maxe >= 0x80000006) // L2 Cache and L2 TLB Identifiers if (maxe >= 0x80000006) /* L2 Cache and L2 TLB Identifiers. */
{ {
unsigned tlb, l2; unsigned tlb, l2;
cpuid (&unused, &tlb, &l2, &unused, 0x80000006); cpuid (&unused, &tlb, &l2, &unused, 0x80000006);
@ -788,7 +784,7 @@ format_proc_cpuinfo (void *, char *&destbuf)
bufptr += __small_sprintf (bufptr, "cache size\t: %d KB\n", bufptr += __small_sprintf (bufptr, "cache size\t: %d KB\n",
cache_size); cache_size);
// Recognize multi-core CPUs /* Recognize multi-core CPUs. */
if (is_amd && maxe >= 0x80000008) if (is_amd && maxe >= 0x80000008)
{ {
unsigned core_info; unsigned core_info;
@ -810,7 +806,7 @@ format_proc_cpuinfo (void *, char *&destbuf)
apic_id, core_id, max_cores); apic_id, core_id, max_cores);
} }
} }
// Recognize Intel Hyper-Transport CPUs /* Recognize Intel Hyper-Transport CPUs. */
else if (is_intel && (features1 & (1 << 28)) && maxf >= 4) else if (is_intel && (features1 & (1 << 28)) && maxf >= 4)
{ {
/* TODO */ /* TODO */
@ -895,7 +891,7 @@ format_proc_cpuinfo (void *, char *&destbuf)
if (features & (1 << 11)) if (features & (1 << 11))
print (" syscall"); print (" syscall");
if (features & (1 << 19)) // Huh? Not in AMD64 specs. if (features & (1 << 19)) /* Huh? Not in AMD64 specs. */
print (" mp"); print (" mp");
if (features & (1 << 20)) if (features & (1 << 20))
print (" nx"); print (" nx");
@ -909,9 +905,9 @@ format_proc_cpuinfo (void *, char *&destbuf)
print (" rdtscp"); print (" rdtscp");
if (features & (1 << 29)) if (features & (1 << 29))
print (" lm"); print (" lm");
if (features & (1 << 30)) // 31th bit is on if (features & (1 << 30)) /* 31th bit is on. */
print (" 3dnowext"); print (" 3dnowext");
if (features & (1 << 31)) // 32th bit (highest) is on if (features & (1 << 31)) /* 32th bit (highest) is on. */
print (" 3dnow"); print (" 3dnow");
} }
@ -1024,7 +1020,7 @@ format_proc_cpuinfo (void *, char *&destbuf)
clflush, clflush,
cache_alignment); cache_alignment);
if (maxe >= 0x80000008) // Address size if (maxe >= 0x80000008) /* Address size. */
{ {
unsigned addr_size, phys, virt; unsigned addr_size, phys, virt;
cpuid (&addr_size, &unused, &unused, &unused, 0x80000008); cpuid (&addr_size, &unused, &unused, &unused, 0x80000008);
@ -1040,7 +1036,7 @@ format_proc_cpuinfo (void *, char *&destbuf)
phys, virt); phys, virt);
} }
if (maxe >= 0x80000007) // advanced power management if (maxe >= 0x80000007) /* Advanced power management. */
{ {
cpuid (&unused, &unused, &unused, &features2, 0x80000007); cpuid (&unused, &unused, &unused, &features2, 0x80000007);
@ -1287,7 +1283,7 @@ format_proc_swaps (void *, char *&destbuf)
ssize_t filename_len; ssize_t filename_len;
PSYSTEM_PAGEFILE_INFORMATION spi = NULL; PSYSTEM_PAGEFILE_INFORMATION spi = NULL;
ULONG size = 512; ULONG size = 512;
NTSTATUS ret = STATUS_SUCCESS; NTSTATUS status = STATUS_SUCCESS;
tmp_pathbuf tp; tmp_pathbuf tp;
char *buf = tp.c_get (); char *buf = tp.c_get ();
@ -1296,39 +1292,41 @@ format_proc_swaps (void *, char *&destbuf)
spi = (PSYSTEM_PAGEFILE_INFORMATION) malloc (size); spi = (PSYSTEM_PAGEFILE_INFORMATION) malloc (size);
if (spi) if (spi)
{ {
ret = NtQuerySystemInformation (SystemPagefileInformation, (PVOID) spi, status = NtQuerySystemInformation (SystemPagefileInformation, (PVOID) spi,
size, &size); size, &size);
if (ret == STATUS_INFO_LENGTH_MISMATCH) if (status == STATUS_INFO_LENGTH_MISMATCH)
{ {
free (spi); free (spi);
spi = (PSYSTEM_PAGEFILE_INFORMATION) malloc (size); spi = (PSYSTEM_PAGEFILE_INFORMATION) malloc (size);
if (spi) if (spi)
ret = NtQuerySystemInformation (SystemPagefileInformation, status = NtQuerySystemInformation (SystemPagefileInformation,
(PVOID) spi, size, &size); (PVOID) spi, size, &size);
} }
} }
bufptr += __small_sprintf (bufptr, bufptr += __small_sprintf (bufptr,
"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n"); "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
if (spi && !ret && GetLastError () != ERROR_PROC_NOT_FOUND) if (spi && NT_SUCCESS (status))
{ {
PSYSTEM_PAGEFILE_INFORMATION spp = spi; PSYSTEM_PAGEFILE_INFORMATION spp = spi;
do do
{ {
total = (unsigned long long) spp->CurrentSize * getsystempagesize (); total = (unsigned long long) spp->CurrentSize * wincap.page_size ();
used = (unsigned long long) spp->TotalUsed * getsystempagesize (); used = (unsigned long long) spp->TotalUsed * wincap.page_size ();
filename_len = cygwin_conv_path (CCP_WIN_W_TO_POSIX, spp->FileName.Buffer, filename, 0); filename_len = cygwin_conv_path (CCP_WIN_W_TO_POSIX,
spp->FileName.Buffer, filename, 0);
filename = (char *) malloc (filename_len); filename = (char *) malloc (filename_len);
cygwin_conv_path (CCP_WIN_W_TO_POSIX, spp->FileName.Buffer, filename, filename_len); cygwin_conv_path (CCP_WIN_W_TO_POSIX, spp->FileName.Buffer,
filename, filename_len);
bufptr += sprintf (bufptr, "%-40s%-16s%-8llu%-8llu%-8d\n", bufptr += sprintf (bufptr, "%-40s%-16s%-8llu%-8llu%-8d\n",
filename, "file", total >> 10, used >> 10, 0); filename, "file", total >> 10, used >> 10, 0);
} }
while (spp->NextEntryOffset while (spp->NextEntryOffset
&& (spp = (PSYSTEM_PAGEFILE_INFORMATION) && (spp = (PSYSTEM_PAGEFILE_INFORMATION)
((char *) spp + spp->NextEntryOffset))); ((char *) spp + spp->NextEntryOffset)));
} }
if (spi) if (spi)

View File

@ -88,9 +88,8 @@ static bool get_mem_values (DWORD dwProcessId, unsigned long *vmsize,
unsigned long *vmshare); unsigned long *vmshare);
/* Returns 0 if path doesn't exist, >0 if path is a directory, /* Returns 0 if path doesn't exist, >0 if path is a directory,
* -1 if path is a file, -2 if path is a symlink, -3 if path is a pipe, -1 if path is a file, -2 if path is a symlink, -3 if path is a pipe,
* -4 if path is a socket. -4 if path is a socket. */
*/
virtual_ftype_t virtual_ftype_t
fhandler_process::exists () fhandler_process::exists ()
{ {
@ -1021,10 +1020,10 @@ format_process_maps (void *data, char *&destbuf)
the same allocation base and effective permissions. */ the same allocation base and effective permissions. */
bool newbase = (next.abase != cur.abase); bool newbase = (next.abase != cur.abase);
if (!last_pass && !newbase && next.a.word == cur.a.word) if (!last_pass && !newbase && next.a.word == cur.a.word)
cur.rend = next.rend; // merge with previous cur.rend = next.rend; /* merge with previous */
else else
{ {
// output the current region if it's "interesting" /* output the current region if it's "interesting". */
if (cur.a.word) if (cur.a.word)
{ {
size_t newlen = strlen (posix_modname) + 62; size_t newlen = strlen (posix_modname) + 62;
@ -1044,9 +1043,9 @@ format_process_maps (void *data, char *&destbuf)
len += written; len += written;
len += __small_sprintf (destbuf + len, "%s\n", posix_modname); len += __small_sprintf (destbuf + len, "%s\n", posix_modname);
} }
// start of a new region (but possibly still the same allocation) /* start of a new region (but possibly still the same allocation). */
cur = next; cur = next;
// if a new allocation, figure out what kind it is /* if a new allocation, figure out what kind it is. */
if (newbase && !last_pass && mb.State != MEM_FREE) if (newbase && !last_pass && mb.State != MEM_FREE)
{ {
/* If the return length pointer is missing, NtQueryVirtualMemory /* If the return length pointer is missing, NtQueryVirtualMemory
@ -1121,10 +1120,8 @@ format_process_stat (void *data, char *&destbuf)
*s = 0; *s = 0;
} }
} }
/* /* Note: under Windows, a process is always running - it's only threads
* Note: under Windows, a _process_ is always running - it's only _threads_ that get suspended. Therefore the default state is R (runnable). */
* that get suspended. Therefore the default state is R (runnable).
*/
if (p->process_state & PID_EXITED) if (p->process_state & PID_EXITED)
state = 'Z'; state = 'Z';
else if (p->process_state & PID_STOPPED) else if (p->process_state & PID_STOPPED)
@ -1133,7 +1130,7 @@ format_process_stat (void *data, char *&destbuf)
state = get_process_state (p->dwProcessId); state = get_process_state (p->dwProcessId);
start_time = (GetTickCount () / 1000 - time (NULL) + p->start_time) * HZ; start_time = (GetTickCount () / 1000 - time (NULL) + p->start_time) * HZ;
NTSTATUS ret; NTSTATUS status;
HANDLE hProcess; HANDLE hProcess;
VM_COUNTERS vmc; VM_COUNTERS vmc;
KERNEL_USER_TIMES put; KERNEL_USER_TIMES put;
@ -1145,25 +1142,17 @@ format_process_stat (void *data, char *&destbuf)
FALSE, p->dwProcessId); FALSE, p->dwProcessId);
if (hProcess != NULL) if (hProcess != NULL)
{ {
ret = NtQueryInformationProcess (hProcess, status = NtQueryInformationProcess (hProcess, ProcessVmCounters,
ProcessVmCounters, (PVOID) &vmc, sizeof vmc, NULL);
(PVOID) &vmc, if (NT_SUCCESS (status))
sizeof vmc, NULL); status = NtQueryInformationProcess (hProcess, ProcessTimes,
if (ret == STATUS_SUCCESS) (PVOID) &put, sizeof put, NULL);
ret = NtQueryInformationProcess (hProcess, if (NT_SUCCESS (status))
ProcessTimes, status = NtQueryInformationProcess (hProcess, ProcessBasicInformation,
(PVOID) &put, (PVOID) &pbi, sizeof pbi, NULL);
sizeof put, NULL); if (NT_SUCCESS (status))
if (ret == STATUS_SUCCESS) status = NtQueryInformationProcess (hProcess, ProcessQuotaLimits,
ret = NtQueryInformationProcess (hProcess, (PVOID) &ql, sizeof ql, NULL);
ProcessBasicInformation,
(PVOID) &pbi,
sizeof pbi, NULL);
if (ret == STATUS_SUCCESS)
ret = NtQueryInformationProcess (hProcess,
ProcessQuotaLimits,
(PVOID) &ql,
sizeof ql, NULL);
CloseHandle (hProcess); CloseHandle (hProcess);
} }
else else
@ -1173,18 +1162,16 @@ format_process_stat (void *data, char *&destbuf)
debug_printf ("OpenProcess: ret %d", error); debug_printf ("OpenProcess: ret %d", error);
return 0; return 0;
} }
if (ret == STATUS_SUCCESS) if (NT_SUCCESS (status))
ret = NtQuerySystemInformation (SystemTimeOfDayInformation, status = NtQuerySystemInformation (SystemTimeOfDayInformation,
(PVOID) &stodi, (PVOID) &stodi, sizeof stodi, NULL);
sizeof stodi, NULL); if (NT_SUCCESS (status))
if (ret == STATUS_SUCCESS) status = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) &spt,
ret = NtQuerySystemInformation (SystemProcessorTimes, sizeof spt, NULL);
(PVOID) &spt, if (!NT_SUCCESS (status))
sizeof spt, NULL);
if (ret != STATUS_SUCCESS)
{ {
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
debug_printf ("NtQueryInformationProcess: ret %d, Dos(ret) %E", ret); debug_printf ("NtQueryInformationProcess: status %p, %E", status);
return 0; return 0;
} }
fault_count = vmc.PageFaultCount; fault_count = vmc.PageFaultCount;
@ -1203,7 +1190,7 @@ format_process_stat (void *data, char *&destbuf)
start_time = (spt.KernelTme.QuadPart + spt.UserTime.QuadPart) * HZ / 10000000ULL; start_time = (spt.KernelTme.QuadPart + spt.UserTime.QuadPart) * HZ / 10000000ULL;
#endif #endif
priority = pbi.BasePriority; priority = pbi.BasePriority;
unsigned page_size = getsystempagesize (); unsigned page_size = wincap.page_size ();
vmsize = vmc.PagefileUsage; vmsize = vmc.PagefileUsage;
vmrss = vmc.WorkingSetSize / page_size; vmrss = vmc.WorkingSetSize / page_size;
vmmaxrss = ql.MaximumWorkingSetSize / page_size; vmmaxrss = ql.MaximumWorkingSetSize / page_size;
@ -1246,10 +1233,8 @@ format_process_status (void *data, char *&destbuf)
if (ascii_strcasematch (s, ".exe")) if (ascii_strcasematch (s, ".exe"))
*s = 0; *s = 0;
} }
/* /* Note: under Windows, a process is always running - it's only threads
* Note: under Windows, a _process_ is always running - it's only _threads_ that get suspended. Therefore the default state is R (runnable). */
* that get suspended. Therefore the default state is R (runnable).
*/
if (p->process_state & PID_EXITED) if (p->process_state & PID_EXITED)
state = 'Z'; state = 'Z';
else if (p->process_state & PID_STOPPED) else if (p->process_state & PID_STOPPED)
@ -1278,12 +1263,12 @@ format_process_status (void *data, char *&destbuf)
if (!get_mem_values (p->dwProcessId, &vmsize, &vmrss, &vmtext, &vmdata, if (!get_mem_values (p->dwProcessId, &vmsize, &vmrss, &vmtext, &vmdata,
&vmlib, &vmshare)) &vmlib, &vmshare))
return 0; return 0;
unsigned page_size = getsystempagesize (); unsigned page_size = wincap.page_size ();
vmsize *= page_size; vmrss *= page_size; vmdata *= page_size; vmsize *= page_size; vmrss *= page_size; vmdata *= page_size;
vmtext *= page_size; vmlib *= page_size; vmtext *= page_size; vmlib *= page_size;
// The real uid value for *this* process is stored at cygheap->user.real_uid /* The real uid value for *this* process is stored at cygheap->user.real_uid
// but we can't get at the real uid value for any other process, so but we can't get at the real uid value for any other process, so
// just fake it as p->uid. Similar for p->gid. just fake it as p->uid. Similar for p->gid. */
destbuf = (char *) crealloc_abort (destbuf, strlen (cmd) + 320); destbuf = (char *) crealloc_abort (destbuf, strlen (cmd) + 320);
return __small_sprintf (destbuf, "Name:\t%s\n" return __small_sprintf (destbuf, "Name:\t%s\n"
"State:\t%c (%s)\n" "State:\t%c (%s)\n"
@ -1393,29 +1378,36 @@ format_process_mounts (void *data, char *&destbuf)
int int
get_process_state (DWORD dwProcessId) get_process_state (DWORD dwProcessId)
{ {
/* /* This isn't really heavy magic - just go through the processes' threads
* This isn't really heavy magic - just go through the processes' one by one and return a value accordingly. Errors are silently ignored. */
* threads one by one and return a value accordingly NTSTATUS status;
* Errors are silently ignored. PSYSTEM_PROCESSES p, sp;
*/ ULONG n = 0x4000;
NTSTATUS ret;
SYSTEM_PROCESSES *sp;
ULONG n = 0x1000;
PULONG p = new ULONG[n];
int state =' '; int state =' ';
while (STATUS_INFO_LENGTH_MISMATCH ==
(ret = NtQuerySystemInformation (SystemProcessesAndThreadsInformation, p = (PSYSTEM_PROCESSES) malloc (n);
(PVOID) p, if (!p)
n * sizeof *p, NULL))) return state;
delete [] p, p = new ULONG[n *= 2]; while (true)
if (ret != STATUS_SUCCESS)
{ {
debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %d", status = NtQuerySystemInformation (SystemProcessesAndThreadsInformation,
ret, RtlNtStatusToDosError (ret)); (PVOID) p, n, NULL);
if (status != STATUS_INFO_LENGTH_MISMATCH)
break;
n <<= 1;
PSYSTEM_PROCESSES new_p = (PSYSTEM_PROCESSES) realloc (p, n);
if (!new_p)
goto out;
p = new_p;
}
if (!NT_SUCCESS (status))
{
debug_printf ("NtQuerySystemInformation: status %p, %lu",
status, RtlNtStatusToDosError (status));
goto out; goto out;
} }
state = 'Z'; state = 'Z';
sp = (SYSTEM_PROCESSES *) p; sp = p;
for (;;) for (;;)
{ {
if (sp->ProcessId == dwProcessId) if (sp->ProcessId == dwProcessId)
@ -1438,10 +1430,10 @@ get_process_state (DWORD dwProcessId)
} }
if (!sp->NextEntryDelta) if (!sp->NextEntryDelta)
break; break;
sp = (SYSTEM_PROCESSES *) ((char *) sp + sp->NextEntryDelta); sp = (PSYSTEM_PROCESSES) ((char *) sp + sp->NextEntryDelta);
} }
out: out:
delete [] p; free (p);
return state; return state;
} }
@ -1451,15 +1443,16 @@ get_mem_values (DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss,
unsigned long *vmlib, unsigned long *vmshare) unsigned long *vmlib, unsigned long *vmshare)
{ {
bool res = false; bool res = false;
NTSTATUS ret; NTSTATUS status;
HANDLE hProcess; HANDLE hProcess;
VM_COUNTERS vmc; VM_COUNTERS vmc;
MEMORY_WORKING_SET_LIST *mwsl; PMEMORY_WORKING_SET_LIST p;
ULONG n = 0x4000, length; ULONG n = 0x4000, length;
PMEMORY_WORKING_SET_LIST p = (PMEMORY_WORKING_SET_LIST) malloc (n);
unsigned page_size = getsystempagesize (); p = (PMEMORY_WORKING_SET_LIST) malloc (n);
hProcess = OpenProcess (PROCESS_QUERY_INFORMATION, if (!p)
FALSE, dwProcessId); return false;
hProcess = OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, dwProcessId);
if (hProcess == NULL) if (hProcess == NULL)
{ {
__seterrno (); __seterrno ();
@ -1468,9 +1461,10 @@ get_mem_values (DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss,
} }
while (true) while (true)
{ {
ret = NtQueryVirtualMemory (hProcess, 0, MemoryWorkingSetList, status = NtQueryVirtualMemory (hProcess, 0, MemoryWorkingSetList,
(PVOID) p, n, (length = ULONG_MAX, &length)); (PVOID) p, n,
if (ret != STATUS_INFO_LENGTH_MISMATCH) (length = ULONG_MAX, &length));
if (status != STATUS_INFO_LENGTH_MISMATCH)
break; break;
n <<= 1; n <<= 1;
PMEMORY_WORKING_SET_LIST new_p = (PMEMORY_WORKING_SET_LIST) PMEMORY_WORKING_SET_LIST new_p = (PMEMORY_WORKING_SET_LIST)
@ -1479,23 +1473,22 @@ get_mem_values (DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss,
goto out; goto out;
p = new_p; p = new_p;
} }
if (!NT_SUCCESS (ret)) if (!NT_SUCCESS (status))
{ {
debug_printf ("NtQueryVirtualMemory: ret %p", ret); debug_printf ("NtQueryVirtualMemory: status %p", status);
if (ret == STATUS_PROCESS_IS_TERMINATING) if (status == STATUS_PROCESS_IS_TERMINATING)
{ {
*vmsize = *vmrss = *vmtext = *vmdata = *vmlib = *vmshare = 0; *vmsize = *vmrss = *vmtext = *vmdata = *vmlib = *vmshare = 0;
res = true; res = true;
} }
else else
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
goto out; goto out;
} }
mwsl = (MEMORY_WORKING_SET_LIST *) p; for (unsigned long i = 0; i < p->NumberOfPages; i++)
for (unsigned long i = 0; i < mwsl->NumberOfPages; i++)
{ {
++*vmrss; ++*vmrss;
unsigned flags = mwsl->WorkingSetList[i] & 0x0FFF; unsigned flags = p->WorkingSetList[i] & 0x0FFF;
if ((flags & (WSLE_PAGE_EXECUTE | WSLE_PAGE_SHAREABLE)) if ((flags & (WSLE_PAGE_EXECUTE | WSLE_PAGE_SHAREABLE))
== (WSLE_PAGE_EXECUTE | WSLE_PAGE_SHAREABLE)) == (WSLE_PAGE_EXECUTE | WSLE_PAGE_SHAREABLE))
++*vmlib; ++*vmlib;
@ -1506,15 +1499,15 @@ get_mem_values (DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss,
else else
++*vmdata; ++*vmdata;
} }
ret = NtQueryInformationProcess (hProcess, ProcessVmCounters, (PVOID) &vmc, status = NtQueryInformationProcess (hProcess, ProcessVmCounters, (PVOID) &vmc,
sizeof vmc, NULL); sizeof vmc, NULL);
if (!NT_SUCCESS (ret)) if (!NT_SUCCESS (status))
{ {
debug_printf ("NtQueryInformationProcess: ret %p", ret); debug_printf ("NtQueryInformationProcess: status %p", status);
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
goto out; goto out;
} }
*vmsize = vmc.PagefileUsage / page_size; *vmsize = vmc.PagefileUsage / wincap.page_size ();
res = true; res = true;
out: out:
free (p); free (p);

View File

@ -37,7 +37,7 @@ details. */
/* Stick with 4K pages for bookkeeping, otherwise we just get confused /* Stick with 4K pages for bookkeeping, otherwise we just get confused
when trying to do file mappings with trailing filler pages correctly. */ when trying to do file mappings with trailing filler pages correctly. */
#define PAGE_CNT(bytes) howmany((bytes),getsystempagesize()) #define PAGE_CNT(bytes) howmany((bytes), wincap.page_size())
#define PGBITS (sizeof (DWORD)*8) #define PGBITS (sizeof (DWORD)*8)
#define MAPSIZE(pages) howmany ((pages), PGBITS) #define MAPSIZE(pages) howmany ((pages), PGBITS)
@ -141,7 +141,7 @@ CreateMapping (HANDLE fhdl, size_t len, _off64_t off, DWORD openflags,
int prot, int flags) int prot, int flags)
{ {
HANDLE h; HANDLE h;
NTSTATUS ret; NTSTATUS status;
LARGE_INTEGER sectionsize = { QuadPart: len }; LARGE_INTEGER sectionsize = { QuadPart: len };
ULONG protect = gen_create_protect (openflags, flags); ULONG protect = gen_create_protect (openflags, flags);
@ -154,8 +154,8 @@ CreateMapping (HANDLE fhdl, size_t len, _off64_t off, DWORD openflags,
if (fhdl == INVALID_HANDLE_VALUE) if (fhdl == INVALID_HANDLE_VALUE)
{ {
/* Standard anonymous mapping needs non-zero len. */ /* Standard anonymous mapping needs non-zero len. */
ret = NtCreateSection (&h, SECTION_ALL_ACCESS, &oa, status = NtCreateSection (&h, SECTION_ALL_ACCESS, &oa, &sectionsize,
&sectionsize, protect, attributes, NULL); protect, attributes, NULL);
} }
else if (autogrow (flags)) else if (autogrow (flags))
{ {
@ -164,13 +164,13 @@ CreateMapping (HANDLE fhdl, size_t len, _off64_t off, DWORD openflags,
requested protection is different, we close the mapping and requested protection is different, we close the mapping and
reopen it again with the correct protection, if auto-grow worked. */ reopen it again with the correct protection, if auto-grow worked. */
sectionsize.QuadPart += off; sectionsize.QuadPart += off;
ret = NtCreateSection (&h, SECTION_ALL_ACCESS, &oa, status = NtCreateSection (&h, SECTION_ALL_ACCESS, &oa, &sectionsize,
&sectionsize, PAGE_READWRITE, attributes, fhdl); PAGE_READWRITE, attributes, fhdl);
if (NT_SUCCESS (ret) && protect != PAGE_READWRITE) if (NT_SUCCESS (status) && protect != PAGE_READWRITE)
{ {
NtClose (h); NtClose (h);
ret = NtCreateSection (&h, SECTION_ALL_ACCESS, &oa, status = NtCreateSection (&h, SECTION_ALL_ACCESS, &oa, &sectionsize,
&sectionsize, protect, attributes, fhdl); protect, attributes, fhdl);
} }
} }
else else
@ -178,13 +178,13 @@ CreateMapping (HANDLE fhdl, size_t len, _off64_t off, DWORD openflags,
/* Zero len creates mapping for whole file and allows /* Zero len creates mapping for whole file and allows
AT_EXTENDABLE_FILE mapping, if we ever use it... */ AT_EXTENDABLE_FILE mapping, if we ever use it... */
sectionsize.QuadPart = 0; sectionsize.QuadPart = 0;
ret = NtCreateSection (&h, SECTION_ALL_ACCESS, &oa, status = NtCreateSection (&h, SECTION_ALL_ACCESS, &oa, &sectionsize,
&sectionsize, protect, attributes, fhdl); protect, attributes, fhdl);
} }
if (!NT_SUCCESS (ret)) if (!NT_SUCCESS (status))
{ {
h = NULL; h = NULL;
SetLastError (RtlNtStatusToDosError (ret)); SetLastError (RtlNtStatusToDosError (status));
} }
return h; return h;
} }
@ -193,7 +193,7 @@ static void *
MapView (HANDLE h, void *addr, size_t len, DWORD openflags, MapView (HANDLE h, void *addr, size_t len, DWORD openflags,
int prot, int flags, _off64_t off) int prot, int flags, _off64_t off)
{ {
NTSTATUS ret; NTSTATUS status;
LARGE_INTEGER offset = { QuadPart:off }; LARGE_INTEGER offset = { QuadPart:off };
DWORD protect = gen_create_protect (openflags, flags); DWORD protect = gen_create_protect (openflags, flags);
void *base = addr; void *base = addr;
@ -208,22 +208,23 @@ MapView (HANDLE h, void *addr, size_t len, DWORD openflags,
Note: Retrying the mapping might be unnecessary, now that mmap64 checks Note: Retrying the mapping might be unnecessary, now that mmap64 checks
for a valid memory area first. */ for a valid memory area first. */
ret = NtMapViewOfSection (h, NtCurrentProcess (), &base, 0, commitsize, status = NtMapViewOfSection (h, NtCurrentProcess (), &base, 0, commitsize,
&offset, &viewsize, ViewShare, alloc_type, protect); &offset, &viewsize, ViewShare, alloc_type,
if (!NT_SUCCESS (ret) && addr && !fixed (flags)) protect);
if (!NT_SUCCESS (status) && addr && !fixed (flags))
{ {
base = NULL; base = NULL;
ret = NtMapViewOfSection (h, NtCurrentProcess (), &base, 0, commitsize, status = NtMapViewOfSection (h, NtCurrentProcess (), &base, 0, commitsize,
&offset, &viewsize, ViewShare, 0, protect); &offset, &viewsize, ViewShare, 0, protect);
} }
if (!NT_SUCCESS (ret)) if (!NT_SUCCESS (status))
{ {
base = NULL; base = NULL;
SetLastError (RtlNtStatusToDosError (ret)); SetLastError (RtlNtStatusToDosError (status));
} }
debug_printf ("%p (status %p) = NtMapViewOfSection (h:%x, addr:%x, len:%u," debug_printf ("%p (status %p) = NtMapViewOfSection (h:%x, addr:%x, len:%u,"
" off:%X, protect:%x, type:%x)", " off:%X, protect:%x, type:%x)",
base, ret, h, addr, len, off, protect, 0); base, status, h, addr, len, off, protect, 0);
return base; return base;
} }
@ -389,7 +390,7 @@ mmap_record::match (caddr_t addr, DWORD len, caddr_t &m_addr, DWORD &m_len)
if (filler ()) if (filler ())
high += get_len (); high += get_len ();
else else
high += (PAGE_CNT (get_len ()) * getsystempagesize ()); high += (PAGE_CNT (get_len ()) * wincap.page_size ());
high = (addr + len < high) ? addr + len : high; high = (addr + len < high) ? addr + len : high;
if (low < high) if (low < high)
{ {
@ -432,8 +433,8 @@ mmap_record::map_pages (_off64_t off, DWORD len)
if ((off = find_unused_pages (len)) == (DWORD)-1) if ((off = find_unused_pages (len)) == (DWORD)-1)
return 0L; return 0L;
if (!noreserve () if (!noreserve ()
&& !VirtualProtect (get_address () + off * getsystempagesize (), && !VirtualProtect (get_address () + off * wincap.page_size (),
len * getsystempagesize (), gen_protect (), len * wincap.page_size (), gen_protect (),
&old_prot)) &old_prot))
{ {
__seterrno (); __seterrno ();
@ -442,7 +443,7 @@ mmap_record::map_pages (_off64_t off, DWORD len)
while (len-- > 0) while (len-- > 0)
MAP_SET (off + len); MAP_SET (off + len);
return off * getsystempagesize (); return off * wincap.page_size ();
} }
bool bool
@ -451,7 +452,7 @@ mmap_record::map_pages (caddr_t addr, DWORD len)
debug_printf ("map_pages (addr=%x, len=%u)", addr, len); debug_printf ("map_pages (addr=%x, len=%u)", addr, len);
DWORD old_prot; DWORD old_prot;
DWORD off = addr - get_address (); DWORD off = addr - get_address ();
off /= getsystempagesize (); off /= wincap.page_size ();
len = PAGE_CNT (len); len = PAGE_CNT (len);
/* First check if the area is unused right now. */ /* First check if the area is unused right now. */
for (DWORD l = 0; l < len; ++l) for (DWORD l = 0; l < len; ++l)
@ -461,8 +462,8 @@ mmap_record::map_pages (caddr_t addr, DWORD len)
return false; return false;
} }
if (!noreserve () if (!noreserve ()
&& !VirtualProtect (get_address () + off * getsystempagesize (), && !VirtualProtect (get_address () + off * wincap.page_size (),
len * getsystempagesize (), gen_protect (), len * wincap.page_size (), gen_protect (),
&old_prot)) &old_prot))
{ {
__seterrno (); __seterrno ();
@ -485,7 +486,7 @@ mmap_record::unmap_pages (caddr_t addr, DWORD len)
&old_prot)) &old_prot))
debug_printf ("VirtualProtect in unmap_pages () failed, %E"); debug_printf ("VirtualProtect in unmap_pages () failed, %E");
off /= getsystempagesize (); off /= wincap.page_size ();
len = PAGE_CNT (len); len = PAGE_CNT (len);
for (; len-- > 0; ++off) for (; len-- > 0; ++off)
MAP_CLR (off); MAP_CLR (off);
@ -502,7 +503,7 @@ mmap_record::access (caddr_t address)
{ {
if (address < get_address () || address >= get_address () + get_len ()) if (address < get_address () || address >= get_address () + get_len ())
return 0; return 0;
DWORD off = (address - get_address ()) / getsystempagesize (); DWORD off = (address - get_address ()) / wincap.page_size ();
return MAP_ISSET (off); return MAP_ISSET (off);
} }
@ -716,7 +717,7 @@ mmap_is_attached_or_noreserve (void *addr, size_t len)
LIST_LOCK (); LIST_LOCK ();
mmap_list *map_list = mmapped_areas.get_list_by_fd (-1, NULL); mmap_list *map_list = mmapped_areas.get_list_by_fd (-1, NULL);
size_t pagesize = getpagesize (); size_t pagesize = wincap.allocation_granularity ();
caddr_t start_addr = (caddr_t) rounddown ((uintptr_t) addr, pagesize); caddr_t start_addr = (caddr_t) rounddown ((uintptr_t) addr, pagesize);
len += ((caddr_t) addr - start_addr); len += ((caddr_t) addr - start_addr);
len = roundup2 (len, pagesize); len = roundup2 (len, pagesize);
@ -803,7 +804,7 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
caddr_t base = NULL; caddr_t base = NULL;
struct __stat64 st; struct __stat64 st;
DWORD pagesize = getpagesize (); DWORD pagesize = wincap.allocation_granularity ();
fh_anonymous.set_io_handle (INVALID_HANDLE_VALUE); fh_anonymous.set_io_handle (INVALID_HANDLE_VALUE);
fh_anonymous.set_access (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE); fh_anonymous.set_access (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE);
@ -966,7 +967,7 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
to get this right. Too bad. */ to get this right. Too bad. */
if (!wincap.is_wow64 () if (!wincap.is_wow64 ()
&& ((len > fsiz && !autogrow (flags)) && ((len > fsiz && !autogrow (flags))
|| roundup2 (len, getsystempagesize ()) || roundup2 (len, wincap.page_size ())
< roundup2 (len, pagesize))) < roundup2 (len, pagesize)))
orig_len = len; orig_len = len;
if (len > fsiz) if (len > fsiz)
@ -1069,7 +1070,7 @@ go_ahead:
#if 0 #if 0
orig_len = roundup2 (orig_len, pagesize); orig_len = roundup2 (orig_len, pagesize);
#endif #endif
len = roundup2 (len, getsystempagesize ()); len = roundup2 (len, wincap.page_size ());
if (orig_len - len) if (orig_len - len)
{ {
orig_len -= len; orig_len -= len;
@ -1140,7 +1141,7 @@ munmap (void *addr, size_t len)
set_errno (EINVAL); set_errno (EINVAL);
return -1; return -1;
} }
size_t pagesize = getpagesize (); size_t pagesize = wincap.allocation_granularity ();
if (((uintptr_t) addr % pagesize) || !len) if (((uintptr_t) addr % pagesize) || !len)
{ {
set_errno (EINVAL); set_errno (EINVAL);
@ -1204,7 +1205,7 @@ msync (void *addr, size_t len, int flags)
LIST_LOCK (); LIST_LOCK ();
if (((uintptr_t) addr % getpagesize ()) if (((uintptr_t) addr % wincap.allocation_granularity ())
|| (flags & ~(MS_ASYNC | MS_SYNC | MS_INVALIDATE)) || (flags & ~(MS_ASYNC | MS_SYNC | MS_INVALIDATE))
|| ((flags & (MS_ASYNC | MS_SYNC)) == (MS_ASYNC | MS_SYNC))) || ((flags & (MS_ASYNC | MS_SYNC)) == (MS_ASYNC | MS_SYNC)))
{ {
@ -1212,7 +1213,7 @@ msync (void *addr, size_t len, int flags)
goto out; goto out;
} }
#if 0 /* If I only knew why I did that... */ #if 0 /* If I only knew why I did that... */
len = roundup2 (len, getpagesize ()); len = roundup2 (len, wincap.allocation_granularity ());
#endif #endif
/* Iterate through the map, looking for the mmapped area. /* Iterate through the map, looking for the mmapped area.
@ -1225,7 +1226,9 @@ msync (void *addr, size_t len, int flags)
if (rec->access ((caddr_t) addr)) if (rec->access ((caddr_t) addr))
{ {
/* Check whole area given by len. */ /* Check whole area given by len. */
for (DWORD i = getpagesize (); i < len; i += getpagesize ()) for (DWORD i = wincap.allocation_granularity ();
i < len;
i += wincap.allocation_granularity ())
if (!rec->access ((caddr_t) addr + i)) if (!rec->access ((caddr_t) addr + i))
{ {
set_errno (ENOMEM); set_errno (ENOMEM);
@ -1261,7 +1264,7 @@ mprotect (void *addr, size_t len, int prot)
syscall_printf ("mprotect (addr: %p, len %u, prot %x)", addr, len, prot); syscall_printf ("mprotect (addr: %p, len %u, prot %x)", addr, len, prot);
/* See comment in mmap64 for a description. */ /* See comment in mmap64 for a description. */
size_t pagesize = getpagesize (); size_t pagesize = wincap.allocation_granularity ();
if ((uintptr_t) addr % pagesize) if ((uintptr_t) addr % pagesize)
{ {
set_errno (EINVAL); set_errno (EINVAL);
@ -1347,7 +1350,7 @@ mlock (const void *addr, size_t len)
int ret = -1; int ret = -1;
/* Align address and length values to page size. */ /* Align address and length values to page size. */
size_t pagesize = getpagesize (); size_t pagesize = wincap.allocation_granularity ();
PVOID base = (PVOID) rounddown((uintptr_t) addr, pagesize); PVOID base = (PVOID) rounddown((uintptr_t) addr, pagesize);
ULONG size = roundup2 (((uintptr_t) addr - (uintptr_t) base) + len, pagesize); ULONG size = roundup2 (((uintptr_t) addr - (uintptr_t) base) + len, pagesize);
NTSTATUS status = 0; NTSTATUS status = 0;
@ -1404,7 +1407,7 @@ munlock (const void *addr, size_t len)
int ret = -1; int ret = -1;
/* Align address and length values to page size. */ /* Align address and length values to page size. */
size_t pagesize = getpagesize (); size_t pagesize = wincap.allocation_granularity ();
PVOID base = (PVOID) rounddown((uintptr_t) addr, pagesize); PVOID base = (PVOID) rounddown((uintptr_t) addr, pagesize);
ULONG size = roundup2 (((uintptr_t) addr - (uintptr_t) base) + len, pagesize); ULONG size = roundup2 (((uintptr_t) addr - (uintptr_t) base) + len, pagesize);
NTSTATUS status = NtUnlockVirtualMemory (NtCurrentProcess (), &base, &size, NTSTATUS status = NtUnlockVirtualMemory (NtCurrentProcess (), &base, &size,
@ -1708,10 +1711,10 @@ fhandler_dev_mem::mmap (caddr_t *addr, size_t len, int prot,
section_access = SECTION_MAP_READ; section_access = SECTION_MAP_READ;
HANDLE h; HANDLE h;
NTSTATUS ret = NtOpenSection (&h, section_access, &attr); NTSTATUS status = NtOpenSection (&h, section_access, &attr);
if (!NT_SUCCESS (ret)) if (!NT_SUCCESS (status))
{ {
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
debug_printf ("-1 = mmap(): NtOpenSection failed with %E"); debug_printf ("-1 = mmap(): NtOpenSection failed with %E");
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} }
@ -1739,10 +1742,10 @@ fhandler_dev_mem::mmap (caddr_t *addr, size_t len, int prot,
int int
fhandler_dev_mem::munmap (HANDLE h, caddr_t addr, size_t len) fhandler_dev_mem::munmap (HANDLE h, caddr_t addr, size_t len)
{ {
NTSTATUS ret; NTSTATUS status;
if (!NT_SUCCESS (ret = NtUnmapViewOfSection (NtCurrentProcess (), addr))) if (!NT_SUCCESS (status = NtUnmapViewOfSection (NtCurrentProcess (), addr)))
{ {
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
return -1; return -1;
} }
NtClose (h); NtClose (h);

View File

@ -1323,29 +1323,51 @@ winpids::enum_processes (bool winpid)
if (winpid) if (winpid)
{ {
static DWORD szprocs; static DWORD szprocs;
static SYSTEM_PROCESSES *procs; static PSYSTEM_PROCESSES procs;
if (!szprocs) if (!szprocs)
procs = (SYSTEM_PROCESSES *) malloc (sizeof (*procs) + (szprocs = 200 * sizeof (*procs)));
NTSTATUS res;
for (;;)
{ {
res = NtQuerySystemInformation (SystemProcessesAndThreadsInformation, procs = (PSYSTEM_PROCESSES)
procs, szprocs, NULL); malloc (sizeof (*procs) + (szprocs = 200 * sizeof (*procs)));
if (res == 0) if (!procs)
break;
if (res == STATUS_INFO_LENGTH_MISMATCH)
procs = (SYSTEM_PROCESSES *) realloc (procs, szprocs += 200 * sizeof (*procs));
else
{ {
system_printf ("error %p reading system process information", res); system_printf ("out of memory reading system process "
"information");
return 0; return 0;
} }
} }
SYSTEM_PROCESSES *px = procs; for (;;)
{
status =
NtQuerySystemInformation (SystemProcessesAndThreadsInformation,
procs, szprocs, NULL);
if (NT_SUCCESS (status))
break;
if (status == STATUS_INFO_LENGTH_MISMATCH)
{
PSYSTEM_PROCESSES new_p;
new_p = (PSYSTEM_PROCESSES)
realloc (procs, szprocs += 200 * sizeof (*procs));
if (!new_p)
{
system_printf ("out of memory reading system process "
"information");
return 0;
}
procs = new_p;
}
else
{
system_printf ("error %p reading system process information",
status);
return 0;
}
}
PSYSTEM_PROCESSES px = procs;
for (;;) for (;;)
{ {
if (px->ProcessId) if (px->ProcessId)
@ -1362,7 +1384,7 @@ winpids::enum_processes (bool winpid)
} }
if (!px->NextEntryDelta) if (!px->NextEntryDelta)
break; break;
px = (SYSTEM_PROCESSES *) ((char *) px + px->NextEntryDelta); px = (PSYSTEM_PROCESSES) ((char *) px + px->NextEntryDelta);
} }
} }

View File

@ -592,7 +592,6 @@ get_priv_list (LSA_HANDLE lsa, cygsid &usersid, cygsidlist &grp_list,
PLSA_UNICODE_STRING privstrs; PLSA_UNICODE_STRING privstrs;
ULONG cnt; ULONG cnt;
PTOKEN_PRIVILEGES privs = NULL; PTOKEN_PRIVILEGES privs = NULL;
NTSTATUS ret;
if (usersid == well_known_system_sid) if (usersid == well_known_system_sid)
{ {
@ -608,13 +607,12 @@ get_priv_list (LSA_HANDLE lsa, cygsid &usersid, cygsidlist &grp_list,
{ {
if (grp == -1) if (grp == -1)
{ {
if ((ret = LsaEnumerateAccountRights (lsa, usersid, &privstrs, if (LsaEnumerateAccountRights (lsa, usersid, &privstrs, &cnt)
&cnt)) != STATUS_SUCCESS) != STATUS_SUCCESS)
continue; continue;
} }
else if ((ret = LsaEnumerateAccountRights (lsa, grp_list.sids[grp], else if (LsaEnumerateAccountRights (lsa, grp_list.sids[grp],
&privstrs, &cnt)) &privstrs, &cnt) != STATUS_SUCCESS)
!= STATUS_SUCCESS)
continue; continue;
for (ULONG i = 0; i < cnt; ++i) for (ULONG i = 0; i < cnt; ++i)
{ {

View File

@ -436,8 +436,6 @@ shared_info::initialize ()
void void
memory_init (bool init_cygheap) memory_init (bool init_cygheap)
{ {
getpagesize ();
/* Initialize the Cygwin heap, if necessary */ /* Initialize the Cygwin heap, if necessary */
if (init_cygheap) if (init_cygheap)
{ {

View File

@ -2447,12 +2447,6 @@ getpagesize ()
return (size_t) wincap.allocation_granularity (); return (size_t) wincap.allocation_granularity ();
} }
size_t
getsystempagesize ()
{
return (size_t) wincap.page_size ();
}
/* FIXME: not all values are correct... */ /* FIXME: not all values are correct... */
extern "C" long int extern "C" long int
fpathconf (int fd, int v) fpathconf (int fd, int v)

View File

@ -32,20 +32,21 @@ get_open_max (int in)
static long static long
get_page_size (int in) get_page_size (int in)
{ {
return getpagesize (); return wincap.allocation_granularity ();
} }
static long static long
get_nproc_values (int in) get_nproc_values (int in)
{ {
NTSTATUS ret; NTSTATUS status;
SYSTEM_BASIC_INFORMATION sbi; SYSTEM_BASIC_INFORMATION sbi;
if ((ret = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi,
sizeof sbi, NULL)) != STATUS_SUCCESS) status = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi,
sizeof sbi, NULL);
if (!NT_SUCCESS (status))
{ {
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E", debug_printf ("NtQuerySystemInformation: status %p, %E", status);
ret);
return -1; return -1;
} }
switch (in) switch (in)
@ -63,7 +64,7 @@ get_nproc_values (int in)
} }
case _SC_PHYS_PAGES: case _SC_PHYS_PAGES:
return sbi.NumberOfPhysicalPages return sbi.NumberOfPhysicalPages
/ (getpagesize () / getsystempagesize ()); / (wincap.allocation_granularity () / wincap.page_size ());
} }
return -1; return -1;
} }
@ -71,18 +72,19 @@ get_nproc_values (int in)
static long static long
get_avphys (int in) get_avphys (int in)
{ {
NTSTATUS ret; NTSTATUS status;
SYSTEM_PERFORMANCE_INFORMATION spi; SYSTEM_PERFORMANCE_INFORMATION spi;
if ((ret = NtQuerySystemInformation (SystemPerformanceInformation,
(PVOID) &spi, sizeof spi, NULL)) status = NtQuerySystemInformation (SystemPerformanceInformation,
!= STATUS_SUCCESS) (PVOID) &spi, sizeof spi, NULL);
if (!NT_SUCCESS (status))
{ {
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (status);
debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E", debug_printf ("NtQuerySystemInformation: status %d, %E", status);
ret);
return -1; return -1;
} }
return spi.AvailablePages / (getpagesize () / getsystempagesize ()); return spi.AvailablePages
/ (wincap.allocation_granularity () / wincap.page_size ());
} }
enum sc_type { nsup, cons, func }; enum sc_type { nsup, cons, func };
@ -334,8 +336,8 @@ sysinfo (struct sysinfo *info)
PSYSTEM_PAGEFILE_INFORMATION spi = NULL; PSYSTEM_PAGEFILE_INFORMATION spi = NULL;
ULONG sizeof_spi = 512; ULONG sizeof_spi = 512;
PSYSTEM_TIME_OF_DAY_INFORMATION stodi = NULL; PSYSTEM_TIME_OF_DAY_INFORMATION stodi = NULL;
ULONG sizeof_stodi = sizeof (SYSTEM_TIME_OF_DAY_INFORMATION); const ULONG sizeof_stodi = sizeof (SYSTEM_TIME_OF_DAY_INFORMATION);
NTSTATUS ret = STATUS_SUCCESS; NTSTATUS status = STATUS_SUCCESS;
winpids pids ((DWORD) 0); winpids pids ((DWORD) 0);
if (!info) if (!info)
@ -345,46 +347,46 @@ sysinfo (struct sysinfo *info)
} }
stodi = (PSYSTEM_TIME_OF_DAY_INFORMATION) malloc (sizeof_stodi); stodi = (PSYSTEM_TIME_OF_DAY_INFORMATION) malloc (sizeof_stodi);
ret = NtQuerySystemInformation (SystemTimeOfDayInformation, (PVOID) stodi, status = NtQuerySystemInformation (SystemTimeOfDayInformation, (PVOID) stodi,
sizeof_stodi, NULL); sizeof_stodi, NULL);
if (NT_SUCCESS (ret)) if (NT_SUCCESS (status))
uptime = (stodi->CurrentTime.QuadPart - stodi->BootTime.QuadPart) / 10000000ULL; uptime = (stodi->CurrentTime.QuadPart - stodi->BootTime.QuadPart)
/ 10000000ULL;
else else
{ debug_printf ("NtQuerySystemInformation(SystemTimeOfDayInformation), "
debug_printf ("NtQuerySystemInformation(SystemTimeOfDayInformation), " "status %p", status);
"status %p", ret);
}
if (stodi) if (stodi)
free (stodi); free (stodi);
memory_status.dwLength = sizeof (MEMORYSTATUSEX); memory_status.dwLength = sizeof (MEMORYSTATUSEX);
GlobalMemoryStatusEx (&memory_status); GlobalMemoryStatusEx (&memory_status);
totalram = memory_status.ullTotalPhys / getsystempagesize (); totalram = memory_status.ullTotalPhys / wincap.page_size ();
freeram = memory_status.ullAvailPhys / getsystempagesize (); freeram = memory_status.ullAvailPhys / wincap.page_size ();
spi = (PSYSTEM_PAGEFILE_INFORMATION) malloc (sizeof_spi); spi = (PSYSTEM_PAGEFILE_INFORMATION) malloc (sizeof_spi);
if (spi) if (spi)
{ {
ret = NtQuerySystemInformation (SystemPagefileInformation, (PVOID) spi, status = NtQuerySystemInformation (SystemPagefileInformation, (PVOID) spi,
sizeof_spi, &sizeof_spi); sizeof_spi, &sizeof_spi);
if (ret == STATUS_INFO_LENGTH_MISMATCH) if (status == STATUS_INFO_LENGTH_MISMATCH)
{ {
free (spi); free (spi);
spi = (PSYSTEM_PAGEFILE_INFORMATION) malloc (sizeof_spi); spi = (PSYSTEM_PAGEFILE_INFORMATION) malloc (sizeof_spi);
if (spi) if (spi)
ret = NtQuerySystemInformation (SystemPagefileInformation, status = NtQuerySystemInformation (SystemPagefileInformation,
(PVOID) spi, sizeof_spi, &sizeof_spi); (PVOID) spi, sizeof_spi,
&sizeof_spi);
} }
} }
if (!spi || ret || (!ret && GetLastError () == ERROR_PROC_NOT_FOUND)) if (!spi || !NT_SUCCESS (status))
{ {
debug_printf ("NtQuerySystemInformation(SystemPagefileInformation), " debug_printf ("NtQuerySystemInformation(SystemPagefileInformation), "
"status %p", ret); "status %p", status);
totalswap = (memory_status.ullTotalPageFile - memory_status.ullTotalPhys) totalswap = (memory_status.ullTotalPageFile - memory_status.ullTotalPhys)
/ getsystempagesize (); / wincap.page_size ();
freeswap = (memory_status.ullAvailPageFile - memory_status.ullTotalPhys) freeswap = (memory_status.ullAvailPageFile - memory_status.ullTotalPhys)
/ getsystempagesize (); / wincap.page_size ();
} }
else else
{ {
@ -407,7 +409,7 @@ sysinfo (struct sysinfo *info)
info->totalswap = (unsigned long) totalswap; info->totalswap = (unsigned long) totalswap;
info->freeswap = (unsigned long) freeswap; info->freeswap = (unsigned long) freeswap;
info->procs = (unsigned short) pids.npids; info->procs = (unsigned short) pids.npids;
info->mem_unit = (unsigned int) getsystempagesize (); info->mem_unit = (unsigned int) wincap.page_size ();
/* FIXME: unsupported */ /* FIXME: unsupported */
info->loads[0] = 0UL; info->loads[0] = 0UL;

View File

@ -2509,7 +2509,7 @@ pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
{ {
const size_t sizeof_tbi = sizeof (THREAD_BASIC_INFORMATION); const size_t sizeof_tbi = sizeof (THREAD_BASIC_INFORMATION);
PTHREAD_BASIC_INFORMATION tbi; PTHREAD_BASIC_INFORMATION tbi;
NTSTATUS ret; NTSTATUS status;
if (!pthread::is_good_object (&thread)) if (!pthread::is_good_object (&thread))
return ESRCH; return ESRCH;
@ -2529,20 +2529,21 @@ pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
(*attr)->guardsize = thread->attr.guardsize; (*attr)->guardsize = thread->attr.guardsize;
tbi = (PTHREAD_BASIC_INFORMATION) malloc (sizeof_tbi); tbi = (PTHREAD_BASIC_INFORMATION) malloc (sizeof_tbi);
ret = NtQueryInformationThread (thread->win32_obj_id, ThreadBasicInformation, status = NtQueryInformationThread (thread->win32_obj_id,
tbi, sizeof_tbi, NULL); ThreadBasicInformation,
tbi, sizeof_tbi, NULL);
if (NT_SUCCESS (ret)) if (NT_SUCCESS (status))
{ {
PNT_TIB tib = tbi->TebBaseAddress; PNT_TIB tib = tbi->TebBaseAddress;
(*attr)->stackaddr = tib->StackBase; (*attr)->stackaddr = tib->StackBase;
/* stack grows downwards on x86 systems */ /* stack grows downwards on x86 systems */
(*attr)->stacksize = (int)tib->StackBase - (int)tib->StackLimit; (*attr)->stacksize = (uintptr_t) tib->StackBase
- (uintptr_t) tib->StackLimit;
} }
else else
{ {
debug_printf ("NtQueryInformationThread(ThreadBasicInformation), " debug_printf ("NtQueryInformationThread(ThreadBasicInformation), "
"status %p", ret); "status %p", status);
(*attr)->stackaddr = thread->attr.stackaddr; (*attr)->stackaddr = thread->attr.stackaddr;
(*attr)->stacksize = thread->attr.stacksize; (*attr)->stacksize = thread->attr.stacksize;
} }

View File

@ -257,9 +257,6 @@ int __stdcall stat_worker (path_conv &pc, struct __stat64 *buf) __attribute__ ((
__ino64_t __stdcall readdir_get_ino (const char *path, bool dot_dot) __attribute__ ((regparm (2))); __ino64_t __stdcall readdir_get_ino (const char *path, bool dot_dot) __attribute__ ((regparm (2)));
/* Returns the real page size, not the allocation size. */
size_t getsystempagesize ();
/* mmap functions. */ /* mmap functions. */
enum mmap_region_status enum mmap_region_status
{ {