* 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.
This commit is contained in:
Christopher Faylor 2001-09-03 02:13:05 +00:00
parent db8b09c306
commit 9867ecfdb3
6 changed files with 80 additions and 61 deletions

View File

@ -1,3 +1,14 @@
Sun Sep 2 22:09:31 2001 Christopher Faylor <cgf@cygnus.com>
* 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 <cgf@cygnus.com> Sat Sep 1 01:37:13 2001 Christopher Faylor <cgf@cygnus.com>
* tty.cc (tty::create_inuse): Eliminate unneeded argument. * tty.cc (tty::create_inuse): Eliminate unneeded argument.
@ -342,8 +353,8 @@ Fri Aug 3 14:02:00 2001 Corinna Vinschen <corinna@vinschen.de>
Fri Aug 3 13:04:00 2001 Corinna Vinschen <corinna@vinschen.de> Fri Aug 3 13:04:00 2001 Corinna Vinschen <corinna@vinschen.de>
* path.cc (fchdir): Set the fhandler's path to absolute value to * path.cc (fchdir): Set the fhandler's path to absolute value to ensure
ensure changing to the correct directory even if the fhandler originally changing to the correct directory even if the fhandler originally
points to a relative path. points to a relative path.
Thu Aug 2 17:59:00 2001 Corinna Vinschen <corinna@vinschen.de> Thu Aug 2 17:59:00 2001 Corinna Vinschen <corinna@vinschen.de>
@ -447,7 +458,7 @@ Wed 18 Jul 2001 12:54:17 Corinna Vinschen <corinna@vinschen.de>
Wed 18 Jul 2001 11:56:00 Corinna Vinschen <corinna@vinschen.de> Wed 18 Jul 2001 11:56:00 Corinna Vinschen <corinna@vinschen.de>
* 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 <corinna@vinschen.de> Tue 17 Jul 2001 10:19:00 Corinna Vinschen <corinna@vinschen.de>
@ -793,7 +804,7 @@ Sat Jun 2 23:11:52 2001 Christopher Faylor <cgf@cygnus.com>
Sat Jun 2 14:07:28 2001 Christopher Faylor <cgf@cygnus.com> Sat Jun 2 14:07:28 2001 Christopher Faylor <cgf@cygnus.com>
* cygheap.cc (cygheap_root::cygheap_rot): Remove constructor. * cygheap.cc (cygheap_root::cygheap_root): Remove constructor.
(cygheap_root::~cygheap_root): Remove destructor. (cygheap_root::~cygheap_root): Remove destructor.
(cygheap_root::operator =): Remove. (cygheap_root::operator =): Remove.
(cygheap_root::set): New method. (cygheap_root::set): New method.
@ -851,7 +862,8 @@ Wed May 30 23:51:32 2001 Christopher Faylor <cgf@cygnus.com>
* fhandler.h (fhandler_base::isremote): New method. * fhandler.h (fhandler_base::isremote): New method.
(fhandler_base::set_isremote): Ditto. (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. (fhandler_base::dont_care_if_execable): New method.
* path.cc (path_conv::check): Clear new flags. Appropriately set * path.cc (path_conv::check): Clear new flags. Appropriately set
vol_flags, drive_type, and is_remote_drive. vol_flags, drive_type, and is_remote_drive.

View File

@ -12,7 +12,7 @@ details. */
enum enum
{ {
PROC_MAGIC = 0xaf10f000, PROC_MAGIC = 0xaf11f000,
PROC_FORK = PROC_MAGIC + 1, PROC_FORK = PROC_MAGIC + 1,
PROC_EXEC = PROC_MAGIC + 2, PROC_EXEC = PROC_MAGIC + 2,
PROC_SPAWN = PROC_MAGIC + 3, PROC_SPAWN = PROC_MAGIC + 3,

View File

@ -72,6 +72,8 @@ unsigned int signal_shift_subtract = 1;
ResourceLocks _reslock NO_COPY; ResourceLocks _reslock NO_COPY;
MTinterface _mtinterf NO_COPY; MTinterface _mtinterf NO_COPY;
bool NO_COPY _cygwin_testing;
extern "C" extern "C"
{ {
void *export_malloc (unsigned int); void *export_malloc (unsigned int);
@ -872,15 +874,18 @@ dll_crt0_1 ()
extern "C" void __stdcall extern "C" void __stdcall
_dll_crt0 () _dll_crt0 ()
{ {
char envbuf[8];
#ifdef DEBUGGING #ifdef DEBUGGING
char buf[80]; if (GetEnvironmentVariable ("CYGWIN_SLEEP", envbuf, sizeof (envbuf) - 1))
if (GetEnvironmentVariable ("CYGWIN_SLEEP", buf, sizeof (buf)))
{ {
console_printf ("Sleeping %d, pid %u\n", atoi (buf), GetCurrentProcessId ()); console_printf ("Sleeping %d, pid %u\n", atoi (envbuf), GetCurrentProcessId ());
Sleep (atoi (buf)); Sleep (atoi (envbuf));
} }
#endif #endif
if (GetEnvironmentVariable ("CYGWIN_TESTING", envbuf, sizeof (envbuf) - 1))
_cygwin_testing = 1;
char zeros[sizeof (fork_info->zero)] = {0}; char zeros[sizeof (fork_info->zero)] = {0};
#ifdef DEBUGGING #ifdef DEBUGGING
strace.microseconds (); strace.microseconds ();
@ -921,7 +926,9 @@ _dll_crt0 ()
break; break;
} }
default: 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"); api_fatal ("conflicting versions of cygwin1.dll detected. Use only the most recent version.\n");
break; break;
} }

View File

@ -62,7 +62,7 @@ class mmap_record
base_address_ (b), base_address_ (b),
map_map_ (NULL) 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 (); devtype_ = cygheap->fdtab[fd]->get_device ();
} }
@ -80,16 +80,16 @@ class mmap_record
void alloc_map () void alloc_map ()
{ {
/* Allocate one bit per page */ /* Allocate one bit per page */
map_map_ = (DWORD *) calloc (MAPSIZE(PAGE_CNT (size_to_map_)), map_map_ = (DWORD *) calloc (MAPSIZE(PAGE_CNT (size_to_map_)),
sizeof (DWORD)); sizeof (DWORD));
if (iswinnt) if (iswinnt)
{ {
DWORD old_prot; DWORD old_prot;
if (!VirtualProtect (base_address_, size_to_map_, if (!VirtualProtect (base_address_, size_to_map_,
PAGE_NOACCESS, &old_prot)) PAGE_NOACCESS, &old_prot))
syscall_printf ("-1 = alloc_map (): %E"); syscall_printf ("-1 = alloc_map (): %E");
} }
} }
void free_map () { if (map_map_) free (map_map_); } 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) for (start = 0; start <= mapped_pages - pages; ++start)
if (!MAP_ISSET (start)) if (!MAP_ISSET (start))
{ {
DWORD cnt; DWORD cnt;
for (cnt = 0; cnt < pages; ++cnt) for (cnt = 0; cnt < pages; ++cnt)
if (MAP_ISSET (start + cnt)) if (MAP_ISSET (start + cnt))
break; break;
if (cnt >= pages) if (cnt >= pages)
return start; return start;
} }
return (DWORD)-1; return (DWORD)-1;
@ -143,10 +143,10 @@ mmap_record::map_map (DWORD off, DWORD len)
{ {
off = find_empty (len); off = find_empty (len);
if (off != (DWORD)-1) if (off != (DWORD)-1)
{ {
if (iswinnt if (iswinnt
&& !VirtualProtect (base_address_ + off * getpagesize (), && !VirtualProtect (base_address_ + off * getpagesize (),
len * getpagesize (), prot, &old_prot)) len * getpagesize (), prot, &old_prot))
syscall_printf ("-1 = map_map (): %E"); syscall_printf ("-1 = map_map (): %E");
while (len-- > 0) while (len-- > 0)
@ -159,7 +159,7 @@ mmap_record::map_map (DWORD off, DWORD len)
DWORD start = off / getpagesize (); DWORD start = off / getpagesize ();
if (iswinnt if (iswinnt
&& !VirtualProtect (base_address_ + start * getpagesize (), && !VirtualProtect (base_address_ + start * getpagesize (),
len * getpagesize (), prot, &old_prot)) len * getpagesize (), prot, &old_prot))
syscall_printf ("-1 = map_map (): %E"); syscall_printf ("-1 = map_map (): %E");
for (; len-- > 0; ++start) for (; len-- > 0; ++start)
@ -176,7 +176,7 @@ mmap_record::unmap_map (caddr_t addr, DWORD len)
len = PAGE_CNT (len); len = PAGE_CNT (len);
if (iswinnt if (iswinnt
&& !VirtualProtect (base_address_ + off * getpagesize (), && !VirtualProtect (base_address_ + off * getpagesize (),
len * getpagesize (), PAGE_NOACCESS, &old_prot)) len * getpagesize (), PAGE_NOACCESS, &old_prot))
syscall_printf ("-1 = unmap_map (): %E"); syscall_printf ("-1 = unmap_map (): %E");
for (; len-- > 0; ++off) for (; len-- > 0; ++off)
@ -211,7 +211,7 @@ mmap_record::fixup_map ()
for (DWORD off = PAGE_CNT (size_to_map_); off > 0; --off) for (DWORD off = PAGE_CNT (size_to_map_); off > 0; --off)
VirtualProtect (base_address_ + off * getpagesize (), VirtualProtect (base_address_ + off * getpagesize (),
getpagesize (), getpagesize (),
MAP_ISSET (off - 1) ? prot : PAGE_NOACCESS, MAP_ISSET (off - 1) ? prot : PAGE_NOACCESS,
&old_prot); &old_prot);
} }
@ -309,7 +309,7 @@ list::match (caddr_t addr, DWORD len, off_t start)
{ {
for (int i = start + 1; i < nrecs; ++i) for (int i = start + 1; i < nrecs; ++i)
if (addr >= recs[i].get_address () 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 i;
return (off_t)-1; 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 0 /* The fd isn't sufficient since it could already be another file. */
if (lists[i]->fd == fd if (lists[i]->fd == fd
#else /* so we use the name hash value to identify the file unless #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) 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 #endif
return lists[i]; return lists[i];
return 0; 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]; fh = cygheap->fdtab[fd];
if (fh->get_device () == FH_DISK) if (fh->get_device () == FH_DISK)
{ {
DWORD fsiz = GetFileSize (fh->get_handle (), NULL); DWORD fsiz = GetFileSize (fh->get_handle (), NULL);
fsiz -= gran_off; fsiz -= gran_off;
if (gran_len > fsiz) 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) else if (fh->get_device () == FH_ZERO)
/* mmap /dev/zero is like MAP_ANONYMOUS. */ /* mmap /dev/zero is like MAP_ANONYMOUS. */
fd = -1; fd = -1;
} }
if (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 */ /* Create a new one */
l = new list; l = new list;
if (l == 0) if (l == 0)
{ {
fh->munmap (h, base, gran_len); fh->munmap (h, base, gran_len);
set_errno (ENOMEM); set_errno (ENOMEM);
syscall_printf ("-1 = mmap(): ENOMEM"); syscall_printf ("-1 = mmap(): ENOMEM");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap"); ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return MAP_FAILED; return MAP_FAILED;
} }
l = mmapped_areas->add_list (l, fd); l = mmapped_areas->add_list (l, fd);
} }
@ -597,9 +597,9 @@ munmap (caddr_t addr, size_t len)
{ {
mmap_record *rec = l->recs + li; mmap_record *rec = l->recs + li;
if (rec->unmap_map (addr, len)) if (rec->unmap_map (addr, len))
{ {
fhandler_base *fh = rec->alloc_fh (); fhandler_base *fh = rec->alloc_fh ();
fh->munmap (rec->get_handle (), addr, len); fh->munmap (rec->get_handle (), addr, len);
rec->free_fh (fh); rec->free_fh (fh);
/* Delete the entry. */ /* Delete the entry. */
@ -661,12 +661,12 @@ msync (caddr_t addr, size_t len, int flags)
if (rec->get_address () == addr) if (rec->get_address () == addr)
{ {
fhandler_base *fh = rec->alloc_fh (); 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); rec->free_fh (fh);
if (ret) if (ret)
syscall_printf ("%d = msync(): %E", ret); syscall_printf ("%d = msync(): %E", ret);
else else
syscall_printf ("0 = msync()"); syscall_printf ("0 = msync()");
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync"); ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
@ -698,7 +698,7 @@ msync (caddr_t addr, size_t len, int flags)
*/ */
HANDLE HANDLE
fhandler_base::mmap (caddr_t *addr, size_t len, DWORD access, fhandler_base::mmap (caddr_t *addr, size_t len, DWORD access,
int flags, off_t off) int flags, off_t off)
{ {
set_errno (ENODEV); set_errno (ENODEV);
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
@ -729,7 +729,7 @@ fhandler_base::fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
/* Implementation for disk files. */ /* Implementation for disk files. */
HANDLE HANDLE
fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access, fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access,
int flags, off_t off) int flags, off_t off)
{ {
DWORD protect; DWORD protect;
@ -751,12 +751,12 @@ fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access,
&& !(access & FILE_MAP_COPY)) && !(access & FILE_MAP_COPY))
{ {
/* Grrr, the whole stuff is just needed to try to get a reliable /* 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... */ proof but it does it's best... */
char namebuf[MAX_PATH]; char namebuf[MAX_PATH];
cygwin_conv_to_full_posix_path (get_name (), namebuf); cygwin_conv_to_full_posix_path (get_name (), namebuf);
for (int i = strlen (namebuf) - 1; i >= 0; --i) 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))) if (!(h = OpenFileMapping (access, TRUE, namebuf)))
h = CreateFileMapping (get_handle(), &sec_none, protect, 0, 0, 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, 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 || ((flags & MAP_FIXED) && base != *addr))
{ {
if (!base) if (!base)
{ {
__seterrno (); __seterrno ();
syscall_printf ("-1 = mmap(): MapViewOfFileEx failed with %E"); syscall_printf ("-1 = mmap(): MapViewOfFileEx failed with %E");
} }
else else
{ {
set_errno (EINVAL); 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); CloseHandle (h);
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} }
@ -906,10 +906,10 @@ fixup_mmaps_after_fork ()
fhandler_base *fh = rec->alloc_fh (); fhandler_base *fh = rec->alloc_fh ();
BOOL ret = fh->fixup_mmap_after_fork (rec->get_handle (), BOOL ret = fh->fixup_mmap_after_fork (rec->get_handle (),
rec->get_access (), rec->get_access (),
rec->get_offset (), rec->get_offset (),
rec->get_size (), rec->get_size (),
rec->get_address ()); rec->get_address ());
rec->free_fh (fh); rec->free_fh (fh);
if (!ret) if (!ret)

View File

@ -43,10 +43,10 @@ char * __stdcall
shared_name (const char *str, int num) shared_name (const char *str, int num)
{ {
static NO_COPY char buf[MAX_PATH] = {0}; 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); __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); strcat (buf, cygwin_version.dll_build_date);
return buf; return buf;
} }

View File

@ -348,7 +348,7 @@ _write (int fd, const void *ptr, size_t len)
fh = cygheap->fdtab[fd]; fh = cygheap->fdtab[fd];
res = fh->bg_check (SIGTTOU); 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) if (res > bg_eof)
{ {
myself->process_state |= PID_TTYOU; myself->process_state |= PID_TTYOU;