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:
authorChristopher Faylor <me@cgf.cx>2001-10-13 21:23:35 +0400
committerChristopher Faylor <me@cgf.cx>2001-10-13 21:23:35 +0400
commit0476bae576d4a21ed57cc55074509c07138d1fba (patch)
treedc30019ce3ba2d8eb84d34f3b650827bbf4fc999 /winsup/cygwin
parent5dec13e1793901735554fd4dd60cad64c9394bb5 (diff)
* fhandler_dsp.cc (fhandler_dsp::ioctl): Return 0 for successful
SNDCTL_DSP_GETBLKSIZE operation. Remove obsolete 'name' arg from fhandler_* constructors throughout. * winsup.h (winsock_active): New macro. (winsock2_active): Ditto. * autoload.cc (wsock_init): Use new macros to decide if winsock or winsock2 is loaded. (nonexist_wsock32): Dummy function to force winsock load. (nonexist_ws2_32): Dummy function to force winsock2 load. * fhandler.h (fhandler_socket::fstat): Declare new method. Currently unused. * fhandler_socket.cc (fhandler_socket::fixup_before_fork_exec): Check that winsock2 is active before trying WSADuplicateSocketA. (fhandler_socket::fixup_after_fork): Add extra check for winsock2_active. Otherwise use iffy procedures for Windows 95. (fhandler_socket::fixup_after_exec): Add debugging. (fhandler_socket::dup): Add debugging. (fhandler_socket::fstat): New method. (fhandler_socket::set_close_on_exec): Attempt to perform iffy stuff on Windows 95. * errno.cc (_sys_nerr): Work around compiler strangeness. * pinfo.cc (winpids::add): Add extra element at end of allocated array for setting to NULL. (winpids::enumNT): Ditto. (winpids::init): Don't modify pidlist if it hasn't been allocated (possibly due to malloc problem).
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog34
-rw-r--r--winsup/cygwin/autoload.cc5
-rw-r--r--winsup/cygwin/dtable.cc36
-rw-r--r--winsup/cygwin/errno.cc11
-rw-r--r--winsup/cygwin/fhandler.cc10
-rw-r--r--winsup/cygwin/fhandler.h50
-rw-r--r--winsup/cygwin/fhandler_clipboard.cc4
-rw-r--r--winsup/cygwin/fhandler_console.cc4
-rw-r--r--winsup/cygwin/fhandler_dsp.cc5
-rw-r--r--winsup/cygwin/fhandler_floppy.cc2
-rw-r--r--winsup/cygwin/fhandler_mem.cc5
-rw-r--r--winsup/cygwin/fhandler_random.cc6
-rw-r--r--winsup/cygwin/fhandler_raw.cc3
-rw-r--r--winsup/cygwin/fhandler_serial.cc4
-rw-r--r--winsup/cygwin/fhandler_socket.cc90
-rw-r--r--winsup/cygwin/fhandler_tape.cc3
-rw-r--r--winsup/cygwin/fhandler_tty.cc16
-rw-r--r--winsup/cygwin/fhandler_windows.cc4
-rw-r--r--winsup/cygwin/fhandler_zero.cc4
-rw-r--r--winsup/cygwin/mmap.cc2
-rw-r--r--winsup/cygwin/net.cc3
-rw-r--r--winsup/cygwin/path.cc4
-rw-r--r--winsup/cygwin/pinfo.cc9
-rw-r--r--winsup/cygwin/pipe.cc5
-rw-r--r--winsup/cygwin/winsup.h4
25 files changed, 188 insertions, 135 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 91562c327..41d490d8e 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,37 @@
+2001-10-13 Ralf Habacker <Ralf.Habacker@freenet.de>
+
+ * fhandler_dsp.cc (fhandler_dsp::ioctl): Return 0 for successful
+ SNDCTL_DSP_GETBLKSIZE operation.
+
+2001-10-13 Christopher Faylor <cgf@redhat.com>
+
+ Remove obsolete 'name' arg from fhandler_* constructors throughout.
+ * winsup.h (winsock_active): New macro.
+ (winsock2_active): Ditto.
+ * autoload.cc (wsock_init): Use new macros to decide if winsock or
+ winsock2 is loaded.
+ (nonexist_wsock32): Dummy function to force winsock load.
+ (nonexist_ws2_32): Dummy function to force winsock2 load.
+ * fhandler.h (fhandler_socket::fstat): Declare new method. Currently
+ unused.
+ * fhandler_socket.cc (fhandler_socket::fixup_before_fork_exec): Check
+ that winsock2 is active before trying WSADuplicateSocketA.
+ (fhandler_socket::fixup_after_fork): Add extra check for
+ winsock2_active. Otherwise use iffy procedures for Windows 95.
+ (fhandler_socket::fixup_after_exec): Add debugging.
+ (fhandler_socket::dup): Add debugging.
+ (fhandler_socket::fstat): New method.
+ (fhandler_socket::set_close_on_exec): Attempt to perform iffy stuff on
+ Windows 95.
+
+ * errno.cc (_sys_nerr): Work around compiler strangeness.
+
+ * pinfo.cc (winpids::add): Add extra element at end of allocated array
+ for setting to NULL.
+ (winpids::enumNT): Ditto.
+ (winpids::init): Don't modify pidlist if it hasn't been allocated
+ (possibly due to malloc problem).
+
2001-10-12 Christopher Faylor <cgf@redhat.com>
* autoload.cc (wsock_init): Reorganize slightly to accomodate a new
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index 5ae8e1c5a..bf8c61252 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -241,7 +241,6 @@ static long long
wsock_init ()
{
static LONG NO_COPY here = -1L;
- extern WSADATA wsadata;
struct func_info *func = (struct func_info *) __builtin_return_address (0);
struct dll_info *dll = func->dll;
@@ -261,7 +260,7 @@ wsock_init ()
Sleep (0);
}
- if (!wsock_started && (wsock32_handle || ws2_32_handle))
+ if (!wsock_started && (winsock_active || winsock2_active))
{
/* Don't use autoload to load WSAStartup to eliminate recursion. */
int (*wsastartup) (int, WSADATA *);
@@ -421,7 +420,7 @@ LoadDLLfunc (WSAAsyncSelect, 16, wsock32)
LoadDLLfunc (WSACleanup, 0, wsock32)
LoadDLLfunc (WSAGetLastError, 0, wsock32)
LoadDLLfunc (WSASetLastError, 4, wsock32)
-LoadDLLfunc (WSAStartup, 8, wsock32)
+// LoadDLLfunc (WSAStartup, 8, wsock32)
LoadDLLfunc (__WSAFDIsSet, 8, wsock32)
LoadDLLfunc (accept, 12, wsock32)
LoadDLLfunc (bind, 12, wsock32)
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index faca5356b..694a7cd84 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -265,63 +265,63 @@ dtable::build_fhandler (int fd, DWORD dev, const char *name, int unit)
switch (dev)
{
case FH_TTYM:
- fh = cnew (fhandler_tty_master) (name, unit);
+ fh = cnew (fhandler_tty_master) (unit);
break;
case FH_CONSOLE:
case FH_CONIN:
case FH_CONOUT:
- fh = cnew (fhandler_console) (name);
+ fh = cnew (fhandler_console) ();
inc_console_fds ();
break;
case FH_PTYM:
- fh = cnew (fhandler_pty_master) (name);
+ fh = cnew (fhandler_pty_master) ();
break;
case FH_TTYS:
if (unit < 0)
- fh = cnew (fhandler_tty_slave) (name);
+ fh = cnew (fhandler_tty_slave) ();
else
- fh = cnew (fhandler_tty_slave) (unit, name);
+ fh = cnew (fhandler_tty_slave) (unit);
break;
case FH_WINDOWS:
- fh = cnew (fhandler_windows) (name);
+ fh = cnew (fhandler_windows) ();
break;
case FH_SERIAL:
- fh = cnew (fhandler_serial) (name, dev, unit);
+ fh = cnew (fhandler_serial) (unit);
break;
case FH_PIPE:
case FH_PIPER:
case FH_PIPEW:
- fh = cnew (fhandler_pipe) (name, dev);
+ fh = cnew (fhandler_pipe) ();
break;
case FH_SOCKET:
- fh = cnew (fhandler_socket) (name);
+ fh = cnew (fhandler_socket) ();
break;
case FH_DISK:
- fh = cnew (fhandler_disk_file) (NULL);
+ fh = cnew (fhandler_disk_file) ();
break;
case FH_FLOPPY:
- fh = cnew (fhandler_dev_floppy) (name, unit);
+ fh = cnew (fhandler_dev_floppy) (unit);
break;
case FH_TAPE:
- fh = cnew (fhandler_dev_tape) (name, unit);
+ fh = cnew (fhandler_dev_tape) (unit);
break;
case FH_NULL:
- fh = cnew (fhandler_dev_null) (name);
+ fh = cnew (fhandler_dev_null) ();
break;
case FH_ZERO:
- fh = cnew (fhandler_dev_zero) (name);
+ fh = cnew (fhandler_dev_zero) ();
break;
case FH_RANDOM:
- fh = cnew (fhandler_dev_random) (name, unit);
+ fh = cnew (fhandler_dev_random) (unit);
break;
case FH_MEM:
- fh = cnew (fhandler_dev_mem) (name, unit);
+ fh = cnew (fhandler_dev_mem) (unit);
break;
case FH_CLIPBOARD:
- fh = cnew (fhandler_dev_clipboard) (name);
+ fh = cnew (fhandler_dev_clipboard) ();
break;
case FH_OSS_DSP:
- fh = cnew (fhandler_dev_dsp) (name);
+ fh = cnew (fhandler_dev_dsp) ();
break;
default:
{
diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc
index 540951c56..0643647b2 100644
--- a/winsup/cygwin/errno.cc
+++ b/winsup/cygwin/errno.cc
@@ -8,12 +8,16 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#define _sys_nerr FOO_sys_nerr
+#define sys_nerr FOOsys_nerr
#include "winsup.h"
#define _REENT_ONLY
#include <stdio.h>
#include <errno.h>
#include "cygerrno.h"
#include "thread.h"
+#undef _sys_nerr
+#undef sys_nerr
/* Table to map Windows error codes to Errno values. */
/* FIXME: Doing things this way is a little slow. It's trivial to change
@@ -145,7 +149,8 @@ seterrno (const char *file, int line)
extern char *_user_strerror _PARAMS ((int));
-extern const NO_COPY char __declspec(dllexport) * const _sys_errlist[]=
+extern "C" {
+const NO_COPY char __declspec(dllexport) * const _sys_errlist[]=
{
/* NOERROR 0 */ "No error",
/* EPERM 1 */ "Not super-user",
@@ -287,8 +292,8 @@ extern const NO_COPY char __declspec(dllexport) * const _sys_errlist[]=
/* ECASECLASH 137 */ "Filename exists with different case"
};
-int NO_COPY __declspec(dllexport) _sys_nerr =
- sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);
+extern int const NO_COPY __declspec(dllexport) _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);
+};
/* FIXME: Why is strerror() a long switch and not just:
return sys_errlist[errnum];
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 07a235c12..bb0089df6 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1329,7 +1329,7 @@ fhandler_base::operator delete (void *p)
}
/* Normal I/O constructor */
-fhandler_base::fhandler_base (DWORD devtype, const char *name, int unit):
+fhandler_base::fhandler_base (DWORD devtype, int unit):
access (0),
io_handle (NULL),
namehash (0),
@@ -1369,8 +1369,8 @@ fhandler_base::~fhandler_base (void)
/**********************************************************************/
/* fhandler_disk_file */
-fhandler_disk_file::fhandler_disk_file (const char *name) :
- fhandler_base (FH_DISK, name)
+fhandler_disk_file::fhandler_disk_file () :
+ fhandler_base (FH_DISK)
{
set_cb (sizeof *this);
}
@@ -1598,8 +1598,8 @@ fhandler_disk_file::lock (int cmd, struct flock *fl)
/**********************************************************************/
/* /dev/null */
-fhandler_dev_null::fhandler_dev_null (const char *name) :
- fhandler_base (FH_NULL, name)
+fhandler_dev_null::fhandler_dev_null () :
+ fhandler_base (FH_NULL)
{
set_cb (sizeof *this);
}
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index d1ebe0a7f..4b19af296 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -188,7 +188,7 @@ public:
void reset_unix_path_name (const char *);
virtual fhandler_base& operator =(fhandler_base &x);
- fhandler_base (DWORD dev, const char *name = 0, int unit = 0);
+ fhandler_base (DWORD dev, int unit = 0);
virtual ~fhandler_base ();
/* Non-virtual simple accessor functions. */
@@ -385,7 +385,7 @@ private:
struct _WSAPROTOCOL_INFOA *prot_info_ptr;
public:
- fhandler_socket (const char *name = 0);
+ fhandler_socket ();
~fhandler_socket ();
int get_socket () { return (int) get_handle(); }
fhandler_socket * is_socket () { return this; }
@@ -422,6 +422,7 @@ public:
int check_peer_secret_event (struct sockaddr_in *peer, int *secret = NULL);
void signal_secret_event ();
void close_secret_event ();
+ int __stdcall fstat (struct stat *buf, path_conv *) __attribute__ ((regparm (2)));
};
class fhandler_pipe: public fhandler_base
@@ -431,7 +432,7 @@ class fhandler_pipe: public fhandler_base
DWORD orig_pid;
unsigned id;
public:
- fhandler_pipe (const char *name = 0, DWORD devtype = FH_PIPE);
+ fhandler_pipe (DWORD devtype = FH_PIPE);
off_t lseek (off_t offset, int whence);
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
@@ -470,7 +471,7 @@ protected:
/* returns not null, if `win_error' determines an end of file condition */
virtual int is_eof(int win_error) = 0;
- fhandler_dev_raw (DWORD dev, const char *name, int unit);
+ fhandler_dev_raw (DWORD dev, int unit);
public:
~fhandler_dev_raw (void);
@@ -498,7 +499,7 @@ protected:
virtual int is_eof (int win_error);
public:
- fhandler_dev_floppy (const char *name, int unit);
+ fhandler_dev_floppy (int unit);
virtual int open (path_conv *, int flags, mode_t mode = 0);
virtual int close (void);
@@ -520,7 +521,7 @@ protected:
virtual int is_eof (int win_error);
public:
- fhandler_dev_tape (const char *name, int unit);
+ fhandler_dev_tape (int unit);
int open (path_conv *, int flags, mode_t mode = 0);
int close (void);
@@ -551,7 +552,7 @@ private:
class fhandler_disk_file: public fhandler_base
{
public:
- fhandler_disk_file (const char *name);
+ fhandler_disk_file ();
int open (path_conv * real_path, int flags, mode_t mode);
int close ();
@@ -579,7 +580,7 @@ public:
OVERLAPPED io_status;
/* Constructor */
- fhandler_serial (const char *name, DWORD devtype = FH_SERIAL, int unit = 0);
+ fhandler_serial (DWORD devtype = FH_SERIAL, int unit = 0);
int open (path_conv *, int flags, mode_t mode);
int close ();
@@ -627,8 +628,8 @@ protected:
virtual int accept_input () {return 1;};
public:
tty_min *tc;
- fhandler_termios (DWORD dev, const char *name = 0, int unit = 0) :
- fhandler_base (dev, name, unit)
+ fhandler_termios (DWORD dev, int unit = 0) :
+ fhandler_base (dev, unit)
{
set_need_fork_fixup ();
}
@@ -740,7 +741,7 @@ private:
public:
- fhandler_console (const char *name);
+ fhandler_console ();
fhandler_console* is_console () { return this; }
@@ -775,9 +776,8 @@ public:
class fhandler_tty_common: public fhandler_termios
{
public:
- fhandler_tty_common (DWORD dev, const char *name = 0, int unit = 0) :
- fhandler_termios (dev, name, unit),
- ttynum (unit)
+ fhandler_tty_common (DWORD dev, int unit = 0)
+ : fhandler_termios (dev, unit), ttynum (unit)
{
// nothing to do
}
@@ -814,8 +814,8 @@ class fhandler_tty_slave: public fhandler_tty_common
{
public:
/* Constructor */
- fhandler_tty_slave (const char *name);
- fhandler_tty_slave (int, const char *name);
+ fhandler_tty_slave ();
+ fhandler_tty_slave (int);
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
@@ -839,7 +839,7 @@ public:
int need_nl; // Next read should start with \n
/* Constructor */
- fhandler_pty_master (const char *name, DWORD devtype = FH_PTYM, int unit = -1);
+ fhandler_pty_master (DWORD devtype = FH_PTYM, int unit = -1);
int process_slave_output (char *buf, size_t len, int pktmode_on);
void doecho (const void *str, DWORD len);
@@ -865,7 +865,7 @@ class fhandler_tty_master: public fhandler_pty_master
{
public:
/* Constructor */
- fhandler_tty_master (const char *name, int unit);
+ fhandler_tty_master (int unit);
fhandler_console *console; // device handler to perform real i/o.
HANDLE hThread; // process_output thread handle.
@@ -878,7 +878,7 @@ public:
class fhandler_dev_null: public fhandler_base
{
public:
- fhandler_dev_null (const char *name);
+ fhandler_dev_null ();
void dump ();
select_record *select_read (select_record *s);
@@ -889,7 +889,7 @@ public:
class fhandler_dev_zero: public fhandler_base
{
public:
- fhandler_dev_zero (const char *name);
+ fhandler_dev_zero ();
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (2)));
@@ -911,7 +911,7 @@ protected:
int pseudo_read (void *ptr, size_t len);
public:
- fhandler_dev_random (const char *name, int unit);
+ fhandler_dev_random (int unit);
int get_unit () { return unit; }
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
@@ -931,7 +931,7 @@ protected:
DWORD pos;
public:
- fhandler_dev_mem (const char *name, int unit);
+ fhandler_dev_mem (int unit);
~fhandler_dev_mem (void);
int open (path_conv *, int flags, mode_t mode = 0);
@@ -954,7 +954,7 @@ public:
class fhandler_dev_clipboard: public fhandler_base
{
public:
- fhandler_dev_clipboard (const char *name);
+ fhandler_dev_clipboard ();
int is_windows (void) { return 1; }
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
@@ -979,7 +979,7 @@ private:
HWND hWnd_; // the window whose messages are to be retrieved by read() call
int method_; // write method (Post or Send)
public:
- fhandler_windows (const char *name = 0);
+ fhandler_windows ();
int is_windows (void) { return 1; }
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
@@ -1005,7 +1005,7 @@ private:
int audiochannels_;
bool setupwav(const char *pData, int nBytes);
public:
- fhandler_dev_dsp (const char *name = 0);
+ fhandler_dev_dsp ();
~fhandler_dev_dsp();
int open (path_conv *, int flags, mode_t mode = 0);
diff --git a/winsup/cygwin/fhandler_clipboard.cc b/winsup/cygwin/fhandler_clipboard.cc
index 489dd7fa5..59bd9660c 100644
--- a/winsup/cygwin/fhandler_clipboard.cc
+++ b/winsup/cygwin/fhandler_clipboard.cc
@@ -32,8 +32,8 @@ static const NO_COPY char *CYGWIN_NATIVE = "CYGWIN_NATIVE_CLIPBOARD";
/* this is MT safe because windows format id's are atomic */
static UINT cygnativeformat;
-fhandler_dev_clipboard::fhandler_dev_clipboard (const char *name):
-fhandler_base (FH_CLIPBOARD, name)
+fhandler_dev_clipboard::fhandler_dev_clipboard ():
+fhandler_base (FH_CLIPBOARD)
{
set_cb (sizeof *this);
eof = true;
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index d9f8cac99..b03f8d130 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -862,8 +862,8 @@ fhandler_console::tcgetattr (struct termios *t)
* Constructor.
*/
-fhandler_console::fhandler_console (const char *name) :
- fhandler_termios (FH_CONSOLE, name, -1)
+fhandler_console::fhandler_console () :
+ fhandler_termios (FH_CONSOLE, -1)
{
set_cb (sizeof *this);
default_color = dim_color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc
index 601bcbe4f..e7f977618 100644
--- a/winsup/cygwin/fhandler_dsp.cc
+++ b/winsup/cygwin/fhandler_dsp.cc
@@ -420,8 +420,8 @@ fhandler_dev_dsp::setupwav (const char *pData, int nBytes)
}
//------------------------------------------------------------------------
-fhandler_dev_dsp::fhandler_dev_dsp (const char *name):
- fhandler_base (FH_OSS_DSP, name)
+fhandler_dev_dsp::fhandler_dev_dsp ():
+ fhandler_base (FH_OSS_DSP)
{
set_cb (sizeof *this);
}
@@ -526,6 +526,7 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
CASE (SNDCTL_DSP_GETBLKSIZE)
*intptr = Audio::BLOCK_SIZE;
+ return 0;
break;
CASE (SNDCTL_DSP_SETFMT)
diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc
index 3c351db5f..68e9d783d 100644
--- a/winsup/cygwin/fhandler_floppy.cc
+++ b/winsup/cygwin/fhandler_floppy.cc
@@ -40,7 +40,7 @@ fhandler_dev_floppy::is_eof (int)
return ret;
}
-fhandler_dev_floppy::fhandler_dev_floppy (const char *name, int unit) : fhandler_dev_raw (FH_FLOPPY, name, unit)
+fhandler_dev_floppy::fhandler_dev_floppy (int unit) : fhandler_dev_raw (FH_FLOPPY, unit)
{
set_cb (sizeof *this);
}
diff --git a/winsup/cygwin/fhandler_mem.cc b/winsup/cygwin/fhandler_mem.cc
index 7a839e99d..84c48cc32 100644
--- a/winsup/cygwin/fhandler_mem.cc
+++ b/winsup/cygwin/fhandler_mem.cc
@@ -23,9 +23,8 @@
/**********************************************************************/
/* fhandler_dev_mem */
-fhandler_dev_mem::fhandler_dev_mem (const char *name, int nunit)
-: fhandler_base (FH_MEM, name),
- unit (nunit)
+fhandler_dev_mem::fhandler_dev_mem (int nunit)
+ : fhandler_base (FH_MEM), unit (nunit)
{
/* Reading physical memory only supported on NT/W2K. */
if (!wincap.has_physical_mem_access ())
diff --git a/winsup/cygwin/fhandler_random.cc b/winsup/cygwin/fhandler_random.cc
index b6c9e1a3d..a933c8140 100644
--- a/winsup/cygwin/fhandler_random.cc
+++ b/winsup/cygwin/fhandler_random.cc
@@ -23,10 +23,8 @@ details. */
#define PSEUDO_MULTIPLIER (6364136223846793005LL)
#define PSEUDO_SHIFTVAL (21)
-fhandler_dev_random::fhandler_dev_random (const char *name, int nunit)
- : fhandler_base (FH_RANDOM, name),
- unit(nunit),
- crypt_prov((HCRYPTPROV)NULL)
+fhandler_dev_random::fhandler_dev_random (int nunit)
+ : fhandler_base (FH_RANDOM), unit(nunit), crypt_prov((HCRYPTPROV)NULL)
{
set_cb (sizeof *this);
}
diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc
index f487ddd3b..a31e73904 100644
--- a/winsup/cygwin/fhandler_raw.cc
+++ b/winsup/cygwin/fhandler_raw.cc
@@ -116,7 +116,8 @@ fhandler_dev_raw::writebuf (void)
return ret;
}
-fhandler_dev_raw::fhandler_dev_raw (DWORD devtype, const char *name, int unit) : fhandler_base (devtype, name)
+fhandler_dev_raw::fhandler_dev_raw (DWORD devtype, int unit)
+ : fhandler_base (devtype)
{
clear ();
this->unit = unit;
diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc
index c60ef996a..3eedd1428 100644
--- a/winsup/cygwin/fhandler_serial.cc
+++ b/winsup/cygwin/fhandler_serial.cc
@@ -24,8 +24,8 @@ details. */
/**********************************************************************/
/* fhandler_serial */
-fhandler_serial::fhandler_serial (const char *name, DWORD devtype, int unit) :
- fhandler_base (devtype, name, unit)
+fhandler_serial::fhandler_serial (DWORD devtype, int unit) :
+ fhandler_base (devtype, unit)
{
set_cb (sizeof *this);
vmin_ = 0;
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 4711189c0..6c92d1e02 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -41,8 +41,8 @@ fhandler_dev_random* entropy_source;
/**********************************************************************/
/* fhandler_socket */
-fhandler_socket::fhandler_socket (const char *name) :
- fhandler_base (FH_SOCKET, name)
+fhandler_socket::fhandler_socket () :
+ fhandler_base (FH_SOCKET)
{
set_cb (sizeof *this);
set_need_fork_fixup ();
@@ -62,8 +62,7 @@ fhandler_socket::set_connect_secret ()
if (!entropy_source)
{
void *buf = malloc (sizeof (fhandler_dev_random));
- entropy_source = new (buf) fhandler_dev_random (ENTROPY_SOURCE_NAME,
- ENTROPY_SOURCE_DEV_UNIT);
+ entropy_source = new (buf) fhandler_dev_random (ENTROPY_SOURCE_DEV_UNIT);
}
if (entropy_source &&
!entropy_source->open (NULL, O_RDONLY))
@@ -115,8 +114,13 @@ fhandler_socket::create_secret_event (int* secret)
void
fhandler_socket::signal_secret_event ()
{
- if (secret_event)
- SetEvent (secret_event);
+ if (!secret_event)
+ debug_printf ("no secret event?");
+ else
+ {
+ SetEvent (secret_event);
+ debug_printf ("signaled secret_event");
+ }
}
void
@@ -160,54 +164,48 @@ fhandler_socket::check_peer_secret_event (struct sockaddr_in* peer, int* secret)
void
fhandler_socket::fixup_before_fork_exec (DWORD win_proc_id)
{
- int ret = 1;
-
- if (prot_info_ptr &&
- (ret = WSADuplicateSocketA (get_socket (), win_proc_id, prot_info_ptr)))
+ if (!winsock2_active)
{
- debug_printf ("WSADuplicateSocket error");
- set_winsock_errno ();
- }
- if (!ret && ws2_32_handle)
- {
- debug_printf ("WSADuplicateSocket went fine, dwServiceFlags1=%d",
- prot_info_ptr->dwServiceFlags1);
+ fhandler_base::fixup_before_fork_exec (win_proc_id);
+ debug_printf ("Without Winsock 2.0");
}
+ else if (!WSADuplicateSocketA (get_socket (), win_proc_id, prot_info_ptr))
+ debug_printf ("WSADuplicateSocket went fine, dwServiceFlags1=%d",
+ prot_info_ptr->dwServiceFlags1);
else
{
- fhandler_base::fixup_before_fork_exec (win_proc_id);
- debug_printf ("Without Winsock 2.0");
+ debug_printf ("WSADuplicateSocket error");
+ set_winsock_errno ();
}
}
void
fhandler_socket::fixup_after_fork (HANDLE parent)
{
- SOCKET new_sock = INVALID_SOCKET;
+ SOCKET new_sock;
debug_printf ("WSASocket begin, dwServiceFlags1=%d",
prot_info_ptr->dwServiceFlags1);
- if (prot_info_ptr &&
- (new_sock = WSASocketA (FROM_PROTOCOL_INFO,
- FROM_PROTOCOL_INFO,
- FROM_PROTOCOL_INFO,
- prot_info_ptr, 0, 0)) == INVALID_SOCKET)
+
+ if ((new_sock = WSASocketA (FROM_PROTOCOL_INFO,
+ FROM_PROTOCOL_INFO,
+ FROM_PROTOCOL_INFO,
+ prot_info_ptr, 0, 0)) == INVALID_SOCKET)
{
debug_printf ("WSASocket error");
set_winsock_errno ();
}
- if (new_sock != INVALID_SOCKET && ws2_32_handle)
+ else if (!new_sock && !winsock2_active)
{
- debug_printf ("WSASocket went fine %p", new_sock);
- set_io_handle ((HANDLE) new_sock);
+ fhandler_base::fixup_after_fork (parent);
+ debug_printf ("Without Winsock 2.0");
}
else
{
-#if 0
- fhandler_base::fixup_after_fork (parent);
-#endif
- debug_printf ("Without Winsock 2.0");
+ debug_printf ("WSASocket went fine %p", new_sock);
+ set_io_handle ((HANDLE) new_sock);
}
+
if (secret_event)
fork_fixup (parent, secret_event, "secret_event");
}
@@ -215,21 +213,24 @@ fhandler_socket::fixup_after_fork (HANDLE parent)
void
fhandler_socket::fixup_after_exec (HANDLE parent)
{
- extern WSADATA wsadata;
+ debug_printf ("here");
if (!get_close_on_exec ())
fixup_after_fork (parent);
- else if (wsadata.wVersion < 512) /* < Winsock 2.0 */
+#if 0
+ else if (!winsock2_active)
closesocket (get_socket ());
+#endif
}
int
fhandler_socket::dup (fhandler_base *child)
{
+ debug_printf ("here");
fhandler_socket *fhs = (fhandler_socket *) child;
fhs->addr_family = addr_family;
fhs->set_io_handle (get_io_handle ());
fhs->fixup_before_fork_exec (GetCurrentProcessId ());
- if (ws2_32_handle)
+ if (winsock2_active)
{
fhs->fixup_after_fork (hMainProc);
return 0;
@@ -237,15 +238,21 @@ fhandler_socket::dup (fhandler_base *child)
return fhandler_base::dup (child);
}
+int __stdcall
+fhandler_socket::fstat (struct stat *buf, path_conv *pc)
+{
+ fhandler_disk_file fh;
+ fh.set_name (get_name (), get_win32_name ());
+ return fh.fstat (buf, pc);
+}
+
int
fhandler_socket::read (void *ptr, size_t len)
{
sigframe thisframe (mainthread);
int res = recv (get_socket (), (char *) ptr, len, 0);
if (res == SOCKET_ERROR)
- {
- set_winsock_errno ();
- }
+ set_winsock_errno ();
return res;
}
@@ -414,7 +421,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
if (cmd == FIONBIO)
{
syscall_printf ("socket is now %sblocking",
- *(int *) p ? "un" : "");
+ *(int *) p ? "non" : "");
/* Start AsyncSelect if async socket unblocked */
if (*(int *) p && get_async ())
WSAAsyncSelect (get_socket (), gethwnd (), WM_ASYNCIO, ASYNC_MASK);
@@ -460,11 +467,8 @@ fhandler_socket::fcntl (int cmd, void *arg)
void
fhandler_socket::set_close_on_exec (int val)
{
-#if 0
- extern WSADATA wsadata;
- if (wsadata.wVersion < 512) /* < Winsock 2.0 */
+ if (!winsock2_active) /* < Winsock 2.0 */
set_inheritance (get_handle (), val);
-#endif
set_close_on_exec_flag (val);
debug_printf ("set close_on_exec for %s to %d", get_name (), val);
}
diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc
index a2bf46b8e..2aabcf9be 100644
--- a/winsup/cygwin/fhandler_tape.cc
+++ b/winsup/cygwin/fhandler_tape.cc
@@ -55,7 +55,8 @@ fhandler_dev_tape::is_eof (int win_error)
return ret;
}
-fhandler_dev_tape::fhandler_dev_tape (const char *name, int unit) : fhandler_dev_raw (FH_TAPE, name, unit)
+fhandler_dev_tape::fhandler_dev_tape (int unit)
+ : fhandler_dev_raw (FH_TAPE, unit)
{
set_cb (sizeof *this);
}
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 0c1cf5c42..5b40f0470 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -35,8 +35,8 @@ static DWORD WINAPI process_input (void *); // Input queue thread
static DWORD WINAPI process_output (void *); // Output queue thread
static DWORD WINAPI process_ioctl (void *); // Ioctl requests thread
-fhandler_tty_master::fhandler_tty_master (const char *name, int unit) :
- fhandler_pty_master (name, FH_TTYM, unit)
+fhandler_tty_master::fhandler_tty_master (int unit) :
+ fhandler_pty_master (FH_TTYM, unit)
{
set_cb (sizeof *this);
console = NULL;
@@ -437,8 +437,8 @@ process_ioctl (void *)
/**********************************************************************/
/* Tty slave stuff */
-fhandler_tty_slave::fhandler_tty_slave (int num, const char *name) :
- fhandler_tty_common (FH_TTYS, name, num)
+fhandler_tty_slave::fhandler_tty_slave (int num)
+ : fhandler_tty_common (FH_TTYS, num)
{
set_cb (sizeof *this);
ttynum = num;
@@ -446,8 +446,8 @@ fhandler_tty_slave::fhandler_tty_slave (int num, const char *name) :
inuse = NULL;
}
-fhandler_tty_slave::fhandler_tty_slave (const char *name) :
- fhandler_tty_common (FH_TTYS, name, 0)
+fhandler_tty_slave::fhandler_tty_slave ()
+ : fhandler_tty_common (FH_TTYS, 0)
{
set_cb (sizeof *this);
inuse = NULL;
@@ -950,8 +950,8 @@ out:
/*******************************************************
fhandler_pty_master
*/
-fhandler_pty_master::fhandler_pty_master (const char *name, DWORD devtype, int unit) :
- fhandler_tty_common (devtype, name, unit)
+fhandler_pty_master::fhandler_pty_master (DWORD devtype, int unit)
+ : fhandler_tty_common (devtype, unit)
{
set_cb (sizeof *this);
ioctl_request_event = NULL;
diff --git a/winsup/cygwin/fhandler_windows.cc b/winsup/cygwin/fhandler_windows.cc
index 61499b68e..4139a8020 100644
--- a/winsup/cygwin/fhandler_windows.cc
+++ b/winsup/cygwin/fhandler_windows.cc
@@ -46,8 +46,8 @@ The following unix-style calls are supported:
select () call marks read fd when any message posted to queue.
*/
-fhandler_windows::fhandler_windows (const char *name) :
- fhandler_base (FH_WINDOWS, name)
+fhandler_windows::fhandler_windows ()
+ : fhandler_base (FH_WINDOWS)
{
set_cb (sizeof *this);
hWnd_ = NULL;
diff --git a/winsup/cygwin/fhandler_zero.cc b/winsup/cygwin/fhandler_zero.cc
index 874dde031..3bca47a03 100644
--- a/winsup/cygwin/fhandler_zero.cc
+++ b/winsup/cygwin/fhandler_zero.cc
@@ -15,8 +15,8 @@ details. */
#include "security.h"
#include "fhandler.h"
-fhandler_dev_zero::fhandler_dev_zero (const char *name)
- : fhandler_base (FH_ZERO, name)
+fhandler_dev_zero::fhandler_dev_zero ()
+ : fhandler_base (FH_ZERO)
{
set_cb (sizeof *this);
}
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index c13a3f365..1163585e9 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -217,7 +217,7 @@ mmap_record::fixup_map ()
&old_prot);
}
-static fhandler_disk_file fh_paging_file (NULL);
+static fhandler_disk_file fh_paging_file;
fhandler_base *
mmap_record::alloc_fh ()
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 94b37c3d8..e14814c69 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -506,12 +506,15 @@ cygwin_getprotobynumber (int number)
fhandler_socket *
fdsock (int fd, const char *name, SOCKET soc)
{
+ SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fdsock");
if (wsadata.wVersion < 512) /* < Winsock 2.0 */
soc = set_socket_inheritance (soc);
fhandler_socket *fh = (fhandler_socket *) cygheap->fdtab.build_fhandler (fd, FH_SOCKET, name);
fh->set_io_handle ((HANDLE) soc);
fh->set_flags (O_RDWR);
cygheap->fdtab.inc_need_fixup_before ();
+ fh->set_name (name, name);
+ ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fdsock");
return fh;
}
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 5e00f3541..cb05f1a2b 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -701,6 +701,10 @@ out:
set_has_buggy_open (strcmp (fs_name, "SUNWNFS") == 0);
}
}
+#if 0
+ if (issocket ())
+ devn = FH_SOCKET;
+#endif
if (!(opt & PC_FULL))
{
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 6e66e47a1..48b257699 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -293,8 +293,8 @@ winpids::add (DWORD& nelem, bool winpid, DWORD pid)
if (nelem >= npidlist)
{
npidlist += slop_pidlist;
- pidlist = (DWORD *) realloc (pidlist, size_pidlist (npidlist));
- pinfolist = (pinfo *) realloc (pinfolist, size_pinfolist (npidlist));
+ pidlist = (DWORD *) realloc (pidlist, size_pidlist (npidlist + 1));
+ pinfolist = (pinfo *) realloc (pinfolist, size_pinfolist (npidlist + 1));
}
pinfolist[nelem].init (cygpid, PID_NOREDIR);
@@ -324,7 +324,7 @@ winpids::enumNT (bool winpid)
DWORD nelem = 0;
if (!szprocs)
- procs = (SYSTEM_PROCESSES *) malloc (szprocs = 200 * sizeof (*procs));
+ procs = (SYSTEM_PROCESSES *) malloc (sizeof (*procs) + (szprocs = 200 * sizeof (*procs)));
NTSTATUS res;
for (;;)
@@ -387,7 +387,8 @@ void
winpids::init (bool winpid)
{
npids = (this->*enum_processes) (winpid);
- pidlist[npids] = 0;
+ if (pidlist)
+ pidlist[npids] = 0;
}
DWORD
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 099aa37b3..6fb9f068a 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -25,9 +25,8 @@ details. */
static unsigned pipecount;
static const NO_COPY char pipeid_fmt[] = "stupid_pipe.%u.%u";
-fhandler_pipe::fhandler_pipe (const char *name, DWORD devtype) :
- fhandler_base (devtype, name),
- guard (0), writepipe_exists(0), orig_pid (0), id (0)
+fhandler_pipe::fhandler_pipe (DWORD devtype)
+ : fhandler_base (devtype), guard (0), writepipe_exists(0), orig_pid (0), id (0)
{
set_cb (sizeof *this);
}
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 10f652dcb..9fcce3a4f 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -265,4 +265,8 @@ extern bool cygwin_testing;
extern unsigned _cygwin_testing_magic;
extern HMODULE cygwin_hmodule;
+#define winsock2_active (wsadata.wVersion >= 512)
+#define winsock_active (wsadata.wVersion < 512)
+extern struct WSAData wsadata;
+
#endif /* defined __cplusplus */