diff options
Diffstat (limited to 'gcc/ada/s-memory.ads')
-rw-r--r-- | gcc/ada/s-memory.ads | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/gcc/ada/s-memory.ads b/gcc/ada/s-memory.ads index 16742357209..d1203381460 100644 --- a/gcc/ada/s-memory.ads +++ b/gcc/ada/s-memory.ads @@ -6,11 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2001 Free Software Foundation, Inc. -- --- -- --- This specification is derived from the Ada Reference Manual for use with -- --- GNAT. The copyright notice above, and the license provisions that follow -- --- apply solely to the contents of the part following the private keyword. -- +-- Copyright (C) 2001-2003 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -43,28 +39,70 @@ -- that the ali and object files for this unit are found in the object -- search path. +-- This unit may be used directly from an application program by providing +-- an appropriate WITH, and the interface can be expected to remain stable. + package System.Memory is pragma Elaborate_Body; type size_t is mod 2 ** Standard'Address_Size; + -- Note: the reason we redefine this here instead of using the + -- definition in Interfaces.C is that we do not want to drag in + -- all of Interfaces.C just because System.Memory is used. function Alloc (Size : size_t) return System.Address; - -- malloc for use by GNAT, with error checking and task lockout, - -- as well as allocation tracking. + -- This is the low level allocation routine. Given a size in storage + -- units, it returns the address of a maximally aligned block of + -- memory. The implementation of this routine is guaranteed to be + -- task safe, and also aborts are deferred if necessary. + -- + -- If size_t is set to size_t'Last on entry, then a Storage_Error + -- exception is raised with a message "object too large". + -- + -- If size_t is set to zero on entry, then a minimal (but non-zero) + -- size block is allocated. + -- + -- Note: this is roughly equivalent to the standard C malloc call + -- with the additional semantics as described above. procedure Free (Ptr : System.Address); - -- free for use by GNAT, with task lockout and allocation tracking. + -- This is the low level free routine. It frees a block previously + -- allocated with a call to Alloc. As in the case of Alloc, this + -- call is guaranteed task safe, and aborts are deferred. + -- + -- Note: this is roughly equivalent to the standard C free call + -- with the additional semantics as described above. function Realloc (Ptr : System.Address; Size : size_t) return System.Address; - -- realloc for use by GNAT, with error checking and task lockout. + -- This is the low level reallocation routine. It takes an existing + -- block address returned by a previous call to Alloc or Realloc, + -- and reallocates the block. The size can either be increased or + -- decreased. If possible the reallocation is done in place, so that + -- the returned result is the same as the value of Ptr on entry. + -- However, it may be necessary to relocate the block to another + -- address, in which case the information is copied to the new + -- block, and the old block is freed. The implementation of this + -- routine is guaranteed to be task safe, and also aborts are + -- deferred as necessary. + -- + -- If size_t is set to size_t'Last on entry, then a Storage_Error + -- exception is raised with a message "object too large". + -- + -- If size_t is set to zero on entry, then a minimal (but non-zero) + -- size block is allocated. + -- + -- Note: this is roughly equivalent to the standard C realloc call + -- with the additional semantics as described above. private - pragma Export (C, Alloc, "__gnat_malloc"); - pragma Export (C, Free, "__gnat_free"); + -- The following names are used from the generated compiler code + + pragma Export (C, Alloc, "__gnat_malloc"); + pragma Export (C, Free, "__gnat_free"); pragma Export (C, Realloc, "__gnat_realloc"); end System.Memory; |