Microport Unix -- Large Model Problems

Doug Gwyn gwyn at brl-smoke.ARPA
Sat Nov 8 18:16:50 AEST 1986


In article <5068 at ukme.ukma.uky.csnet> david at ukme.UUCP (David Herron, NPR Lover) writes:
-In article <840 at ur-valhalla.UUCP> dave at valhalla.UUCP (Dave Carlson) writes:
->A potential problem I smacked into yesterday when porting BSD to SV/AT
->is ioctl(2) expects as the third argument:
->union   { int iarg;
->        char *cparg;}
->Problem is that the union will pull 4 bytes off the stack (in large model)
->but the program calling with an integer will only push 2 bytes.  Oh S*$&!
->I cast my integer args long and everything seems ok but what a pain...
-
-Argh!  And you're doing a port of an operating system???
-
-UNIONS are the SAME size regardless of WHICH part of them you use!
-
-A user which passes an int to a routine expecting a union is ASKING
-for trouble!

Oh, good grief!  Mr. Carlson is talking about ioctl(), which is a
well-known function whose third argument has a type that depends on
its second argument's value; usually it's an (int) or a (struct termio *).
The problem is not his; rather it is due to the SV/AT implementor
changing ioctl()'s third argument to be a union.  This is in violation
of the SVID and of common sense, since (as Mr. Carlson reports) this
breaks correctly-written code.



More information about the Comp.unix.wizards mailing list