This is the mail archive of the
cygwin-cvs@cygwin.com
mailing list for the Cygwin project.
[newlib-cygwin] Implement fhandler_dev_null::write to workaround a problem with NUL
- From: Corinna Vinschen <corinna at sourceware dot org>
- To: cygwin-cvs at sourceware dot org
- Date: 12 Mar 2017 11:18:00 -0000
- Subject: [newlib-cygwin] Implement fhandler_dev_null::write to workaround a problem with NUL
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=dd757cc43a710204046919da2cecf5f3b72ba33c
commit dd757cc43a710204046919da2cecf5f3b72ba33c
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Sun Mar 12 12:17:43 2017 +0100
Implement fhandler_dev_null::write to workaround a problem with NUL
Windows NUL device returns only the lower 32 bit of the number of
bytes written. Implement a fake write function to ignore the underlying
NUL device.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/fhandler.cc | 9 +++++++++
winsup/cygwin/fhandler.h | 2 ++
2 files changed, 11 insertions(+)
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index af33480..d719b7c 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1529,6 +1529,15 @@ fhandler_dev_null::fhandler_dev_null () :
{
}
+ssize_t __stdcall
+fhandler_dev_null::write (const void *ptr, size_t len)
+{
+ /* Shortcut. This also fixes a problem with the NUL device on 64 bit:
+ If you write > 4 GB in a single attempt, the bytes written returned
+ from by is numBytes & 0xffffffff. */
+ return len;
+}
+
void
fhandler_base::set_no_inheritance (HANDLE &h, bool not_inheriting)
{
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 14f7680..153e384 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1682,6 +1682,8 @@ class fhandler_dev_null: public fhandler_base
copyto (fh);
return fh;
}
+
+ ssize_t __stdcall write (const void *ptr, size_t len);
};
class fhandler_dev_zero: public fhandler_base