This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3] extern/fixed-memory/archive allocator
- From: Gabriel Dos Reis <gdr at cs dot tamu dot edu>
- To: Benjamin Kosnik <bkoz at redhat dot com>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: 29 Sep 2004 09:03:14 -0500
- Subject: Re: [v3] extern/fixed-memory/archive allocator
- Organization: Texas A&M University, Department of Computer Science
- References: <20040929002344.2785a19c.bkoz@redhat.com>
Benjamin Kosnik <bkoz@redhat.com> writes:
| I'm planning on using this in place of the current strategy for
| allocating global objects. Seems to work well in preliminary tests, but
| I post this for more comments.
|
| This is just a way of taking existing storage and fitting it in to the
| std::allocator model so that STL, string, etc can use it. It can be thought of
|
| http://gcc.gnu.org/ml/libstdc++/2003-01/msg00103.html
|
| crossed with src/global*.cc
|
| Actually I'd like to experiment with pre-allocating space for pools in
| mt_alloc with this. But, that's a later patch.
I really like the general idea. And I'd like to see our basic_string
use that technique too. However I think we would need first to fix the
front-end so that this works properly
+ typedef char layout_type[sizeof(_Tp)]
+ __attribute__ ((aligned(__alignof__(_Tp))));
Also, I'm wondering whether it should not be
typedef char storage_type[sizeof(_Tp)];
storage_type _M_instance __attribute__((__aligned__(__alignof(_Tp))));
(as I remember -- maybe that is fixed now -- attributes on array
typedefs used to be silently stripped)
We might want to abstract that into a standalone class, as it
basically implement the aligned_storage functionality in TR1.
-- Gaby