Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: danpop@mail.cern.ch (Dan Pop)
Subject: Re: ALPHA SLOWER THAN PENTIUM !!!!
Date: 1995/12/15	[thread overview]
Message-ID: <danpop.818990982@rscernix> (raw)
In-Reply-To: qxpn38wgwkx.fsf@foobar.cs.colorado.edu

In <qxpn38wgwkx.fsf@foobar.cs.colorado.edu> grunwald@foobar.cs.colorado.edu (Dirk Grunwald) writes:

>#include <stdio.h>
>main(int argc, char**argv)
>{
>
>  char *woof = "woof";
>  char *block = argv[0];
>  fprintf(stderr,"woof = 0x%lx\n", woof);
>  fprintf(stderr,"block = 0x%lx\n", block);
>  fprintf(stderr,"woof = %s\n", woof);
>  fprintf(stderr,"block = %s\n", block);
>
>}
>
>I now compile it with -xtaso & run it.
>
>[foobar-33] cc -xtaso -o foo foo.c
>[foobar-34] ./foo
>woof = 0x140000d0
>block = 0x11ffedd8
>woof = woof
>block = ./foo
>
>Those look like 32-bit pointer values to me.
>What am I missing?

First, basic C knowledge :-)

Your conclusion is incorrect and it is based on broken code, which 
invokes undefined behaviour, hence it cannot be used to prove anything
even if it happens to "work".

The correct way to display pointer values is to use %p and to cast the
pointers to void *, because this is what %p expects.  %lx expects an
unsigned long, not a pointer of whatever size.  So, the correct fprintf
calls are:

    fprintf(stderr,"woof = 0x%p\n", (void *)woof);
    fprintf(stderr,"block = 0x%p\n", (void *)block);

Second, the way -xtaso works.  Your pointers are still 64-bit, but the
most significant 32 bits are zero.  This can be easily proved:

    ues5:~/tmp 76> cat test.c
    #include <stdio.h>
    main(int argc, char **argv)
    {
	char *p;
	printf("%ld\n", (long)sizeof p);
	return 0;
    }
    ues5:~/tmp 77> cc -xtaso test.c
    ues5:~/tmp 78> ./a.out
    8

The easiest way to get 32-bit pointers is to use -xtaso_short instead:

    ues5:~/tmp 79> cc -xtaso_short test.c
    ues5:~/tmp 80> ./a.out
    4

Dan
--
Dan Pop
CERN, CN Division
Email: danpop@mail.cern.ch 
Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland



  parent reply	other threads:[~1995-12-15  5:00 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-12-06  5:00 ALPHA SLOWER THAN PENTIUM !!!! Emiliano Stesinach
1995-12-07  5:00 ` Javier Henderson
1995-12-08  5:00   ` michael
1995-12-07  5:00 ` Rob Young
1995-12-07  5:00   ` Yan-Song Chen
1995-12-07  5:00 ` Dan Pop
1995-12-07  5:00   ` Gromit
1995-12-08  5:00   ` John Hascall
1995-12-07  5:00 ` Andrew Armstrong
1995-12-08  5:00   ` Yan-Song Chen
1995-12-09  5:00     ` Thumper!
1995-12-11  5:00       ` Dan Pop
1995-12-11  5:00         ` Robin.Fairbairns
1995-12-12  5:00       ` Michael Brodeur
1995-12-13  5:00         ` Dan Pop
1995-12-12  5:00   ` Richard Ingram
1995-12-12  5:00   ` Dirk Grunwald
1995-12-13  5:00     ` Dan Pop
1995-12-13  5:00       ` Ron Natalie
1995-12-14  5:00         ` Dan Pop
1995-12-14  5:00           ` Ron Natalie
     [not found]             ` <danpop.819045506@rscernix>
1995-12-15  5:00               ` Ron Natalie
1995-12-16  5:00       ` Larry Kilgallen
1995-12-17  5:00       ` Dave Cherkus
1995-12-13  5:00   ` Mike Weber
1995-12-13  5:00   ` Dirk Grunwald
1995-12-14  5:00     ` Dan Pop
1995-12-14  5:00       ` Joseph Vigneau
1995-12-14  5:00         ` Ron Natalie
1995-12-14  5:00       ` Gromit
1995-12-13  5:00   ` Dirk Grunwald
1995-12-14  5:00     ` Ron Natalie
1995-12-15  5:00     ` Dan Pop [this message]
1995-12-16  5:00       ` a little more about -xtaso and -taso in Digital UNIX Jeffrey Mogul
1995-12-22  5:00       ` ALPHA SLOWER THAN PENTIUM !!!! Alan H. Martin
1995-12-13  5:00   ` Mike Weber
1995-12-14  5:00   ` David Mosberger-Tang
1995-12-14  5:00   ` Dirk Grunwald
1995-12-15  5:00   ` Dirk Grunwald
1995-12-07  5:00 ` Ron Fox
1995-12-08  5:00 ` Yan-Song Chen
1995-12-12  5:00   ` dave pierson
     [not found] <199512110641.WAA20124@helix.net>
1995-12-12  5:00 ` michael
read-only archive

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