aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-07-10 01:10:44 +0000
committerChristopher Faylor <me@cgf.cx>2003-07-10 01:10:44 +0000
commitb8b408d0b74a56da3c642b6c01d4d52f5e333fe5 (patch)
tree910676c7c76b33714352f64f9b1450999aa864f5 /winsup
parent6c32d2025ad18373167f74c8525ff89333763ac7 (diff)
downloadnewlib-b8b408d0b74a56da3c642b6c01d4d52f5e333fe5.zip
newlib-b8b408d0b74a56da3c642b6c01d4d52f5e333fe5.tar.gz
newlib-b8b408d0b74a56da3c642b6c01d4d52f5e333fe5.tar.bz2
merge from trunk
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/Makefile.in4
-rw-r--r--winsup/cygwin/cygheap.cc4
-rw-r--r--winsup/cygwin/dtable.cc10
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc2
-rw-r--r--winsup/cygwin/fhandler_proc.cc77
-rw-r--r--winsup/cygwin/fhandler_process.cc30
-rwxr-xr-xwinsup/cygwin/newsym23
-rw-r--r--winsup/cygwin/pinfo.cc2
-rw-r--r--winsup/cygwin/resource.cc2
-rwxr-xr-xwinsup/cygwin/rmsym6
-rw-r--r--winsup/cygwin/syscalls.cc10
-rw-r--r--winsup/cygwin/sysconf.cc16
13 files changed, 135 insertions, 57 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 47ee10b..909830d 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,11 @@
2003-07-09 Christopher Faylor <cgf@redhat.com>
+ * fhandler_proc.cc (fhandler_proc::fill_filebuf): Allocate more space
+ for stat buffer.
+ (format_proc_stat): Reorganize to accumulate and report on all cpus.
+
+2003-07-09 Christopher Faylor <cgf@redhat.com>
+
* sysconf.cc (sysconf): Return processors online rather than bitmask
for _SC_NPROCESSORS_ONLN.
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index 53422ac..4346027 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -345,8 +345,8 @@ $(TEST_DLL_NAME): $(LDSCRIPT) $(DLL_OFILES) $(DEF_FILE) $(DLL_IMPORTS) $(LIBC) $
# Rule to build libcygwin.a
$(LIB_NAME): rmsym newsym $(TEST_DLL_NAME) $(LIBCOS)
- /bin/sh ${word 1,$^} ./cygdll.a "$(NM)" "$(AR)" "$(RANLIB)" $(OBSOLETE_FUNCTIONS) || exit 0
- /bin/sh ${word 2,$^} ./cygdll.a "$(AS)" "$(AR)" "$(RANLIB)" $(NEW_FUNCTIONS) || exit 0
+ /bin/sh ${word 1,$^} ./cygdll.a "$(NM)" "$(AR)" $(OBSOLETE_FUNCTIONS) || exit 0
+ /bin/sh ${word 2,$^} ./cygdll.a "$(AS)" "$(AR)" $(NEW_FUNCTIONS) || exit 0
(echo create $(LIB_NAME); echo addmod $(LIBCOS); echo addlib cygdll.a; echo save) | $(AR) -M
$(RANLIB) $@
diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc
index 1ee1f2d..c18232e 100644
--- a/winsup/cygwin/cygheap.cc
+++ b/winsup/cygwin/cygheap.cc
@@ -285,7 +285,7 @@ creturn (cygheap_types x, cygheap_entry * c, unsigned len)
{
if (!c)
{
- __seterrno ();
+ set_errno (ENOMEM);
return NULL;
}
c->type = x;
@@ -348,8 +348,10 @@ ccalloc (cygheap_types x, DWORD n, DWORD size)
c = (cygheap_entry *) _cmalloc (sizeof_cygheap (n));
if (c)
memset (c->data, 0, n);
+#ifdef DEBUGGING
if (!c)
system_printf ("ccalloc returned NULL");
+#endif
return creturn (x, c, n);
}
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index 6ff8121..9ca5d6a 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -65,18 +65,25 @@ dtable::extend (int howmuch)
if (howmuch <= 0)
return 0;
+ if (new_size > (100 * NOFILE_INCR))
+ {
+ set_errno (EMFILE);
+ return 0;
+ }
+
/* Try to allocate more space for fd table. We can't call realloc ()
here to preserve old table if memory allocation fails */
if (!(newfds = (fhandler_base **) ccalloc (HEAP_ARGV, new_size, sizeof newfds[0])))
{
debug_printf ("calloc failed");
+ set_errno (ENOMEM);
return 0;
}
if (fds)
{
- memcpy (newfds, fds, size * sizeof (fds[0]));
cfree (fds);
+ memcpy (newfds, fds, size * sizeof (fds[0]));
}
size = new_size;
@@ -434,6 +441,7 @@ build_fh_pc (path_conv& pc)
fh = cnew (fhandler_nodevice) ();
fh->set_name (pc);
+
debug_printf ("fh %p", fh);
return fh;
}
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index d97b5dc..49aae6c 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -626,7 +626,7 @@ fhandler_disk_file::opendir ()
res = dir;
}
- if (real_name.isencoded ())
+ if (pc.isencoded ())
set_encoded ();
}
diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc
index 081fcf5..6687317 100644
--- a/winsup/cygwin/fhandler_proc.cc
+++ b/winsup/cygwin/fhandler_proc.cc
@@ -344,7 +344,7 @@ fhandler_proc::fill_filebuf ()
}
case PROC_STAT:
{
- filebuf = (char *) realloc (filebuf, bufalloc = 2048);
+ filebuf = (char *) realloc (filebuf, bufalloc = 16384);
filesize = format_proc_stat (filebuf, bufalloc);
break;
}
@@ -451,24 +451,61 @@ out:
static _off64_t
format_proc_stat (char *destbuf, size_t maxsize)
{
- unsigned long long user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL;
unsigned long pages_in = 0UL, pages_out = 0UL, interrupt_count = 0UL,
context_switches = 0UL, swap_in = 0UL, swap_out = 0UL;
time_t boot_time = 0;
- if (wincap.is_winnt ())
+ char *eobuf = destbuf;
+ if (!wincap.is_winnt ())
+ eobuf += __small_sprintf (destbuf, "cpu %U %U %U %U\n", 0, 0, 0, 0);
+ else
{
NTSTATUS ret;
- SYSTEM_PROCESSOR_TIMES spt;
SYSTEM_PERFORMANCE_INFORMATION spi;
SYSTEM_TIME_OF_DAY_INFORMATION stodi;
- ret = NtQuerySystemInformation (SystemProcessorTimes,
- (PVOID) &spt,
- sizeof spt, NULL);
+
+ SYSTEM_BASIC_INFORMATION sbi;
+ if ((ret = NtQuerySystemInformation (SystemBasicInformation,
+ (PVOID) &sbi, sizeof sbi, NULL))
+ != STATUS_SUCCESS)
+ {
+ __seterrno_from_win_error (RtlNtStatusToDosError (ret));
+ debug_printf ("NtQuerySystemInformation: ret = %d, "
+ "Dos(ret) = %d",
+ ret, RtlNtStatusToDosError (ret));
+ sbi.NumberProcessors = 1;
+ }
+
+ SYSTEM_PROCESSOR_TIMES spt[sbi.NumberProcessors];
+ ret = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) spt,
+ sizeof spt[0] * sbi.NumberProcessors, NULL);
+ interrupt_count = 0;
if (ret == STATUS_SUCCESS)
- ret = NtQuerySystemInformation (SystemPerformanceInformation,
- (PVOID) &spi,
- sizeof spi, NULL);
+ {
+ unsigned long long user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL;
+ for (int i = 0; i < sbi.NumberProcessors; i++)
+ {
+ kernel_time += (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart) * HZ / 10000000ULL;
+ user_time += spt[i].UserTime.QuadPart * HZ / 10000000ULL;
+ idle_time += spt[i].IdleTime.QuadPart * HZ / 10000000ULL;
+ }
+
+ eobuf += __small_sprintf (eobuf, "cpu %U %U %U %U\n",
+ user_time, 0ULL, kernel_time, idle_time);
+ user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL;
+ for (int i = 0; i < sbi.NumberProcessors; i++)
+ {
+ interrupt_count += spt[i].InterruptCount;
+ kernel_time = (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart) * HZ / 10000000ULL;
+ user_time = spt[i].UserTime.QuadPart * HZ / 10000000ULL;
+ idle_time = spt[i].IdleTime.QuadPart * HZ / 10000000ULL;
+ eobuf += __small_sprintf (eobuf, "cpu%d %U %U %U %U\n", i,
+ user_time, 0ULL, kernel_time, idle_time);
+ }
+
+ ret = NtQuerySystemInformation (SystemPerformanceInformation,
+ (PVOID) &spi, sizeof spi, NULL);
+ }
if (ret == STATUS_SUCCESS)
ret = NtQuerySystemInformation (SystemTimeOfDayInformation,
(PVOID) &stodi,
@@ -481,10 +518,6 @@ format_proc_stat (char *destbuf, size_t maxsize)
ret, RtlNtStatusToDosError (ret));
return 0;
}
- kernel_time = (spt.KernelTime.QuadPart - spt.IdleTime.QuadPart) * HZ / 10000000ULL;
- user_time = spt.UserTime.QuadPart * HZ / 10000000ULL;
- idle_time = spt.IdleTime.QuadPart * HZ / 10000000ULL;
- interrupt_count = spt.InterruptCount;
pages_in = spi.PagesRead;
pages_out = spi.PagefilePagesWritten + spi.MappedFilePagesWritten;
/*
@@ -507,19 +540,17 @@ format_proc_stat (char *destbuf, size_t maxsize)
* counters is by no means worth it.
* }
*/
- return __small_sprintf (destbuf, "cpu %U %U %U %U\n"
- "page %u %u\n"
+ eobuf += __small_sprintf (eobuf, "page %u %u\n"
"swap %u %u\n"
"intr %u\n"
"ctxt %u\n"
"btime %u\n",
- user_time, 0ULL,
- kernel_time, idle_time,
- pages_in, pages_out,
- swap_in, swap_out,
- interrupt_count,
- context_switches,
- boot_time);
+ pages_in, pages_out,
+ swap_in, swap_out,
+ interrupt_count,
+ context_switches,
+ boot_time);
+ return eobuf - destbuf;
}
#define read_value(x,y) \
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
index ca48352..92eb22a 100644
--- a/winsup/cygwin/fhandler_process.cc
+++ b/winsup/cygwin/fhandler_process.cc
@@ -400,7 +400,9 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
state = 'T';
else if (wincap.is_winnt ())
state = get_process_state (p->dwProcessId);
- if (wincap.is_winnt ())
+ if (!wincap.is_winnt ())
+ start_time = (GetTickCount () / 1000 - time (NULL) + p->start_time) * HZ;
+ else
{
NTSTATUS ret;
HANDLE hProcess;
@@ -459,9 +461,11 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
ret, RtlNtStatusToDosError (ret));
return 0;
}
- fault_count = vmc.PageFaultCount;
- utime = put.UserTime.QuadPart * HZ / 10000000ULL;
- stime = put.KernelTime.QuadPart * HZ / 10000000ULL;
+ fault_count = vmc.PageFaultCount;
+ utime = put.UserTime.QuadPart * HZ / 10000000ULL;
+ stime = put.KernelTime.QuadPart * HZ / 10000000ULL;
+ start_time = (put.CreateTime.QuadPart - stodi.BootTime.QuadPart) * HZ / 10000000ULL;
+#if 0
if (stodi.CurrentTime.QuadPart > put.CreateTime.QuadPart)
start_time = (spt.KernelTime.QuadPart + spt.UserTime.QuadPart -
stodi.CurrentTime.QuadPart + put.CreateTime.QuadPart) * HZ / 10000000ULL;
@@ -471,17 +475,15 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
* Note: some older versions of procps are broken and can't cope
* with process start times > time(NULL).
*/
- start_time = (spt.KernelTime.QuadPart + spt.UserTime.QuadPart) * HZ / 10000000ULL;
- priority = pbi.BasePriority;
- unsigned page_size = getpagesize ();
- vmsize = vmc.PagefileUsage;
- vmrss = vmc.WorkingSetSize / page_size;
- vmmaxrss = ql.MaximumWorkingSetSize / page_size;
- }
- else
- {
- start_time = (GetTickCount () / 1000 - time (NULL) + p->start_time) * HZ;
+ start_time = (spt.KernelTme.QuadPart + spt.UserTime.QuadPart) * HZ / 10000000ULL;
+#endif
+ priority = pbi.BasePriority;
+ unsigned page_size = getpagesize ();
+ vmsize = vmc.PagefileUsage;
+ vmrss = vmc.WorkingSetSize / page_size;
+ vmmaxrss = ql.MaximumWorkingSetSize / page_size;
}
+
return __small_sprintf (destbuf, "%d (%s) %c "
"%d %d %d %d %d "
"%lu %lu %lu %lu %lu %lu %lu "
diff --git a/winsup/cygwin/newsym b/winsup/cygwin/newsym
index 688a8c6..301958e 100755
--- a/winsup/cygwin/newsym
+++ b/winsup/cygwin/newsym
@@ -1,8 +1,7 @@
-#!/bin/sh -x
+#!/bin/sh
lib=$1; shift
as=$1; shift
ar=$1; shift
-ranlib=$1; shift
rm -rf newsym.dir
trap "rm -rf newsym.dir" 0 1 2 15
mkdir newsym.dir
@@ -10,15 +9,25 @@ while [ -n "$1" ]; do
newsym=$1; shift
oldsym=$1; shift
cat <<EOF > newsym.dir/$newsym.s
- .section .idata$6
- .extern __imp__$oldsym
- .extern __head_cygwin1_dll
.section .text
.global _$newsym
+ .global __imp__$newsym
_$newsym:
jmp *__imp__$oldsym
+
+ .section .idata\$7
+ .long __head_cygwin1_dll
+
+ .section .idata\$5
+__imp__$newsym: .rva 1f
+
+ .section .idata\$4
+ .rva 1f
+
+ .section .idata\$6
+1: .short 2
+ .asciz "$oldsym"
EOF
$as -o newsym.dir/$newsym.o newsym.dir/$newsym.s
done
-$ar cru $lib newsym.dir/*.o
-$ranlib $lib
+$ar crus $lib newsym.dir/*.o
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index e7eeb43..489a91e 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -406,7 +406,7 @@ _pinfo::commune_send (DWORD code, ...)
/* FIXME: Need something better than an busy loop here */
bool isalive;
- while ((isalive = alive ()))
+ for (int i = 0; (isalive = alive ()) || (i < 65536); i++)
if (myself->hello_pid <= 0)
break;
else
diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc
index e87702b..536dfe8 100644
--- a/winsup/cygwin/resource.cc
+++ b/winsup/cygwin/resource.cc
@@ -137,6 +137,8 @@ getrlimit (int resource, struct rlimit *rlp)
break;
case RLIMIT_NOFILE:
rlp->rlim_cur = getdtablesize ();
+ if (rlp->rlim_cur < OPEN_MAX)
+ rlp->rlim_cur = OPEN_MAX;
break;
case RLIMIT_CORE:
rlp->rlim_cur = rlim_core;
diff --git a/winsup/cygwin/rmsym b/winsup/cygwin/rmsym
index 428aa9d..1549eed 100755
--- a/winsup/cygwin/rmsym
+++ b/winsup/cygwin/rmsym
@@ -2,10 +2,8 @@
lib=$1; shift
nm=$1; shift
ar=$1; shift
-ranlib=$1; shift
grepit=`echo $* | sed 's/ /\$|__imp__/g'`
[ -n "$grepit" ] && grepit="__imp__$grepit\$"
-objs=`$nm $lib | awk -F: '/^d[0-9]*.o:/ {obj=$1} '"/$grepit/"'{print obj}'`
+objs=`$nm $lib | awk -F: '/^d*[0-9][0-9]*.o:/ {obj=$1} '"/$grepit/"'{print obj}'`
[ -n "$objs" ] || exit 1
-$ar d $lib $objs
-$ranlib $lib
+$ar ds $lib $objs
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 91b533f..229c1f5 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2852,6 +2852,11 @@ long gethostid(void)
0x00290012};
bool has_cpuid = false;
+ sigframe thisframe (mainthread);
+
+ DWORD opmask = SetThreadAffinityMask (GetCurrentThread (), 1);
+ if (!opmask)
+ debug_printf ("SetThreadAffinityMask to 1 failed, %E");
if (!can_set_flag (0x00040000))
debug_printf ("386 processor - no cpuid");
@@ -2933,7 +2938,10 @@ long gethostid(void)
// a random hashing algorithm
// dependancy on md5 is probably too costly
for (int i=0;i<13;i++)
- hostid ^= ((data[i] << (i << 2)) | (data[i] >> (32 - (i << 2))));
+ hostid ^= ((data[i] << (i << 2)) | (data[i] >> (32 - (i << 2))));
+
+ if (opmask && !SetThreadAffinityMask (GetCurrentThread (), opmask))
+ debug_printf ("SetThreadAffinityMask to %p failed, %E", opmask);
debug_printf ("hostid: %08x", hostid);
diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc
index 55eaa8c..ac5b350 100644
--- a/winsup/cygwin/sysconf.cc
+++ b/winsup/cygwin/sysconf.cc
@@ -35,7 +35,12 @@ sysconf (int in)
case _SC_OPEN_MAX:
return getdtablesize ();
case _SC_PAGESIZE:
- return getpagesize ();
+ {
+ long max = getdtablesize ();
+ if (max < OPEN_MAX)
+ max = OPEN_MAX;
+ return max;
+ }
case _SC_CLK_TCK:
return CLOCKS_PER_SEC;
case _SC_JOB_CONTROL:
@@ -85,7 +90,14 @@ sysconf (int in)
case _SC_NPROCESSORS_CONF:
return sbi.NumberProcessors;
case _SC_NPROCESSORS_ONLN:
- return sbi.ActiveProcessors;
+ {
+ int i = 0;
+ do
+ if (sbi.ActiveProcessors & 1)
+ i++;
+ while (sbi.ActiveProcessors >>= 1);
+ return i;
+ }
case _SC_PHYS_PAGES:
return sbi.NumberOfPhysicalPages;
case _SC_AVPHYS_PAGES: