shared memory under SysV

Doug Gwyn gwyn at brl-smoke.ARPA
Tue May 17 17:35:59 AEST 1988


In article <10861 at steinmetz.ge.com> davidsen at crdos1.UUCP (bill davidsen) writes:
>  I think this is a major conflict with ANSI C. The procedure must
>return either an int or a pointer, but it can't portably do both, since
>some systems don't represent the two types remotely the same way. This
>works on the nice machine on which SysV was developed, but you better
>hope that what's really returned for an error is "(char *) -1".

This botch has nothing to do with ANSI C.  A lot of old UNIX code
(mostly inherited from PDP-11-only days) did not properly distinguish
between integers and pointers.  Due to the way the system call error
handling routine worked, functions such as sbrk() returned some form of
-1, perhaps ((char *)-1), on error.  Obviously the proper C design for
such error returns (reported in-band in a nominally pointer value)
would be a null pointer, not some sort of cast -1.

Why this wasn't fixed when the IPC stuff was added for USG 4.x I don't
know.  Probably the same reason the PWB/Graphics unportable uses of
getc() were "fixed" by adding #if u3b2 instead of doing it right.



More information about the Comp.unix.wizards mailing list