LWN.net Logo

Pettenò: Debunking x32 myths

Pettenò: Debunking x32 myths

Posted Jun 27, 2012 13:49 UTC (Wed) by nix (subscriber, #2304)
In reply to: Pettenò: Debunking x32 myths by cmccabe
Parent article: Pettenò: Debunking x32 myths

char is "the smallest addressable unit" (in practice always 1 byte)
It's not a matter of 'in practice'. char is, by definition, one byte long. In closely adjacent paragraphs of every C Standard ever published, sizeof() is defined as yielding 'the size (in bytes) of its operand', and then sizeof (char) is defined as returning 1. If you change sizeof (char), you change the definition of a byte on that platform's C ABI.


(Log in to post comments)

Pettenò: Debunking x32 myths

Posted Jun 27, 2012 14:22 UTC (Wed) by mansr (guest, #85328) [Link]

While char is always and by definition one byte, a byte is not always one octet.

Pettenò: Debunking x32 myths

Posted Jun 27, 2012 21:27 UTC (Wed) by nix (subscriber, #2304) [Link]

Exactly. Of course, on any reasonable platform these days (other than tiny DSPs normally not programmed in C at all), a byte is one octet, but in olden days this was not true. Of course by the time C was standardized at all it was pretty widely true, and by the time of C99 it was universal. But it wasn't always so.

Pettenò: Debunking x32 myths

Posted Jun 27, 2012 21:45 UTC (Wed) by mansr (guest, #85328) [Link]

POSIX does mandate 8-bit bytes. As for those DSPs, a lot of code running on them is actually written in C. Only the critical parts are typically done in assembly.

Pettenò: Debunking x32 myths

Posted Jun 29, 2012 4:57 UTC (Fri) by sethml (subscriber, #8471) [Link]

Check out the TI C2000 / TMS320 architecture. I've written a lot of C++ with 16-bit chars on that architecture over the past few years. Yes, it's a bit of a brain-dead architecture, but there are definitely archs with non 8 bit chars around still.

Pettenò: Debunking x32 myths

Posted Jun 29, 2012 12:11 UTC (Fri) by nix (subscriber, #2304) [Link]

At least that's a multiple of 8. Are there any 9/18/36-bit bytes around these days? I hope not :}

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds