You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by "Roy T. Fielding" <fi...@gbiv.com> on 2008/04/26 00:01:56 UTC

Re: svn commit: r651704 - in /apr/apr/trunk: file_io/unix/copy.c include/arch/netware/apr_arch_file_io.h include/arch/os2/apr_arch_file_io.h include/arch/unix/apr_arch_file_io.h include/arch/win32/apr_arch_file_io.h

On Apr 25, 2008, at 2:52 PM, bojan@apache.org wrote:

> ====================================================================== 
> ========
> --- apr/apr/trunk/file_io/unix/copy.c (original)
> +++ apr/apr/trunk/file_io/unix/copy.c Fri Apr 25 14:52:36 2008
> @@ -54,7 +54,8 @@
>
>      /* Copy bytes till the cows come home. */
>      while (1) {
> -        char buf[APR_BUFSIZ];
> +        char buf[BUFSIZ > APR_FILE_DEFAULT_BUFSIZE ? BUFSIZ
> +                                                   :  
> APR_FILE_DEFAULT_BUFSIZE];

I'm not sure that is portable C.  Is the compiler guaranteed to  
optimize that
into a constant?

....Roy


Re: svn commit: r651704 - in /apr/apr/trunk: file_io/unix/copy.c include/arch/netware/apr_arch_file_io.h include/arch/os2/apr_arch_file_io.h include/arch/unix/apr_arch_file_io.h include/arch/win32/apr_arch_file_io.h

Posted by Bojan Smojver <bo...@rexursive.com>.
On Fri, 2008-04-25 at 15:42 -0700, Roy T. Fielding wrote:

> I just checked by K&R 1st edition and it allows constants
> "possibly connected" by the ternary operator.  So, unless we find a
> specific compiler that doesn't accept it, I think we can leave it as is.

Too late... Already changed :-)

-- 
Bojan


Re: svn commit: r651704 - in /apr/apr/trunk: file_io/unix/copy.c include/arch/netware/apr_arch_file_io.h include/arch/os2/apr_arch_file_io.h include/arch/unix/apr_arch_file_io.h include/arch/win32/apr_arch_file_io.h

Posted by "Roy T. Fielding" <fi...@gbiv.com>.
On Apr 25, 2008, at 3:20 PM, Bojan Smojver wrote:
> On Sat, 2008-04-26 at 08:07 +1000, Bojan Smojver wrote:
>
>>> I'm not sure that is portable C.  Is the compiler guaranteed to
>>> optimize that
>>> into a constant?
>>
>> I would think so. BUFSIZ is defined as constant, as well as
>> APR_FILE_DEFAULT_SIZE. But, I'll check again...
>
> The book says that such expressions _may_ be evaluated during
> compilation. So, I guess it is not guaranteed (I would think any  
> modern
> compiler would do it, though).
>
> If you wish, I can have the classic #if (the one I did in header files
> before) in copy.c. That should make it clear.

I just checked by K&R 1st edition and it allows constants
"possibly connected" by the ternary operator.  So, unless we find a
specific compiler that doesn't accept it, I think we can leave it as is.

....Roy


Re: svn commit: r651704 - in /apr/apr/trunk: file_io/unix/copy.c include/arch/netware/apr_arch_file_io.h include/arch/os2/apr_arch_file_io.h include/arch/unix/apr_arch_file_io.h include/arch/win32/apr_arch_file_io.h

Posted by Bojan Smojver <bo...@rexursive.com>.
On Sat, 2008-04-26 at 08:07 +1000, Bojan Smojver wrote:

> > I'm not sure that is portable C.  Is the compiler guaranteed to  
> > optimize that
> > into a constant?
> 
> I would think so. BUFSIZ is defined as constant, as well as
> APR_FILE_DEFAULT_SIZE. But, I'll check again...

The book says that such expressions _may_ be evaluated during
compilation. So, I guess it is not guaranteed (I would think any modern
compiler would do it, though).

If you wish, I can have the classic #if (the one I did in header files
before) in copy.c. That should make it clear.

-- 
Bojan


Re: svn commit: r651704 - in /apr/apr/trunk: file_io/unix/copy.c include/arch/netware/apr_arch_file_io.h include/arch/os2/apr_arch_file_io.h include/arch/unix/apr_arch_file_io.h include/arch/win32/apr_arch_file_io.h

Posted by Bojan Smojver <bo...@rexursive.com>.
On Fri, 2008-04-25 at 15:01 -0700, Roy T. Fielding wrote:
> On Apr 25, 2008, at 2:52 PM, bojan@apache.org wrote:
> 
> > ====================================================================== 
> > ========
> > --- apr/apr/trunk/file_io/unix/copy.c (original)
> > +++ apr/apr/trunk/file_io/unix/copy.c Fri Apr 25 14:52:36 2008
> > @@ -54,7 +54,8 @@
> >
> >      /* Copy bytes till the cows come home. */
> >      while (1) {
> > -        char buf[APR_BUFSIZ];
> > +        char buf[BUFSIZ > APR_FILE_DEFAULT_BUFSIZE ? BUFSIZ
> > +                                                   :  
> > APR_FILE_DEFAULT_BUFSIZE];
> 
> I'm not sure that is portable C.  Is the compiler guaranteed to  
> optimize that
> into a constant?

I would think so. BUFSIZ is defined as constant, as well as
APR_FILE_DEFAULT_SIZE. But, I'll check again...

-- 
Bojan