From nobody@FreeBSD.org  Tue Nov 13 12:23:32 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 5ABF737B416
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 13 Nov 2001 12:23:28 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.4/8.11.4) id fADKNSb92636;
	Tue, 13 Nov 2001 12:23:28 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200111132023.fADKNSb92636@freefall.freebsd.org>
Date: Tue, 13 Nov 2001 12:23:28 -0800 (PST)
From: Sean Jensen-Grey <seanj@xyke.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ULONG_MAX defined as hex on freebsd, ULONG_MAX defined as int on GNU, breaks autoconf
X-Send-Pr-Version: www-1.0

>Number:         31955
>Category:       misc
>Synopsis:       ULONG_MAX defined as hex on freebsd, ULONG_MAX defined as int on GNU, breaks autoconf
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 13 12:30:01 PST 2001
>Closed-Date:    Tue Nov 13 12:58:13 PST 2001
>Last-Modified:  Tue Nov 13 13:00:01 PST 2001
>Originator:     Sean Jensen-Grey
>Release:        
>Organization:
>Environment:
bash-2.05$ uname -a
FreeBSD node2 4.3-RELEASE FreeBSD 4.3-RELEASE #0: Fri Jun 29 01:36:59 GMT 2001     xxx@:/usr/src/sys/compile/node2  i386
      
>Description:
I hit this when trying to compile the non-ports version of boa 0.94.11  on freebsd 4.3.

In the configure script is has a little piece of bc(1) code that determines how many bit to shift a ulong.

#include "confdefs.h"
#include <limits.h>

a = ULONG_MAX;
for (i=0;a;i++)
  a=a/2
for(j=0;i;j++)
  i=i/2
print j-1

on FreeBSD ULONG_MAX is defined as 0xfffffffful;

on GNU/Linux it is defined as 

[seanj@scale src]$ grep "ULONG_MAX" `locate limits.h`
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/limits.h:#undef ULONG_MAX
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/limits.h:#define ULONG_MAX (LONG_MAX * 2UL + 1)
/usr/lib/bcc/include/asm/limits.h:#define ULONG_MAX     0xffffffff      /* maximum unsigned long value */
/usr/include/limits.h:#   define ULONG_MAX      18446744073709551615UL
/usr/include/limits.h:#    define ULONG_MAX     4294967295UL
/usr/include/limits.h:#    define ULONG_MAX     4294967295L

on freebsd 4.3 it is

bash-2.05$ grep "ULONG_MAX" `locate limits.h`
/usr/include/machine/limits.h:#define   ULONG_MAX       0xffffffffffffffffUL
/usr/include/machine/limits.h:#define   ULONG_MAX       0xffffffffUL    /* max value for an unsigned long */
/usr/src/contrib/gcc/glimits.h:#undef ULONG_MAX
/usr/src/contrib/gcc/glimits.h:#define ULONG_MAX (LONG_MAX * 2UL + 1)
/usr/src/sys/alpha/include/limits.h:#define     ULONG_MAX       0xffffffffffffffffUL    /* max for an unsigned long */
/usr/src/sys/alpha/include/limits.h:#define     SIZE_T_MAX      ULONG_MAX       /* max value for a size_t */
/usr/src/sys/alpha/include/limits.h:#define     UQUAD_MAX       (ULONG_MAX)     /* max value for a uquad_t */
/usr/src/sys/i386/include/limits.h:#define      ULONG_MAX       0xffffffffffffffffUL
/usr/src/sys/i386/include/limits.h:#define      ULONG_MAX       0xffffffffUL    /* max value for an unsigned long */

this code gets piped through the cpp, then tr to remove the UL and then passed to bc. But on freebsd bc barfs on the 0xffff; it actually barfs on any hex format. 

I kludged the configure script by replacing the ulong_max line with

a = 2^32;

and skipping the whole cpp, tr step

Now my question is. Is this actually a bug? Or is it something we can change to be more inline with everything else and make configure scripts run more reliably? Or is this just one of the differences between GNU and FreeBSD? I haven't tried changing the definition of ULONG_MAX and recompiling world. Do we just patch the configure script in the ports and call it a day?      
>How-To-Repeat:
      
>Fix:
patch the boa configure script and let differences be differences?
>Release-Note:
>Audit-Trail:

From: David Malone <dwmalone@maths.tcd.ie>
To: Sean Jensen-Grey <seanj@xyke.com>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/31955: ULONG_MAX defined as hex on freebsd, ULONG_MAX defined as int on GNU, breaks autoconf
Date: Tue, 13 Nov 2001 20:49:05 +0000

 On Tue, Nov 13, 2001 at 12:23:28PM -0800, Sean Jensen-Grey wrote:
 > Now my question is. Is this actually a bug?
 
 This is a bug in either boa configure script or autoconf, I guess.
 It's reading a C header file, so it should be expected to understand
 anything which C can.
 
 I'll close the PR, unless you feel strongly otherwise?
 
 	David.
State-Changed-From-To: open->closed 
State-Changed-By: dwmalone 
State-Changed-When: Tue Nov 13 12:58:13 PST 2001 
State-Changed-Why:  
Submitter is going to take it up with the boa guys. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31955 

From: _-__-_ <seanj@xyke.com>
To: David Malone <dwmalone@maths.tcd.ie>
Cc: <freebsd-gnats-submit@FreeBSD.org>
Subject: Re: misc/31955: ULONG_MAX defined as hex on freebsd, ULONG_MAX
 defined as int on GNU, breaks autoconf
Date: Tue, 13 Nov 2001 13:01:20 -0800 (PST)

 damn logic, you have a point.
 
 I'll check with the boa guys and see if they manually added that check or
 if it is an autoconf thing.
 
 go ahead and close the PR.
 
 Sean.
 
 On Tue, 13 Nov 2001, David Malone wrote:
 
 > On Tue, Nov 13, 2001 at 12:23:28PM -0800, Sean Jensen-Grey wrote:
 > > Now my question is. Is this actually a bug?
 >
 > This is a bug in either boa configure script or autoconf, I guess.
 > It's reading a C header file, so it should be expected to understand
 > anything which C can.
 >
 > I'll close the PR, unless you feel strongly otherwise?
 >
 > 	David.
 >
 
>Unformatted:
