httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <>
Subject Re: [APR] Universal return syntax
Date Mon, 01 Feb 1999 17:35:56 GMT

On Tue, 26 Jan 1999, Ryan Bloom wrote:

> As one of the writers of the original document, I was hoping for
> acceptance of the always return an APRStatus.  However, you have convinced
> me this is not a great idea, so I have another thought.

I would much rather have a simple integer APRStatus than some of the other
proposals floating around.

That is, my first choice is:

- result = f(); /* int errno in thread-local-storage */

    This method does not force every function to have a stack frame.  The
    cost of the second return value is essentially the same as the cost
    of thread-local storage access -- which is something the kernel/libc
    folks have to optimize... and they can optimize it because they
    know the architecture and don't have to worry about portability.

    The simplicity of an integer errno means at no time will any CPU be
    wasted setting up strings and a structure which aren't going to
    be used.

and my second choice is:

- int errno = f(&result);

    This method costs a stack frame for all functions, no matter how
    small, using APR.  But maintains the simplicity of an enumerated
    error type.

In any case I strongly advocate that a single comparison *against zero*
be sufficient to answer the question "did an error occur?"  This is
the most portable fast comparison.  (This isn't true of the current
APRStatus proposal.)

And uh, I'm sorry for dragging this debate out.


View raw message