* autoload.cc (noload): Use proper method for multiline strings or newer gcc's

complain.
* exceptions.cc (unused_sig_wrapper): Ditto.
* fhandler.h (fhandler_base): Make get_io_handle and friends return self.
* fhandler_tty.cc (fhandler_pty_common::close_on_exec): Accomodate DEBUGGING
flag to avoid spurious warnings when inheritance is set.
This commit is contained in:
Christopher Faylor 2001-03-11 01:58:23 +00:00
parent 7cf3b655ec
commit 2116a17508
5 changed files with 186 additions and 167 deletions

View File

@ -1,3 +1,13 @@
Sat Mar 10 20:54:47 2001 Christopher Faylor <cgf@cygnus.com>
* autoload.cc (noload): Use proper method for multiline strings or
newer gcc's complain.
* exceptions.cc (unused_sig_wrapper): Ditto.
* fhandler.h (fhandler_base): Make get_io_handle and friends return
self.
* fhandler_tty.cc (fhandler_pty_common::close_on_exec): Accomodate
DEBUGGING flag to avoid spurious warnings when inheritance is set.
Sat Mar 10 16:52:12 2001 Christopher Faylor <cgf@cygnus.com> Sat Mar 10 16:52:12 2001 Christopher Faylor <cgf@cygnus.com>
* shortcut.c (PATH_ALL_EXEC): Add parentheses to avoid a compiler * shortcut.c (PATH_ALL_EXEC): Add parentheses to avoid a compiler

View File

@ -24,45 +24,45 @@ struct DLLinfo
}; };
/* FIXME: This is not thread-safe! */ /* FIXME: This is not thread-safe! */
__asm__ (" __asm__ ("\n\
msg1: msg1:\n\
.ascii \"couldn't dynamically determine load address for '%s' (handle %p), %E\\0\" .ascii \"couldn't dynamically determine load address for '%s' (handle %p), %E\\0\"\n\
\n\
.align 32 .align 32\n\
noload: noload:\n\
popl %edx # Get the address of the information block popl %edx # Get the address of the information block\n\
movl 8(%edx),%eax # Should we 'ignore' the lack movl 8(%edx),%eax # Should we 'ignore' the lack\n\
test $1,%eax # of this function? test $1,%eax # of this function?\n\
jz 1f # Nope. jz 1f # Nope.\n\
decl %eax # Yes. This is the # of bytes + 1 decl %eax # Yes. This is the # of bytes + 1\n\
popl %edx # Caller's caller popl %edx # Caller's caller\n\
addl %eax,%esp # Pop off bytes addl %eax,%esp # Pop off bytes\n\
xor %eax,%eax # Zero functional return xor %eax,%eax # Zero functional return\n\
jmp *%edx # Return jmp *%edx # Return\n\
1: 1:\n\
movl 4(%edx),%eax # Handle value movl 4(%edx),%eax # Handle value\n\
pushl (%eax) pushl (%eax)\n\
leal 12(%edx),%eax # Location of name of function leal 12(%edx),%eax # Location of name of function\n\
push %eax push %eax\n\
push $msg1 # The message push $msg1 # The message\n\
call ___api_fatal # Print message. Never returns call ___api_fatal # Print message. Never returns\n\
\n\
.globl cygwin_dll_func_load .globl cygwin_dll_func_load\n\
cygwin_dll_func_load: cygwin_dll_func_load:\n\
movl (%esp),%eax # 'Return address' contains load info movl (%esp),%eax # 'Return address' contains load info\n\
addl $12,%eax # Address of name of function to load addl $12,%eax # Address of name of function to load\n\
pushl %eax # Second argument pushl %eax # Second argument\n\
movl -8(%eax),%eax # Address of Handle to DLL movl -8(%eax),%eax # Address of Handle to DLL\n\
pushl (%eax) # Handle to DLL pushl (%eax) # Handle to DLL\n\
call _GetProcAddress@8# Load it call _GetProcAddress@8# Load it\n\
test %eax,%eax # Success? test %eax,%eax # Success?\n\
jne gotit # Yes jne gotit # Yes\n\
jmp noload # Issue an error or return jmp noload # Issue an error or return\n\
gotit: gotit:\n\
popl %ecx # Pointer to 'return address' popl %ecx # Pointer to 'return address'\n\
movb $0xe0,-1(%ecx) # Turn preceding call to a jmp *%eax movb $0xe0,-1(%ecx) # Turn preceding call to a jmp *%eax\n\
movl %eax,(%ecx) # Point dispatch to address loaded above movl %eax,(%ecx) # Point dispatch to address loaded above\n\
jmp *%eax jmp *%eax\n\
"); ");
LoadDLLinitfunc (advapi32) LoadDLLinitfunc (advapi32)

View File

@ -1144,69 +1144,69 @@ void unused_sig_wrapper ()
prototype signal handlers as __stdcall), calls _set_process_mask prototype signal handlers as __stdcall), calls _set_process_mask
to restore any mask, restores any potentially clobbered registers to restore any mask, restores any potentially clobbered registers
and returns to original caller. */ and returns to original caller. */
__asm__ volatile (" __asm__ volatile ("\n\
.text .text\n\
\n\
_sigreturn: _sigreturn:\n\
addl $4,%%esp # Remove argument addl $4,%%esp # Remove argument\n\
movl %%esp,%%ebp movl %%esp,%%ebp\n\
addl $36,%%ebp addl $36,%%ebp\n\
\n\
cmpl $0,%4 # Did a signal come in? cmpl $0,%4 # Did a signal come in?\n\
jz 1f # No, if zero jz 1f # No, if zero\n\
call _call_signal_handler@0 # yes handle the signal call _call_signal_handler@0 # yes handle the signal\n\
\n\
# FIXME: There is a race here. The signal handler could set up # FIXME: There is a race here. The signal handler could set up\n\
# the sigsave structure between _call_signal_handler and the # the sigsave structure between _call_signal_handler and the\n\
# end of _set_process_mask. This would make cygwin detect an # end of _set_process_mask. This would make cygwin detect an\n\
# incorrect signal mask. # incorrect signal mask.\n\
\n\
1: call _set_process_mask@4 1: call _set_process_mask@4\n\
popl %%eax # saved errno popl %%eax # saved errno\n\
testl %%eax,%%eax # Is it < 0 testl %%eax,%%eax # Is it < 0\n\
jl 2f # yup. ignore it jl 2f # yup. ignore it\n\
movl %1,%%ebx movl %1,%%ebx\n\
movl %%eax,(%%ebx) movl %%eax,(%%ebx)\n\
2: popl %%eax 2: popl %%eax\n\
popl %%ebx popl %%ebx\n\
popl %%ecx popl %%ecx\n\
popl %%edx popl %%edx\n\
popl %%edi popl %%edi\n\
popl %%esi popl %%esi\n\
popf popf\n\
popl %%ebp popl %%ebp\n\
ret ret\n\
\n\
__no_sig_start: __no_sig_start:\n\
_sigdelayed: _sigdelayed:\n\
pushl %2 # original return address pushl %2 # original return address\n\
_sigdelayed0: _sigdelayed0:\n\
pushl %%ebp pushl %%ebp\n\
movl %%esp,%%ebp movl %%esp,%%ebp\n\
pushf pushf\n\
pushl %%esi pushl %%esi\n\
pushl %%edi pushl %%edi\n\
pushl %%edx pushl %%edx\n\
pushl %%ecx pushl %%ecx\n\
pushl %%ebx pushl %%ebx\n\
pushl %%eax pushl %%eax\n\
pushl %7 # saved errno pushl %7 # saved errno\n\
pushl %3 # oldmask pushl %3 # oldmask\n\
pushl %4 # signal argument pushl %4 # signal argument\n\
pushl $_sigreturn pushl $_sigreturn\n\
\n\
call _reset_signal_arrived@0 call _reset_signal_arrived@0\n\
pushl %5 # signal number pushl %5 # signal number\n\
movl $0,%0 # zero the signal number as a movl $0,%0 # zero the signal number as a\n\
# flag to the signal handler thread # flag to the signal handler thread\n\
# that it is ok to set up sigsave # that it is ok to set up sigsave\n\
\n\
pushl %8 pushl %8\n\
call _set_process_mask@4 call _set_process_mask@4\n\
popl %%eax popl %%eax\n\
jmp *%%eax jmp *%%eax\n\
__no_sig_end: __no_sig_end:\n\
\n\
" : "=m" (sigsave.sig) : "m" (&_impure_ptr->_errno), " : "=m" (sigsave.sig) : "m" (&_impure_ptr->_errno),
"g" (sigsave.retaddr), "g" (sigsave.oldmask), "g" (sigsave.sig), "g" (sigsave.retaddr), "g" (sigsave.oldmask), "g" (sigsave.sig),
"g" (sigsave.func), "o" (pid_offset), "g" (sigsave.saved_errno), "g" (sigsave.newmask) "g" (sigsave.func), "o" (pid_offset), "g" (sigsave.saved_errno), "g" (sigsave.newmask)

View File

@ -317,9 +317,9 @@ public:
/* Virtual accessor functions to hide the fact /* Virtual accessor functions to hide the fact
that some fd's have two handles. */ that some fd's have two handles. */
virtual HANDLE get_handle () const { return io_handle; } virtual HANDLE& get_handle () { return io_handle; }
virtual HANDLE get_io_handle () const { return io_handle; } virtual HANDLE& get_io_handle () { return io_handle; }
virtual HANDLE get_output_handle () const { return io_handle; } virtual HANDLE& get_output_handle () { return io_handle; }
virtual BOOL hit_eof () {return FALSE;} virtual BOOL hit_eof () {return FALSE;}
virtual select_record *select_read (select_record *s); virtual select_record *select_read (select_record *s);
virtual select_record *select_write (select_record *s); virtual select_record *select_write (select_record *s);
@ -347,7 +347,7 @@ private:
public: public:
fhandler_socket (const char *name = 0); fhandler_socket (const char *name = 0);
~fhandler_socket (); ~fhandler_socket ();
int get_socket () const { return (int) get_handle(); } int get_socket () { return (int) get_handle(); }
fhandler_socket * is_socket () { return this; } fhandler_socket * is_socket () { return this; }
int write (const void *ptr, size_t len); int write (const void *ptr, size_t len);
int read (void *ptr, size_t len); int read (void *ptr, size_t len);
@ -570,7 +570,7 @@ public:
{ {
// nothing to do // nothing to do
} }
HANDLE get_output_handle () const { return output_handle; } HANDLE& get_output_handle () { return output_handle; }
int line_edit (const char *rptr, int nread, int always_accept = 0); int line_edit (const char *rptr, int nread, int always_accept = 0);
void set_output_handle (HANDLE h) { output_handle = h; } void set_output_handle (HANDLE h) { output_handle = h; }
void tcinit (tty_min *this_tc, int force = FALSE); void tcinit (tty_min *this_tc, int force = FALSE);

View File

@ -1,6 +1,6 @@
/* fhandler_tty.cc /* fhandler_tty.cc
Copyright 1997, 1998, 2000 Cygnus Solutions. Copyright 1997, 1998, 2000, 2001 Red Hat, Inc.
This file is part of Cygwin. This file is part of Cygwin.
@ -144,7 +144,7 @@ fhandler_tty_common::__release_output_mutex (const char *fn, int ln)
if (osi > 0) if (osi > 0)
osi--; osi--;
termios_printf ("released at %s:%d, osi %d", fn, ln, osi); termios_printf ("released at %s:%d, osi %d", fn, ln, osi);
termios_printf(" for %s:%d (%s)", ostack[osi].fn, ostack[osi].ln, ostack[osi].tname); termios_printf (" for %s:%d (%s)", ostack[osi].fn, ostack[osi].ln, ostack[osi].tname);
ostack[osi].ln = -ln; ostack[osi].ln = -ln;
#endif #endif
} }
@ -173,7 +173,7 @@ fhandler_pty_master::accept_input ()
n = get_ttyp ()->read_retval = eat_readahead (-1); n = get_ttyp ()->read_retval = eat_readahead (-1);
if ( n != 0 ) if (n != 0)
{ {
termios_printf ("about to write %d chars to slave", n); termios_printf ("about to write %d chars to slave", n);
rc = WriteFile (get_output_handle (), rabuf, n, &written, NULL); rc = WriteFile (get_output_handle (), rabuf, n, &written, NULL);
@ -411,21 +411,21 @@ process_ioctl (void *)
/**********************************************************************/ /**********************************************************************/
/* Tty slave stuff */ /* Tty slave stuff */
fhandler_tty_slave::fhandler_tty_slave(int num, const char *name) : fhandler_tty_slave::fhandler_tty_slave (int num, const char *name) :
fhandler_tty_common (FH_TTYS, name, num) fhandler_tty_common (FH_TTYS, name, num)
{ {
set_cb (sizeof *this); set_cb (sizeof *this);
ttynum = num; ttynum = num;
/* FIXME: This is wasteful. We should rewrite the set_name path to eliminate the /* FIXME: This is wasteful. We should rewrite the set_name path to eliminate the
need for double allocates. */ need for double allocates. */
unix_path_name_ = (char *) crealloc (unix_path_name_, strlen(win32_path_name_) + 1); unix_path_name_ = (char *) crealloc (unix_path_name_, strlen (win32_path_name_) + 1);
strcpy (unix_path_name_, win32_path_name_); strcpy (unix_path_name_, win32_path_name_);
unix_path_name_[0] = unix_path_name_[4] = '/'; unix_path_name_[0] = unix_path_name_[4] = '/';
debug_printf ("unix '%s', win32 '%s'", unix_path_name_, win32_path_name_); debug_printf ("unix '%s', win32 '%s'", unix_path_name_, win32_path_name_);
inuse = NULL; inuse = NULL;
} }
fhandler_tty_slave::fhandler_tty_slave(const char *name) : fhandler_tty_slave::fhandler_tty_slave (const char *name) :
fhandler_tty_common (FH_TTYS, name, 0) fhandler_tty_common (FH_TTYS, name, 0)
{ {
set_cb (sizeof *this); set_cb (sizeof *this);
@ -452,13 +452,13 @@ fhandler_tty_slave::open (const char *, int flags, mode_t)
__small_sprintf (buf, OUTPUT_DONE_EVENT, ttynum); __small_sprintf (buf, OUTPUT_DONE_EVENT, ttynum);
output_done_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf); output_done_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf);
if (!(output_mutex = get_ttyp()->open_output_mutex (TRUE))) if (!(output_mutex = get_ttyp ()->open_output_mutex (TRUE)))
{ {
termios_printf ("open output mutex failed, %E"); termios_printf ("open output mutex failed, %E");
__seterrno (); __seterrno ();
return 0; return 0;
} }
if (!(input_mutex = get_ttyp()->open_input_mutex (TRUE))) if (!(input_mutex = get_ttyp ()->open_input_mutex (TRUE)))
{ {
termios_printf ("open input mutex failed, %E"); termios_printf ("open input mutex failed, %E");
__seterrno (); __seterrno ();
@ -500,7 +500,7 @@ fhandler_tty_slave::open (const char *, int flags, mode_t)
get_ttyp ()->master_pid); get_ttyp ()->master_pid);
if (tty_owner == NULL) if (tty_owner == NULL)
{ {
termios_printf ("can't open tty(%d) handle process %d", termios_printf ("can't open tty (%d) handle process %d",
ttynum, get_ttyp ()->master_pid); ttynum, get_ttyp ()->master_pid);
__seterrno (); __seterrno ();
return 0; return 0;
@ -529,7 +529,7 @@ fhandler_tty_slave::open (const char *, int flags, mode_t)
ProtectHandle1 (nh, to_pty); ProtectHandle1 (nh, to_pty);
CloseHandle (tty_owner); CloseHandle (tty_owner);
termios_printf("tty%d opened", ttynum); termios_printf ("tty%d opened", ttynum);
return 1; return 1;
} }
@ -555,7 +555,7 @@ fhandler_tty_slave::write (const void *ptr, size_t len)
{ {
DWORD n, towrite = len; DWORD n, towrite = len;
termios_printf("tty%d, write(%x, %d)", ttynum, ptr, len); termios_printf ("tty%d, write(%x, %d)", ttynum, ptr, len);
acquire_output_mutex (INFINITE); acquire_output_mutex (INFINITE);
@ -597,7 +597,7 @@ fhandler_tty_slave::write (const void *ptr, size_t len)
DWORD rc; DWORD rc;
DWORD x = n * 1000; DWORD x = n * 1000;
rc = WaitForSingleObject (output_done_event, x); rc = WaitForSingleObject (output_done_event, x);
termios_printf("waited %d ms for output_done_event, WFSO %d", x, rc); termios_printf ("waited %d ms for output_done_event, WFSO %d", x, rc);
} }
} }
release_output_mutex (); release_output_mutex ();
@ -627,9 +627,9 @@ fhandler_tty_slave::read (void *ptr, size_t len)
if (vmin < 0) vmin = 0; if (vmin < 0) vmin = 0;
if (vtime < 0) vtime = 0; if (vtime < 0) vtime = 0;
if (vmin == 0) if (vmin == 0)
time_to_wait = INFINITE; time_to_wait = INFINITE;
else else
time_to_wait = (vtime == 0 ? INFINITE : 10 * vtime); time_to_wait = (vtime == 0 ? INFINITE : 10 * vtime);
} }
else else
time_to_wait = INFINITE; time_to_wait = INFINITE;
@ -641,58 +641,58 @@ fhandler_tty_slave::read (void *ptr, size_t len)
{ {
rc = WaitForMultipleObjects (2, w4, FALSE, time_to_wait); rc = WaitForMultipleObjects (2, w4, FALSE, time_to_wait);
if (rc == WAIT_OBJECT_0) if (rc == WAIT_OBJECT_0)
{ {
/* if we've recieved signal after successfully reading some data, /* if we've recieved signal after successfully reading some data,
just return all data successfully read */ just return all data successfully read */
if (totalread > 0) if (totalread > 0)
break; break;
set_sig_errno (EINTR); set_sig_errno (EINTR);
return -1; return -1;
} }
else if (rc == WAIT_FAILED) else if (rc == WAIT_FAILED)
{ {
termios_printf ("wait for input event failed, %E"); termios_printf ("wait for input event failed, %E");
break; break;
} }
else if (rc == WAIT_TIMEOUT) else if (rc == WAIT_TIMEOUT)
break; break;
rc = WaitForSingleObject (input_mutex, 1000); rc = WaitForSingleObject (input_mutex, 1000);
if (rc == WAIT_FAILED) if (rc == WAIT_FAILED)
{ {
termios_printf ("wait for input mutex failed, %E"); termios_printf ("wait for input mutex failed, %E");
break; break;
} }
else if (rc == WAIT_TIMEOUT) else if (rc == WAIT_TIMEOUT)
{ {
termios_printf ("failed to acquire input mutex after input event arrived"); termios_printf ("failed to acquire input mutex after input event arrived");
break; break;
} }
if (!PeekNamedPipe (get_handle (), NULL, 0, NULL, &bytes_in_pipe, NULL)) if (!PeekNamedPipe (get_handle (), NULL, 0, NULL, &bytes_in_pipe, NULL))
{ {
termios_printf ("PeekNamedPipe failed, %E"); termios_printf ("PeekNamedPipe failed, %E");
_raise (SIGHUP); _raise (SIGHUP);
bytes_in_pipe = 0; bytes_in_pipe = 0;
} }
readlen = min (bytes_in_pipe, min (len, sizeof (buf))); readlen = min (bytes_in_pipe, min (len, sizeof (buf)));
if ( readlen ) if (readlen)
{ {
termios_printf ("reading %d bytes (vtime %d)", readlen, vtime); termios_printf ("reading %d bytes (vtime %d)", readlen, vtime);
if (ReadFile (get_handle (), buf, readlen, &n, NULL) == FALSE) if (ReadFile (get_handle (), buf, readlen, &n, NULL) == FALSE)
{ {
termios_printf ("read failed, %E"); termios_printf ("read failed, %E");
_raise (SIGHUP); _raise (SIGHUP);
} }
if (n) if (n)
{ {
len -= n; len -= n;
totalread += n; totalread += n;
memcpy (ptr, buf, n); memcpy (ptr, buf, n);
ptr = (char *) ptr + n; ptr = (char *) ptr + n;
} }
} }
if (readlen != bytes_in_pipe) if (readlen != bytes_in_pipe)
SetEvent (input_available_event); SetEvent (input_available_event);
ReleaseMutex (input_mutex); ReleaseMutex (input_mutex);
@ -707,11 +707,11 @@ fhandler_tty_slave::read (void *ptr, size_t len)
termios_printf ("saw EOF"); termios_printf ("saw EOF");
break; break;
} }
if ( get_ttyp ()->ti.c_lflag & ICANON || if (get_ttyp ()->ti.c_lflag & ICANON ||
get_flags () & (O_NONBLOCK | O_NDELAY)) get_flags () & (O_NONBLOCK | O_NDELAY))
break; break;
if (totalread >= vmin && (vmin > 0 || totalread > 0)) if (totalread >= vmin && (vmin > 0 || totalread > 0))
break; break;
/* vmin == 0 && vtime == 0: /* vmin == 0 && vtime == 0:
* we've already read all input, if any, so return immediately * we've already read all input, if any, so return immediately
@ -728,7 +728,8 @@ fhandler_tty_slave::read (void *ptr, size_t len)
* so "restart timer" and wait until more data arrive * so "restart timer" and wait until more data arrive
*/ */
if (vmin == 0) break; if (vmin == 0)
break;
} }
termios_printf ("%d=read(%x, %d)", totalread, ptr, len); termios_printf ("%d=read(%x, %d)", totalread, ptr, len);
return totalread; return totalread;
@ -861,8 +862,8 @@ fhandler_tty_slave::ioctl (unsigned int cmd, void *arg)
myself->ctty == ttynum && (get_ttyp ()->ti.c_lflag & TOSTOP)) myself->ctty == ttynum && (get_ttyp ()->ti.c_lflag & TOSTOP))
{ {
/* background process */ /* background process */
termios_printf("bg ioctl pgid %d, tpgid %d, ctty %d", termios_printf ("bg ioctl pgid %d, tpgid %d, ctty %d",
myself->pgid, get_ttyp ()->getpgid (), myself->ctty); myself->pgid, get_ttyp ()->getpgid (), myself->ctty);
_raise (SIGTTOU); _raise (SIGTTOU);
} }
@ -1070,7 +1071,15 @@ fhandler_pty_master::ptsname (void)
void void
fhandler_tty_common::set_close_on_exec (int val) fhandler_tty_common::set_close_on_exec (int val)
{ {
#ifndef DEBUGGING
this->fhandler_base::set_close_on_exec (val); this->fhandler_base::set_close_on_exec (val);
#else
/* FIXME: This is a duplication from fhandler_base::set_close_on_exec.
It is here because we need to specify the "from_pty" stuff here or
we'll get warnings from ForceCloseHandle when debugging. */
set_inheritance (get_io_handle (), val, "from_pty");
set_close_on_exec_flag (val);
#endif
if (output_done_event) if (output_done_event)
set_inheritance (output_done_event, val); set_inheritance (output_done_event, val);
if (ioctl_request_event) if (ioctl_request_event)
@ -1082,7 +1091,7 @@ fhandler_tty_common::set_close_on_exec (int val)
set_inheritance (output_mutex, val, "output_mutex"); set_inheritance (output_mutex, val, "output_mutex");
set_inheritance (input_mutex, val, "input_mutex"); set_inheritance (input_mutex, val, "input_mutex");
set_inheritance (input_available_event, val); set_inheritance (input_available_event, val);
set_inheritance (output_handle, val); set_inheritance (output_handle, val, "to_pty");
} }
void void