Am 10.02.2008 22:32 schrieb Mike Frysinger:
On Sunday 10 February 2008, Tilman Schmidt wrote:
#ifndef TCGETS2 #define termios2 termios #define TCGETS2 TCGETS #define TCSETS2 TCSETS #endif ... #ifdef BOTHER < do BOTHER / CBAUD stuff > if (ioctl( TCGETS ) works) return; #endif < normal speed functions >
Can I really? Imagine building the above against recent headers on arch=powerpc. BOTHER is defined, TCGETS2 isn't. [...] Now run that executable on a pre-BOTHER kernel, which doesn't know about c_ispeed and c_ospeed. The ioctl(TCGETS) will succeed, but c_ispeed and c_ospeed will not have been filled. How is the executable to detect that situation?that's why it's an ABI. on say ppc, the termios struct has always had the speed members and the kernel has always filled them in. so that takes care of the GET path.
Ok, if it's guaranteed that (defined(BOTHER) && !defined(TCGETS2) => in every previous kernel version of the same architecture, struct termios does have members c_ispeed and c_ospeed) then that's fine. Except ...
the SET path cannot make any assumptions. if BOTHER is defined, you'll have to try to use it and then do a GET and compare the speeds. if they differ, you're running on an old kernel which does not support BOTHER so you'll have to fall back to using the libc termios functions.
Hrmph. So ioctl(TCSETS) doesn't even return an error on an unsupported request for BOTHER? Even if it returns 0 I have to verify it actually did what I asked it to do? Then I'd rather renounce the ability to run an executable compiled for a newer kernel on an older one.
while true, i was referring to the existence of the Bnnn values, not the actual values. every Linux arch is guaranteed to support up to 115200.the Bnnn list beyond 115200 is not consistent across arches :/In fact, the divergence starts after 38400, the last value defined by POSIX. [...]
I wasn't aware of that. So B57600 and B115200 are officially guaranteed to exist and work, but B230400 isn't? In that case, I might throw all those ifdefs overboard and just cut off my backward compatibility code at 115200. Thanks, Tilman -- Tilman Schmidt E-Mail: tilman@xxxxxxx Bonn, Germany Diese Nachricht besteht zu 100% aus wiederverwerteten Bits. Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
Attachment:
signature.asc
Description: OpenPGP digital signature