add some git ignore files
[A2k.git] / crtl / crtl.adb
blobb46696c9a32a01101845483c680164211cb97db7
1 with Interfaces;
2 with Unchecked_Conversion;
3 with System.Storage_Elements;
5 package body Crtl is
7 function memcpy
8 (S1 : System.Address; S2 : System.Address; N : size_t)
9 return System.Address
11 type Pointer is access all Interfaces.Unsigned_8;
13 function To_Pointer is new Unchecked_Conversion (System.Address, Pointer);
14 function To_Address is new Unchecked_Conversion (Pointer, System.Address);
16 ---------
17 -- "+" --
18 ---------
20 function "+" (Left : Pointer; Right : size_t) return Pointer is
21 use System.Storage_Elements;
22 begin
23 return To_Pointer (To_Address (Left) +
24 System.Storage_Elements.Storage_Offset (Right));
25 end "+";
26 pragma Inline ("+");
28 ---------------
29 -- Increment --
30 ---------------
32 procedure Increment (Ref : in out Pointer) is
33 begin
34 Ref := Ref + 1;
35 end Increment;
36 pragma Inline (Increment);
38 T : Pointer := To_Pointer (S1);
39 S : Pointer := To_Pointer (S2);
41 begin
42 -- if S = null or else T = null then
43 -- raise Dereference_Error;
44 -- else
45 for J in 1 .. N loop
46 T.all := S.all;
47 Increment (T);
48 Increment (S);
49 end loop;
50 -- end if;
51 return S1;
52 end memcpy;
54 end Crtl;