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

View File

@ -1144,69 +1144,69 @@ void unused_sig_wrapper ()
prototype signal handlers as __stdcall), calls _set_process_mask
to restore any mask, restores any potentially clobbered registers
and returns to original caller. */
__asm__ volatile ("
.text
_sigreturn:
addl $4,%%esp # Remove argument
movl %%esp,%%ebp
addl $36,%%ebp
cmpl $0,%4 # Did a signal come in?
jz 1f # No, if zero
call _call_signal_handler@0 # yes handle the signal
# FIXME: There is a race here. The signal handler could set up
# the sigsave structure between _call_signal_handler and the
# end of _set_process_mask. This would make cygwin detect an
# incorrect signal mask.
1: call _set_process_mask@4
popl %%eax # saved errno
testl %%eax,%%eax # Is it < 0
jl 2f # yup. ignore it
movl %1,%%ebx
movl %%eax,(%%ebx)
2: popl %%eax
popl %%ebx
popl %%ecx
popl %%edx
popl %%edi
popl %%esi
popf
popl %%ebp
ret
__no_sig_start:
_sigdelayed:
pushl %2 # original return address
_sigdelayed0:
pushl %%ebp
movl %%esp,%%ebp
pushf
pushl %%esi
pushl %%edi
pushl %%edx
pushl %%ecx
pushl %%ebx
pushl %%eax
pushl %7 # saved errno
pushl %3 # oldmask
pushl %4 # signal argument
pushl $_sigreturn
call _reset_signal_arrived@0
pushl %5 # signal number
movl $0,%0 # zero the signal number as a
# flag to the signal handler thread
# that it is ok to set up sigsave
pushl %8
call _set_process_mask@4
popl %%eax
jmp *%%eax
__no_sig_end:
__asm__ volatile ("\n\
.text\n\
\n\
_sigreturn:\n\
addl $4,%%esp # Remove argument\n\
movl %%esp,%%ebp\n\
addl $36,%%ebp\n\
\n\
cmpl $0,%4 # Did a signal come in?\n\
jz 1f # No, if zero\n\
call _call_signal_handler@0 # yes handle the signal\n\
\n\
# FIXME: There is a race here. The signal handler could set up\n\
# the sigsave structure between _call_signal_handler and the\n\
# end of _set_process_mask. This would make cygwin detect an\n\
# incorrect signal mask.\n\
\n\
1: call _set_process_mask@4\n\
popl %%eax # saved errno\n\
testl %%eax,%%eax # Is it < 0\n\
jl 2f # yup. ignore it\n\
movl %1,%%ebx\n\
movl %%eax,(%%ebx)\n\
2: popl %%eax\n\
popl %%ebx\n\
popl %%ecx\n\
popl %%edx\n\
popl %%edi\n\
popl %%esi\n\
popf\n\
popl %%ebp\n\
ret\n\
\n\
__no_sig_start:\n\
_sigdelayed:\n\
pushl %2 # original return address\n\
_sigdelayed0:\n\
pushl %%ebp\n\
movl %%esp,%%ebp\n\
pushf\n\
pushl %%esi\n\
pushl %%edi\n\
pushl %%edx\n\
pushl %%ecx\n\
pushl %%ebx\n\
pushl %%eax\n\
pushl %7 # saved errno\n\
pushl %3 # oldmask\n\
pushl %4 # signal argument\n\
pushl $_sigreturn\n\
\n\
call _reset_signal_arrived@0\n\
pushl %5 # signal number\n\
movl $0,%0 # zero the signal number as a\n\
# flag to the signal handler thread\n\
# that it is ok to set up sigsave\n\
\n\
pushl %8\n\
call _set_process_mask@4\n\
popl %%eax\n\
jmp *%%eax\n\
__no_sig_end:\n\
\n\
" : "=m" (sigsave.sig) : "m" (&_impure_ptr->_errno),
"g" (sigsave.retaddr), "g" (sigsave.oldmask), "g" (sigsave.sig),
"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
that some fd's have two handles. */
virtual HANDLE get_handle () const { return io_handle; }
virtual HANDLE get_io_handle () const { return io_handle; }
virtual HANDLE get_output_handle () const { return io_handle; }
virtual HANDLE& get_handle () { return io_handle; }
virtual HANDLE& get_io_handle () { return io_handle; }
virtual HANDLE& get_output_handle () { return io_handle; }
virtual BOOL hit_eof () {return FALSE;}
virtual select_record *select_read (select_record *s);
virtual select_record *select_write (select_record *s);
@ -347,7 +347,7 @@ private:
public:
fhandler_socket (const char *name = 0);
~fhandler_socket ();
int get_socket () const { return (int) get_handle(); }
int get_socket () { return (int) get_handle(); }
fhandler_socket * is_socket () { return this; }
int write (const void *ptr, size_t len);
int read (void *ptr, size_t len);
@ -570,7 +570,7 @@ public:
{
// 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);
void set_output_handle (HANDLE h) { output_handle = h; }
void tcinit (tty_min *this_tc, int force = FALSE);

View File

@ -1,6 +1,6 @@
/* fhandler_tty.cc
Copyright 1997, 1998, 2000 Cygnus Solutions.
Copyright 1997, 1998, 2000, 2001 Red Hat, Inc.
This file is part of Cygwin.
@ -144,7 +144,7 @@ fhandler_tty_common::__release_output_mutex (const char *fn, int ln)
if (osi > 0)
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;
#endif
}
@ -173,7 +173,7 @@ fhandler_pty_master::accept_input ()
n = get_ttyp ()->read_retval = eat_readahead (-1);
if ( n != 0 )
if (n != 0)
{
termios_printf ("about to write %d chars to slave", n);
rc = WriteFile (get_output_handle (), rabuf, n, &written, NULL);
@ -411,21 +411,21 @@ process_ioctl (void *)
/**********************************************************************/
/* 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)
{
set_cb (sizeof *this);
ttynum = num;
/* FIXME: This is wasteful. We should rewrite the set_name path to eliminate the
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_);
unix_path_name_[0] = unix_path_name_[4] = '/';
debug_printf ("unix '%s', win32 '%s'", unix_path_name_, win32_path_name_);
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)
{
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);
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");
__seterrno ();
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");
__seterrno ();
@ -500,7 +500,7 @@ fhandler_tty_slave::open (const char *, int flags, mode_t)
get_ttyp ()->master_pid);
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);
__seterrno ();
return 0;
@ -529,7 +529,7 @@ fhandler_tty_slave::open (const char *, int flags, mode_t)
ProtectHandle1 (nh, to_pty);
CloseHandle (tty_owner);
termios_printf("tty%d opened", ttynum);
termios_printf ("tty%d opened", ttynum);
return 1;
}
@ -555,7 +555,7 @@ fhandler_tty_slave::write (const void *ptr, size_t 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);
@ -597,7 +597,7 @@ fhandler_tty_slave::write (const void *ptr, size_t len)
DWORD rc;
DWORD x = n * 1000;
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 ();
@ -674,7 +674,7 @@ fhandler_tty_slave::read (void *ptr, size_t len)
bytes_in_pipe = 0;
}
readlen = min (bytes_in_pipe, min (len, sizeof (buf)));
if ( readlen )
if (readlen)
{
termios_printf ("reading %d bytes (vtime %d)", readlen, vtime);
if (ReadFile (get_handle (), buf, readlen, &n, NULL) == FALSE)
@ -707,7 +707,7 @@ fhandler_tty_slave::read (void *ptr, size_t len)
termios_printf ("saw EOF");
break;
}
if ( get_ttyp ()->ti.c_lflag & ICANON ||
if (get_ttyp ()->ti.c_lflag & ICANON ||
get_flags () & (O_NONBLOCK | O_NDELAY))
break;
if (totalread >= vmin && (vmin > 0 || totalread > 0))
@ -728,7 +728,8 @@ fhandler_tty_slave::read (void *ptr, size_t len)
* 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);
return totalread;
@ -861,7 +862,7 @@ fhandler_tty_slave::ioctl (unsigned int cmd, void *arg)
myself->ctty == ttynum && (get_ttyp ()->ti.c_lflag & TOSTOP))
{
/* 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);
_raise (SIGTTOU);
}
@ -1070,7 +1071,15 @@ fhandler_pty_master::ptsname (void)
void
fhandler_tty_common::set_close_on_exec (int val)
{
#ifndef DEBUGGING
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)
set_inheritance (output_done_event, val);
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 (input_mutex, val, "input_mutex");
set_inheritance (input_available_event, val);
set_inheritance (output_handle, val);
set_inheritance (output_handle, val, "to_pty");
}
void