diff options
author | Olivier Hainque <hainque@adacore.com> | 2009-06-09 15:32:03 +0000 |
---|---|---|
committer | Olivier Hainque <hainque@gcc.gnu.org> | 2009-06-09 15:32:03 +0000 |
commit | ff346f70754c95c575fabaecb428d29115e7a7a5 (patch) | |
tree | 5a201c72baed287b76549a13fc9f60bd546845d5 /gcc/ada/gcc-interface/trans.c | |
parent | 6aa0b21841f542af5e5f30054744f81905108ad0 (diff) | |
download | gcc-ff346f70754c95c575fabaecb428d29115e7a7a5.zip gcc-ff346f70754c95c575fabaecb428d29115e7a7a5.tar.gz gcc-ff346f70754c95c575fabaecb428d29115e7a7a5.tar.bz2 |
utils2.c (build_call_alloc_dealloc_proc): New helper for build_call_alloc_dealloc with arguments to be interpreted...
ada/
* gcc-interface/utils2.c (build_call_alloc_dealloc_proc): New
helper for build_call_alloc_dealloc with arguments to be interpreted
identically. Process the case where a GNAT_PROC to call is provided.
(maybe_wrap_malloc): New helper for build_call_alloc_dealloc, to build
and return an allocator for DATA_SIZE bytes aimed at containing a
DATA_TYPE object, using the default __gnat_malloc allocator. Honor
DATA_TYPE alignments greater than what the latter offers.
(maybe_wrap_free): New helper for build_call_alloc_dealloc, to
release a DATA_TYPE object designated by DATA_PTR using the
__gnat_free entry point.
(build_call_alloc_dealloc): Expect object data type instead of naked
alignment constraint. Use the new helpers.
(build_allocator): Remove special processing for the super-aligned
case, now handled by build_call_alloc_dealloc. Pass data type instead
of the former alignment argument, as expected by the new interface.
* gcc-interface/gigi.h (build_call_alloc_dealloc): Adjust prototype
and comment.
* gcc-interface/trans.c (gnat_to_gnu) <case N_Free_Statement>:
Remove special processing for the super-aligned case, now handled
by build_call_alloc_dealloc. Pass data type instead of the former
alignment argument, as expected by the new interface.
testsuite/
* gnat.dg/align_max.adb: New test.
From-SVN: r148314
Diffstat (limited to 'gcc/ada/gcc-interface/trans.c')
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 45 |
1 files changed, 5 insertions, 40 deletions
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 2c471f1..d37e3c1 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -5101,9 +5101,6 @@ gnat_to_gnu (Node_Id gnat_node) tree gnu_obj_type; tree gnu_actual_obj_type = 0; tree gnu_obj_size; - unsigned int align; - unsigned int default_allocator_alignment - = get_target_default_allocator_alignment () * BITS_PER_UNIT; /* If this is a thin pointer, we must dereference it to create a fat pointer, then go back below to a thin pointer. The @@ -5142,7 +5139,6 @@ gnat_to_gnu (Node_Id gnat_node) gnu_actual_obj_type = gnu_obj_type; gnu_obj_size = TYPE_SIZE_UNIT (gnu_actual_obj_type); - align = TYPE_ALIGN (gnu_obj_type); if (TREE_CODE (gnu_obj_type) == RECORD_TYPE && TYPE_CONTAINS_TEMPLATE_P (gnu_obj_type)) @@ -5159,42 +5155,11 @@ gnat_to_gnu (Node_Id gnat_node) gnu_ptr, gnu_byte_offset); } - /* If the object was allocated from the default storage pool, the - alignment was greater than what the allocator provides, and this - is not a fat or thin pointer, what we have in gnu_ptr here is an - address dynamically adjusted to match the alignment requirement - (see build_allocator). What we need to pass to free is the - initial allocator's return value, which has been stored just in - front of the block we have. */ - - if (No (Procedure_To_Call (gnat_node)) - && align > default_allocator_alignment - && ! TYPE_FAT_OR_THIN_POINTER_P (gnu_ptr_type)) - { - /* We set GNU_PTR - as * (void **)((void *)GNU_PTR - (void *)sizeof(void *)) - in two steps: */ - - /* GNU_PTR (void *) - = (void *)GNU_PTR - (void *)sizeof (void *)) */ - gnu_ptr - = build_binary_op - (POINTER_PLUS_EXPR, ptr_void_type_node, - convert (ptr_void_type_node, gnu_ptr), - size_int (-POINTER_SIZE/BITS_PER_UNIT)); - - /* GNU_PTR (void *) = *(void **)GNU_PTR */ - gnu_ptr - = build_unary_op - (INDIRECT_REF, NULL_TREE, - convert (build_pointer_type (ptr_void_type_node), - gnu_ptr)); - } - - gnu_result = build_call_alloc_dealloc (gnu_ptr, gnu_obj_size, align, - Procedure_To_Call (gnat_node), - Storage_Pool (gnat_node), - gnat_node); + gnu_result + = build_call_alloc_dealloc (gnu_ptr, gnu_obj_size, gnu_obj_type, + Procedure_To_Call (gnat_node), + Storage_Pool (gnat_node), + gnat_node); } break; |