3.1 PATCH: Check for setenv declaration for libstdc++-v3 testsuite

Rainer Orth ro@TechFak.Uni-Bielefeld.DE
Wed Mar 20 11:59:00 GMT 2002


Further comparison of Tru64 UNIX testsuite results

	http://gcc.gnu.org/ml/gcc-patches/2002-03/msg01239.html

found several new testsuite failures compared to 3.0.5:

FAIL: 22_locale/codecvt_members_char_char.cc (test for excess errors)
FAIL: 22_locale/collate_members_char.cc (test for excess errors)
FAIL: 22_locale/ctype_members_char.cc (test for excess errors)
FAIL: 22_locale/messages_members_char.cc (test for excess errors)
FAIL: 22_locale/money_get_members_char.cc (test for excess errors)
FAIL: 22_locale/money_put_members_char.cc (test for excess errors)
FAIL: 22_locale/moneypunct_members_char.cc (test for excess errors)
FAIL: 22_locale/num_get_members_char.cc (test for excess errors)
FAIL: 22_locale/num_put_members_char.cc (test for excess errors)
FAIL: 22_locale/numpunct_members_char.cc (test for excess errors)
FAIL: 22_locale/time_get_members_char.cc (test for excess errors)
FAIL: 22_locale/time_put_members_char.cc (test for excess errors)

They all have a common cause:

libstdc++-v3/testsuite/22_locale/codecvt_members_char_char.cc:92: `setenv' undeclared (first use this function)
libstdc++-v3/testsuite/22_locale/codecvt_members_char_char.cc:92: (Each undeclared identifier is reported only once for each function it appears in.)

This happens because configure.in used AC_CHECK_FUNCS(setenv).  Both Tru64
UNIX V4.0F and V5.1 have this function, but it's declaration in <unistd.h>
is protected by AES_SOURCE in V4.0F and _BSD in V5.1 and thus not visible.
The patch below checks for a declaration of setenv() usable from C++ and
thus fixes those failures.

Checking out other platforms here (Solaris 2 and IRIX 6), I noticed that
they lack setenv completely, but have putenv instead, like most (all?)
other System V platforms.  putenv is in POSIX.1-2001 as well, although
setenv is preferred:

	http://www.UNIX-systems.org/version3/

A future patch should test for and use putenv if it is available instead.

Bootstrapped without regressions on alpha-dec-osf5.1.

Ok for 3.1 branch and mainline?

	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University


Sat Mar 16 01:47:22 2002  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* acinclude.m4 (GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3): New.
	(GLIBCPP_CONFIGURE_TESTSUITE): Use it to check for setenv.
	* aclocal.m4: Regenerate.
	* configure: Likewise.
	
Index: acinclude.m4
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/acinclude.m4,v
retrieving revision 1.194.2.3
diff -u -p -r1.194.2.3 acinclude.m4
--- acinclude.m4	2002/03/13 06:25:29	1.194.2.3
+++ acinclude.m4	2002/03/20 19:53:19
@@ -559,6 +559,35 @@ AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_L
 
 
 dnl
+dnl Check to see if the (stdlib function) argument passed is
+dnl 1) declared when using the c++ compiler
+dnl 2) has "C" linkage
+dnl
+dnl argument 1 is name of function to check
+dnl
+dnl ASSUMES argument is a function with THREE parameters
+dnl
+dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3
+AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3, [
+  AC_MSG_CHECKING([for $1 declaration])
+  if test x${glibcpp_cv_func_$1_use+set} != xset; then
+    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
+      AC_LANG_SAVE
+      AC_LANG_CPLUSPLUS
+      AC_TRY_COMPILE([#include <stdlib.h>], 
+                     [ $1(0, 0, 0);], 
+                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
+      AC_LANG_RESTORE
+    ])
+  fi
+  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
+  if test x$glibcpp_cv_func_$1_use = x"yes"; then
+    AC_CHECK_FUNCS($1)    
+  fi
+])
+
+
+dnl
 dnl Because the builtins are picky picky picky about the arguments they take, 
 dnl do an explict linkage tests here.
 dnl Check to see if the (math function) argument passed is
@@ -1965,7 +1994,7 @@ AC_DEFUN(GLIBCPP_CONFIGURE_TESTSUITE, [
   GLIBCPP_CHECK_SETRLIMIT
 
   # Look for setenv, so that extended locale tests can be performed.
-  AC_CHECK_FUNCS(setenv)
+  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
 ])
 
 



More information about the Gcc-patches mailing list