Grant and company-
It is simply a way to define the parameters being passed. See "Function
Declarations" in http://www-ccs.ucsd.edu/c/index.html
It does look strange, but is legal on some (all??) modern compilers. I'll have
to try it.
I've used the timeval stuff to optimize efficiency and to find out when my code
is not receiving sufficient time from the scheduler. I know what the code
does, but did not know that the declaration was legit. I figured it was made
legal back when C was hacked to allow C++.
Now we all know!
-Scott
---- Grant Kelly <[EMAIL PROTECTED]> wrote:
> I came across this code which does something I've never seen before. Could
> someone explain what the variable declaration between the function header
> and the function body do? Or at least point me in a direction to find out
> for myself. Again, I know what the code does, but I don't know what the line
> marked with <==== does.
>
> Thanks,
> Grant
>
> int timeval_subtract (result, x, y)
> struct timeval *result, *x, *y; <==== What does this do???
> {
> /* Perform the carry for the later subtraction by updating y. */
> if (x->tv_usec < y->tv_usec) {
> int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
> y->tv_usec -= 1000000 * nsec;
> y->tv_sec += nsec;
> }
> if (x->tv_usec - y->tv_usec > 1000000) {
> int nsec = (y->tv_usec - x->tv_usec) / 1000000;
> y->tv_usec += 1000000 * nsec;
> y->tv_sec -= nsec;
> }
>
> /* Compute the time remaining to wait.
> tv_usec is certainly positive. */
> result->tv_sec = x->tv_sec - y->tv_sec;
> result->tv_usec = x->tv_usec - y->tv_usec;
>
> /* Return 1 if result is negative. */
> return x->tv_sec < y->tv_sec;
> }
_______________________________________________
RLUG mailing list
[email protected]
http://lists.rlug.org/mailman/listinfo/rlug