Re: Elimitate duplication of get_catalogs in different abi

2015-09-30 Thread Jonathan Wakely

On 29/09/15 21:49 +0200, François Dumont wrote:

Indeed, I just rerun all tests with success. I am re-attaching the patch.

2015-09-30  François Dumont  
   Jonathan Wakely  

   * config/locale/gnu/messages_members.cc (Catalog_info, Catalogs):
   Move...
   * config/locale/gnu/c++locale_internal.h: ...here in std namespace.
   * config/locale/gnu/c_locale.cc: Move implementation of latter here.
   * config/abi/pre/gnu.ver: Adjust.

Ok to commit ?


OK, thanks.



Re: Elimitate duplication of get_catalogs in different abi

2015-09-29 Thread François Dumont
On 25/09/2015 17:58, Jonathan Wakely wrote:
> On 25/09/15 16:10 +0100, Jonathan Wakely wrote:
>> On 25/09/15 16:08 +0100, Jonathan Wakely wrote:
>>> On 23/09/15 21:28 +0200, François Dumont wrote:
 On 05/09/2015 23:02, François Dumont wrote:
> On 22/08/2015 14:24, Daniel Krügler wrote:
>> 2015-08-21 23:11 GMT+02:00 François Dumont :
>>> I think I found a better way to handle this problem. It is
>>> c++locale.cc
>>> that needs to be built with --fimplicit-templates. I even think
>>> that the
>>> *_cow.cc file do not need this option but as I don't know what
>>> is the
>>> drawback of this option I kept it. I also explicitely used the
>>> file name
>>> c++locale.cc even if it is an alias to a configurable source
>>> file.  I
>>> guess there must be some variable to use no ?
>>>
>>> With this patch there are 6 additional symbols. I guess I need to
>>> declare those in the scripts even if it is for internal library
>>> usage,
>>> right ?
>> I would expect that the new Catalog_info definition either has
>> deleted
>> or properly (user-)defined copy constructor and copy assignment
>> operator.
>>
>>
>> - Daniel
>>
> This type is used in C++98 so I need to make those private, not
> deleted.
>
> With this change, is the patch ok to commit ?
>
> François
>

 What about this patch ?

 I am still uncomfortable in exposing those implementation details
 in the
 versionned symbols but I don't know how to do otherwise. Do you
 want me
 to push this code in std::__detail namespace ?
>>>
>>> I think because the types are only used internally in the library we
>>> don't need to export them. The other code inside the shared library
>>> can refer to those symbols without them being exported.
>>>
>>> That way users can't see their names (because they're not in any
>>> public headers) and can't use the symbols (because they're not
>>> exported) so they're pure internal implementation details.
>>>
>>> I tested it briefly and it seems to work, so if you can confirm it
>>> still works then the patch is OK without the changes to gnu.ver
>>
>> Oh, the problem is that the symbols are matched by patterns in the
>> _GLIBCXX_3.4 version, so get exported with that version instead. Gah.
>>
>> In that case your patch would not have worked on Solaris anyway, as
>> the SOlaris linker gives an error if a symbol matches patterns in more
>> than one symbol version.
>>
>> Let me try to adjust the gnu.ver script to make this work ...
>
> This should do it ...
>
Indeed, I just rerun all tests with success. I am re-attaching the patch.

2015-09-30  François Dumont  
Jonathan Wakely  

* config/locale/gnu/messages_members.cc (Catalog_info, Catalogs):
Move...
* config/locale/gnu/c++locale_internal.h: ...here in std namespace.
* config/locale/gnu/c_locale.cc: Move implementation of latter here.
* config/abi/pre/gnu.ver: Adjust.

Ok to commit ?

François

diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index d42cd37..c761052 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -24,7 +24,7 @@ GLIBCXX_3.4 {
 # Names inside the 'extern' block are demangled names.
 extern "C++"
 {
-  std::[A-Z]*;
+  std::[ABD-Z]*;
   std::a[a-c]*;
   std::ad[a-n]*;
   std::ad[p-z]*;
@@ -106,7 +106,7 @@ GLIBCXX_3.4 {
 # std::istringstream*;
   std::istrstream*;
   std::i[t-z]*;
-  std::[A-Zj-k]*;
+  std::[j-k]*;
 # std::length_error::l*;
 # std::length_error::~l*;
   std::locale::[A-Za-e]*;
@@ -132,9 +132,8 @@ GLIBCXX_3.4 {
 # std::logic_error::l*;
   std::logic_error::what*;
 # std::logic_error::~l*;
-# std::[A-Zm-r]*;
-# std::[A-Zm]*;
-  std::[A-Z]*;
+# std::[m-r]*;
+# std::[m]*;
   std::messages[^_]*;
 # std::messages_byname*;
   std::money_*;
@@ -175,11 +174,13 @@ GLIBCXX_3.4 {
 # std::t[i-n]*;
   std::tr1::h[^a]*;
   std::t[s-z]*;
-# std::[A-Zu-z]*;
+# std::[u-z]*;
 # std::underflow_error::u*;
 # std::underflow_error::~u*;
   std::unexpected*;
-  std::[A-Zv-z]*;
+  std::valarray*;
+  # std::vector*
+  std::[w-z]*;
   std::_List_node_base::hook*;
   std::_List_node_base::swap*;
   std::_List_node_base::unhook*;
diff --git a/libstdc++-v3/config/locale/gnu/c++locale_internal.h b/libstdc++-v3/config/locale/gnu/c++locale_internal.h
index f1959d6..7db354c 100644
--- a/libstdc++-v3/config/locale/gnu/c++locale_internal.h
+++ b/libstdc++-v3/config/locale/gnu/c++locale_internal.h
@@ -36,8 +36,13 @@
 #include 
 #include 
 
+#include 
+#include 	// ::strdup
+
+#include 
+
 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
-  
+
 extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
 extern

Re: Elimitate duplication of get_catalogs in different abi

2015-09-25 Thread Jonathan Wakely

On 25/09/15 16:10 +0100, Jonathan Wakely wrote:

On 25/09/15 16:08 +0100, Jonathan Wakely wrote:

On 23/09/15 21:28 +0200, François Dumont wrote:

On 05/09/2015 23:02, François Dumont wrote:

On 22/08/2015 14:24, Daniel Krügler wrote:

2015-08-21 23:11 GMT+02:00 François Dumont :

I think I found a better way to handle this problem. It is c++locale.cc
that needs to be built with --fimplicit-templates. I even think that the
*_cow.cc file do not need this option but as I don't know what is the
drawback of this option I kept it. I also explicitely used the file name
c++locale.cc even if it is an alias to a configurable source file.  I
guess there must be some variable to use no ?

With this patch there are 6 additional symbols. I guess I need to
declare those in the scripts even if it is for internal library usage,
right ?

I would expect that the new Catalog_info definition either has deleted
or properly (user-)defined copy constructor and copy assignment
operator.


- Daniel


This type is used in C++98 so I need to make those private, not deleted.

With this change, is the patch ok to commit ?

François



What about this patch ?

I am still uncomfortable in exposing those implementation details in the
versionned symbols but I don't know how to do otherwise. Do you want me
to push this code in std::__detail namespace ?


I think because the types are only used internally in the library we
don't need to export them. The other code inside the shared library
can refer to those symbols without them being exported.

That way users can't see their names (because they're not in any
public headers) and can't use the symbols (because they're not
exported) so they're pure internal implementation details.

I tested it briefly and it seems to work, so if you can confirm it
still works then the patch is OK without the changes to gnu.ver


Oh, the problem is that the symbols are matched by patterns in the
_GLIBCXX_3.4 version, so get exported with that version instead. Gah.

In that case your patch would not have worked on Solaris anyway, as
the SOlaris linker gives an error if a symbol matches patterns in more
than one symbol version.

Let me try to adjust the gnu.ver script to make this work ...


This should do it ...

diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index d42cd37..c761052 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -24,7 +24,7 @@ GLIBCXX_3.4 {
 # Names inside the 'extern' block are demangled names.
 extern "C++"
 {
-  std::[A-Z]*;
+  std::[ABD-Z]*;
   std::a[a-c]*;
   std::ad[a-n]*;
   std::ad[p-z]*;
@@ -106,7 +106,7 @@ GLIBCXX_3.4 {
 # std::istringstream*;
   std::istrstream*;
   std::i[t-z]*;
-  std::[A-Zj-k]*;
+  std::[j-k]*;
 # std::length_error::l*;
 # std::length_error::~l*;
   std::locale::[A-Za-e]*;
@@ -132,9 +132,8 @@ GLIBCXX_3.4 {
 # std::logic_error::l*;
   std::logic_error::what*;
 # std::logic_error::~l*;
-# std::[A-Zm-r]*;
-# std::[A-Zm]*;
-  std::[A-Z]*;
+# std::[m-r]*;
+# std::[m]*;
   std::messages[^_]*;
 # std::messages_byname*;
   std::money_*;
@@ -175,11 +174,13 @@ GLIBCXX_3.4 {
 # std::t[i-n]*;
   std::tr1::h[^a]*;
   std::t[s-z]*;
-# std::[A-Zu-z]*;
+# std::[u-z]*;
 # std::underflow_error::u*;
 # std::underflow_error::~u*;
   std::unexpected*;
-  std::[A-Zv-z]*;
+  std::valarray*;
+  # std::vector*
+  std::[w-z]*;
   std::_List_node_base::hook*;
   std::_List_node_base::swap*;
   std::_List_node_base::unhook*;


Re: Elimitate duplication of get_catalogs in different abi

2015-09-25 Thread Jonathan Wakely

On 25/09/15 16:08 +0100, Jonathan Wakely wrote:

On 23/09/15 21:28 +0200, François Dumont wrote:

On 05/09/2015 23:02, François Dumont wrote:

On 22/08/2015 14:24, Daniel Krügler wrote:

2015-08-21 23:11 GMT+02:00 François Dumont :

I think I found a better way to handle this problem. It is c++locale.cc
that needs to be built with --fimplicit-templates. I even think that the
*_cow.cc file do not need this option but as I don't know what is the
drawback of this option I kept it. I also explicitely used the file name
c++locale.cc even if it is an alias to a configurable source file.  I
guess there must be some variable to use no ?

With this patch there are 6 additional symbols. I guess I need to
declare those in the scripts even if it is for internal library usage,
right ?

I would expect that the new Catalog_info definition either has deleted
or properly (user-)defined copy constructor and copy assignment
operator.


- Daniel


This type is used in C++98 so I need to make those private, not deleted.

With this change, is the patch ok to commit ?

François



What about this patch ?

I am still uncomfortable in exposing those implementation details in the
versionned symbols but I don't know how to do otherwise. Do you want me
to push this code in std::__detail namespace ?


I think because the types are only used internally in the library we
don't need to export them. The other code inside the shared library
can refer to those symbols without them being exported.

That way users can't see their names (because they're not in any
public headers) and can't use the symbols (because they're not
exported) so they're pure internal implementation details.

I tested it briefly and it seems to work, so if you can confirm it
still works then the patch is OK without the changes to gnu.ver


Oh, the problem is that the symbols are matched by patterns in the
_GLIBCXX_3.4 version, so get exported with that version instead. Gah.

In that case your patch would not have worked on Solaris anyway, as
the SOlaris linker gives an error if a symbol matches patterns in more
than one symbol version.

Let me try to adjust the gnu.ver script to make this work ...


Re: Elimitate duplication of get_catalogs in different abi

2015-09-25 Thread Jonathan Wakely

On 23/09/15 21:28 +0200, François Dumont wrote:

On 05/09/2015 23:02, François Dumont wrote:

On 22/08/2015 14:24, Daniel Krügler wrote:

2015-08-21 23:11 GMT+02:00 François Dumont :

I think I found a better way to handle this problem. It is c++locale.cc
that needs to be built with --fimplicit-templates. I even think that the
*_cow.cc file do not need this option but as I don't know what is the
drawback of this option I kept it. I also explicitely used the file name
c++locale.cc even if it is an alias to a configurable source file.  I
guess there must be some variable to use no ?

With this patch there are 6 additional symbols. I guess I need to
declare those in the scripts even if it is for internal library usage,
right ?

I would expect that the new Catalog_info definition either has deleted
or properly (user-)defined copy constructor and copy assignment
operator.


- Daniel


This type is used in C++98 so I need to make those private, not deleted.

With this change, is the patch ok to commit ?

François



What about this patch ?

I am still uncomfortable in exposing those implementation details in the
versionned symbols but I don't know how to do otherwise. Do you want me
to push this code in std::__detail namespace ?


I think because the types are only used internally in the library we
don't need to export them. The other code inside the shared library
can refer to those symbols without them being exported.

That way users can't see their names (because they're not in any
public headers) and can't use the symbols (because they're not
exported) so they're pure internal implementation details.

I tested it briefly and it seems to work, so if you can confirm it
still works then the patch is OK without the changes to gnu.ver

Thanks.


Re: Elimitate duplication of get_catalogs in different abi

2015-09-23 Thread François Dumont
On 05/09/2015 23:02, François Dumont wrote:
> On 22/08/2015 14:24, Daniel Krügler wrote:
>> 2015-08-21 23:11 GMT+02:00 François Dumont :
>>> I think I found a better way to handle this problem. It is c++locale.cc
>>> that needs to be built with --fimplicit-templates. I even think that the
>>> *_cow.cc file do not need this option but as I don't know what is the
>>> drawback of this option I kept it. I also explicitely used the file name
>>> c++locale.cc even if it is an alias to a configurable source file.  I
>>> guess there must be some variable to use no ?
>>>
>>> With this patch there are 6 additional symbols. I guess I need to
>>> declare those in the scripts even if it is for internal library usage,
>>> right ?
>> I would expect that the new Catalog_info definition either has deleted
>> or properly (user-)defined copy constructor and copy assignment
>> operator.
>>
>>
>> - Daniel
>>
> This type is used in C++98 so I need to make those private, not deleted.
>
> With this change, is the patch ok to commit ?
>
> François
>

What about this patch ?

I am still uncomfortable in exposing those implementation details in the
versionned symbols but I don't know how to do otherwise. Do you want me
to push this code in std::__detail namespace ?

François



Re: Elimitate duplication of get_catalogs in different abi

2015-09-05 Thread François Dumont
On 22/08/2015 14:24, Daniel Krügler wrote:
> 2015-08-21 23:11 GMT+02:00 François Dumont :
>> I think I found a better way to handle this problem. It is c++locale.cc
>> that needs to be built with --fimplicit-templates. I even think that the
>> *_cow.cc file do not need this option but as I don't know what is the
>> drawback of this option I kept it. I also explicitely used the file name
>> c++locale.cc even if it is an alias to a configurable source file.  I
>> guess there must be some variable to use no ?
>>
>> With this patch there are 6 additional symbols. I guess I need to
>> declare those in the scripts even if it is for internal library usage,
>> right ?
> I would expect that the new Catalog_info definition either has deleted
> or properly (user-)defined copy constructor and copy assignment
> operator.
>
>
> - Daniel
>
This type is used in C++98 so I need to make those private, not deleted.

With this change, is the patch ok to commit ?

François

diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index fc97cdf..8f9f99a 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -1871,6 +1871,14 @@ GLIBCXX_3.4.22 {
 # std::uncaught_exceptions()
 _ZSt19uncaught_exceptionsv;
 
+# std::Catalogs::*
+extern "C++"
+{
+  std::Catalogs::*;
+};
+
+_ZNSt6vectorIPSt12Catalog_info*;
+
 } GLIBCXX_3.4.21;
 
 # Symbols in the support library (libsupc++) have their own tag.
diff --git a/libstdc++-v3/config/locale/gnu/c++locale_internal.h b/libstdc++-v3/config/locale/gnu/c++locale_internal.h
index f1959d6..7db354c 100644
--- a/libstdc++-v3/config/locale/gnu/c++locale_internal.h
+++ b/libstdc++-v3/config/locale/gnu/c++locale_internal.h
@@ -36,8 +36,13 @@
 #include 
 #include 
 
+#include 
+#include 	// ::strdup
+
+#include 
+
 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
-  
+
 extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
 extern "C" __typeof(strcoll_l) __strcoll_l;
 extern "C" __typeof(strftime_l) __strftime_l;
@@ -61,3 +66,55 @@ extern "C" __typeof(wctype_l) __wctype_l;
 #endif 
 
 #endif // GLIBC 2.3 and later
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  struct Catalog_info
+  {
+Catalog_info(messages_base::catalog __id, const char* __domain,
+		 locale __loc)
+  : _M_id(__id), _M_domain(strdup(__domain)), _M_locale(__loc)
+{ }
+
+~Catalog_info()
+{ free(_M_domain); }
+
+messages_base::catalog _M_id;
+char* _M_domain;
+locale _M_locale;
+
+  private:
+Catalog_info(const Catalog_info&);
+
+Catalog_info&
+operator=(const Catalog_info&);
+  };
+
+  class Catalogs
+  {
+  public:
+Catalogs() : _M_catalog_counter(0) { }
+~Catalogs();
+
+messages_base::catalog
+_M_add(const char* __domain, locale __l);
+
+void
+_M_erase(messages_base::catalog __c);
+
+const Catalog_info*
+_M_get(messages_base::catalog __c) const;
+
+  private:
+mutable __gnu_cxx::__mutex _M_mutex;
+messages_base::catalog _M_catalog_counter;
+vector _M_infos;
+  };
+
+  Catalogs&
+  get_catalogs();
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/config/locale/gnu/c_locale.cc b/libstdc++-v3/config/locale/gnu/c_locale.cc
index 4612c64..708af0e 100644
--- a/libstdc++-v3/config/locale/gnu/c_locale.cc
+++ b/libstdc++-v3/config/locale/gnu/c_locale.cc
@@ -31,9 +31,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
+#include 
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -170,6 +173,85 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 return __changed;
   }
 
+  struct _CatalogIdComp
+  {
+bool
+operator()(messages_base::catalog __cat, const Catalog_info* __info) const
+{ return __cat < __info->_M_id; }
+
+bool
+operator()(const Catalog_info* __info, messages_base::catalog __cat) const
+{ return __info->_M_id < __cat; }
+  };
+
+  Catalogs::~Catalogs()
+  {
+for (vector::iterator __it = _M_infos.begin();
+	 __it != _M_infos.end(); ++__it)
+  delete *__it;
+  }
+
+  messages_base::catalog
+  Catalogs::_M_add(const char* __domain, locale __l)
+  {
+__gnu_cxx::__scoped_lock lock(_M_mutex);
+
+// The counter is not likely to roll unless catalogs keep on being
+// opened/closed which is consider as an application mistake for the
+// moment.
+if (_M_catalog_counter == numeric_limits::max())
+  return -1;
+
+auto_ptr info(new Catalog_info(_M_catalog_counter++,
+		 __domain, __l));
+
+// Check if we managed to allocate memory for domain.
+if (!info->_M_domain)
+  return -1;
+
+_M_infos.push_back(info.get());
+return info.release()->_M_id;
+  }
+
+  void
+  Catalogs::_M_erase(messages_base::catalog __c)
+  {
+__gnu_cxx::__scoped_lock lock(_M_mutex);
+
+vector::iterator __res =
+  lower_bound(_M_info

Re: Elimitate duplication of get_catalogs in different abi

2015-08-22 Thread Daniel Krügler
2015-08-21 23:11 GMT+02:00 François Dumont :
> I think I found a better way to handle this problem. It is c++locale.cc
> that needs to be built with --fimplicit-templates. I even think that the
> *_cow.cc file do not need this option but as I don't know what is the
> drawback of this option I kept it. I also explicitely used the file name
> c++locale.cc even if it is an alias to a configurable source file.  I
> guess there must be some variable to use no ?
>
> With this patch there are 6 additional symbols. I guess I need to
> declare those in the scripts even if it is for internal library usage,
> right ?

I would expect that the new Catalog_info definition either has deleted
or properly (user-)defined copy constructor and copy assignment
operator.


- Daniel


Re: Elimitate duplication of get_catalogs in different abi

2015-08-21 Thread François Dumont
On 05/08/2015 22:57, Jonathan Wakely wrote:
> On 30/07/15 21:57 +0200, François Dumont wrote:
>> It seems that this patch results in unresolved symbols.
>>
>> I am quite sure that the code is right but build system should be
>> adapted.
>>
>> I noticed that *_cow.cc files are built with -fimplicit-templates. I try
>> to apply the same with the old abi but I still experiment unresolved
>> symbols.
>>
>> Any help is welcome.
>
> OK, I'll look into it next week, when I'm back from the GNU Cauldron.
>
>
I think I found a better way to handle this problem. It is c++locale.cc
that needs to be built with --fimplicit-templates. I even think that the
*_cow.cc file do not need this option but as I don't know what is the
drawback of this option I kept it. I also explicitely used the file name
c++locale.cc even if it is an alias to a configurable source file.  I
guess there must be some variable to use no ?

With this patch there are 6 additional symbols. I guess I need to
declare those in the scripts even if it is for internal library usage,
right ?

François

diff --git libstdc++-v3/config/locale/gnu/c++locale_internal.h libstdc++-v3/config/locale/gnu/c++locale_internal.h
index f1959d6..eeac620 100644
--- libstdc++-v3/config/locale/gnu/c++locale_internal.h
+++ libstdc++-v3/config/locale/gnu/c++locale_internal.h
@@ -36,8 +36,13 @@
 #include 
 #include 
 
+#include 
+#include 	// ::strdup
+
+#include 
+
 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
-  
+
 extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
 extern "C" __typeof(strcoll_l) __strcoll_l;
 extern "C" __typeof(strftime_l) __strftime_l;
@@ -61,3 +66,49 @@ extern "C" __typeof(wctype_l) __wctype_l;
 #endif 
 
 #endif // GLIBC 2.3 and later
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  struct Catalog_info
+  {
+Catalog_info(messages_base::catalog __id, const char* __domain,
+		 locale __loc)
+  : _M_id(__id), _M_domain(strdup(__domain)), _M_locale(__loc)
+{ }
+
+~Catalog_info()
+{ free(_M_domain); }
+
+messages_base::catalog _M_id;
+char* _M_domain;
+locale _M_locale;
+  };
+
+  class Catalogs
+  {
+  public:
+Catalogs() : _M_catalog_counter(0) { }
+~Catalogs();
+
+messages_base::catalog
+_M_add(const char* __domain, locale __l);
+
+void
+_M_erase(messages_base::catalog __c);
+
+const Catalog_info*
+_M_get(messages_base::catalog __c) const;
+
+  private:
+mutable __gnu_cxx::__mutex _M_mutex;
+messages_base::catalog _M_catalog_counter;
+vector _M_infos;
+  };
+
+  Catalogs&
+  get_catalogs();
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git libstdc++-v3/config/locale/gnu/c_locale.cc libstdc++-v3/config/locale/gnu/c_locale.cc
index 4612c64..708af0e 100644
--- libstdc++-v3/config/locale/gnu/c_locale.cc
+++ libstdc++-v3/config/locale/gnu/c_locale.cc
@@ -31,9 +31,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
+#include 
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -170,6 +173,85 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 return __changed;
   }
 
+  struct _CatalogIdComp
+  {
+bool
+operator()(messages_base::catalog __cat, const Catalog_info* __info) const
+{ return __cat < __info->_M_id; }
+
+bool
+operator()(const Catalog_info* __info, messages_base::catalog __cat) const
+{ return __info->_M_id < __cat; }
+  };
+
+  Catalogs::~Catalogs()
+  {
+for (vector::iterator __it = _M_infos.begin();
+	 __it != _M_infos.end(); ++__it)
+  delete *__it;
+  }
+
+  messages_base::catalog
+  Catalogs::_M_add(const char* __domain, locale __l)
+  {
+__gnu_cxx::__scoped_lock lock(_M_mutex);
+
+// The counter is not likely to roll unless catalogs keep on being
+// opened/closed which is consider as an application mistake for the
+// moment.
+if (_M_catalog_counter == numeric_limits::max())
+  return -1;
+
+auto_ptr info(new Catalog_info(_M_catalog_counter++,
+		 __domain, __l));
+
+// Check if we managed to allocate memory for domain.
+if (!info->_M_domain)
+  return -1;
+
+_M_infos.push_back(info.get());
+return info.release()->_M_id;
+  }
+
+  void
+  Catalogs::_M_erase(messages_base::catalog __c)
+  {
+__gnu_cxx::__scoped_lock lock(_M_mutex);
+
+vector::iterator __res =
+  lower_bound(_M_infos.begin(), _M_infos.end(), __c, _CatalogIdComp());
+if (__res == _M_infos.end() || (*__res)->_M_id != __c)
+  return;
+
+delete *__res;
+_M_infos.erase(__res);
+
+// Just in case closed catalog was the last open.
+if (__c == _M_catalog_counter - 1)
+  --_M_catalog_counter;
+  }
+
+  const Catalog_info*
+  Catalogs::_M_get(messages_base::catalog __c) const
+  {
+__gnu_cxx::__scoped_lock lock(_M_mutex);
+
+vector::const_iterator __res =
+  lower_bound(_M_infos.begin(), _M_infos.end(), __c, _CatalogIdComp());

Re: Elimitate duplication of get_catalogs in different abi

2015-08-05 Thread Jonathan Wakely

On 30/07/15 21:57 +0200, François Dumont wrote:

It seems that this patch results in unresolved symbols.

I am quite sure that the code is right but build system should be adapted.

I noticed that *_cow.cc files are built with -fimplicit-templates. I try
to apply the same with the old abi but I still experiment unresolved
symbols.

Any help is welcome.


OK, I'll look into it next week, when I'm back from the GNU Cauldron.



Re: Elimitate duplication of get_catalogs in different abi

2015-07-30 Thread François Dumont
It seems that this patch results in unresolved symbols.

I am quite sure that the code is right but build system should be adapted.

I noticed that *_cow.cc files are built with -fimplicit-templates. I try
to apply the same with the old abi but I still experiment unresolved
symbols.

Any help is welcome.

François


On 27/07/2015 22:30, François Dumont wrote:
> Hi
>
> This is the patch to get rid of the duplication of the get_catalogs
> functions in the .so.
>
> I used c++locale_internal.h that seems to be there for this kind of
> purpose.
>
> * config/locale/gnu/messages_members.cc (Catalog_info, Catalogs):
> Move...
> * config/locale/gnu/c++locale_internal.h: ...here in std namespace.
> * config/locale/gnu/c_locale.cc: Move implementation of latter here.
>
> Tested under linux x86_64.
>
> Ok to commit ?
>
> François
>



Elimitate duplication of get_catalogs in different abi

2015-07-27 Thread François Dumont
Hi

This is the patch to get rid of the duplication of the get_catalogs
functions in the .so.

I used c++locale_internal.h that seems to be there for this kind of
purpose.

* config/locale/gnu/messages_members.cc (Catalog_info, Catalogs):
Move...
* config/locale/gnu/c++locale_internal.h: ...here in std namespace.
* config/locale/gnu/c_locale.cc: Move implementation of latter here.

Tested under linux x86_64.

Ok to commit ?

François

diff --git libstdc++-v3/config/locale/gnu/c++locale_internal.h libstdc++-v3/config/locale/gnu/c++locale_internal.h
index f1959d6..eeac620 100644
--- libstdc++-v3/config/locale/gnu/c++locale_internal.h
+++ libstdc++-v3/config/locale/gnu/c++locale_internal.h
@@ -36,8 +36,13 @@
 #include 
 #include 
 
+#include 
+#include 	// ::strdup
+
+#include 
+
 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
-  
+
 extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
 extern "C" __typeof(strcoll_l) __strcoll_l;
 extern "C" __typeof(strftime_l) __strftime_l;
@@ -61,3 +66,49 @@ extern "C" __typeof(wctype_l) __wctype_l;
 #endif 
 
 #endif // GLIBC 2.3 and later
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  struct Catalog_info
+  {
+Catalog_info(messages_base::catalog __id, const char* __domain,
+		 locale __loc)
+  : _M_id(__id), _M_domain(strdup(__domain)), _M_locale(__loc)
+{ }
+
+~Catalog_info()
+{ free(_M_domain); }
+
+messages_base::catalog _M_id;
+char* _M_domain;
+locale _M_locale;
+  };
+
+  class Catalogs
+  {
+  public:
+Catalogs() : _M_catalog_counter(0) { }
+~Catalogs();
+
+messages_base::catalog
+_M_add(const char* __domain, locale __l);
+
+void
+_M_erase(messages_base::catalog __c);
+
+const Catalog_info*
+_M_get(messages_base::catalog __c) const;
+
+  private:
+mutable __gnu_cxx::__mutex _M_mutex;
+messages_base::catalog _M_catalog_counter;
+vector _M_infos;
+  };
+
+  Catalogs&
+  get_catalogs();
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git libstdc++-v3/config/locale/gnu/c_locale.cc libstdc++-v3/config/locale/gnu/c_locale.cc
index 4612c64..0d6d204 100644
--- libstdc++-v3/config/locale/gnu/c_locale.cc
+++ libstdc++-v3/config/locale/gnu/c_locale.cc
@@ -31,9 +31,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
+#include 
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -170,6 +173,85 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 return __changed;
   }
 
+  struct _CatalogIdComp
+  {
+bool
+operator()(messages_base::catalog __cat, const Catalog_info* __info) const
+{ return __cat < __info->_M_id; }
+
+bool
+operator()(const Catalog_info* __info, messages_base::catalog __cat) const
+{ return __info->_M_id < __cat; }
+  };
+
+  Catalogs::~Catalogs()
+  {
+for (vector::iterator __it = _M_infos.begin();
+	 __it != _M_infos.end(); ++__it)
+  delete *__it;
+  }
+
+  messages_base::catalog
+  Catalogs::_M_add(const char* __domain, locale __l)
+  {
+__gnu_cxx::__scoped_lock lock(_M_mutex);
+
+// The counter is not likely to roll unless catalogs keep on being
+// opened/closed which is consider as an application mistake for the
+// moment.
+if (_M_catalog_counter == numeric_limits::max())
+  return -1;
+
+auto_ptr info(new Catalog_info(_M_catalog_counter++,
+		 __domain, __l));
+
+// Check if we managed to allocate memory for domain.
+if (!info->_M_domain)
+  return -1;
+
+_M_infos.push_back(info.get());
+return info.release()->_M_id;
+  }
+
+  void
+  Catalogs::_M_erase(messages_base::catalog __c)
+  {
+__gnu_cxx::__scoped_lock lock(_M_mutex);
+
+vector::iterator __res =
+  lower_bound(_M_infos.begin(), _M_infos.end(), __c, _CatalogIdComp());
+if (__res == _M_infos.end() || (*__res)->_M_id != __c)
+  return;
+
+delete *__res;
+_M_infos.erase(__res);
+
+// Just in case closed catalog was the last open.
+if (__c == _M_catalog_counter - 1)
+  --_M_catalog_counter;
+  }
+
+  const Catalog_info*
+  Catalogs::_M_get(messages_base::catalog __c) const
+  {
+__gnu_cxx::__scoped_lock lock(_M_mutex);
+
+vector::const_iterator __res =
+  lower_bound(_M_infos.begin(), _M_infos.end(), __c, _CatalogIdComp());
+
+if (__res != _M_infos.end() && (*__res)->_M_id == __c)
+  return *__res;
+
+return 0;
+  }
+
+  Catalogs&
+  get_catalogs()
+  {
+static Catalogs __catalogs;
+return __catalogs;
+  }
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
diff --git libstdc++-v3/config/locale/gnu/messages_members.cc libstdc++-v3/config/locale/gnu/messages_members.cc
index 2e6122d..90f4b8d 100644
--- libstdc++-v3/config/locale/gnu/messages_members.cc
+++ libstdc++-v3/config/locale/gnu/messages_members.cc
@@ -31,115 +31,13 @@
 #include 
 #include 
 
-#include 
-#include 
-#include 
 #inc