comp.lang.ada
 help / color / mirror / Atom feed
From: anon@att.net
Subject: Re: What is the warning about builtin-function on gcc-4.6.0 ?
Date: Sun, 27 Mar 2011 23:35:52 +0000 (UTC)
Date: 2011-03-27T23:35:52+00:00	[thread overview]
Message-ID: <imohkn$dc6$1@speranza.aioe.org> (raw)
In-Reply-To: 0ea88302-a755-4a61-bf5b-728469c9d5d2@34g2000pru.googlegroups.com

In <0ea88302-a755-4a61-bf5b-728469c9d5d2@34g2000pru.googlegroups.com>, ytomino <aghia05@gmail.com> writes:
>On Mar 27, 9:00=A0pm, a...@att.net wrote:
>> Using C you may need to also change the first underscore or remove both
>> such as
>>
>> =A0 pragma Import (C, isfinite, "_builtin_isfinite");
>
>$ /usr/local/bin/gcc-4.6.0/gnatmake test1
>gcc -c test1.adb
>gnatbind -x test1.ali
>gnatlink test1.ali
>Undefined symbols:
>  "__builtin_isfinite", referenced from:
>      __ada_test1 in test1.o
>      __ada_test1 in test1.o
>ld: symbol(s) not found
>collect2: ld returned 1 exit status
>gnatlink: error when calling /usr/local/bin/gcc-4.6.0/gcc
>gnatmake: *** link failed.
>
>> or
>> =A0 pragma Import (C, isfinite, "builtin_isfinite");
>
>$ /usr/local/bin/gcc-4.6.0/gnatmake test1
>gcc -c test1.adb
>gnatbind -x test1.ali
>gnatlink test1.ali
>Undefined symbols:
>  "_builtin_isfinite", referenced from:
>      __ada_test1 in test1.o
>      __ada_test1 in test1.o
>ld: symbol(s) not found
>collect2: ld returned 1 exit status
>gnatlink: error when calling /usr/local/bin/gcc-4.6.0/gcc
>gnatmake: *** link failed.
>
>In the first, libc.a (or libm.a) does not have the body of "isfinite"
>function.
>gcc expands builtin-functions to inline-assembly code.
>To tell the truth, libm.a has "_isfinite", but that is unused to call
>"__builtin_isfinite".
>Please make sure with nm.
The problem with builtin routines is that you need to write a C interface 
routine that is called by Ada and then that routine calls the 
"__builtin_isfinite" macro. Such as:

   function isfinite ( X : Long_Float ) return Integer;
   pragma Import ( C, isfinite, "_gnat_builtin_isfinite" ) ;


/* 
 * File: builtin.c
 * the C code 
 */
void _gnat_builtin_isfinite ( x )
     long x ;
  {
    __builtin_isfinite ( x ) ;
  }


to compile 
  gcc -c builtin.c
  gnat make <program>.adb   -largs builtin.o
or
  gnat link <program>.ali builtin.o


But the easiest way is just use Ada:

   function isfinite ( S : Long_Float ) return Boolean ;


   function isfinite ( S : Long_Float ) return Boolean ;
      
     begin
  
       -- IEEE 754 standards
      
       If S'Exponent = -1 and S'Fraction = 0 Then
         return True ;
       end if ;            
       return False ;

     end isfinite ;





  reply	other threads:[~2011-03-27 23:35 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-26  6:32 What is the warning about builtin-function on gcc-4.6.0 ? ytomino
2011-03-26  8:45 ` Florian Weimer
2011-03-26  9:13   ` ytomino
2011-03-26  9:43     ` Florian Weimer
2011-03-26 10:07       ` ytomino
2011-03-26 10:24         ` Florian Weimer
2011-03-26 15:14           ` Dmitry A. Kazakov
2011-03-26 21:36             ` ytomino
2011-03-27  9:50               ` Dmitry A. Kazakov
2011-03-26 14:50         ` Simon Wright
2011-03-26 15:50           ` Florian Weimer
2011-03-26 16:32             ` Simon Wright
2011-03-26 17:02               ` Florian Weimer
2011-03-26 17:48                 ` Simon Wright
2011-03-26 18:48                   ` Florian Weimer
2011-03-27  2:08                 ` Randy Brukardt
2011-03-27  8:37                   ` Florian Weimer
2011-03-27 16:41                     ` Robert A Duff
2011-03-27 17:21                       ` Florian Weimer
2011-03-27 17:56                         ` Robert A Duff
2011-03-27 16:51                     ` Robert A Duff
2011-03-27 17:05                       ` Florian Weimer
2011-03-27 17:14                         ` Robert A Duff
2011-03-29  2:20                           ` Randy Brukardt
2011-03-29 18:35                             ` Robert A Duff
2011-03-29 23:35                               ` Randy Brukardt
2011-03-30  1:02                               ` Adam Beneschan
2011-03-30 12:57                                 ` Robert A Duff
2011-03-30 14:41                                   ` Adam Beneschan
2011-03-30 18:39                                     ` Robert A Duff
2011-03-30 19:28                                   ` Randy Brukardt
2011-03-26 21:58       ` ytomino
2011-03-26 22:00         ` Florian Weimer
2011-03-26 22:22 ` anon
2011-03-26 22:36   ` ytomino
2011-03-27 12:00     ` anon
2011-03-27 18:50       ` ytomino
2011-03-27 23:35         ` anon [this message]
2011-03-27 23:42         ` 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