mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-20 07:51:35 +08:00
Corinna Vinschen <corinna@vinschen.de>
* fhandler.cc: Add #include for asm/socket.h for dealing with FIONREAD. (fhandler_base::ioctl): Special-case errno for FIONREAD. * fhandler_dsp.cc (fhandler_dev_dsp::ioctl): Rename parameter for consistency. Call fhandler_base::ioctl to decode default condition. * fhandler_serial.cc (fhandler_serial::ioctl): Ditto. * fhandler_tty.cc (fhandler_pty_slave::ioctl): Call fhandler_base::ioctl to decode default condition. * fhandler_windows.cc (fhandler_windows::ioctl): Ditto.
This commit is contained in:
parent
37aeec7f72
commit
e9b5cc32f7
@ -1,3 +1,15 @@
|
||||
2011-07-21 Christopher Faylor <me.cygwin2011@cgf.cx>
|
||||
Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* fhandler.cc: Add #include for asm/socket.h for dealing with FIONREAD.
|
||||
(fhandler_base::ioctl): Special-case errno for FIONREAD.
|
||||
* fhandler_dsp.cc (fhandler_dev_dsp::ioctl): Rename parameter for
|
||||
consistency. Call fhandler_base::ioctl to decode default condition.
|
||||
* fhandler_serial.cc (fhandler_serial::ioctl): Ditto.
|
||||
* fhandler_tty.cc (fhandler_pty_slave::ioctl): Call
|
||||
fhandler_base::ioctl to decode default condition.
|
||||
* fhandler_windows.cc (fhandler_windows::ioctl): Ditto.
|
||||
|
||||
2011-07-21 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* heap.cc (eval_start_address): Simplify test for large address
|
||||
|
@ -28,6 +28,7 @@ details. */
|
||||
#include "ntdll.h"
|
||||
#include "cygtls.h"
|
||||
#include "sigproc.h"
|
||||
#include <asm/socket.h>
|
||||
|
||||
#define MAX_OVERLAPPED_WRITE_LEN (64 * 1024 * 1024)
|
||||
#define MIN_OVERLAPPED_WRITE_LEN (1 * 1024 * 1024)
|
||||
@ -1151,6 +1152,10 @@ fhandler_base::ioctl (unsigned int cmd, void *buf)
|
||||
set_nonblocking (*(int *) buf);
|
||||
res = 0;
|
||||
break;
|
||||
case FIONREAD:
|
||||
set_errno (ENOTTY);
|
||||
res = -1;
|
||||
break;
|
||||
default:
|
||||
set_errno (EINVAL);
|
||||
res = -1;
|
||||
|
@ -1170,11 +1170,11 @@ fhandler_dev_dsp::close ()
|
||||
}
|
||||
|
||||
int
|
||||
fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
|
||||
fhandler_dev_dsp::ioctl (unsigned int cmd, void *buf)
|
||||
{
|
||||
debug_printf ("audio_in=%08x audio_out=%08x",
|
||||
(int)audio_in_, (int)audio_out_);
|
||||
int *intptr = (int *) ptr;
|
||||
int *intbuf = (int *) buf;
|
||||
switch (cmd)
|
||||
{
|
||||
#define CASE(a) case a : debug_printf ("/dev/dsp: ioctl %s", #a);
|
||||
@ -1189,13 +1189,13 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
|
||||
/* This is valid even if audio_X is NULL */
|
||||
if (IS_WRITE ())
|
||||
{
|
||||
*intptr = audio_out_->blockSize (audiofreq_,
|
||||
*intbuf = audio_out_->blockSize (audiofreq_,
|
||||
audiobits_,
|
||||
audiochannels_);
|
||||
}
|
||||
else
|
||||
{ // I am very sure that IS_READ is valid
|
||||
*intptr = audio_in_->blockSize (audiofreq_,
|
||||
*intbuf = audio_in_->blockSize (audiofreq_,
|
||||
audiobits_,
|
||||
audiochannels_);
|
||||
}
|
||||
@ -1204,10 +1204,10 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
|
||||
CASE (SNDCTL_DSP_SETFMT)
|
||||
{
|
||||
int nBits;
|
||||
switch (*intptr)
|
||||
switch (*intbuf)
|
||||
{
|
||||
case AFMT_QUERY:
|
||||
*intptr = audioformat_;
|
||||
*intbuf = audioformat_;
|
||||
return 0;
|
||||
break;
|
||||
case AFMT_U16_BE:
|
||||
@ -1229,11 +1229,11 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
|
||||
if (audio_out_->query (audiofreq_, nBits, audiochannels_))
|
||||
{
|
||||
audiobits_ = nBits;
|
||||
audioformat_ = *intptr;
|
||||
audioformat_ = *intbuf;
|
||||
}
|
||||
else
|
||||
{
|
||||
*intptr = audiobits_;
|
||||
*intbuf = audiobits_;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1243,11 +1243,11 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
|
||||
if (audio_in_->query (audiofreq_, nBits, audiochannels_))
|
||||
{
|
||||
audiobits_ = nBits;
|
||||
audioformat_ = *intptr;
|
||||
audioformat_ = *intbuf;
|
||||
}
|
||||
else
|
||||
{
|
||||
*intptr = audiobits_;
|
||||
*intbuf = audiobits_;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1258,22 +1258,22 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
|
||||
if (IS_WRITE ())
|
||||
{
|
||||
close_audio_out ();
|
||||
if (audio_out_->query (*intptr, audiobits_, audiochannels_))
|
||||
audiofreq_ = *intptr;
|
||||
if (audio_out_->query (*intbuf, audiobits_, audiochannels_))
|
||||
audiofreq_ = *intbuf;
|
||||
else
|
||||
{
|
||||
*intptr = audiofreq_;
|
||||
*intbuf = audiofreq_;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (IS_READ ())
|
||||
{
|
||||
close_audio_in ();
|
||||
if (audio_in_->query (*intptr, audiobits_, audiochannels_))
|
||||
audiofreq_ = *intptr;
|
||||
if (audio_in_->query (*intbuf, audiobits_, audiochannels_))
|
||||
audiofreq_ = *intbuf;
|
||||
else
|
||||
{
|
||||
*intptr = audiofreq_;
|
||||
*intbuf = audiofreq_;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1281,15 +1281,15 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
|
||||
|
||||
CASE (SNDCTL_DSP_STEREO)
|
||||
{
|
||||
int nChannels = *intptr + 1;
|
||||
int nChannels = *intbuf + 1;
|
||||
int res = ioctl (SNDCTL_DSP_CHANNELS, &nChannels);
|
||||
*intptr = nChannels - 1;
|
||||
*intbuf = nChannels - 1;
|
||||
return res;
|
||||
}
|
||||
|
||||
CASE (SNDCTL_DSP_CHANNELS)
|
||||
{
|
||||
int nChannels = *intptr;
|
||||
int nChannels = *intbuf;
|
||||
|
||||
if (IS_WRITE ())
|
||||
{
|
||||
@ -1298,7 +1298,7 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
|
||||
audiochannels_ = nChannels;
|
||||
else
|
||||
{
|
||||
*intptr = audiochannels_;
|
||||
*intbuf = audiochannels_;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1309,7 +1309,7 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
|
||||
audiochannels_ = nChannels;
|
||||
else
|
||||
{
|
||||
*intptr = audiochannels_;
|
||||
*intbuf = audiochannels_;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1323,10 +1323,10 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
|
||||
set_errno(EBADF);
|
||||
return -1;
|
||||
}
|
||||
audio_buf_info *p = (audio_buf_info *) ptr;
|
||||
audio_buf_info *p = (audio_buf_info *) buf;
|
||||
audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
|
||||
debug_printf ("ptr=%p frags=%d fragsize=%d bytes=%d",
|
||||
ptr, p->fragments, p->fragsize, p->bytes);
|
||||
debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d",
|
||||
buf, p->fragments, p->fragsize, p->bytes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1337,10 +1337,10 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
|
||||
set_errno(EBADF);
|
||||
return -1;
|
||||
}
|
||||
audio_buf_info *p = (audio_buf_info *) ptr;
|
||||
audio_buf_info *p = (audio_buf_info *) buf;
|
||||
audio_in_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
|
||||
debug_printf ("ptr=%p frags=%d fragsize=%d bytes=%d",
|
||||
ptr, p->fragments, p->fragsize, p->bytes);
|
||||
debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d",
|
||||
buf, p->fragments, p->fragsize, p->bytes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1350,11 +1350,11 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
|
||||
return 0;
|
||||
|
||||
CASE (SNDCTL_DSP_GETFMTS)
|
||||
*intptr = AFMT_S16_LE | AFMT_U8; // only native formats returned here
|
||||
*intbuf = AFMT_S16_LE | AFMT_U8; // only native formats returned here
|
||||
return 0;
|
||||
|
||||
CASE (SNDCTL_DSP_GETCAPS)
|
||||
*intptr = DSP_CAP_BATCH | DSP_CAP_DUPLEX;
|
||||
*intbuf = DSP_CAP_BATCH | DSP_CAP_DUPLEX;
|
||||
return 0;
|
||||
|
||||
CASE (SNDCTL_DSP_POST)
|
||||
@ -1366,13 +1366,11 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *ptr)
|
||||
return 0;
|
||||
|
||||
default:
|
||||
debug_printf ("/dev/dsp: ioctl 0x%08x not handled yet! FIXME:", cmd);
|
||||
return fhandler_base::ioctl (cmd, buf);
|
||||
break;
|
||||
|
||||
#undef CASE
|
||||
};
|
||||
set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -17,6 +17,7 @@ details. */
|
||||
#include "fhandler.h"
|
||||
#include "sigproc.h"
|
||||
#include "pinfo.h"
|
||||
#include <asm/socket.h>
|
||||
#include <ddk/ntddser.h>
|
||||
|
||||
/**********************************************************************/
|
||||
@ -454,12 +455,12 @@ fhandler_serial::switch_modem_lines (int set, int clr)
|
||||
|
||||
/* ioctl: */
|
||||
int
|
||||
fhandler_serial::ioctl (unsigned int cmd, void *buffer)
|
||||
fhandler_serial::ioctl (unsigned int cmd, void *buf)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
# define ibuffer ((int) buffer)
|
||||
# define ipbuffer (*(int *) buffer)
|
||||
# define ibuf ((int) buf)
|
||||
# define ipbuf (*(int *) buf)
|
||||
|
||||
DWORD ev;
|
||||
COMSTAT st;
|
||||
@ -472,7 +473,7 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
|
||||
switch (cmd)
|
||||
{
|
||||
case TCFLSH:
|
||||
res = tcflush (ibuffer);
|
||||
res = tcflush (ibuf);
|
||||
break;
|
||||
case TIOCMGET:
|
||||
DWORD modem_lines;
|
||||
@ -483,40 +484,40 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
|
||||
}
|
||||
else
|
||||
{
|
||||
ipbuffer = 0;
|
||||
ipbuf = 0;
|
||||
if (modem_lines & MS_CTS_ON)
|
||||
ipbuffer |= TIOCM_CTS;
|
||||
ipbuf |= TIOCM_CTS;
|
||||
if (modem_lines & MS_DSR_ON)
|
||||
ipbuffer |= TIOCM_DSR;
|
||||
ipbuf |= TIOCM_DSR;
|
||||
if (modem_lines & MS_RING_ON)
|
||||
ipbuffer |= TIOCM_RI;
|
||||
ipbuf |= TIOCM_RI;
|
||||
if (modem_lines & MS_RLSD_ON)
|
||||
ipbuffer |= TIOCM_CD;
|
||||
ipbuf |= TIOCM_CD;
|
||||
|
||||
DWORD cb;
|
||||
DWORD mcr;
|
||||
if (!DeviceIoControl (get_handle (), IOCTL_SERIAL_GET_DTRRTS,
|
||||
NULL, 0, &mcr, 4, &cb, 0) || cb != 4)
|
||||
ipbuffer |= rts | dtr;
|
||||
ipbuf |= rts | dtr;
|
||||
else
|
||||
{
|
||||
if (mcr & 2)
|
||||
ipbuffer |= TIOCM_RTS;
|
||||
ipbuf |= TIOCM_RTS;
|
||||
if (mcr & 1)
|
||||
ipbuffer |= TIOCM_DTR;
|
||||
ipbuf |= TIOCM_DTR;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TIOCMSET:
|
||||
if (switch_modem_lines (ipbuffer, ~ipbuffer))
|
||||
if (switch_modem_lines (ipbuf, ~ipbuf))
|
||||
res = -1;
|
||||
break;
|
||||
case TIOCMBIS:
|
||||
if (switch_modem_lines (ipbuffer, 0))
|
||||
if (switch_modem_lines (ipbuf, 0))
|
||||
res = -1;
|
||||
break;
|
||||
case TIOCMBIC:
|
||||
if (switch_modem_lines (0, ipbuffer))
|
||||
if (switch_modem_lines (0, ipbuf))
|
||||
res = -1;
|
||||
break;
|
||||
case TIOCCBRK:
|
||||
@ -541,21 +542,24 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
|
||||
res = -1;
|
||||
}
|
||||
else
|
||||
ipbuffer = st.cbInQue;
|
||||
ipbuf = st.cbInQue;
|
||||
break;
|
||||
case TIOCGWINSZ:
|
||||
((struct winsize *) buffer)->ws_row = 0;
|
||||
((struct winsize *) buffer)->ws_col = 0;
|
||||
((struct winsize *) buf)->ws_row = 0;
|
||||
((struct winsize *) buf)->ws_col = 0;
|
||||
break;
|
||||
case FIONREAD:
|
||||
set_errno (ENOTSUP);
|
||||
res = -1;
|
||||
break;
|
||||
default:
|
||||
set_errno (ENOSYS);
|
||||
res = -1;
|
||||
res = fhandler_base::ioctl (cmd, buf);
|
||||
break;
|
||||
}
|
||||
|
||||
termios_printf ("%d = ioctl (%p, %p)", res, cmd, buffer);
|
||||
# undef ibuffer
|
||||
# undef ipbuffer
|
||||
termios_printf ("%d = ioctl (%p, %p)", res, cmd, buf);
|
||||
# undef ibuf
|
||||
# undef ipbuf
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -980,8 +980,7 @@ fhandler_pty_slave::ioctl (unsigned int cmd, void *arg)
|
||||
retval = this->tcsetpgrp ((pid_t) arg);
|
||||
goto out;
|
||||
default:
|
||||
set_errno (EINVAL);
|
||||
return -1;
|
||||
return fhandler_base::ioctl (cmd, arg);
|
||||
}
|
||||
|
||||
acquire_output_mutex (INFINITE);
|
||||
|
@ -155,8 +155,7 @@ fhandler_windows::ioctl (unsigned int cmd, void *val)
|
||||
hWnd_ = * ((HWND *) val);
|
||||
break;
|
||||
default:
|
||||
set_errno (EINVAL);
|
||||
return -1;
|
||||
return fhandler_base::ioctl (cmd, val);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user