time(0L) - history of a misconception (was Re: SCO password generator)

Chris Torek torek at elf.ee.lbl.gov
Thu May 23 03:28:19 AEST 1991


In article <1141 at mwtech.UUCP> martin at mwtech.UUCP (Martin Weitzel) writes:
>... I'm curious if anybody has ideas from where this misconception
>[about the type of the argument to time()] originated.

Perhaps it dates back to Version 6 Unix, when C did not have a `long'
type.  The time() system call took a pointer to the first of two
`ints'.  In V7 this became a pointer to a long, but of course in V6
pointers and integers were freely interchangeable, and people wrote
such gems as

	struct xxreg {
		int	csr;	/* control/status */
		int	bar;	/* unibus address */
	};

	...
	0177440->bar = bp->b_addr;
	0177440->csr = XXREAD | XXGO;

One can speculate that `long' went in before `pointers are not ints',
and people changed their

	time(vec);

calls to

	t = time(0);

calls, but for backwards compatibility the time() function still
accepted pointers.  It still does; it should be `time_t time(void)',
but compatibility with 20-year-old software is oh so terribly
important :-) .

Perhaps if dmr is indulging his news habit and sees this, he might
comment....
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA		Domain:	torek at ee.lbl.gov



More information about the Comp.lang.c mailing list