Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-14 Thread Jason Merrill

On 02/14/2013 02:16 PM, Paolo Carlini wrote:

... or the below, just in case an interesting system provides the
*quick_exit functions but doesn't define _GLIBCXX_USE_C99.


It seems rather unlikely that the system would provide some C11 
functions without the corresponding C99 ones.  I'm just going to #if out 
the whole test if the relevant functions aren't available:



commit e203f2dcdf077fcf61b4d6b3f8e399c25cc44dfb
Author: Jason Merrill 
Date:   Thu Feb 14 11:15:28 2013 -0500

	* testsuite/18_support/quick_exit/quick_exit.cc: #if out the whole
	test if unsupported.

diff --git a/libstdc++-v3/testsuite/18_support/quick_exit/quick_exit.cc b/libstdc++-v3/testsuite/18_support/quick_exit/quick_exit.cc
index 8e55890..b91cbe2 100644
--- a/libstdc++-v3/testsuite/18_support/quick_exit/quick_exit.cc
+++ b/libstdc++-v3/testsuite/18_support/quick_exit/quick_exit.cc
@@ -21,6 +21,7 @@
 
 // 18.5 - Start and termination
 
+#if defined(_GLIBCXX_HAVE_AT_QUICK_EXIT) && defined(_GLIBCXX_HAVE_QUICK_EXIT)
 #include 
 
 void handler()
@@ -35,9 +36,10 @@ void wrong_handler()
 
 int main()
 {
-#if defined(_GLIBCXX_HAVE_AT_QUICK_EXIT) && defined(_GLIBCXX_HAVE_QUICK_EXIT)
   std::at_quick_exit (handler);
   std::atexit (wrong_handler);
   std::quick_exit (1);
+}
+#else
+int main() {}
 #endif
-}


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-14 Thread Paolo Carlini
... or the below, just in case an interesting system provides the 
*quick_exit functions but doesn't define _GLIBCXX_USE_C99.


Paolo.

///
Index: testsuite/18_support/quick_exit/quick_exit.cc
===
--- testsuite/18_support/quick_exit/quick_exit.cc   (revision 196056)
+++ testsuite/18_support/quick_exit/quick_exit.cc   (working copy)
@@ -25,7 +25,9 @@
 
 void handler()
 {
+#if _GLIBCXX_USE_C99
   std::_Exit(0);
+#endif
 }
 
 void wrong_handler()
@@ -35,9 +37,11 @@
 
 int main()
 {
+#if _GLIBCXX_USE_C99
 #if defined(_GLIBCXX_HAVE_AT_QUICK_EXIT) && defined(_GLIBCXX_HAVE_QUICK_EXIT)
   std::at_quick_exit (handler);
   std::atexit (wrong_handler);
   std::quick_exit (1);
 #endif
+#endif
 }


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-14 Thread Paolo Carlini

Hi Rainer,

On 02/14/2013 04:45 PM, Rainer Orth wrote:

Jason Merrill  writes:


While I was going over the C++11 status page, I noticed that quick_exit is
implemented by glibc, it just needed to be added to the libstdc++ cstdlib
header.

The test fails on Solaris 9:

FAIL: 18_support/quick_exit/quick_exit.cc (test for excess errors)
Excess errors:
/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/18_support/quick_exit/quick_e
xit.cc:28:3: error: '_Exit' is not a member of 'std'

WARNING: 18_support/quick_exit/quick_exit.cc compilation failed to produce execu
table
extra_tool_flags are:
  -std=gnu++11

_Exit seems to be a C99 addition, only present since Solaris 10.
Indeed. Given the very simple nature of the testcase, I think something 
like the below can do, at least for 4.8.0, if Jason has no objections. 
Can you double check it on Solaris and in case commit it?


Thanks,
Paolo.

/
Index: testsuite/18_support/quick_exit/quick_exit.cc
===
--- testsuite/18_support/quick_exit/quick_exit.cc   (revision 196056)
+++ testsuite/18_support/quick_exit/quick_exit.cc   (working copy)
@@ -25,7 +25,9 @@
 
 void handler()
 {
+#if _GLIBCXX_USE_C99
   std::_Exit(0);
+#endif
 }
 
 void wrong_handler()


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-14 Thread Rainer Orth
Jason Merrill  writes:

> While I was going over the C++11 status page, I noticed that quick_exit is
> implemented by glibc, it just needed to be added to the libstdc++ cstdlib
> header.

The test fails on Solaris 9:

FAIL: 18_support/quick_exit/quick_exit.cc (test for excess errors)
Excess errors:
/vol/gcc/src/hg/trunk/local/libstdc++-v3/testsuite/18_support/quick_exit/quick_e
xit.cc:28:3: error: '_Exit' is not a member of 'std'

WARNING: 18_support/quick_exit/quick_exit.cc compilation failed to produce execu
table
extra_tool_flags are:
 -std=gnu++11

_Exit seems to be a C99 addition, only present since Solaris 10.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-13 Thread Paolo Carlini

Hi,

On 02/13/2013 03:38 PM, Jason Merrill wrote:

On 02/12/2013 07:55 AM, Paolo Carlini wrote:

Again, the current status is in a sense good because when the
_GLIBCXX_HAVE_AT_QUICK_EXIT and _GLIBCXX_HAVE_QUICK_EXIT are defined,
thus the system has the functions in its c library, including 
makes available the functions in namespace std irrespective of the
configury. But then why having c_std in the first place? I'll leave this
to Benjamin...
As I understand it, the difference between c_std and c_global is 
supposed to be that c_std keeps the C library in std, whereas c_global 
has it in both std and the global namespace.  All the other 
differences that have arisen between them seem unintended and wrong.
The fact is, for many, many years we didn't even try to keep the C 
library in std only. On the other hand the split c_std / c_global is 
relatively recent (was born in 4.3). Yes, I'm quite confused ;)
There is, however, a question whether we need c_std at all now that 
the standard allows the C library to be in the global namespace as well.

Indeed. We could maybe imagine do away with c_std in 4.9...

Paolo.


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-13 Thread Jason Merrill

On 02/12/2013 07:55 AM, Paolo Carlini wrote:

Again, the current status is in a sense good because when the
_GLIBCXX_HAVE_AT_QUICK_EXIT and _GLIBCXX_HAVE_QUICK_EXIT are defined,
thus the system has the functions in its c library, including 
makes available the functions in namespace std irrespective of the
configury. But then why having c_std in the first place? I'll leave this
to Benjamin...


As I understand it, the difference between c_std and c_global is 
supposed to be that c_std keeps the C library in std, whereas c_global 
has it in both std and the global namespace.  All the other differences 
that have arisen between them seem unintended and wrong.


There is, however, a question whether we need c_std at all now that the 
standard allows the C library to be in the global namespace as well.


Jason



Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-12 Thread Paolo Carlini

On 02/12/2013 01:47 PM, domi...@lps.ens.fr wrote:

But the last time I checked, modern darwin defined
_GLIBCXX_USE_C99_MATH_TR1, no problems.

AFAICT this is true, but I think darwin10 was released in 2011
so I doubt it has any support for c++11.


Anyway, about the cstdlib issue the below makes available the new
functions in c_std/cstdlib too, and I'm going to commit it, it's close
to what Jason originally committed. ...

It works, thanks,
Good, thus looks like you are using c_std on your machine?!? Because I 
just tried, and on a Darwin 12.2.0 machine the build uses c_global by 
default and everything was fine even before my last patchlet 
(_GLIBCXX_USE_C99_MATH_TR1 defined of course).


I think current Darwin is already fine, in general, in these areas.

Again, the current status is in a sense good because when the
_GLIBCXX_HAVE_AT_QUICK_EXIT and _GLIBCXX_HAVE_QUICK_EXIT are defined, 
thus the system has the functions in its c library, including  
makes available the functions in namespace std irrespective of the 
configury. But then why having c_std in the first place? I'll leave this 
to Benjamin...


Paolo.


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-12 Thread Dominique Dhumieres
> But the last time I checked, modern darwin defined
> _GLIBCXX_USE_C99_MATH_TR1, no problems.

AFAICT this is true, but I think darwin10 was released in 2011
so I doubt it has any support for c++11.

> Anyway, about the cstdlib issue the below makes available the new 
> functions in c_std/cstdlib too, and I'm going to commit it, it's close
> to what Jason originally committed. ...

It works, thanks,

Dominique

PS any chance to use this machinery for other missing items:
hypot, erf, ..., i.e., the c++11 additions?


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-12 Thread Paolo Carlini

On 02/12/2013 12:40 PM, domi...@lps.ens.fr wrote:

IIRC I have already asked a similar question about atan2, erf, ...
which don't appear in the std namespace on darwin.
You should check whether darwin by chance uses by default c_std instead 
of c_global. The former doesn't provide C++11 facilities. If, on the 
other hand, it uses c_global, it means _GLIBCXX_USE_C99_MATH_TR1 is 
undefined because a configure test fails on that specific darwin release 
you are using. But the last time I checked, modern darwin defined 
_GLIBCXX_USE_C99_MATH_TR1, no problems.


Anyway, about the cstdlib issue the below makes available the new 
functions in c_std/cstdlib too, and I'm going to commit it, it's close 
to what Jason originally committed. But, as I said already we don't 
normally provide C++11 functions in c_std, Benjamin may want to review 
what we are doing in c_std vs c_global, he designed the split.


Paolo.

//
Index: include/c_std/cstdlib
===
--- include/c_std/cstdlib   (revision 195968)
+++ include/c_std/cstdlib   (working copy)
@@ -57,6 +57,14 @@
   extern "C" void abort(void) throw () _GLIBCXX_NORETURN;
   extern "C" int atexit(void (*)()) throw ();
   extern "C" void exit(int) throw () _GLIBCXX_NORETURN;
+#if __cplusplus >= 201103L
+# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
+  extern "C" int at_quick_exit(void (*)()) throw ();
+# endif
+# ifdef _GLIBCXX_HAVE_QUICK_EXIT
+  extern "C" void quick_exit(int) throw() _GLIBCXX_NORETURN;
+# endif
+#endif
 } // namespace
 
 #else
@@ -67,6 +75,11 @@
 #undef abort
 #undef abs
 #undef atexit
+#if __cplusplus >= 201103L
+# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
+#  undef at_quick_exit
+# endif
+#endif
 #undef atof
 #undef atoi
 #undef atol
@@ -83,6 +96,11 @@
 #undef mbstowcs
 #undef mbtowc
 #undef qsort
+#if __cplusplus >= 201103L
+# ifdef _GLIBCXX_HAVE_QUICK_EXIT
+#  undef quick_exit
+# endif
+#endif
 #undef rand
 #undef realloc
 #undef srand
@@ -103,6 +121,11 @@
   using ::abort;
   using ::abs;
   using ::atexit;
+#if __cplusplus >= 201103L
+# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
+  using ::at_quick_exit;
+# endif
+#endif
   using ::atof;
   using ::atoi;
   using ::atol;
@@ -121,6 +144,11 @@
   using ::mbtowc;
 #endif // _GLIBCXX_HAVE_MBSTATE_T
   using ::qsort;
+#if __cplusplus >= 201103L
+# ifdef _GLIBCXX_HAVE_QUICK_EXIT
+  using ::quick_exit;
+# endif
+#endif
   using ::rand;
   using ::realloc;
   using ::srand;


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-12 Thread Dominique Dhumieres
IIRC I have already asked a similar question about atan2, erf, ...
which don't appear in the std namespace on darwin.

Dominique


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-12 Thread Paolo Carlini

On 02/12/2013 12:32 PM, Paolo Carlini wrote:

On 02/12/2013 12:26 PM, domi...@lps.ens.fr wrote:

The test fails on x86_64-apple-darwin10 with

FAIL: 18_support/quick_exit/quick_exit.cc (test for excess errors)
Excess errors:
/opt/gcc/work/libstdc++-v3/testsuite/18_support/quick_exit/quick_exit.cc:36:3: 
error: 'at_quick_exit' is not a member of 'std'
/opt/gcc/work/libstdc++-v3/testsuite/18_support/quick_exit/quick_exit.cc:38:3: 
error: 'quick_exit' is not a member of 'std'


UNRESOLVED: 18_support/quick_exit/quick_exit.cc compilation failed to 
produce executable
Looks like the configure test isn't strict enough and ends up defining 
the macros when the darwin libc actually doesn't provide the 
functions. Jason may want to review it...
An alternate explanation would be that darwin provides the functions but 
uses c_std instead of c_global. I can add back the functions to 
c_std/cstdlib too, but that seems wrong, because, as I said, normally we 
don't provide C++11 facilities in c_std.


Paolo.


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-12 Thread Paolo Carlini

On 02/12/2013 12:26 PM, domi...@lps.ens.fr wrote:

The test fails on x86_64-apple-darwin10 with

FAIL: 18_support/quick_exit/quick_exit.cc (test for excess errors)
Excess errors:
/opt/gcc/work/libstdc++-v3/testsuite/18_support/quick_exit/quick_exit.cc:36:3: 
error: 'at_quick_exit' is not a member of 'std'
/opt/gcc/work/libstdc++-v3/testsuite/18_support/quick_exit/quick_exit.cc:38:3: 
error: 'quick_exit' is not a member of 'std'

UNRESOLVED: 18_support/quick_exit/quick_exit.cc compilation failed to produce 
executable
Looks like the configure test isn't strict enough and ends up defining 
the macros when the darwin libc actually doesn't provide the functions. 
Jason may want to review it...


Paolo.


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-12 Thread Dominique Dhumieres
The test fails on x86_64-apple-darwin10 with

FAIL: 18_support/quick_exit/quick_exit.cc (test for excess errors)
Excess errors:
/opt/gcc/work/libstdc++-v3/testsuite/18_support/quick_exit/quick_exit.cc:36:3: 
error: 'at_quick_exit' is not a member of 'std'
/opt/gcc/work/libstdc++-v3/testsuite/18_support/quick_exit/quick_exit.cc:38:3: 
error: 'quick_exit' is not a member of 'std'

UNRESOLVED: 18_support/quick_exit/quick_exit.cc compilation failed to produce 
executable

TIA

Dominique


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-11 Thread Paolo Carlini

... this is what I committed.

Thanks,
Paolo.

/
2013-02-11  Paolo Carlini  

* include/c_std/cstdlib (at_quick_exit, quick_exit): Do not declare.
* include/c_global/cstdlib (at_quick_exit, quick_exit): Declare only
in C++11 mode and if available in the underlying C library.
* testsuite/18_support/quick_exit/quick_exit.cc: Compile with
-std=gnu++11; check _GLIBCXX_HAVE_AT_QUICK_EXIT and
_GLIBCXX_HAVE_QUICK_EXIT.
Index: include/c_global/cstdlib
===
--- include/c_global/cstdlib(revision 195952)
+++ include/c_global/cstdlib(working copy)
@@ -57,8 +57,14 @@
   extern "C" void abort(void) throw () _GLIBCXX_NORETURN;
   extern "C" int atexit(void (*)()) throw ();
   extern "C" void exit(int) throw () _GLIBCXX_NORETURN;
+#if __cplusplus >= 201103L
+# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
   extern "C" int at_quick_exit(void (*)()) throw ();
+# endif
+# ifdef _GLIBCXX_HAVE_QUICK_EXIT
   extern "C" void quick_exit(int) throw() _GLIBCXX_NORETURN;
+# endif
+#endif
 } // namespace std
 
 #else
@@ -69,7 +75,11 @@
 #undef abort
 #undef abs
 #undef atexit
-#undef at_quick_exit
+#if __cplusplus >= 201103L
+# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
+#  undef at_quick_exit
+# endif
+#endif
 #undef atof
 #undef atoi
 #undef atol
@@ -86,7 +96,11 @@
 #undef mbstowcs
 #undef mbtowc
 #undef qsort
-#undef quick_exit
+#if __cplusplus >= 201103L
+# ifdef _GLIBCXX_HAVE_QUICK_EXIT
+#  undef quick_exit
+# endif
+#endif
 #undef rand
 #undef realloc
 #undef srand
@@ -107,8 +121,10 @@
   using ::abort;
   using ::abs;
   using ::atexit;
-#ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
+#if __cplusplus >= 201103L
+# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
   using ::at_quick_exit;
+# endif
 #endif
   using ::atof;
   using ::atoi;
@@ -128,8 +144,10 @@
   using ::mbtowc;
 #endif // _GLIBCXX_HAVE_MBSTATE_T
   using ::qsort;
-#ifdef _GLIBCXX_HAVE_QUICK_EXIT
+#if __cplusplus >= 201103L
+# ifdef _GLIBCXX_HAVE_QUICK_EXIT
   using ::quick_exit;
+# endif
 #endif
   using ::rand;
   using ::realloc;
Index: include/c_std/cstdlib
===
--- include/c_std/cstdlib   (revision 195952)
+++ include/c_std/cstdlib   (working copy)
@@ -57,8 +57,6 @@
   extern "C" void abort(void) throw () _GLIBCXX_NORETURN;
   extern "C" int atexit(void (*)()) throw ();
   extern "C" void exit(int) throw () _GLIBCXX_NORETURN;
-  extern "C" int at_quick_exit(void (*)()) throw ();
-  extern "C" void quick_exit(int) throw() _GLIBCXX_NORETURN;
 } // namespace
 
 #else
@@ -69,7 +67,6 @@
 #undef abort
 #undef abs
 #undef atexit
-#undef at_quick_exit
 #undef atof
 #undef atoi
 #undef atol
@@ -86,7 +83,6 @@
 #undef mbstowcs
 #undef mbtowc
 #undef qsort
-#undef quick_exit
 #undef rand
 #undef realloc
 #undef srand
@@ -107,9 +103,6 @@
   using ::abort;
   using ::abs;
   using ::atexit;
-#ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
-  using ::at_quick_exit;
-#endif
   using ::atof;
   using ::atoi;
   using ::atol;
@@ -128,9 +121,6 @@
   using ::mbtowc;
 #endif // _GLIBCXX_HAVE_MBSTATE_T
   using ::qsort;
-#ifdef _GLIBCXX_HAVE_QUICK_EXIT
-  using ::quick_exit;
-#endif
   using ::rand;
   using ::realloc;
   using ::srand;
Index: testsuite/18_support/quick_exit/quick_exit.cc
===
--- testsuite/18_support/quick_exit/quick_exit.cc   (revision 195952)
+++ testsuite/18_support/quick_exit/quick_exit.cc   (working copy)
@@ -1,5 +1,7 @@
-// 2013-02-11 Jason Merrill
-
+// { dg-options "-std=gnu++11" }
+//
+// 2013-02-11  Jason  Merrill
+//
 // Copyright (C) 2013 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -33,7 +35,9 @@
 
 int main()
 {
+#if defined(_GLIBCXX_HAVE_AT_QUICK_EXIT) && defined(_GLIBCXX_HAVE_QUICK_EXIT)
   std::at_quick_exit (handler);
   std::atexit (wrong_handler);
   std::quick_exit (1);
+#endif
 }


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-11 Thread Paolo Carlini

On 02/11/2013 07:54 PM, Benjamin De Kosnik wrote:

I can tweak things for the two issues I noticed.

Thanks.

It seems like this is still 4.8 material to me.
Great. I'll take care of that later today. I'm also going to make sure 
the new testcase doesn't spuriously fail if the functions aren't 
actually available.


Paolo.


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-11 Thread Benjamin De Kosnik

> .. also, I think we should have #if __cplusplus >= 201103L protecting 
> these functions too, exactly like all the other C++11 bits. Eg, I
> don't think we should unconditionally, ie in C++03 mode too, declare 
> at_quick_exit and quick_exit in namespace std.

Yeah.
 
> I can tweak things for the two issues I noticed.

Thanks. 

It seems like this is still 4.8 material to me.

-benjamin


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-11 Thread Paolo Carlini
.. also, I think we should have #if __cplusplus >= 201103L protecting 
these functions too, exactly like all the other C++11 bits. Eg, I don't 
think we should unconditionally, ie in C++03 mode too, declare 
at_quick_exit and quick_exit in namespace std.


I can tweak things for the two issues I noticed.

Paolo.


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-11 Thread Paolo Carlini

Hi,

On 02/11/2013 06:33 PM, Jason Merrill wrote:
While I was going over the C++11 status page, I noticed that 
quick_exit is implemented by glibc, it just needed to be added to the 
libstdc++ cstdlib header.


Does this configury/feature macro handling look right?  Is this enough 
testcase?  Is this small/safe enough to go in for 4.8?
I'm only not sure we want to add the new C++11 functions to c_std too, 
besides c_global, because normally we don't, AFAIK. But Benjamin 
invented the split c_std / c_global, I'm only raising a trivial 
consistency issue.


Thanks!
Paolo.


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-11 Thread Benjamin De Kosnik

> Does this configury/feature macro handling look right? 

yes.

> Is this enough testcase? 

yes.

> Is this small/safe enough to go in for 4.8?

yes.
 
> commit 884a2a7815a95bade9d23f01b4c64a16808c7f05
> Author: Jason Merrill 
> Date:   Mon Feb 11 11:23:30 2013 -0500
> 
>   * linkage.m4 (GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE): New.
>   (GLIBCXX_CHECK_STDLIB_SUPPORT): Check for atexit and
> at_quick_exit.
>   * include/c_std/cstdlib: Add atexit and at_quick_exit.
>   * include/c_global/cstdlib: Add atexit and at_quick_exit.
>   * testsuite/18_support/quick_exit/quick_exit.cc: New.


thanks Jason

-benjamin