This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libquadmath/85440] libquadmath and quadmath.h do not exist on ppc64


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85440

--- Comment #19 from Dennis Clarke <dclarke at blastwave dot org> ---
status : RESOLVED FIXED <-- seems to not apply. 

For the sake of showing how there really is a problem here, we can 
neatly compile some trivial code and get bizarre results simply
because the platform would prefer to use the non-standard IBM long
double data type.  Any attempt to "add" two long doubles will result
in a call to _q_add which doesn't exist and ld fails. 

ppc64$ cat foo.c 

#define _XOPEN_SOURCE 600

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <sys/utsname.h>

int main ( int argc, char *argv[] ) {

    int j;
    struct utsname uname_data;
    long double pi = 3.14159265358979323846264338327950288419716939937510L;
    long double one = 1.0L;
    long double two = 2.0L;

    setlocale( LC_MESSAGES, "C" );
    if ( uname( &uname_data ) < 0 ) {
        fprintf ( stderr,
                 "WARNING : Could not attain system uname data.\n" );
        perror ( "uname" );
    } else {
        printf ("        system name = %s\n", uname_data.sysname );
        printf ("          node name = %s\n", uname_data.nodename );
        printf ("            release = %s\n", uname_data.release );
        printf ("            version = %s\n", uname_data.version );
        printf ("            machine = %s\n", uname_data.machine );
    }
    printf ("\n");

    /* correct 128 bit big endian hex representation of pi is 
     *   0x40 00 92 1f b5 44 42 d1 84 69 89 8c c5 17 01 b8 */

    printf("\naddr \"pi\" is %p\n", &pi );
    printf("\ncontents : " );
    for ( j=0; j<sizeof(long double); j++ )
        printf("%02x ", ((unsigned char *)&pi)[j] );
    printf("\n" );

    printf("%+42.38Lf\n", pi );
    printf(" +3.1415926535897932384626433832795028841971 <- pi\n" );

    printf("\n\naddr \"one\" is %p\n", &one );
    printf("\ncontents : " );
    for ( j=0; j<sizeof(long double); j++ )
        printf("%02x ", ((unsigned char *)&one)[j] );
    printf("\n" );

    printf("%+42.38Lf\n", one );

    printf("\n\naddr \"two\" is %p\n", &two );
    printf("\ncontents : " );
    for ( j=0; j<sizeof(long double); j++ )
        printf("%02x ", ((unsigned char *)&two)[j] );
    printf("\n" );

    printf("%+42.38Lf\n", two );

    return (EXIT_SUCCESS);
}

ppc64$ 
ppc64$ /usr/local/gcc7/bin/gcc -m64 -std=iso9899:2011 \
> -Wfatal-errors -pedantic-errors -mcpu=970 -mfull-toc \
> -mregnames -mabi=ieeelongdouble -o foo foo.c
gcc: warning: using IEEE extended precision long double
cc1: warning: using IEEE extended precision long double
ppc64$ 
ppc64$ ./foo
        system name = Linux
          node name = nix
            release = 4.16.2-genunix
            version = #1 SMP Wed Apr 18 16:41:48 GMT 2018
            machine = ppc64


addr "pi" is 0x7fffe4399650

contents : 40 00 92 1f b5 44 42 d1 84 69 89 8c c5 17 01 b8 
 +2.07134954084936184770526779175270348787
 +3.1415926535897932384626433832795028841971 <- pi


addr "one" is 0x7fffe4399660

contents : 3f ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 +1.93750000000000000000000000000000000000


addr "two" is 0x7fffe4399670

contents : 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 +2.00000000000000000000000000000000000000
ppc64$ 
ppc64$ 
ppc64$ /usr/local/gcc7/bin/gcc -m64 -std=iso9899:2011 \
> -Wfatal-errors -pedantic-errors -mcpu=970 -mfull-toc \
> -mregnames -mabi=ibmlongdouble -o foo foo.c
gcc: warning: using IBM extended precision long double
cc1: warning: using IBM extended precision long double
ppc64$ ./foo
        system name = Linux
          node name = nix
            release = 4.16.2-genunix
            version = #1 SMP Wed Apr 18 16:41:48 GMT 2018
            machine = ppc64


addr "pi" is 0x7ffff5eef3e0

contents : 40 09 21 fb 54 44 2d 18 3c a1 a6 26 33 14 5c 06 
 +3.14159265358979323846264338327948122706
 +3.1415926535897932384626433832795028841971 <- pi


addr "one" is 0x7ffff5eef3f0

contents : 3f f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 +1.00000000000000000000000000000000000000


addr "two" is 0x7ffff5eef400

contents : 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 +2.00000000000000000000000000000000000000
ppc64$ 


Like you say "...it doesn't work at all unless you provide your own library."

So very true. 

Well this has been fun and I think a POWER9 server is needed to do 
any real work and certainly the hardware support will be fun.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]