mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [OT] sizeof C types ...
@ 2003-08-25 19:13 Herbert Pötzl
  2003-08-25 19:27 ` Christoph Hellwig
  2003-08-25 19:29 ` Randy.Dunlap
  0 siblings, 2 replies; 11+ messages in thread
From: Herbert Pötzl @ 2003-08-25 19:13 UTC (permalink / raw)
  To: linux-kernel


Hi Everyone!

this time not sooo off topic but ...

anyway, ist there some kind of overview how
large the basic C types are on the different
architectures Linux runs on?

char, short, int, long, long int, long long, ...

TIA,
Herbert


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

* Re: [OT] sizeof C types ...
  2003-08-25 19:13 [OT] sizeof C types Herbert Pötzl
@ 2003-08-25 19:27 ` Christoph Hellwig
  2003-08-25 19:38   ` Herbert Pötzl
  2003-08-25 21:19   ` J.A. Magallon
  2003-08-25 19:29 ` Randy.Dunlap
  1 sibling, 2 replies; 11+ messages in thread
From: Christoph Hellwig @ 2003-08-25 19:27 UTC (permalink / raw)
  To: linux-kernel

> char,

8 bits

> short,

16 bits

> int,

32 bits

> long,

either 32 or 64 bits

> long int,

dito. long is just the short form of long int

> long long, ...

64 bits


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

* Re: [OT] sizeof C types ...
  2003-08-25 19:13 [OT] sizeof C types Herbert Pötzl
  2003-08-25 19:27 ` Christoph Hellwig
@ 2003-08-25 19:29 ` Randy.Dunlap
  2003-08-25 19:41   ` Herbert Pötzl
  2003-08-25 19:44   ` Christoph Hellwig
  1 sibling, 2 replies; 11+ messages in thread
From: Randy.Dunlap @ 2003-08-25 19:29 UTC (permalink / raw)
  To: herbert; +Cc: linux-kernel

On Mon, 25 Aug 2003 21:13:39 +0200 Herbert Pötzl <herbert@13thfloor.at> wrote:

| 
| Hi Everyone!
| 
| this time not sooo off topic but ...
| 
| anyway, ist there some kind of overview how
| large the basic C types are on the different
| architectures Linux runs on?
| 
| char, short, int, long, long int, long long, ...

>From gcc mailing list today: <quote>

All GCC targets (except perhaps some specialized targets for certain DSPs
and microcontrollers) support 64-bit integers.

Almost all GCC targets are either "ILP32" or "LP64".

For ILP32:
	short is 16 bits
	int, long, pointers are 32 bits
	"long long" is 64 bits

For LP64:
	short is 16 bits
	int is 32 bits
	long, pointers, and "long long" are 64 bits

None of this requires a specific version, as all these types have been
around for a long time.
</quote>

Also see Ch. 10 of the LDD book:
  http://www.xml.com/ldd/chapter/book/ch10.html

--
~Randy   [mantra:  Always include kernel version.]
"Everything is relative."

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

* Re: [OT] sizeof C types ...
  2003-08-25 19:27 ` Christoph Hellwig
@ 2003-08-25 19:38   ` Herbert Pötzl
  2003-08-25 22:37     ` Erik Andersen
  2003-08-25 21:19   ` J.A. Magallon
  1 sibling, 1 reply; 11+ messages in thread
From: Herbert Pötzl @ 2003-08-25 19:38 UTC (permalink / raw)
  To: Christoph Hellwig, linux-kernel

On Mon, Aug 25, 2003 at 08:27:21PM +0100, Christoph Hellwig wrote:
> > char,
> 
> 8 bits
> 
> > short,
> 
> 16 bits
> 
> > int,
> 
> 32 bits
> 
> > long,
> 
> either 32 or 64 bits
> 
> > long int,
> 
> dito. long is just the short form of long int
> 
> > long long, ...
> 
> 64 bits

thanks, almost figured that, but I'm looking for
a tabular info where the different architectures
are present like the folowing:

	      i386 | ia64 | alpha | sparc | wossname ...
-----------+-------+------+-------+-------+-------------------
char	   |     8 |      |       |       |
short      |    16 |      |       |       |
int        |    32 |      |       |       |
long       |    32 |      |       |       |
long long  |    64 |      |       |       |

best,
Herbert

> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [OT] sizeof C types ...
  2003-08-25 19:29 ` Randy.Dunlap
@ 2003-08-25 19:41   ` Herbert Pötzl
  2003-08-25 19:44   ` Christoph Hellwig
  1 sibling, 0 replies; 11+ messages in thread
From: Herbert Pötzl @ 2003-08-25 19:41 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: linux-kernel

On Mon, Aug 25, 2003 at 12:29:06PM -0700, Randy.Dunlap wrote:
> On Mon, 25 Aug 2003 21:13:39 +0200 Herbert Pötzl <herbert@13thfloor.at> wrote:
> 
> | 
> | Hi Everyone!
> | 
> | this time not sooo off topic but ...
> | 
> | anyway, ist there some kind of overview how
> | large the basic C types are on the different
> | architectures Linux runs on?
> | 
> | char, short, int, long, long int, long long, ...
> 
> >From gcc mailing list today: <quote>
> 
> All GCC targets (except perhaps some specialized targets for certain DSPs
> and microcontrollers) support 64-bit integers.
> 
> Almost all GCC targets are either "ILP32" or "LP64".
> 
> For ILP32:
> 	short is 16 bits
> 	int, long, pointers are 32 bits
> 	"long long" is 64 bits
> 
> For LP64:
> 	short is 16 bits
> 	int is 32 bits
> 	long, pointers, and "long long" are 64 bits
> 
> None of this requires a specific version, as all these types have been
> around for a long time.
> </quote>
> 
> Also see Ch. 10 of the LDD book:
>   http://www.xml.com/ldd/chapter/book/ch10.html

ahh there is the tabular I was looking for ...

many thanks,
Herbert

> --
> ~Randy   [mantra:  Always include kernel version.]
> "Everything is relative."
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [OT] sizeof C types ...
  2003-08-25 19:29 ` Randy.Dunlap
  2003-08-25 19:41   ` Herbert Pötzl
@ 2003-08-25 19:44   ` Christoph Hellwig
  2003-08-25 19:56     ` Herbert Pötzl
  1 sibling, 1 reply; 11+ messages in thread
From: Christoph Hellwig @ 2003-08-25 19:44 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: herbert, linux-kernel

On Mon, Aug 25, 2003 at 12:29:06PM -0700, Randy.Dunlap wrote:
> Also see Ch. 10 of the LDD book:
>   http://www.xml.com/ldd/chapter/book/ch10.html

Well, that chapter has some issue.  It talks of sparc64 when actually
meaning a sparc32 userland on sparc64, and it missed the 2.6 merge of
mips64 into mips as mips can now have either 32 or 64bit longs and
pointers.


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

* Re: [OT] sizeof C types ...
  2003-08-25 19:44   ` Christoph Hellwig
@ 2003-08-25 19:56     ` Herbert Pötzl
  0 siblings, 0 replies; 11+ messages in thread
From: Herbert Pötzl @ 2003-08-25 19:56 UTC (permalink / raw)
  To: Christoph Hellwig, Randy.Dunlap, linux-kernel

On Mon, Aug 25, 2003 at 08:44:26PM +0100, Christoph Hellwig wrote:
> On Mon, Aug 25, 2003 at 12:29:06PM -0700, Randy.Dunlap wrote:
> > Also see Ch. 10 of the LDD book:
> >   http://www.xml.com/ldd/chapter/book/ch10.html
> 
> Well, that chapter has some issue.  It talks of sparc64 when actually
> meaning a sparc32 userland on sparc64, and it missed the 2.6 merge of
> mips64 into mips as mips can now have either 32 or 64bit longs and
> pointers.

hmm, good to know :( ... isn't this tracked somewhere?
guess it would be an interesting table, especially regarding
the more exotic architectures like arm, cris, s390 ...

what do you think?

best,
Herbert

> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [OT] sizeof C types ...
  2003-08-25 19:27 ` Christoph Hellwig
  2003-08-25 19:38   ` Herbert Pötzl
@ 2003-08-25 21:19   ` J.A. Magallon
  2003-08-25 22:09     ` Zwane Mwaikambo
  2003-08-26  7:30     ` Christoph Hellwig
  1 sibling, 2 replies; 11+ messages in thread
From: J.A. Magallon @ 2003-08-25 21:19 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-kernel


On 08.25, Christoph Hellwig wrote:
> > char,
> 
> 8 bits
> 
> > short,
> 
> 16 bits
> 
> > int,
> 
> 32 bits
> 
> > long,
> 
> either 32 or 64 bits
> 
> > long int,
> 
> dito. long is just the short form of long int
> 
> > long long, ...
> 
> 64 bits
> 

If you don't go away from linux, OK.

Really:
char = 8bit
long int = 32 or 64, depending on arch
long long = 64 bits

int = ??? almost anything, depending on arch and compiler.
Run DOS on your P4, with an old compiler, and int defaults to 16 bits.
I think the same also happens for Win16.

int is defined ad the native word size of the hardware+OS.

-- 
J.A. Magallon <jamagallon@able.es>      \                 Software is like sex:
werewolf.able.es                         \           It's better when it's free
Mandrake Linux release 9.2 (Cooker) for i586
Linux 2.4.22-rc3-jam1m (gcc 3.3.1 (Mandrake Linux 9.2 3.3.1-1mdk))

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

* Re: [OT] sizeof C types ...
  2003-08-25 21:19   ` J.A. Magallon
@ 2003-08-25 22:09     ` Zwane Mwaikambo
  2003-08-26  7:30     ` Christoph Hellwig
  1 sibling, 0 replies; 11+ messages in thread
From: Zwane Mwaikambo @ 2003-08-25 22:09 UTC (permalink / raw)
  To: J.A. Magallon; +Cc: Christoph Hellwig, Linux Kernel

On Mon, 25 Aug 2003, J.A. Magallon wrote:

> If you don't go away from linux, OK.
> 
> Really:
> char = 8bit
> long int = 32 or 64, depending on arch

Well then you can argue that 'long int' is 32bit on 64bit platforms on 
Windows (the Windows API dictates LLP64) </pedantry>

> long long = 64 bits
> 
> int = ??? almost anything, depending on arch and compiler.
> Run DOS on your P4, with an old compiler, and int defaults to 16 bits.
> I think the same also happens for Win16.
> 
> int is defined ad the native word size of the hardware+OS.

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

* Re: [OT] sizeof C types ...
  2003-08-25 19:38   ` Herbert Pötzl
@ 2003-08-25 22:37     ` Erik Andersen
  0 siblings, 0 replies; 11+ messages in thread
From: Erik Andersen @ 2003-08-25 22:37 UTC (permalink / raw)
  To: Herbert Pötzl; +Cc: linux-kernel

On Mon Aug 25, 2003 at 09:38:37PM +0200, Herbert Pötzl wrote:
> thanks, almost figured that, but I'm looking for
> a tabular info where the different architectures
> are present like the folowing:
> 
> 	      i386 | ia64 | alpha | sparc | wossname ...
> -----------+-------+------+-------+-------+-------------------
> char	   |     8 |      |       |       |
> short      |    16 |      |       |       |
> int        |    32 |      |       |       |
> long       |    32 |      |       |       |
> long long  |    64 |      |       |       |

If one cares about the exact number of bits, IMHO one should be
using stdint.h, as defined by ISO-IEC-9899-1999 (C99), section
7.18 Integer types.  

Using type such as int8_t, int16_t, int32_t, int64_t, and
uint8_t, uint16_t, uint32_t, uint64_t are the One True Way of
reliably, portably, getting the number of bits you want.  It
would be very nice if the kernel were converted to use these
types as well.  It would also be nice if every architecture
properly supported C99.  Unfortunately, that is not true on
either count.  For example, if you want your code to interoperate
with windoz, you will want to do something such as....

#if defined(_WIN32) || defined(__WIN32__)
# define uint8_t  unsigned __int8
# define uint16_t unsigned __int16
# define uint32_t unsigned __int32
# define uint64_t unsigned __int64
# define int8_t  __int8
# define int16_t __int16
# define int32_t __int32
# define int64_t __int64
#else
# include <stdint.h>
#endif

 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--

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

* Re: [OT] sizeof C types ...
  2003-08-25 21:19   ` J.A. Magallon
  2003-08-25 22:09     ` Zwane Mwaikambo
@ 2003-08-26  7:30     ` Christoph Hellwig
  1 sibling, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2003-08-26  7:30 UTC (permalink / raw)
  To: J.A. Magallon; +Cc: Christoph Hellwig, linux-kernel

On Mon, Aug 25, 2003 at 11:19:50PM +0200, J.A. Magallon wrote:
> If you don't go away from linux, OK.

He specificy asked for Linux...


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

end of thread, other threads:[~2003-08-26  7:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-25 19:13 [OT] sizeof C types Herbert Pötzl
2003-08-25 19:27 ` Christoph Hellwig
2003-08-25 19:38   ` Herbert Pötzl
2003-08-25 22:37     ` Erik Andersen
2003-08-25 21:19   ` J.A. Magallon
2003-08-25 22:09     ` Zwane Mwaikambo
2003-08-26  7:30     ` Christoph Hellwig
2003-08-25 19:29 ` Randy.Dunlap
2003-08-25 19:41   ` Herbert Pötzl
2003-08-25 19:44   ` Christoph Hellwig
2003-08-25 19:56     ` Herbert Pötzl

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

all inboxes | Powered by JetHome®