This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: Use __LONG_LONG_MAX__ if LONG_LONG_MIN etc are not available


> The problem is described in
> 	http://gcc.gnu.org/ml/gcc-bugs/2001-07/msg01112.html

It means your bits/std_limits.h was created incorrectly.  I think this
code removal from ./src/gen-num-limits.cc is causing your problem:

< // Force Linux <limits.h> to define the *LONG_LONG*
< #if __linux__ && _GLIBCPP_USE_LONG_LONG
[...]
< #endif

Now, that code removal actually looks good to me (because that code
contains unstated assumptions that only targets that define __linux__
use glibc etc)...  Why this change causes no problems for other glibc
Linux targets is beyond me...  Perhaps, no one else has long long
support enabled at the moment?

Instead of all the shenanigans to get this right in light of various
glibc versions and command line switches that influence limits.h, how
about we convert uses of LONG_LONG_MIN, LONG_LONG_MAX and
ULONG_LONG_MAX to use __LONG_LONG_MAX__ (which is unconditionally
defined by the gcc-generated limits.h file) when the former macros are
not available.  I will arbitrarily key off LONG_LONG_MIN.

[Notice that I constructed it so that it should break no functioning
 use of code.  Tested on i386-unknown-freebsd4.3 (mainline), which
 usually does not define long long support in libstdc++-v3, by forcing
 _GLIBCPP_USE_LONG_LONG to be defined while building bits/std_limits.h
 only.  I then inspected the generated file by hand.  Tested by Rod
 Stewart <stewart@lab43.org> on armv4l-*-linux-gnu (3.0 branch) with
 no related regressions since he last was able to bootstrap.]

To be installed on mainline and 3.0 after others that care about
related issues have a chance to complain.  BTW, armv4l-*-linux-gnu
bootstraps are broken on both 3.0 branch and mainline at the moment
due to the latest round of libstdc++ configuration patches so we need
this technique or a replacement ASAP.

Regards,
Loren

2001-07-31  Loren J. Rittle  <ljrittle@acm.org>

	* src/gen-num-limits.cc:  Use __LONG_LONG_MAX__ if
	LONG_LONG_MIN etc appear to not be defined.

Index: src/gen-num-limits.cc
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/src/gen-num-limits.cc,v
retrieving revision 1.13
diff -c -r1.13 gen-num-limits.cc
*** gen-num-limits.cc	2001/07/20 00:09:31	1.13
--- gen-num-limits.cc	2001/07/30 23:11:28
***************
*** 373,380 ****
--- 373,385 ----
  DEFINE_EXTREMA(long, LONG_MIN, LONG_MAX);
  DEFINE_EXTREMA(unsigned long, 0, ULONG_MAX);
  #ifdef _GLIBCPP_USE_LONG_LONG
+ #ifdef LONG_LONG_MIN 
  DEFINE_EXTREMA(long long, LONG_LONG_MIN, LONG_LONG_MAX);
  DEFINE_EXTREMA(unsigned long long, 0, ULONG_LONG_MAX);
+ #else
+ DEFINE_EXTREMA(long long, (-__LONG_LONG_MAX__-1), __LONG_LONG_MAX__);
+ DEFINE_EXTREMA(unsigned long long, 0, (__LONG_LONG_MAX__ * 2ULL + 1));
+ #endif
  #endif
  DEFINE_EXTREMA(float, FLT_MIN, FLT_MAX);
  DEFINE_EXTREMA(double, DBL_MIN, DBL_MAX);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]