This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] libstdc++/13943


Hi,

the below is what I have. As you can see, the PR is pretty old, closed
by mistake, then reopened today. Those special circumstances may explain
why the problem is still there: in the light of the present neighboring
code the fix seems rather simple, actually...

... nonetheless, I would appreciate a lot if Gaby could double check it ;)

Paolo.

/////////////////
2005-05-23  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/13943
	* include/c_std/std_cstdlib.h: Do not open code llabs and lldiv,
	available when _GLIBCXX_USE_C99 is defined.
	* testsuite/26_numerics/cstdlib/13943.cc: New.

	* acinclude.m4 ([GLIBCXX_ENABLE_C99]): For completeness, check
	also strtoll and strtoull for ac_c99_stdlib.
	* configure: Regenerate.
diff -urN libstdc++-v3-orig/acinclude.m4 libstdc++-v3/acinclude.m4
--- libstdc++-v3-orig/acinclude.m4	2005-05-05 18:10:35.000000000 +0200
+++ libstdc++-v3/acinclude.m4	2005-05-23 00:01:57.000000000 +0200
@@ -879,12 +879,14 @@
   AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
   AC_CACHE_VAL(ac_c99_stdlib, [
   AC_TRY_COMPILE([#include <stdlib.h>],
-                 [char* tmp; 
-	    	  strtof("gnu", &tmp); 
+                 [char* tmp;
+	    	  strtof("gnu", &tmp);
 		  strtold("gnu", &tmp);
-                  llabs(10); 
-		  lldiv(10,1); 
-		  atoll("10"); 
+	          strtoll("gnu", &tmp, 10);
+	          strtoull("gnu", &tmp, 10);
+	          llabs(10);
+		  lldiv(10,1);
+		  atoll("10");
 		  _Exit(0);
 		  lldiv_t mydivt;],[ac_c99_stdlib=yes], [ac_c99_stdlib=no])
   ])
diff -urN libstdc++-v3-orig/configure libstdc++-v3/configure
--- libstdc++-v3-orig/configure	2005-05-10 03:38:12.000000000 +0200
+++ libstdc++-v3/configure	2005-05-23 00:03:08.000000000 +0200
@@ -7059,7 +7059,9 @@
 char* tmp;
 	    	  strtof("gnu", &tmp);
 		  strtold("gnu", &tmp);
-                  llabs(10);
+	          strtoll("gnu", &tmp, 10);
+	          strtoull("gnu", &tmp, 10);
+	          llabs(10);
 		  lldiv(10,1);
 		  atoll("10");
 		  _Exit(0);
diff -urN libstdc++-v3-orig/include/c_std/std_cstdlib.h libstdc++-v3/include/c_std/std_cstdlib.h
--- libstdc++-v3-orig/include/c_std/std_cstdlib.h	2004-08-02 22:28:21.000000000 +0200
+++ libstdc++-v3/include/c_std/std_cstdlib.h	2005-05-22 23:32:54.000000000 +0200
@@ -1,6 +1,6 @@
 // -*- C++ -*- forwarding header.
 
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -168,17 +168,14 @@
   inline long long
   abs(long long __x) { return __x >= 0 ? __x : -__x; }
 
-  inline long long
-  llabs(long long __x) { return __x >= 0 ? __x : -__x; }
-
 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
+  using ::llabs;
+
   inline lldiv_t
   div(long long __n, long long __d)
   { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
 
-  inline lldiv_t
-  lldiv(long long __n, long long __d)
-  { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
+  using ::lldiv;
 #endif
 
 #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
@@ -204,8 +201,8 @@
 #endif
   using __gnu_cxx::_Exit;
   using __gnu_cxx::abs;
-  using __gnu_cxx::llabs;
 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
+  using __gnu_cxx::llabs;
   using __gnu_cxx::div;
   using __gnu_cxx::lldiv;
 #endif
diff -urN libstdc++-v3-orig/testsuite/26_numerics/cstdlib/13943.cc libstdc++-v3/testsuite/26_numerics/cstdlib/13943.cc
--- libstdc++-v3-orig/testsuite/26_numerics/cstdlib/13943.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/26_numerics/cstdlib/13943.cc	2005-05-22 23:53:36.000000000 +0200
@@ -0,0 +1,52 @@
+// Copyright (C) 2005 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+#if _GLIBCXX_USE_C99
+// libstdc++/13943
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+
+  VERIFY( llabs(-3) == 3 );
+  
+  lldiv_t q = lldiv(6, 4);
+  VERIFY( q.quot == 1 );
+  VERIFY( q.rem == 2 );
+}
+#endif
+
+int main()
+{
+#if _GLIBCXX_USE_C99
+  test01();
+#endif
+  return 0;
+}

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