From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6b93224dbe2bb55b,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.224.173.202 with SMTP id q10mr3569065qaz.3.1354415902796; Sat, 01 Dec 2012 18:38:22 -0800 (PST) Received: by 10.49.75.9 with SMTP id y9mr1404758qev.9.1354415902771; Sat, 01 Dec 2012 18:38:22 -0800 (PST) Path: gf5ni37485490qab.0!nntp.google.com!i9no553952qap.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 1 Dec 2012 18:38:22 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=200.148.120.20; posting-account=TRgI1QoAAABSsYi-ox3Pi6N-JEKKU0cu NNTP-Posting-Host: 200.148.120.20 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3254b304-ed8b-4601-8a3c-ab3df74d84ad@googlegroups.com> Subject: Return unconstrained types in ZFP From: "Rego, P." Injection-Date: Sun, 02 Dec 2012 02:38:22 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-12-01T18:38:22-08:00 List-Id: Dear fellows,=20 I am trying to implement, for an ATmega2560 (Arduino Mega) micro-controller= using ZFP in GNAT-AVR, an USART unconstrained Get string like function Get (Port : USART_Port_Type; Size : Unsigned_8) return Strin= g_U8; assuming that USART_Port_Type is an enumeration, and type String_U8 is array (Unsigned_8 range <>) of Character; So I tried function Get (Port : USART_Port_Type; Size : Unsigned_8) return Strin= g_U8 is Curr_String : String_U8 (1 .. Size); Null_String : constant String_U8 (1 .. Size) :=3D (others =3D> ' '= ); begin for Index in 1 .. Curr_String'Length loop Curr_String (Unsigned_8 (Index)) :=3D Get (Port); -- BTW, funct= ion Get (Port : USART_Port_Type) return Character; works ok! end loop; return Curr_String; exception when others =3D> return Null_String; end Get; and the compiler complained that I am not defining the Last_Chance_Handler.= Now I found in GNAT documentation, that I should define it using procedure Last_Chance_Handler (Source_Location : System.Address; Line : Integer); pragma Export (C, Last_Chance_Handler, "__gnat_last_chance_handler"); and at least (for now) a null procedure would be enough procedure Last_Chance_Handler (Source_Location : System.Address; Line : Integer) is begin null; end Last_Chance_Handler;=20 But now the compiler complains that I also did not define the Get_Secondary= _Stack, and found no reference to memcpy. I found in GNAT documentation the= Secondary Stack definition, but with no syntax information, and nothing el= se. And regarding to memcpy, found nothing. -- The Secondary Stack -- The secondary stack is a special storage pool that is used for -- this purpose. The called function places the result on the -- secondary stack, and the caller uses or copies the value from -- the secondary stack, and pops the secondary stack after the -- value is consumed. The secondary stack is outside the system -- ABI, and the important point is that although generally it is -- handled in a stack like manner corresponding to the subprogram -- call structure, a return from a function does NOT pop the stack. Actually the compiler returned me In function `avr__atmega2560__usart__get__7': avr-atmega2560-usart.adb:(.text+0x164c): undefined reference to `memcpy' avr-atmega2560-usart.adb:(.text+0x1694): undefined reference to `memcpy' C:/GNAT/2012/lib/gcc/avr/4.5.4/rts-zfp\adalib\libgnat.a(s-secsta.o): In = function `system__secondary_stack__ss_allocate': s-secsta.adb:(.text+0x8): undefined reference to `__gnat_get_secondary_s= tack' C:/GNAT/2012/lib/gcc/avr/4.5.4/rts-zfp\adalib\libgnat.a(s-secsta.o): In = function `system__secondary_stack__ss_mark': s-secsta.adb:(.text+0x54): undefined reference to `__gnat_get_secondary_= stack' C:/GNAT/2012/lib/gcc/avr/4.5.4/rts-zfp\adalib\libgnat.a(s-secsta.o): In = function `system__secondary_stack__ss_release': s-secsta.adb:(.text+0x66): undefined reference to `__gnat_get_secondary_= stack' collect2: ld returned 1 exit status avr-gnatlink: error when calling C:\GNAT\2012\bin\avr-gcc.exe avr-gnatmake: *** link failed. I also tried to define null bodies like the Last_Chance_Handler, and at thi= s point the code linked with success. But I am afraid that doing this I cou= ld make a big mess, so I did not burn the chip using this .hex (specially d= ue to Memcpy null body). Thus, could someone give me a light on this? How c= an I implement correctly the Secondary_Stack procedure and Memcpy? Or maybe= a better documentation or a tutorial would be very helpful. Thanks.