Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2005-03-01 14:51:29 +0300
committerCorinna Vinschen <corinna@vinschen.de>2005-03-01 14:51:29 +0300
commit4717214c201b6d54b7c58d1fedf6e88c5336f55c (patch)
treea744789ae843e8d73f7a0c2f78ba8862bca80104
parent93c60b6d6a34653d966a90f2bdb4fd6e28ed0a76 (diff)
* fhandler_clipboard.cc (fhandler_dev_clipboard::write): Never set
errno to 0. (fhandler_dev_clipboard::read): Ditto. * fhandler_windows.cc (fhandler_windows::read): Ditto. * scandir.cc (scandir): Ditto. * syscalls.cc (_fstat64_r): Ditto. (_fstat_r): Ditto. (_stat64_r): Ditto. (_stat_r): Ditto. * mmap.cc (mmap64): Fix /dev/zero mapping.
-rw-r--r--winsup/cygwin/ChangeLog14
-rw-r--r--winsup/cygwin/fhandler_clipboard.cc3
-rw-r--r--winsup/cygwin/fhandler_windows.cc2
-rw-r--r--winsup/cygwin/mmap.cc79
-rw-r--r--winsup/cygwin/net.cc3
-rw-r--r--winsup/cygwin/scandir.cc16
-rw-r--r--winsup/cygwin/syscalls.cc12
7 files changed, 65 insertions, 64 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 49093a524..0003aec05 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,17 @@
+2005-03-01 Corinna Vinschen <corinna@vinschen.de>
+
+ * fhandler_clipboard.cc (fhandler_dev_clipboard::write): Never set
+ errno to 0.
+ (fhandler_dev_clipboard::read): Ditto.
+ * fhandler_windows.cc (fhandler_windows::read): Ditto.
+ * scandir.cc (scandir): Ditto.
+ * syscalls.cc (_fstat64_r): Ditto.
+ (_fstat_r): Ditto.
+ (_stat64_r): Ditto.
+ (_stat_r): Ditto.
+
+ * mmap.cc (mmap64): Fix /dev/zero mapping.
+
2005-02-28 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Declare new method
diff --git a/winsup/cygwin/fhandler_clipboard.cc b/winsup/cygwin/fhandler_clipboard.cc
index c31442076..25ed1ddc9 100644
--- a/winsup/cygwin/fhandler_clipboard.cc
+++ b/winsup/cygwin/fhandler_clipboard.cc
@@ -174,7 +174,6 @@ fhandler_dev_clipboard::write (const void *buf, size_t len)
pos = msize;
- set_errno (0);
eof = false;
return len;
}
@@ -205,7 +204,6 @@ fhandler_dev_clipboard::read (void *ptr, size_t& len)
#if 0
system_printf ("a non-accepted format! %d", format);
#endif
- set_errno (0);
len = 0;
}
else
@@ -238,7 +236,6 @@ fhandler_dev_clipboard::read (void *ptr, size_t& len)
GlobalUnlock (hglb);
}
CloseClipboard ();
- set_errno (0);
len = ret;
}
}
diff --git a/winsup/cygwin/fhandler_windows.cc b/winsup/cygwin/fhandler_windows.cc
index 0fbba7120..a7848bc07 100644
--- a/winsup/cygwin/fhandler_windows.cc
+++ b/winsup/cygwin/fhandler_windows.cc
@@ -95,8 +95,6 @@ fhandler_windows::read (void *buf, size_t& len)
if ((ssize_t) len == -1)
__seterrno ();
- else
- set_errno (0);
return;
}
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index 36db16ce6..9a34ba4d2 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -538,24 +538,9 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
if (flags & MAP_ANONYMOUS)
fd = -1;
- /* 9x only: If MAP_FIXED is requested on a non-granularity boundary,
- change request so that this looks like a request with offset
- addr % granularity. */
- if (wincap.share_mmaps_only_by_name () && fd == -1 && (flags & MAP_FIXED)
- && ((DWORD)addr % granularity) && !off)
- off = (DWORD)addr % granularity;
- /* Map always in multipliers of `granularity'-sized chunks.
- Not necessary for anonymous maps on NT. */
- _off64_t gran_off = off;
- DWORD gran_len = len;
- if (wincap.share_mmaps_only_by_name () || fd != -1)
- {
- gran_off = off & ~(granularity - 1);
- gran_len = howmany (off + len, granularity) * granularity - gran_off;
- }
-
fhandler_base *fh;
+ /* Get fhandler and convert /dev/zero mapping to MAP_ANONYMOUS mapping. */
if (fd != -1)
{
/* Ensure that fd is open */
@@ -567,27 +552,8 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
return MAP_FAILED;
}
fh = cfd;
- if (fh->get_device () == FH_FS)
- {
- DWORD high;
- DWORD low = GetFileSize (fh->get_handle (), &high);
- _off64_t fsiz = ((_off64_t)high << 32) + low;
- /* Don't allow mappings beginning beyond EOF since Windows can't
- handle that POSIX like. FIXME: Still looking for a good idea
- to allow that nevertheless. */
- if (gran_off >= fsiz)
- {
- set_errno (ENXIO);
- ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK,
- "mmap");
- return MAP_FAILED;
- }
- fsiz -= gran_off;
- if (gran_len > fsiz)
- gran_len = fsiz;
- }
- else if (fh->get_device () == FH_ZERO)
- {
+ if (fh->get_device () == FH_ZERO)
+ {
/* mmap /dev/zero is like MAP_ANONYMOUS. */
fd = -1;
flags |= MAP_ANONYMOUS;
@@ -599,6 +565,45 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
fh = &fh_paging_file;
}
+ /* 9x only: If MAP_FIXED is requested on a non-granularity boundary,
+ change request so that this looks like a request with offset
+ addr % granularity. */
+ if (wincap.share_mmaps_only_by_name () && fd == -1 && (flags & MAP_FIXED)
+ && ((DWORD)addr % granularity) && !off)
+ off = (DWORD)addr % granularity;
+ /* Map always in multipliers of `granularity'-sized chunks.
+ Not necessary for anonymous maps on NT. */
+ _off64_t gran_off = off;
+ DWORD gran_len = len;
+ if (wincap.share_mmaps_only_by_name () || fd != -1)
+ {
+ gran_off = off & ~(granularity - 1);
+ gran_len = howmany (off + len, granularity) * granularity - gran_off;
+ }
+
+ /* File mappings needs some extra care. */
+ if (fd != -1 && fh->get_device () == FH_FS)
+ {
+ DWORD high;
+ DWORD low = GetFileSize (fh->get_handle (), &high);
+ _off64_t fsiz = ((_off64_t)high << 32) + low;
+ /* Don't allow mappings beginning beyond EOF since Windows can't
+ handle that POSIX like. FIXME: Still looking for a good idea
+ to allow that nevertheless. */
+ if (gran_off >= fsiz)
+ {
+ set_errno (ENXIO);
+ ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK,
+ "mmap");
+ return MAP_FAILED;
+ }
+ /* Don't map beyond EOF. Windows would change the file to the
+ new length otherwise, in contrast to POSIX. */
+ fsiz -= gran_off;
+ if (gran_len > fsiz)
+ gran_len = fsiz;
+ }
+
DWORD access = (prot & PROT_WRITE) ? FILE_MAP_WRITE : FILE_MAP_READ;
/* copy-on-write doesn't work at all on 9x using anonymous maps.
Workaround: Anonymous mappings always use normal READ or WRITE
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 472e97c3e..3fee9eb91 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -946,7 +946,6 @@ cygwin_gethostname (char *name, size_t len)
}
}
debug_printf ("name %s", name);
- h_errno = 0;
return 0;
}
@@ -996,7 +995,6 @@ cygwin_gethostbyname (const char *name)
else
{
debug_printf ("h_name %s", _my_tls.locals.hostent_buf->h_name);
- h_errno = 0;
}
return _my_tls.locals.hostent_buf;
}
@@ -1020,7 +1018,6 @@ cygwin_gethostbyaddr (const char *addr, int len, int type)
else
{
debug_printf ("h_name %s", _my_tls.locals.hostent_buf->h_name);
- h_errno = 0;
}
return _my_tls.locals.hostent_buf;
}
diff --git a/winsup/cygwin/scandir.cc b/winsup/cygwin/scandir.cc
index a2f682a50..84b6538a4 100644
--- a/winsup/cygwin/scandir.cc
+++ b/winsup/cygwin/scandir.cc
@@ -31,12 +31,11 @@ scandir (const char *dir,
struct dirent *ent, *etmp, **nl = NULL, **ntmp;
int count = 0;
int allocated = 0;
+ int err = 0;
if (!(dirp = opendir (dir)))
return -1;
- int prior_errno = get_errno ();
- set_errno (0);
if (!compar)
compar = alphasort;
@@ -44,10 +43,6 @@ scandir (const char *dir,
{
if (!select || select (ent))
{
-
- /* Ignore error from readdir/select. See POSIX specs. */
- set_errno (0);
-
if (count == allocated)
{
@@ -59,7 +54,7 @@ scandir (const char *dir,
ntmp = (struct dirent **) realloc (nl, allocated * sizeof *nl);
if (!ntmp)
{
- set_errno (ENOMEM);
+ err = ENOMEM;
break;
}
nl = ntmp;
@@ -67,7 +62,7 @@ scandir (const char *dir,
if (!(etmp = (struct dirent *) malloc (sizeof *ent)))
{
- set_errno (ENOMEM);
+ err = ENOMEM;
break;
}
*etmp = *ent;
@@ -75,7 +70,7 @@ scandir (const char *dir,
}
}
- if ((prior_errno = get_errno ()) != 0)
+ if (err != 0)
{
closedir (dirp);
if (nl)
@@ -85,12 +80,11 @@ scandir (const char *dir,
free (nl);
}
/* Ignore errors from closedir() and what not else. */
- set_errno (prior_errno);
+ set_errno (err);
return -1;
}
closedir (dirp);
- set_errno (prior_errno);
qsort (nl, count, sizeof *nl, (int (*)(const void *, const void *)) compar);
if (namelist)
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 8cd7368ec..4eda42bee 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -879,8 +879,7 @@ _fstat64_r (struct _reent *ptr, int fd, struct __stat64 *buf)
{
int ret;
- set_errno (0);
- if ((ret = fstat64 (fd, buf)) == -1 && get_errno () != 0)
+ if ((ret = fstat64 (fd, buf)) == -1)
ptr->_errno = get_errno ();
return ret;
}
@@ -900,8 +899,7 @@ _fstat_r (struct _reent *ptr, int fd, struct __stat32 *buf)
{
int ret;
- set_errno (0);
- if ((ret = fstat (fd, buf)) == -1 && get_errno () != 0)
+ if ((ret = fstat (fd, buf)) == -1)
ptr->_errno = get_errno ();
return ret;
}
@@ -1039,8 +1037,7 @@ _stat64_r (struct _reent *ptr, const char *name, struct __stat64 *buf)
{
int ret;
- set_errno (0);
- if ((ret = stat64 (name, buf)) == -1 && get_errno () != 0)
+ if ((ret = stat64 (name, buf)) == -1)
ptr->_errno = get_errno ();
return ret;
}
@@ -1060,8 +1057,7 @@ _stat_r (struct _reent *ptr, const char *name, struct __stat32 *buf)
{
int ret;
- set_errno (0);
- if ((ret = stat (name, buf)) == -1 && get_errno () != 0)
+ if ((ret = stat (name, buf)) == -1)
ptr->_errno = get_errno ();
return ret;
}