Re: Function Signatures In time.h
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Sun, 30 Apr 2006 17:53:57 GMT
August Karlstrom <fusionfive@xxxxxxxxx> writes:
Diomidis Spinellis wrote:
August Karlstrom wrote:OK, thanks for the input. On the other hand, the function difftime
Does anyone know why some of the functions in time.h use pointersMy guess is that this is an implementation decision related to the
to constant objects of type time_t when time_t is an aritmetic
type. Why is e.g. ctime declared as
char* ctime(const time_t* tp);
and not as
char* ctime(time_t t);
environment where C has its roots. In the Seventh Edition Unix (and
probably also in earlier versions), time_t is implemented as a long
<http://minnie.tuhs.org/UnixTree/V7/usr/include/sys/types.h.html>.
On a PDP-11 where that 1979 version of Unix run, passing as an
argument a 16 bit pointer to a 32 bit long was probably more
efficient than passing the actual 32 bit value.
double difftime(time_t t2, time_t t1);
does not use pointer arguments.
Probably difftime() wasn't added until later.
I *think* that on some early implementations, 32-bit ints weren't
directly supported, and what's now a ftime_t was probably defined as
an array of two ints. The declaration of time() may have been
something like:
time(int t[2]);
Certainly much of the C library would be different if it were being
defined from scratch today, without concern for backward
compatibility.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- Follow-Ups:
- Re: Function Signatures In time.h
- From: Diomidis Spinellis
- Re: Function Signatures In time.h
- References:
- Function Signatures In time.h
- From: August Karlstrom
- Re: Function Signatures In time.h
- From: Diomidis Spinellis
- Re: Function Signatures In time.h
- From: August Karlstrom
- Function Signatures In time.h
- Prev by Date: Re: 3n+1 problem of acm
- Next by Date: Re: Boost process and C
- Previous by thread: Re: Function Signatures In time.h
- Next by thread: Re: Function Signatures In time.h
- Index(es):
Relevant Pages
|