diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c661e8ba8..167457d31 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,14 @@ +Sun Sep 2 22:09:31 2001 Christopher Faylor + + * child_info.h: Modify magic number. + * dcrt0.cc (_cygwin_testing): Define. + (_dll_crt0): Set _cygwin_testing if CYGWIN_TESTING environment variable + exists. Don't issue "conflicting versions" error if _cygwin_testing is + true. + * shared.cc (shared_name): Use _cygwin_testing global rather than + testing the environment. + * syscalls.cc (_write): Remove debugging info. + Sat Sep 1 01:37:13 2001 Christopher Faylor * tty.cc (tty::create_inuse): Eliminate unneeded argument. @@ -342,8 +353,8 @@ Fri Aug 3 14:02:00 2001 Corinna Vinschen Fri Aug 3 13:04:00 2001 Corinna Vinschen - * path.cc (fchdir): Set the fhandler's path to absolute value to - ensure changing to the correct directory even if the fhandler originally + * path.cc (fchdir): Set the fhandler's path to absolute value to ensure + changing to the correct directory even if the fhandler originally points to a relative path. Thu Aug 2 17:59:00 2001 Corinna Vinschen @@ -447,7 +458,7 @@ Wed 18 Jul 2001 12:54:17 Corinna Vinschen Wed 18 Jul 2001 11:56:00 Corinna Vinschen - * syscalls.cc (_unlink): Explicitely check for non-existant file. + * syscalls.cc (_unlink): Explicitly check for non-existant file. Tue 17 Jul 2001 10:19:00 Corinna Vinschen @@ -793,7 +804,7 @@ Sat Jun 2 23:11:52 2001 Christopher Faylor Sat Jun 2 14:07:28 2001 Christopher Faylor - * cygheap.cc (cygheap_root::cygheap_rot): Remove constructor. + * cygheap.cc (cygheap_root::cygheap_root): Remove constructor. (cygheap_root::~cygheap_root): Remove destructor. (cygheap_root::operator =): Remove. (cygheap_root::set): New method. @@ -851,7 +862,8 @@ Wed May 30 23:51:32 2001 Christopher Faylor * fhandler.h (fhandler_base::isremote): New method. (fhandler_base::set_isremote): Ditto. - (fhandler_base::set_execable_p): Also record "don't care if executable state". + (fhandler_base::set_execable_p): Also record "don't care if executable + state". (fhandler_base::dont_care_if_execable): New method. * path.cc (path_conv::check): Clear new flags. Appropriately set vol_flags, drive_type, and is_remote_drive. diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h index c838ceda6..4dfca8d9b 100644 --- a/winsup/cygwin/child_info.h +++ b/winsup/cygwin/child_info.h @@ -12,7 +12,7 @@ details. */ enum { - PROC_MAGIC = 0xaf10f000, + PROC_MAGIC = 0xaf11f000, PROC_FORK = PROC_MAGIC + 1, PROC_EXEC = PROC_MAGIC + 2, PROC_SPAWN = PROC_MAGIC + 3, diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index bdaa3129c..f4acc8d44 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -72,6 +72,8 @@ unsigned int signal_shift_subtract = 1; ResourceLocks _reslock NO_COPY; MTinterface _mtinterf NO_COPY; +bool NO_COPY _cygwin_testing; + extern "C" { void *export_malloc (unsigned int); @@ -872,15 +874,18 @@ dll_crt0_1 () extern "C" void __stdcall _dll_crt0 () { + char envbuf[8]; #ifdef DEBUGGING - char buf[80]; - if (GetEnvironmentVariable ("CYGWIN_SLEEP", buf, sizeof (buf))) + if (GetEnvironmentVariable ("CYGWIN_SLEEP", envbuf, sizeof (envbuf) - 1)) { - console_printf ("Sleeping %d, pid %u\n", atoi (buf), GetCurrentProcessId ()); - Sleep (atoi (buf)); + console_printf ("Sleeping %d, pid %u\n", atoi (envbuf), GetCurrentProcessId ()); + Sleep (atoi (envbuf)); } #endif + if (GetEnvironmentVariable ("CYGWIN_TESTING", envbuf, sizeof (envbuf) - 1)) + _cygwin_testing = 1; + char zeros[sizeof (fork_info->zero)] = {0}; #ifdef DEBUGGING strace.microseconds (); @@ -921,7 +926,9 @@ _dll_crt0 () break; } default: - if ((fork_info->type & PROC_MAGIC_MASK) == PROC_MAGIC_GENERIC) + if (_cygwin_testing) + fork_info = NULL; + else if ((fork_info->type & PROC_MAGIC_MASK) == PROC_MAGIC_GENERIC) api_fatal ("conflicting versions of cygwin1.dll detected. Use only the most recent version.\n"); break; } diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc index 6e866004b..e3e592885 100644 --- a/winsup/cygwin/mmap.cc +++ b/winsup/cygwin/mmap.cc @@ -62,7 +62,7 @@ class mmap_record base_address_ (b), map_map_ (NULL) { - if (fd >= 0 && !cygheap->fdtab.not_open (fd)) + if (fd >= 0 && !cygheap->fdtab.not_open (fd)) devtype_ = cygheap->fdtab[fd]->get_device (); } @@ -80,16 +80,16 @@ class mmap_record void alloc_map () { - /* Allocate one bit per page */ - map_map_ = (DWORD *) calloc (MAPSIZE(PAGE_CNT (size_to_map_)), + /* Allocate one bit per page */ + map_map_ = (DWORD *) calloc (MAPSIZE(PAGE_CNT (size_to_map_)), sizeof (DWORD)); if (iswinnt) { DWORD old_prot; if (!VirtualProtect (base_address_, size_to_map_, - PAGE_NOACCESS, &old_prot)) + PAGE_NOACCESS, &old_prot)) syscall_printf ("-1 = alloc_map (): %E"); - } + } } void free_map () { if (map_map_) free (map_map_); } @@ -111,11 +111,11 @@ mmap_record::find_empty (DWORD pages) for (start = 0; start <= mapped_pages - pages; ++start) if (!MAP_ISSET (start)) { - DWORD cnt; - for (cnt = 0; cnt < pages; ++cnt) + DWORD cnt; + for (cnt = 0; cnt < pages; ++cnt) if (MAP_ISSET (start + cnt)) break; - if (cnt >= pages) + if (cnt >= pages) return start; } return (DWORD)-1; @@ -143,10 +143,10 @@ mmap_record::map_map (DWORD off, DWORD len) { off = find_empty (len); if (off != (DWORD)-1) - { + { if (iswinnt - && !VirtualProtect (base_address_ + off * getpagesize (), - len * getpagesize (), prot, &old_prot)) + && !VirtualProtect (base_address_ + off * getpagesize (), + len * getpagesize (), prot, &old_prot)) syscall_printf ("-1 = map_map (): %E"); while (len-- > 0) @@ -159,7 +159,7 @@ mmap_record::map_map (DWORD off, DWORD len) DWORD start = off / getpagesize (); if (iswinnt && !VirtualProtect (base_address_ + start * getpagesize (), - len * getpagesize (), prot, &old_prot)) + len * getpagesize (), prot, &old_prot)) syscall_printf ("-1 = map_map (): %E"); for (; len-- > 0; ++start) @@ -176,7 +176,7 @@ mmap_record::unmap_map (caddr_t addr, DWORD len) len = PAGE_CNT (len); if (iswinnt && !VirtualProtect (base_address_ + off * getpagesize (), - len * getpagesize (), PAGE_NOACCESS, &old_prot)) + len * getpagesize (), PAGE_NOACCESS, &old_prot)) syscall_printf ("-1 = unmap_map (): %E"); for (; len-- > 0; ++off) @@ -211,7 +211,7 @@ mmap_record::fixup_map () for (DWORD off = PAGE_CNT (size_to_map_); off > 0; --off) VirtualProtect (base_address_ + off * getpagesize (), - getpagesize (), + getpagesize (), MAP_ISSET (off - 1) ? prot : PAGE_NOACCESS, &old_prot); } @@ -309,7 +309,7 @@ list::match (caddr_t addr, DWORD len, off_t start) { for (int i = start + 1; i < nrecs; ++i) if (addr >= recs[i].get_address () - && addr + len <= recs[i].get_address () + recs[i].get_size ()) + && addr + len <= recs[i].get_address () + recs[i].get_size ()) return i; return (off_t)-1; } @@ -354,9 +354,9 @@ map::get_list_by_fd (int fd) #if 0 /* The fd isn't sufficient since it could already be another file. */ if (lists[i]->fd == fd #else /* so we use the name hash value to identify the file unless - it's not an anonymous mapping. */ + it's not an anonymous mapping. */ if ((fd == -1 && lists[i]->fd == -1) - || (fd != -1 && lists[i]->hash == cygheap->fdtab[fd]->get_namehash ())) + || (fd != -1 && lists[i]->hash == cygheap->fdtab[fd]->get_namehash ())) #endif return lists[i]; return 0; @@ -481,7 +481,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off) } fh = cygheap->fdtab[fd]; if (fh->get_device () == FH_DISK) - { + { DWORD fsiz = GetFileSize (fh->get_handle (), NULL); fsiz -= gran_off; if (gran_len > fsiz) @@ -489,7 +489,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off) } else if (fh->get_device () == FH_ZERO) /* mmap /dev/zero is like MAP_ANONYMOUS. */ - fd = -1; + fd = -1; } if (fd == -1) { @@ -538,13 +538,13 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off) /* Create a new one */ l = new list; if (l == 0) - { - fh->munmap (h, base, gran_len); - set_errno (ENOMEM); - syscall_printf ("-1 = mmap(): ENOMEM"); - ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap"); - return MAP_FAILED; - } + { + fh->munmap (h, base, gran_len); + set_errno (ENOMEM); + syscall_printf ("-1 = mmap(): ENOMEM"); + ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap"); + return MAP_FAILED; + } l = mmapped_areas->add_list (l, fd); } @@ -597,9 +597,9 @@ munmap (caddr_t addr, size_t len) { mmap_record *rec = l->recs + li; if (rec->unmap_map (addr, len)) - { + { fhandler_base *fh = rec->alloc_fh (); - fh->munmap (rec->get_handle (), addr, len); + fh->munmap (rec->get_handle (), addr, len); rec->free_fh (fh); /* Delete the entry. */ @@ -661,12 +661,12 @@ msync (caddr_t addr, size_t len, int flags) if (rec->get_address () == addr) { fhandler_base *fh = rec->alloc_fh (); - int ret = fh->msync (rec->get_handle (), addr, len, flags); + int ret = fh->msync (rec->get_handle (), addr, len, flags); rec->free_fh (fh); - if (ret) + if (ret) syscall_printf ("%d = msync(): %E", ret); - else + else syscall_printf ("0 = msync()"); ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync"); @@ -698,7 +698,7 @@ msync (caddr_t addr, size_t len, int flags) */ HANDLE fhandler_base::mmap (caddr_t *addr, size_t len, DWORD access, - int flags, off_t off) + int flags, off_t off) { set_errno (ENODEV); return INVALID_HANDLE_VALUE; @@ -729,7 +729,7 @@ fhandler_base::fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset, /* Implementation for disk files. */ HANDLE fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access, - int flags, off_t off) + int flags, off_t off) { DWORD protect; @@ -751,12 +751,12 @@ fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access, && !(access & FILE_MAP_COPY)) { /* Grrr, the whole stuff is just needed to try to get a reliable - mapping of the same file. Even that uprising isn't bullet + mapping of the same file. Even that uprising isn't bullet proof but it does it's best... */ char namebuf[MAX_PATH]; cygwin_conv_to_full_posix_path (get_name (), namebuf); for (int i = strlen (namebuf) - 1; i >= 0; --i) - namebuf[i] = cyg_tolower (namebuf [i]); + namebuf[i] = cyg_tolower (namebuf [i]); if (!(h = OpenFileMapping (access, TRUE, namebuf))) h = CreateFileMapping (get_handle(), &sec_none, protect, 0, 0, namebuf); @@ -773,20 +773,20 @@ fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access, } void *base = MapViewOfFileEx (h, access, 0, off, len, - (flags & MAP_FIXED) ? *addr : NULL); + (flags & MAP_FIXED) ? *addr : NULL); if (!base || ((flags & MAP_FIXED) && base != *addr)) { if (!base) - { - __seterrno (); - syscall_printf ("-1 = mmap(): MapViewOfFileEx failed with %E"); - } + { + __seterrno (); + syscall_printf ("-1 = mmap(): MapViewOfFileEx failed with %E"); + } else - { + { set_errno (EINVAL); - syscall_printf ("-1 = mmap(): address shift with MAP_FIXED given"); - } + syscall_printf ("-1 = mmap(): address shift with MAP_FIXED given"); + } CloseHandle (h); return INVALID_HANDLE_VALUE; } @@ -906,10 +906,10 @@ fixup_mmaps_after_fork () fhandler_base *fh = rec->alloc_fh (); BOOL ret = fh->fixup_mmap_after_fork (rec->get_handle (), - rec->get_access (), - rec->get_offset (), - rec->get_size (), - rec->get_address ()); + rec->get_access (), + rec->get_offset (), + rec->get_size (), + rec->get_address ()); rec->free_fh (fh); if (!ret) diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index 309965c00..91fc48e5f 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -43,10 +43,10 @@ char * __stdcall shared_name (const char *str, int num) { static NO_COPY char buf[MAX_PATH] = {0}; - char envbuf[6]; + extern bool _cygwin_testing; __small_sprintf (buf, "%s.%s.%d", cygwin_version.shared_id, str, num); - if (GetEnvironmentVariable ("CYGWIN_TESTING", envbuf, 5)) + if (!_cygwin_testing) strcat (buf, cygwin_version.dll_build_date); return buf; } diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index ca76b07a9..6f26e882e 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -348,7 +348,7 @@ _write (int fd, const void *ptr, size_t len) fh = cygheap->fdtab[fd]; res = fh->bg_check (SIGTTOU); -syscall_printf ("write fh %p, name '%s' bg_check %d, bg_eof %d", fh, fh->get_name(), res, bg_eof); + if (res > bg_eof) { myself->process_state |= PID_TTYOU;