[Box Backup-dev] Patch: Fix compilation problems on Gentoo with gcc 4.1.1

Ben Summers boxbackup-dev at fluffy.co.uk
Mon Jun 19 09:46:19 BST 2006


Word-wrapping killed the patch. Could you try again as an attachment?

I propose to do cursory checks on a couple of non-Linux platforms,  
then just merge with trunk. It doesn't look very controversial.

I must get around to installing trac. :-)

Ben


On 18 Jun 2006, at 11:26, Stuart Hickinbottom wrote:

> Included below is a patch against the trunk (r625) that I've  
> produced to
> correct compilation failures on Gentoo since switching to GCC 4.1.1
> (this was discussed on the main discussion list previously, I've
> switched to the dev list for the discussion of the patch). The  
> original
> problem was tracked down to a more vigorous optimisation in GCC 4.1.1
> that caused a configure test to always fail - see the following thread
> for the details:
> http://lists.warhead.org.uk/pipermail/boxbackup/2006-June/002701.html
>
> The patch removes the reliance on the definition LLONG_MIN and  
> LLONG_MAX
> and replaces them with std::numeric_limits<long long>::min() and
> std::numeric_limits<long long>::max(). This was only actually being  
> used
> in bin/bbackupquery/BackupQueries.cpp so I'm reasonably confident it's
> unlikely to affect the actual core backup behaviour.
>
> As LLONG_MIN/LLONG_MAX are no longer needed I've also removed the
> configure test for that, and removed it from the hand-rolled  
> config.h.win32.
>
> I have tested this patch on Gentoo Linux with the following  
> versions of GCC:
> 3.3.6
> 3.4.6
> 4.1.1
>
> All compile cleanly and all pass.
>
> These were all tested with glibc-2.3.6 - that's the latest version
> marked stable for Gentoo and I don't really want to upgrade that to an
> unstable one to test.
>
> As for Win32, I have been unable to rebuild Box Backup with Visual C++
> (I was using 2005 Express Edition), and couldn't find any instructions
> to help sort out the problems (configure was failing to find
> nanosleep()). However, I've checked std::numeric_limits<long
> long>::min/max and they compile and behave as expected under the VC++
> compiler so I'm confident that it will work.
>
> If possible, I'd like this patch considered for inclusion in the next
> release of Box Backup.
>
> If you're happy, I'll also submit this as a local patch to Gentoo so
> that the current 0.10 version continues to compile for people who  
> switch
> to GCC 4.1.x (Gentoo is imminently moving to the 4.1 series  
> compiler and
> so this is necessary to let Gentoo people continue to use Box Backup).
>
> Any comments and questions, just let me know.
>
> Stuart
>
> ----- patch below (from 'svn diff'). If this isn't readable let me  
> know
> and I'll send it some other way - I wasn't sure whether the mailing  
> list
> accepted attachments.
>
> Index: infrastructure/m4/ax_check_llong_minmax.m4
> ===================================================================
> --- infrastructure/m4/ax_check_llong_minmax.m4	(revision 625)
> +++ infrastructure/m4/ax_check_llong_minmax.m4	(working copy)
> @@ -1,76 +0,0 @@
> -dnl @synopsis AX_CHECK_LLONG_MINMAX
> -dnl
> -dnl This macro will fix up LLONG_MIN and LLONG_MAX as appropriate.  
> I'm
> finding
> -dnl it quite difficult to believe that so many hoops are  
> necessary. The
> world
> -dnl seems to have gone quite mad.
> -dnl
> -dnl This gem is adapted from the OpenSSH configure script so here's
> -dnl the original copyright notice:
> -dnl
> -dnl Copyright (c) 1999-2004 Damien Miller
> -dnl
> -dnl Permission to use, copy, modify, and distribute this software  
> for any
> -dnl purpose with or without fee is hereby granted, provided that  
> the above
> -dnl copyright notice and this permission notice appear in all copies.
> -dnl
> -dnl @category C
> -dnl @author Martin Ebourne and Damien Miller
> -dnl @version 2005/07/07
> -
> -AC_DEFUN([AX_CHECK_LLONG_MINMAX], [
> -  AC_CHECK_DECL([LLONG_MAX], [have_llong_max=1], , [[#include  
> <limits.h>]])
> -  if test -z "$have_llong_max"; then
> -    AC_MSG_CHECKING([[for max value of long long]])
> -    AC_RUN_IFELSE([AC_LANG_SOURCE([[
> -      #include <stdio.h>
> -      /* Why is this so damn hard? */
> -      #undef __GNUC__
> -      #undef __USE_ISOC99
> -      #define __USE_ISOC99
> -      #include <limits.h>
> -      #define DATA "conftest.llminmax"
> -      int main(void) {
> -        FILE *f;
> -        long long i, llmin, llmax = 0;
> -
> -        if((f = fopen(DATA,"w")) == NULL)
> -          exit(1);
> -
> -        #if defined(LLONG_MIN) && defined(LLONG_MAX)
> -        fprintf(stderr, "Using system header for LLONG_MIN and
> LLONG_MAX\n");
> -        llmin = LLONG_MIN;
> -        llmax = LLONG_MAX;
> -        #else
> -        fprintf(stderr, "Calculating LLONG_MIN and LLONG_MAX\n");
> -        /* This will work on one's complement and two's complement */
> -        for (i = 1; i > llmax; i <<= 1, i++)
> -          llmax = i;
> -        llmin = llmax + 1LL;    /* wrap */
> -        #endif
> -
> -        /* Sanity check */
> -        if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 >  
> llmax
> || llmax - 1 > llmax) {
> -          fprintf(f, "unknown unknown\n");
> -          exit(2);
> -        }
> -
> -        if (fprintf(f ,"%lld %lld", llmin, llmax) < 0)
> -          exit(3);
> -
> -        exit(0);
> -      }
> -      ]])], [
> -      read llong_min llong_max < conftest.llminmax
> -      AC_MSG_RESULT([$llong_max])
> -      AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL],
> -                         [max value of long long calculated by  
> configure])
> -      AC_MSG_CHECKING([[for min value of long long]])
> -      AC_MSG_RESULT([$llong_min])
> -      AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL],
> -                         [min value of long long calculated by  
> configure])
> -      ],
> -      [AC_MSG_RESULT(not found)],
> -      [AC_MSG_WARN([[cross compiling: not checking]])]
> -      )
> -    fi
> -  ])dnl
> Index: configure.ac
> ===================================================================
> --- configure.ac	(revision 625)
> +++ configure.ac	(working copy)
> @@ -120,7 +120,6 @@
>  AC_STRUCT_TM
>  AX_CHECK_DIRENT_D_TYPE
>  AC_SYS_LARGEFILE
> -AX_CHECK_LLONG_MINMAX
>  AX_CHECK_DEFINE_PRAGMA
>  if test "x$ac_cv_c_bigendian" != "xyes"; then
>    AX_BSWAP64
> Index: lib/win32/config.h.win32
> ===================================================================
> --- lib/win32/config.h.win32	(revision 625)
> +++ lib/win32/config.h.win32	(working copy)
> @@ -318,12 +318,6 @@
>  /* Define to 1 if __syscall is available but needs a definition */
>  /* #undef HAVE___SYSCALL_NEED_DEFN */
>
> -/* max value of long long calculated by configure */
> -/* #undef LLONG_MAX */
> -
> -/* min value of long long calculated by configure */
> -/* #undef LLONG_MIN */
> -
>  /* Define to 1 if `lstat' dereferences a symlink specified with a  
> trailing
>     slash. */
>  /* #undef LSTAT_FOLLOWS_SLASHED_SYMLINK */
> Index: bin/bbackupquery/BackupQueries.cpp
> ===================================================================
> --- bin/bbackupquery/BackupQueries.cpp	(revision 625)
> +++ bin/bbackupquery/BackupQueries.cpp	(working copy)
> @@ -26,6 +26,7 @@
>  #endif
>
>  #include <set>
> +#include <limits>
>
>  #include "BackupQueries.h"
>  #include "Utils.h"
> @@ -777,7 +778,7 @@
>  	}
>  	
>  	int64_t id = ::strtoll(args[0].c_str(), 0, 16);
> -	if(id == LLONG_MIN || id == LLONG_MAX || id == 0)
> +	if(id == std::numeric_limits<long long>::min() || id ==
> std::numeric_limits<long long>::max() || id == 0)
>  	{
>  		printf("Not a valid object ID (specified in hex)\n");
>  		return;
> @@ -863,7 +864,7 @@
>  		{
>  			// Specified as ID.
>  			id = ::strtoll(args[0].c_str(), 0, 16);
> -			if(id == LLONG_MIN || id == LLONG_MAX || id == 0)
> +			if(id == std::numeric_limits<long long>::min() || id ==
> std::numeric_limits<long long>::max() || id == 0)
>  			{
>  				printf("Not a valid object ID (specified in hex)\n");
>  				return;
> @@ -1733,7 +1734,7 @@
>  	{
>  		// Specified as ID.
>  		dirID = ::strtoll(args[0].c_str(), 0, 16);
> -		if(dirID == LLONG_MIN || dirID == LLONG_MAX || dirID == 0)
> +		if(dirID == std::numeric_limits<long long>::min() || dirID ==
> std::numeric_limits<long long>::max() || dirID == 0)
>  		{
>  			printf("Not a valid object ID (specified in hex)\n");
>  			return;
> _______________________________________________
> Boxbackup-dev mailing list
> Boxbackup-dev at fluffy.co.uk
> http://lists.warhead.org.uk/mailman/listinfo/boxbackup-dev




More information about the Boxbackup-dev mailing list