Subject: Re: xterm jump scrolling on sparc64
To: Eduardo Horvath <eeh@netbsd.org>
From: Thomas Dickey <dickey@his.com>
List: tech-x11
Date: 06/06/2004 16:20:20
On Tue, 1 Jun 2004, Eduardo Horvath wrote:

> On Tue, Jun 01, 2004 at 07:54:19AM -0700, john heasley wrote:
> > Tue, Jun 01, 2004 at 01:28:33PM +0200, Matthias Scheler:
> > > But if SUS indeed says that FIONREAD expects an "int" argument you
> > > should better write like this:

SUS doesn't appear to mention it.  SUS2 for example:

	http://www.opengroup.org/onlinepubs/7908799/xsh/ioctl.html

I don't see it in SUS3 either (much the same content):

	http://www.unix-systems.org/single_unix_specification/

> > > #if defined(FIONREAD)
> > > #ifdef SGIArchitecture
> > >    long arg = 0;
> > >    ioctl(fd, FIONREAD, (char *) &arg);
> > >    return (int) arg;
> > > #else
> > >    int arg = 0;
> > >    ioctl(fd, FIONREAD, &arg);
> > >    return arg;
> > > #endif
> > > #elif defined(__CYGWIN__)
> >
> > Does that do it for windows + x86_64?
>
> Since Windows is little-endian, and what's more ILP32 or ILP64
> (not I32LP64) it shouldn't care which version is used.
>
> BTW, you probably should verify that FIONREAD returns a long on
> 64-bit IRIX and they weren't just getting lucky on 32-bit IRIX.

Reading the available documentation (mostly header files that give the
size as part of the _IOR macro) for Solaris, IRIX64, HPUX, Tru64 and AIX,
they all state that the value is an int. (Actually IRIX64 states that it
would be a size_t - 64-bits - if it is for a file, but 32-bits for a
socket).

The suggested ifdef's would make those cases not work (changing the value
to an int except if there are specific cases where it should be a long
seems to be the best approach).  The only ones of those appear to be on
the Windows platform.

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net