Bug 582 - long long vs. unsigned long long
Summary: long long vs. unsigned long long
Status: RESOLVED WONTFIX
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: Build environment (show other bugs)
Version: 3.0.0
Hardware: Other other
: P3 normal
Target Milestone: none
Assignee: Tim Potter
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-07 08:13 UTC by Joachim Schmitz (mail address dead)
Modified: 2004-03-08 19:08 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joachim Schmitz (mail address dead) 2003-10-07 08:13:00 UTC
Hi there

configure checks whether "long long" is supported but in the code depending on 
that check "unsigned long long" is used, sometime pretty well hidden.

from configure.in:
AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
AC_TRY_RUN([#include <stdio.h>
main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }]
,
samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cros
s)])
if test x"$samba_cv_have_longlong" = x"yes"; then
    AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
fi

just run a 'grep HAVE_LONGLONG' on all .c and .h files to find where it's used.

Main and most obvious example is source/include/include.h:
#if defined(HAVE_LONGLONG)
#define SMB_BIG_UINT unsigned long long
#define SMB_BIG_INT long long
#define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>
32))
#else
#define SMB_BIG_UINT unsigned long
#define SMB_BIG_INT long
#define SBIG_UINT(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
#endif

My idea for a fix in configure.in, just test for unsigned long long instead:
AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
AC_TRY_RUN([#include <stdio.h>
main() { unsigned long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 
0: 1); }]
,
samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cros
s)])
if test x"$samba_cv_have_longlong" = x"yes"; then
    AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
fi

I guess no compiler would be so sick to support unsigned long long but not long 
long....

Bye, Jojo
Comment 1 Tim Potter 2003-10-15 00:07:57 UTC
I don't think there is an actual bug here.  I'm pretty sure that a compiler that
supports long long but not unsigned long long is very badly broken.

Jojo, have you run in to a particular problem?
Comment 2 Joachim Schmitz (mail address dead) 2003-10-15 02:36:25 UTC
Hi Tim

Yes I ran into a problem, I had to manually disable long long (export 
samba_cv_have_longlong=no; ./configure).

AFAIK neither long long, nor unsigned long long is a required part of the c89  
standard (it is required part of C99 standard though), and it is IMHO perfectly 
legal to add support for one but not for the other. I would agree though, that 
a compiler that supports unsigned long long, but not long long is pretty sick, 
hence my proposal to check for unsigned long long instead. Just strlen
("unsigned ") additional characters in configure.in...
The perfect fix would of course check for and act on both, but would probably 
not be worth the efford... 

bye, Jojo
Comment 3 Tim Potter 2003-11-04 12:03:05 UTC
I don't think there is anything else to do on this bug so I'm closing it off.
Comment 4 Joachim Schmitz (mail address dead) 2004-03-08 04:53:14 UTC
Does this mean 'won't fix'?
Comment 5 Tim Potter 2004-03-08 19:07:59 UTC
Yep.
Comment 6 Tim Potter 2004-03-08 19:08:32 UTC
Correctly mark as WONTFIX instead of FIXED.