-- --
-- S Y S T E M . M E M O R Y --
-- --
--- S p e c --
+-- B o d y --
-- --
--- Copyright (C) 2001-2002 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-2005 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- --
-- This implementation assumes that the underlying malloc/free/realloc
-- implementation is thread safe, and thus, no additional lock is required.
--- Note that we still need to defer abortion because on most systems,
--- an asynchronous signal (as used for implementing asynchronous abortion
--- of task) cannot safely be handled while malloc is executing.
+-- Note that we still need to defer abort because on most systems, an
+-- asynchronous signal (as used for implementing asynchronous abort of
+-- task) cannot safely be handled while malloc is executing.
--- If you are not using Ada constructs containing the "abort" keyword,
--- then you can remove the calls to Abort_Defer.all and Abort_Undefer.all
--- from this unit.
+-- If you are not using Ada constructs containing the "abort" keyword, then
+-- you can remove the calls to Abort_Defer.all and Abort_Undefer.all from
+-- this unit.
with Ada.Exceptions;
with System.Soft_Links;
with System.Parameters;
+with System.CRTL;
package body System.Memory is
use Ada.Exceptions;
use System.Soft_Links;
- function c_malloc (Size : size_t) return System.Address;
- pragma Import (C, c_malloc, "malloc");
+ function c_malloc (Size : System.CRTL.size_t) return System.Address
+ renames System.CRTL.malloc;
- procedure c_free (Ptr : System.Address);
- pragma Import (C, c_free, "free");
+ procedure c_free (Ptr : System.Address)
+ renames System.CRTL.free;
function c_realloc
- (Ptr : System.Address; Size : size_t) return System.Address;
- pragma Import (C, c_realloc, "realloc");
+ (Ptr : System.Address; Size : System.CRTL.size_t) return System.Address
+ renames System.CRTL.realloc;
-----------
-- Alloc --
end if;
if Parameters.No_Abort then
- Result := c_malloc (Actual_Size);
+ Result := c_malloc (System.CRTL.size_t (Actual_Size));
else
Abort_Defer.all;
- Result := c_malloc (Actual_Size);
+ Result := c_malloc (System.CRTL.size_t (Actual_Size));
Abort_Undefer.all;
end if;
return System.Address
is
Result : System.Address;
- Actual_Size : size_t := Size;
+ Actual_Size : constant size_t := Size;
begin
if Size = size_t'Last then
end if;
if Parameters.No_Abort then
- Result := c_realloc (Ptr, Actual_Size);
+ Result := c_realloc (Ptr, System.CRTL.size_t (Actual_Size));
else
Abort_Defer.all;
- Result := c_realloc (Ptr, Actual_Size);
+ Result := c_realloc (Ptr, System.CRTL.size_t (Actual_Size));
Abort_Undefer.all;
end if;