C optimizer

der Mouse mouse at mcgill-vision.UUCP
Tue Mar 7 20:08:34 AEST 1989


In article <1028 at frog.UUCP>, john at frog.UUCP (John Woods) writes:
> In article <3121 at ficc.uu.net>, peter at ficc.uu.net (Peter da Silva) writes:
>> Can anyone think of any pure system calls? ioctl(fd, TCGETA, tbuf)?

This really belongs in an OS-specific group.

Let's see....I just ran through the table of syscalls on this system
and getpagesize() and getdtablesize() are the only really pure syscalls
I see there.

> I think that if
> 	(getpid() != getpid())
> ever evaluated to 1, I would be severely astonished.

Signal handlers aside, that's not the point.  If I write

int pid1;
int pid2;

pid1 = getpid();
runinchild();
pid2 = getpid();

then I don't want the compiler to decide that it can rewrite the second
one to "pid2 = pid1;" because getpid() is pure - presumably
runinchild() will fork.

Here's a quick test: a function is pure if it can be replaced with a
memo-function wrapper without changing the semantics.  This is not true
of getpid() or sync(), to pick two examples that are tempting.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse at larry.mcrcim.mcgill.edu



More information about the Comp.unix.wizards mailing list