diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 84 | ||||
-rw-r--r-- | winsup/cygwin/Makefile.in | 4 | ||||
-rw-r--r-- | winsup/cygwin/cygheap.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/dtable.cc | 10 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_process.cc | 30 | ||||
-rwxr-xr-x | winsup/cygwin/newsym | 33 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/resource.cc | 2 | ||||
-rwxr-xr-x | winsup/cygwin/rmsym | 6 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 10 | ||||
-rw-r--r-- | winsup/cygwin/sysconf.cc | 16 |
12 files changed, 170 insertions, 33 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 352df7b9dd6..47ee10ba6cb 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,75 @@ +2003-07-09 Christopher Faylor <cgf@redhat.com> + + * sysconf.cc (sysconf): Return processors online rather than bitmask + for _SC_NPROCESSORS_ONLN. + +2003-07-08 Christopher Faylor <cgf@redhat.com> + + * cygheap.cc (creturn): Set appropriate errno when out of memory. + (ccalloc): Only issue system_printf when debugging. + * dtable.cc (dtable::extend): Only allocate 100 * the incremental growth + size max. Set errno appropriately. + (dtable::build_fhandler): Check for error from set_name. + * fhandler.cc (fhandler_base::set_name): Set errno and return error on OOM. + * fhandler.h (fhandler_base::set_name): Change to bool. + * fhandler_process.cc (format_process_stat): Fix formatting. + * resource.cc (getrlimit): Return greater of OPEN_MAX or fd table size. + * sysconf.cc (sysconf): Ditto. + +2003-07-07 Christopher Faylor <cgf@redhat.com> + + * rmsym: Don't use ranlib. + +2003-07-07 Christopher Faylor <cgf@redhat.com> + + * newsym: Reenable removal of tmp directory. Just use ar to generate + archive index. + * Makefile.in: Don't send ranlib to newsym or rmsym. + +2003-07-07 Christopher Faylor <cgf@redhat.com> + + * newsym: Create objects that are closer to those created by dlltool so + as not to confuse --export-all-symbols. + * rmsym: Be a little more accepting of object filenames now that + dlltool can create different format files. + +2003-07-06 Christopher Faylor <cgf@redhat.com> + + * newsym: Oops. Revert below change. + +2003-07-06 Christopher Faylor <cgf@redhat.com> + + * newsym: Use correct prefix for generating imports. + * pinfo.cc (_pinfo::commune_send): Don't wait forever for a response + from another process. + +2003-07-06 Christopher Faylor <cgf@redhat.com> + + * syscalls.cc (gethostid): Set thread affinity so that results are + predictable. + +2003-07-05 Corinna Vinschen <corinna@vinschen.de> + + * mmap.cc (list::match): Add parameters to return valid address and + length back to munmap(). Evaluate intersection between given + area and mapped area and return it, if any. + (mmap64): On regular files, don't allow mappings beginning beyond + EOF. Return with errno set to ENXIO instead. + (munmap): Rewrite SUSv3 conformant. Check if given memory area is + valid. Unmap all maps inside given memory area. Don't return error + if no mapping has been unmapped. + +2003-07-05 N Stephens <nigel@mips.com> + + * fhandler.h (fhandler_socket::get_connect_state): New method to + return socket connection state. + * fhandler_socket.cc (dup): Copy socket connect state to new file + handle. + * net.cc (cygwin_rcmd): Mark file handles of sockets returned by + rcmd() as CONNECTED state. + (cygwin_rexec): Similarly for rexec(). + (socketpair): Mark both ends of a new socket pair as CONNECTED. + 2003-07-04 Corinna Vinschen <corinna@vinschen.de> * mmap.cc (fhandler_disk_file::mmap): Fix address test. @@ -116,7 +188,7 @@ (cygheap_user::internal_token): New member. (cygheap_user::impersonation_state): New member. (cygheap_user::issetuid): Modify. - (cygheap_user::token): New method. + (cygheap_user::token): New method. (cygheap_user::deimpersonate): New method. (cygheap_user::reimpersonate): New method. (cygheap_user::has_impersonation_tokens): New method. @@ -168,9 +240,9 @@ 2003-06-18 Pierre Humblet <pierre.humblet@ieee.org> - * autoload.cc (GetNetworkParams): Add. - * net.cc (getdomainname): Call GetNetworkParams and read the - DhcpDomain registry value if warranted. + * autoload.cc (GetNetworkParams): Add. + * net.cc (getdomainname): Call GetNetworkParams and read the + DhcpDomain registry value if warranted. 2003-06-17 Christopher Faylor <cgf@redhat.com> @@ -429,7 +501,7 @@ (fhandler_base::lseek): Call set_did_lseek() instead of set_check_win95_lseek_bug(). (fhandler_base::fhandler_base): Initialize fs_flags to 0. - * fhandler_disk_file.cc (fhandler_disk_file::open): Don't create files + * fhandler_disk_file.cc (fhandler_disk_file::open): Don't create files as "sparse" unconditionally. Set fs_flags member. 2003-05-25 Pierre Humblet <pierre.humblet@ieee.org> @@ -507,7 +579,7 @@ * dcrt0.cc (dll_crt_0_1) Fix calls to MTinterface::Init and pthread::init_mainthread. Call pthread::init_mainthread only when not forked. - + 2003-05-15 Corinna Vinschen <corinna@vinschen.de> * fhandler_proc.cc (format_proc_meminfo): Make swap memory output diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in index 53422ac9bcd..4346027546f 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 1ee1f2d7192..c18232eed82 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 6ff8121c72a..9ca5d6a8679 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 d97b5dc63eb..49aae6c55f2 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_process.cc b/winsup/cygwin/fhandler_process.cc index ca48352cd5c..92eb22ab3d9 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 new file mode 100755 index 00000000000..301958ee59e --- /dev/null +++ b/winsup/cygwin/newsym @@ -0,0 +1,33 @@ +#!/bin/sh +lib=$1; shift +as=$1; shift +ar=$1; shift +rm -rf newsym.dir +trap "rm -rf newsym.dir" 0 1 2 15 +mkdir newsym.dir +while [ -n "$1" ]; do + newsym=$1; shift + oldsym=$1; shift + cat <<EOF > newsym.dir/$newsym.s + .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 crus $lib newsym.dir/*.o diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index e7eeb43c9fb..489a91e0642 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 e87702babfa..536dfe8a53d 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 428aa9d5064..1549eed9992 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 91b533f19c4..229c1f5ec14 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 55eaa8cee93..ac5b3500464 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: |