This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] fix processing of allocators for overaligned unconstrained arrays


Ada allocators for maximally aligned types calls for special treatment
when the alignment request is greater than what the system malloc
honors, as is typical on x86-linux targets..

The unconstrained array part of the test currently fails on such targets
because the "special processing" is explicitely not applied to these types
in gigi.

There is actually no reason to process the base allocation of unconstrained
arrays specially, so the patch attached fixes the bug at hand by factorizing
the super-alignment processing in (now helpers of) build_call_alloc_dealloc
instead of dealing with it in too ad-hoc a manner in clients. An opportunity
to cleanup this area a bit.

Tested on x86-suse--linux.

Applying to mainline.

Olivier

2009-06-09  Olivier Hainque  <hainque@adacore.com>

	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.

Attachment: align_max.dif
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]