Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Re: GCC 64 bit compliance
  1998-04-29 15:33 GCC 64 bit compliance brinkmann
@ 1998-04-29 14:36 ` Stephen Williams
  1998-04-29 17:09   ` Michal Jaegermann
  1998-04-29 16:22 ` Alexander V. Lukyanov
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Stephen Williams @ 1998-04-29 14:36 UTC (permalink / raw)
  To: axp-list


brinkmann@nmsu.edu said:
> I thought that the definition of "size_t" was supposed to be the same
> size as a pointer (or memory address).

Minor nit:

The definition of size_t is the type that sizeof returns, and is an
unsigned integral type. There is no mention if the pointer size in the
definition of size_t in the C standard that I have in front of me.

The definition if ptrdiff_t is the signed integral type returned by the
subtraction of two pointers.

That is not to say that the "#define size_t unsigned int" is correct.
It probably is not. Anyhow, the canonical definition is in <stddef.h>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* GCC 64 bit compliance
@ 1998-04-29 15:33 brinkmann
  1998-04-29 14:36 ` Stephen Williams
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: brinkmann @ 1998-04-29 15:33 UTC (permalink / raw)
  To: axp-list

I have a question regarding GCC's compliance with the 64 bit Alpha
architecture.  This came up in conjunction with compiling XPostitPlus,
which casts pointers to int, always a bad idea.  I wrote a simple
program to check data type sizes.  As expected:

	char =		1 byte
	short int =	2 bytes
	int =		4 bytes
	long int =	8 bytes

	pointer =	8 bytes,

Checking further, I took a look in malloc.h, where size_t is defined,
on my Alpha and found

	#define size_t          unsigned int

shouldn't it be

	#define size_t          unsigned long int

on the Alpha???

I thought that the definition of "size_t" was supposed to be the same
size as a pointer (or memory address).  Otherwise, functions that
manipulate memory and/or return pointers, e.g., malloc, won't take
advantage of the available address space.

Jon
---
Dr. Jon Brinkmann				Apache Point Observatory
Instrument Scientist				2001 Apache Point Road
Internet:	brinkmann@nmsu.edu		P.O. Box 59
URL:	http://www.apo.nmsu.edu/brinkmann/	Sunspot, NM 88349-0059


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GCC 64 bit compliance
  1998-04-29 17:09   ` Michal Jaegermann
@ 1998-04-29 15:48     ` Stephen Williams
  0 siblings, 0 replies; 12+ messages in thread
From: Stephen Williams @ 1998-04-29 15:48 UTC (permalink / raw)
  To: axp-list

> Minor nit:
> 
> The definition of size_t is the type that sizeof returns, and is an
> unsigned integral type. There is no mention if the pointer size in the
> definition of size_t in the C standard that I have in front of me.

michal@ellpspace.math.ualberta.ca said:
> In other words, if you compiler allows for arrays indexed by an
> 'unsigned long int' then size_t cannot be too narrow.  Or, if you
> prefer, a width of size_t sets an upper limit on a size of any
> structure, union or array which your compiler is able to accept.

True enough. I never said that having a narrow size_t was a good idea,
just that it is legal (though kinda silly) to be smaller then a pointer.
Hell, there are people running 16bit Windows code on Pentiums:-)
-- 
Steve Williams                "The woods are lovely, dark and deep.
steve@icarus.com              But I have promises to keep,
steve@picturel.com            and lines to code before I sleep,
http://www.picturel.com       And lines to code before I sleep."



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GCC 64 bit compliance
  1998-04-29 15:33 GCC 64 bit compliance brinkmann
  1998-04-29 14:36 ` Stephen Williams
@ 1998-04-29 16:22 ` Alexander V. Lukyanov
  1998-04-29 16:27 ` Richard Hadsell
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Alexander V. Lukyanov @ 1998-04-29 16:22 UTC (permalink / raw)
  To: axp-list

On Wed, Apr 29, 1998 at 09:33:25AM -0600, brinkmann@nmsu.edu wrote:
> Checking further, I took a look in malloc.h, where size_t is defined,
> on my Alpha and found
> 
> 	#define size_t          unsigned int

This code is in effect only when __STDC__ is undefined, which is not the normal
case. The real size_t definition is in /usr/lib/gcc-lib/.../include/stddef.h
and it is `unsigned long int'.

   Alexander.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GCC 64 bit compliance
  1998-04-29 15:33 GCC 64 bit compliance brinkmann
  1998-04-29 14:36 ` Stephen Williams
  1998-04-29 16:22 ` Alexander V. Lukyanov
@ 1998-04-29 16:27 ` Richard Hadsell
  1998-04-29 16:45 ` Michal Jaegermann
  1998-04-29 17:53 ` Uncle George
  4 siblings, 0 replies; 12+ messages in thread
From: Richard Hadsell @ 1998-04-29 16:27 UTC (permalink / raw)
  To: axp-list

brinkmann@nmsu.edu wrote:
> 
> Checking further, I took a look in malloc.h, where size_t is defined,
> on my Alpha and found
> 
>         #define size_t          unsigned int
> 
> shouldn't it be
> 
>         #define size_t          unsigned long int
> 
> on the Alpha???

With a C++ program, I get sizeof (size_t) == 8 on my alpha.  Part of the
-v info:

GNU C++ version egcs-2.90.23 980102 (egcs-1.0.1 release)
(alphaev5-unknown-linux-gnu) 

-- 
Dick Hadsell			914-381-8400  Fax: 914-381-9790
Reply-to:			hadsell@blueskystudios.com
Blue Sky | VIFX			http://www.blueskystudios.com
1 South Road, Harrison, NY 10528


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GCC 64 bit compliance
  1998-04-29 15:33 GCC 64 bit compliance brinkmann
                   ` (2 preceding siblings ...)
  1998-04-29 16:27 ` Richard Hadsell
@ 1998-04-29 16:45 ` Michal Jaegermann
  1998-04-29 17:08   ` Dan Bethe
  1998-04-29 17:53 ` Uncle George
  4 siblings, 1 reply; 12+ messages in thread
From: Michal Jaegermann @ 1998-04-29 16:45 UTC (permalink / raw)
  To: axp-list


> 
> Checking further, I took a look in malloc.h, where size_t is defined,
> on my Alpha and found
> 
> 	#define size_t          unsigned int
> 
> shouldn't it be
> 
> 	#define size_t          unsigned long int
> 
> on the Alpha???

Which version of libraries, headers, etc. you are using?  And are
you sure that you are looking at the right place?  Headers are often
included behind muli-story defines are macro-expansions and their
text likely covers more than one platform.

Doing a real check, which consists of running a program like that:

#include <stdio.h>

int
main(void)
{
    printf("%ld\n", sizeof(size_t));
    return 0;
}

I see a number 8 (glibc-2.0.7-7 and its headers on Alpha) but AFAIK
it was always like that.

Saying that - to assume in your programs some particular widths of
types, beyond what C standard says about their relative widths,
is a bad practice.  It leads to numerous bugs which later haunt
us on Alpha.  Some programmer knew what these sizes were and now
we have to "port" (translation - fix) this code for Alpha.
Bugs are masked on a platform when assumptions about sizes happens
to be true and the original code is passing for a correct one.

  Michal


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: GCC 64 bit compliance
@ 1998-04-29 16:53 Alan Wood
  0 siblings, 0 replies; 12+ messages in thread
From: Alan Wood @ 1998-04-29 16:53 UTC (permalink / raw)
  To: axp-list@redhat.com


I know that it is not 32bit here after a few problems with dates after 
compiling Roxen. This is using RH4.2 & gcc 2.7.2.1 on a UDB

Alan

----------
From:  Richard Hadsell[SMTP:hadsell@blueskystudios.com]
Sent:  29 April 1998 17:28
To:  axp-list@redhat.com
Subject:  Re: GCC 64 bit compliance

brinkmann@nmsu.edu wrote:
> 
> Checking further, I took a look in malloc.h, where size_t is defined,
> on my Alpha and found
> 
>         #define size_t          unsigned int
> 
> shouldn't it be
> 
>         #define size_t          unsigned long int
> 
> on the Alpha???

With a C++ program, I get sizeof (size_t) == 8 on my alpha.  Part of the
-v info:

GNU C++ version egcs-2.90.23 980102 (egcs-1.0.1 release)
(alphaev5-unknown-linux-gnu) 

-- 
Dick Hadsell			914-381-8400  Fax: 914-381-9790
Reply-to:			hadsell@blueskystudios.com
Blue Sky | VIFX			http://www.blueskystudios.com
1 South Road, Harrison, NY 10528

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GCC 64 bit compliance
  1998-04-29 16:45 ` Michal Jaegermann
@ 1998-04-29 17:08   ` Dan Bethe
  1998-04-29 17:34     ` Craig Burley
  0 siblings, 1 reply; 12+ messages in thread
From: Dan Bethe @ 1998-04-29 17:08 UTC (permalink / raw)
  To: axp-list

On Wed, 29 Apr 1998, Michal Jaegermann wrote:

> Saying that - to assume in your programs some particular widths of
> types, beyond what C standard says about their relative widths,
> is a bad practice.  It leads to numerous bugs which later haunt
> us on Alpha.  Some programmer knew what these sizes were and now
> we have to "port" (translation - fix) this code for Alpha.
> Bugs are masked on a platform when assumptions about sizes happens
> to be true and the original code is passing for a correct one.

	So, what's a simple explanation for why someone woudl do that?  
Lack of understanding?  Some optimization tradeoff?

=========
With kind regards from Dan Bethe of the Hex.Net Support Team...      
My home             :  metro (972) 261-1711    mailto:    dtm@hex.net |\ _.._
Hex.Net Superhighway:  metro (817) 329-3182 -- mailto:support@hex.net |/(_|| )


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GCC 64 bit compliance
  1998-04-29 14:36 ` Stephen Williams
@ 1998-04-29 17:09   ` Michal Jaegermann
  1998-04-29 15:48     ` Stephen Williams
  0 siblings, 1 reply; 12+ messages in thread
From: Michal Jaegermann @ 1998-04-29 17:09 UTC (permalink / raw)
  To: axp-list

> 
> 
> brinkmann@nmsu.edu said:
> > I thought that the definition of "size_t" was supposed to be the same
> > size as a pointer (or memory address).
> 
> Minor nit:
> 
> The definition of size_t is the type that sizeof returns, and is an
> unsigned integral type. There is no mention if the pointer size in the
> definition of size_t in the C standard that I have in front of me.

That is correct.  But C standard also says that size_t is a return
type of a sizeof operator and about the later C standard says, among
other things, "When applied to an operand that has array type, the
result is the total number of bytes in the array".  In other words,
if you compiler allows for arrays indexed by an 'unsigned long int'
then size_t cannot be too narrow.  Or, if you prefer, a width of
size_t sets an upper limit on a size of any structure, union or array
which your compiler is able to accept.

  Michal


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GCC 64 bit compliance
@ 1998-04-29 17:18 brinkmann
  0 siblings, 0 replies; 12+ messages in thread
From: brinkmann @ 1998-04-29 17:18 UTC (permalink / raw)
  To: axp-list

Looking further, size_t is actually 8 bytes.  Looking at the preprocessor
output (cc -E "file"), I found the definition in the tree included by
<stdio.h> in the file
/usr/lib/gcc-lib/alpha-redhat-linux/2.7.2.3/include/stddef.h:

typedef long unsigned int size_t;

which is what it should be.  I have no idea why "include" files are in
the /usr/lib tree, but the immediate question is answered.

As to the use of "size_t", I haven't
seen a mention of it in any standard.  My comments are based on
perusing the /usr/include tree in various C implementations, both ANSI
and K&R, and various man pages for functions such as malloc.

Jon
---
Dr. Jon Brinkmann				Apache Point Observatory
Instrument Scientist				2001 Apache Point Road
Internet:	brinkmann@nmsu.edu		P.O. Box 59
URL:	http://www.apo.nmsu.edu/brinkmann/	Sunspot, NM 88349-0059


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GCC 64 bit compliance
  1998-04-29 17:08   ` Dan Bethe
@ 1998-04-29 17:34     ` Craig Burley
  0 siblings, 0 replies; 12+ messages in thread
From: Craig Burley @ 1998-04-29 17:34 UTC (permalink / raw)
  To: axp-list

>	So, what's a simple explanation for why someone woudl do that?  
>Lack of understanding?  Some optimization tradeoff?

Usually a combination of:

  -  Lack of understanding of the issues

  -  Lack of faith that the software will have much longevity

  -  Belief that the underlying system is the One True System everyone
     should, and probably will be someday, using, anyway

  -  Assumption that the way other code they're looking at does
     something must therefore be "right", sometimes without realizing
     that the other code's containing application is inherently
     non-portable while theirs isn't

  -  Lack of time to "do it right" *and* later "make it fast" such
     that it remains portable

Etc.
-- 

"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson    burley@gnu.org


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GCC 64 bit compliance
  1998-04-29 15:33 GCC 64 bit compliance brinkmann
                   ` (3 preceding siblings ...)
  1998-04-29 16:45 ` Michal Jaegermann
@ 1998-04-29 17:53 ` Uncle George
  4 siblings, 0 replies; 12+ messages in thread
From: Uncle George @ 1998-04-29 17:53 UTC (permalink / raw)
  To: axp-list

i generally get confused as to what equals what on the alpha, BUT is u
compile with
a -E, u will get the correct includes as used by the program.  with the cpp
output file you can search for what size_t is really equal to.
Searching through the /usr/include files are not always definitive.

brinkmann@nmsu.edu wrote:

> I have a question regarding GCC's compliance with the 64 bit Alpha
> architecture.  This came up in conjunction with compiling XPostitPlus,
> which casts pointers to int, always a bad idea.  I wrote a simple
> program to check data type sizes.  As expected:




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~1998-04-29 17:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-04-29 15:33 GCC 64 bit compliance brinkmann
1998-04-29 14:36 ` Stephen Williams
1998-04-29 17:09   ` Michal Jaegermann
1998-04-29 15:48     ` Stephen Williams
1998-04-29 16:22 ` Alexander V. Lukyanov
1998-04-29 16:27 ` Richard Hadsell
1998-04-29 16:45 ` Michal Jaegermann
1998-04-29 17:08   ` Dan Bethe
1998-04-29 17:34     ` Craig Burley
1998-04-29 17:53 ` Uncle George
  -- strict thread matches above, loose matches on Subject: below --
1998-04-29 16:53 Alan Wood
1998-04-29 17:18 brinkmann

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