Re: Compiling problem on AIX 4.2.1 with gcc

From: Chris Wedgwood <chris@dont-contact.us>
Date: Wed, 21 Apr 1999 14:47:11 +1200

On Tue, Apr 20, 1999 at 06:22:33PM -0700, Michael V. Pelletier wrote:

> It works best if the starting point is a power of two, since we're
> dealing with integer values and division by two via the
> bit-shift-right operator. On five occasions, the bit shift pushed
> off a one value in the 2^0 position of the number, losing the 0.5
> and leading to the 60002 result. The better starting value would
> be 524288, also known as 2^19.

Right... my brain was on vacation when I wrote that. The below code
below will however handle non-power-of-two situations, etc.

main()
{
        int c = 1024*1024;
        int f = 3,g;
        
        while((c - f) > 1){
                g = (c + f) / 2;
                
                if(dup2(0,g) < 0)
                        c = g;
                else
                        close(f = g);
        }
        
        printf("maxfd = %d\n",c);
}
Received on Tue Jul 29 2003 - 13:15:57 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:05 MST