comp.lang.ada
 help / color / mirror / Atom feed
From: anon@att.net
Subject: Re: GLIBC_2.14  memcpy
Date: Thu, 24 Apr 2014 09:56:15 +0000 (UTC)
Date: 2014-04-24T09:56:15+00:00	[thread overview]
Message-ID: <ljan3u$bim$1@speranza.aioe.org> (raw)
In-Reply-To: a9877c3f-072f-4ade-9664-c789b3f8390f@googlegroups.com

A simple System.Memory_Copy package

Compile the following package in a local directory using

  gnat compile -a s-memcop.adb

then compile your program 

  gnat make hello -largs s-memcop.o 

"-largs s-memcop.o" causes the linker to use the new version 
instead of the standard library version. Note: The "-largs" must 
be lower case.


-- File: s-memcop.ads

package System.Memory_Copy is
pragma Preelaborate ;

  type Memory_Range is mod Memory_Size ;

  procedure Memcpy ( Target_Address : in Address      ;
                     Source_Address : in Address      ;
                     Count          : in Memory_Range ) ;
  pragma Export ( C, Memcpy, "memcpy" ) ;

end System.Memory_Copy ;


-- File: s-memcop.adb

pragma Style_Checks (OFF);        --  removes warning about souce 
                                  --  code format

pragma Suppress ( All_Checks ) ;  --  removes all run-time checks
                                  --  for this low-level package

with Interfaces ;

package body System.Memory_Copy is

  procedure Memcpy ( Target_Address : in Address      ;
                     Source_Address : in Address      ;
                     Count          : in Memory_Range ) is

    use  Interfaces ;

    type Storage_Array is array ( 0 .. Count ) of Unsigned_8 ;

    Target : Storage_Array ;
        for Target ' Address use Target_Address ;

    Source : Storage_Array ;
      for Source ' Address use Source_Address ;

  begin -- Memcpy
      for Index in 0 .. Count loop 
        Target ( Index ) := Source ( Index ) ;
      end loop ;
  end Memcpy ;

end System.Memory_Copy ;


In <a9877c3f-072f-4ade-9664-c789b3f8390f@googlegroups.com>, Ian Douglas <ian@vionia.com> writes:
>hi All
>
>On Wednesday, 23 April 2014 09:53:00 UTC+2, an...@att.net  wrote:
>> Why not use the HI-E (high integrity version) of "System-Memory_Copy" 
>> 
>> package which routines can be written Ada. Instead of using 'libC'
>> 
>> gnat compile s-memcop
>> 
>> then add "-largs s-memcop.o" at the end of gnat command line
>> 
>> gnat make hello.adb -largs s-memcop.o
>
>Thanks for the suggestion. Results below.
>
>~/1web/adatest1 $ gnat compile s-memcop 
>gcc -gnatpg -c -I./ -I- /usr/gnat/lib/gcc/x86_64-pc-linux-gnu/4.7.4/adainclude/s-memcop.ads
>~/1web/adatest1 $ ll
>total 564
>-rwxr-xr-x 1 ian ian 547443 Apr 21 22:20 Hello1
>-rw-r--r-- 1 ian ian    172 Apr 21 22:18 Hello1.adb
>-rw-r--r-- 1 ian ian   1574 Apr 22 14:25 Hello1.ali
>-rw-r--r-- 1 ian ian   1824 Apr 22 14:25 Hello1.o
>-rw-r--r-- 1 ian ian    695 Apr 22 14:25 hello.gpr
>-rw-r--r-- 1 ian ian    783 Apr 23 20:32 s-memcop.ali
>-rw-r--r-- 1 ian ian   1004 Apr 23 20:32 s-memcop.o
>~/1web/adatest1 $ gnat make Hello1.adb -largs s-memcop.o 
>gnatbind -x Hello1.ali
>gnatlink Hello1.ali s-memcop.o
>~/1web/adatest1 $ ll
>total 564
>-rwxr-xr-x 1 ian ian 547654 Apr 23 20:32 Hello1
>-rw-r--r-- 1 ian ian    172 Apr 21 22:18 Hello1.adb
>-rw-r--r-- 1 ian ian   1574 Apr 22 14:25 Hello1.ali
>-rw-r--r-- 1 ian ian   1824 Apr 22 14:25 Hello1.o
>-rw-r--r-- 1 ian ian    695 Apr 22 14:25 hello.gpr
>-rw-r--r-- 1 ian ian    783 Apr 23 20:32 s-memcop.ali
>-rw-r--r-- 1 ian ian   1004 Apr 23 20:32 s-memcop.o
>~/1web/adatest1 $ ./Hello1 
>Hello, cruel world!
>
>I am an Ada program with package use.
>
>===============
>
>Upload to server, SSH in and make executable.
>
>[root@xaxint web]# ll
>total 560
>-rw-r--r-- 1 web1 client1 547654 Apr 23 20:33 Hello1
>-rwxr-xr-- 1 web1 client1   7358 Apr 15 15:28 favicon.ico
>-rwxr-xr-- 1 web1 client1   1861 Apr 15 15:28 index.html
>-rwxr-xr-- 1 web1 client1     14 Apr 15 15:28 robots.txt
>drwxr-xr-x 2 root root      4096 Apr 17 00:30 stats
>[root@xaxint web]# chmod 744 Hello1 
>[root@xaxint web]# ./Hello1 
>../Hello1: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./Hello1)
>[root@xaxint web]# 
>
>=============================
>
>So end up with same issue....
>
>thanks, Ian
>

  reply	other threads:[~2014-04-24  9:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-22 13:28 GLIBC_2.14 memcpy Ian Douglas
2014-04-22 16:54 ` Tero Koskinen
2014-04-22 19:41   ` Ian Douglas
2014-04-22 21:58     ` Jeffrey Carter
2014-04-23  7:47 ` Stephen Leake
2014-04-23 11:11   ` G.B.
2014-04-23 18:30   ` Ian Douglas
2014-04-23  7:53 ` anon
2014-04-23 18:37   ` Ian Douglas
2014-04-24  9:56     ` anon [this message]
2014-04-26 20:10       ` Ian Douglas
2014-04-28 12:23         ` anon
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox