aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-08-07 00:01:42 +0000
committerChristopher Faylor <me@cgf.cx>2001-08-07 00:01:42 +0000
commit96a3f4ae6884bbf0c2e96d8ab332c3fad85613bf (patch)
tree68d8717111e5f046c192a1dd0f0dbd2481367f20 /winsup
parent386abb05d958a410c90cd4b7ea25187c7f6f1fbc (diff)
downloadnewlib-96a3f4ae6884bbf0c2e96d8ab332c3fad85613bf.zip
newlib-96a3f4ae6884bbf0c2e96d8ab332c3fad85613bf.tar.gz
newlib-96a3f4ae6884bbf0c2e96d8ab332c3fad85613bf.tar.bz2
* cygheap.cc (cygheap_root::set): Avoid treating '/' specially.
* fhandler.cc (fhandler_base::fcntl): Only set specific O_NDELAY style flag passed in from application. * fhandler_socket.cc (fhandler_socket::fcntl): Ditto. * fhandler.h: Set constant for future use. * winsup.h: Define OLD_O_NDELAY only for old programs. * include/cygwin/version.h: Define CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog12
-rw-r--r--winsup/cygwin/cygheap.cc9
-rw-r--r--winsup/cygwin/fhandler.cc17
-rw-r--r--winsup/cygwin/fhandler.h2
-rw-r--r--winsup/cygwin/fhandler_socket.cc23
-rw-r--r--winsup/cygwin/include/cygwin/version.h4
-rw-r--r--winsup/cygwin/net.cc4
-rw-r--r--winsup/cygwin/pipe.cc14
-rw-r--r--winsup/cygwin/winsup.h2
9 files changed, 57 insertions, 30 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 00e540d..bf1cda1 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,15 @@
+Mon Aug 6 19:58:43 2001 Christopher Faylor <cgf@cygnus.com>
+
+ * cygheap.cc (cygheap_root::set): Avoid treating '/' specially.
+
+ * fhandler.cc (fhandler_base::fcntl): Only set specific O_NDELAY style
+ flag passed in from application.
+ * fhandler_socket.cc (fhandler_socket::fcntl): Ditto.
+ * fhandler.h: Set constant for future use.
+ * winsup.h: Define OLD_O_NDELAY only for old programs.
+ * include/cygwin/version.h: Define
+ CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK.
+
Sat Aug 4 16:52:03 2001 Christopher Faylor <cgf@cygnus.com>
Throughout, change check for running under Windows NT to 'iswinnt'.
diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc
index d6caf33..f0efabf 100644
--- a/winsup/cygwin/cygheap.cc
+++ b/winsup/cygwin/cygheap.cc
@@ -330,6 +330,15 @@ cstrdup1 (const char *s)
void
cygheap_root::set (const char *posix, const char *native)
{
+ if (*posix == '/' && posix[1] == '\0')
+ {
+ if (m)
+ {
+ cfree (m);
+ m = NULL;
+ }
+ return;
+ }
if (!m)
m = (struct cygheap_root_mount_info *) ccalloc (HEAP_MOUNT, 1, sizeof (*m));
strcpy (m->posix_path, posix);
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index c6dbf93..ca912cb 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -18,6 +18,7 @@ details. */
#include "cygerrno.h"
#include "perprocess.h"
#include "security.h"
+#include "cygwin/version.h"
#include "fhandler.h"
#include "dtable.h"
#include "cygheap.h"
@@ -1084,15 +1085,13 @@ int fhandler_base::fcntl (int cmd, void *arg)
* ignored as well.
*/
const int allowed_flags = O_APPEND | O_NONBLOCK | OLD_O_NDELAY;
-
- /* Care for the old O_NDELAY flag. If one of the flags is set,
- both flags are set. */
- int new_flags = (int) arg;
- if (new_flags & (O_NONBLOCK | OLD_O_NDELAY))
- new_flags |= O_NONBLOCK | OLD_O_NDELAY;
-
- int flags = get_flags () & ~allowed_flags;
- set_flags (flags | (new_flags & allowed_flags));
+ int new_flags = (int) arg & allowed_flags;
+ /* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
+ Set only the flag that has been passed in. If both are set, just
+ record O_NONBLOCK. */
+ if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
+ new_flags = O_NONBLOCK;
+ set_flags ((get_flags () & ~allowed_flags) | new_flags);
}
res = 0;
break;
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index dc36c4e..4ff0bb3 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -57,7 +57,7 @@ enum
FH_WBINSET = 0x00010000, /* binary write mode has been explicitly set */
FH_APPEND = 0x00020000, /* always append */
FH_ASYNC = 0x00040000, /* async I/O */
- FH_HADEOF = 0x00080000, /* EOF seen */
+ FH_SIGCLOSE = 0x00080000, /* signal handler should close fd on interrupt */
FH_SYMLINK = 0x00100000, /* is a symlink */
FH_EXECABL = 0x00200000, /* file looked like it would run:
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 13cbe9f..185843b 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -24,6 +24,8 @@
#include <winsock2.h>
#include "cygerrno.h"
#include "security.h"
+#include "cygwin/version.h"
+#include "perprocess.h"
#include "fhandler.h"
#include "dtable.h"
#include "cygheap.h"
@@ -412,17 +414,18 @@ fhandler_socket::fcntl (int cmd, void *arg)
{
/* Care for the old O_NDELAY flag. If one of the flags is set,
both flags are set. */
- int new_flags = (int) arg;
- if (new_flags & (O_NONBLOCK | OLD_O_NDELAY))
- new_flags |= O_NONBLOCK | OLD_O_NDELAY;
- request = (new_flags & O_NONBLOCK) ? 1 : 0;
- current = (get_flags () & O_NONBLOCK) ? 1 : 0;
- if (request != current && (res = ioctl (FIONBIO, &request)))
+ const int allowed_flags = O_NONBLOCK | OLD_O_NDELAY;
+
+ /* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
+ Set only the flag that has been passed in. If both are set, just
+ record O_NONBLOCK. */
+ int new_flags = (int) arg & allowed_flags;
+ if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
+ new_flags = O_NONBLOCK;
+ current = get_flags () & allowed_flags;
+ if (!!current != !!new_flags && (res = ioctl (FIONBIO, &request)))
break;
- if (request)
- set_flags (get_flags () | O_NONBLOCK | OLD_O_NDELAY);
- else
- set_flags (get_flags () & ~(O_NONBLOCK | OLD_O_NDELAY));
+ set_flags ((get_flags () & ~allowed_flags) | new_flags);
break;
}
default:
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 5ca5719..84aba9a 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -82,6 +82,10 @@ details. */
#define CYGWIN_VERSION_CHECK_FOR_S_IEXEC \
(CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) >= \
36)
+
+#define CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK \
+ (CYGWIN_VERSION_DLL_MAKE_COMBINED (user_data->api_major, user_data->api_minor) <= \
+ 28)
/* We used to use the DLL major/minor to track
non-backward-compatible interface changes to the API. Now we
use an API major/minor number for this purpose. */
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index f9c6853..4bce7b1 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -904,9 +904,9 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
struct sockaddr_in peer_dummy;
int len_dummy;
if (!peer)
- peer = (struct sockaddr *) &peer_dummy;
+ peer = (struct sockaddr *) &peer_dummy;
if (!len)
- {
+ {
len_dummy = sizeof (struct sockaddr_in);
len = &len_dummy;
}
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index e111ba1..4f0bd54 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -1,6 +1,6 @@
/* pipe.cc: pipe for Cygwin.
- Copyright 1996, 1998, 1999, 2000 Cygnus Solutions.
+ Copyright 1996, 1998, 1999, 2000, 2001 Cygnus Solutions.
This file is part of Cygwin.
@@ -22,7 +22,7 @@ details. */
static int
make_pipe (int fildes[2], unsigned int psize, int mode)
{
- SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," make_pipe");
+ SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "make_pipe");
HANDLE r, w;
int fdr = -1, fdw = -1;
@@ -37,8 +37,8 @@ make_pipe (int fildes[2], unsigned int psize, int mode)
__seterrno ();
else
{
- fhandler_base *fhr = cygheap->fdtab.build_fhandler (fdr, FH_PIPER, "/dev/piper");
- fhandler_base *fhw = cygheap->fdtab.build_fhandler (fdw, FH_PIPEW, "/dev/pipew");
+ fhandler_pipe *fhr = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdr, FH_PIPER, "/dev/piper");
+ fhandler_pipe *fhw = (fhandler_pipe *) cygheap->fdtab.build_fhandler (fdw, FH_PIPEW, "/dev/pipew");
int binmode = mode & O_TEXT ? 0 : 1;
fhr->init (r, GENERIC_READ, binmode);
@@ -56,7 +56,7 @@ make_pipe (int fildes[2], unsigned int psize, int mode)
}
syscall_printf ("%d = make_pipe ([%d, %d], %d, %p)", res, fdr, fdw, psize, mode);
- ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," make_pipe");
+ ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "make_pipe");
return res;
}
@@ -81,11 +81,11 @@ int
dup (int fd)
{
int res;
- SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," dup");
+ SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup");
res = dup2 (fd, cygheap->fdtab.find_unused_handle ());
- ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," dup");
+ ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup");
return res;
}
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index dd932e8..f43d940 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -250,7 +250,7 @@ extern SYSTEM_INFO system_info;
/* newlib used to define O_NDELAY differently from O_NONBLOCK. Now it
properly defines both to be the same. Unfortunately, we have to
behave properly the old version, too, to accomodate older executables. */
-#define OLD_O_NDELAY 4
+#define OLD_O_NDELAY (CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK ? 4 : 0)
/* The title on program start. */
extern char *old_title;