Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #59528

Re: Alignment requirement of basic types

From glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups comp.lang.c
Subject Re: Alignment requirement of basic types
Date 2015-04-03 16:48 +0000
Organization Aioe.org NNTP Server
Message-ID <mfmg9g$nd$1@speranza.aioe.org> (permalink)
References <mfm5mg$4rp$1@dont-email.me> <NSyTw.156257$uD5.43837@fx02.iad>

Show all headers | View raw


Richard Damon <Richard@damon-family.org> wrote:
> On 4/3/15 9:48 AM, Noob wrote:
(snip)
>> Do you know platforms where 4-byte types are only 2-byte aligned?

> It is common that alignment requirements are not stricter than the 
> machines memory bus width, so a machine that fetches only 16 bits at a 
> time, often will not have alignment restrictions stricter than that for 
> many types. (there may be special objects with stricter alignment, like 
> paging tables).
 
>> Perhaps 8086 had 32-bit longs that were only 16-bit aligned?
 
> I seem to remember that as true.

The history is more interesting for floating point types.

The original 8087 and the 80287 have a 16 bit data bus, and only
needed 16 bit (2 byte) alignment for 32 bit and 64 bit floating
point (C float and double).   

(Needed instead of required. They can work without such alignment,
but run much slower.)

Later, when processors with 32 bit and 64 bit data buses came along,
many compilers still generated, and C malloc() still returned,
addresses with only two byte alignment. While it worked, it was
much slower than it should have been with such misaligned data.
 
>> Maybe recent platforms have 64-bit long longs that are only
>> 32-bit aligned?

-- glen

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Alignment requirement of basic types Noob <root@127.0.0.1> - 2015-04-03 15:48 +0200
  Re: Alignment requirement of basic types Tim Prince <tprince@computer.org> - 2015-04-03 10:23 -0400
  Re: Alignment requirement of basic types James Kuyper <jameskuyper@verizon.net> - 2015-04-03 11:37 -0400
    Re: Alignment requirement of basic types John Temples <usenet@xargs-spam.com> - 2015-04-03 17:21 +0000
      Re: Alignment requirement of basic types James Kuyper <jameskuyper@verizon.net> - 2015-04-03 13:45 -0400
        Re: Alignment requirement of basic types Kaz Kylheku <kaz@kylheku.com> - 2015-04-03 18:40 +0000
      Re: Alignment requirement of basic types Keith Thompson <kst-u@mib.org> - 2015-04-03 10:50 -0700
      Re: Alignment requirement of basic types glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-04-03 19:02 +0000
    Re: Alignment requirement of basic types Kaz Kylheku <kaz@kylheku.com> - 2015-04-03 18:01 +0000
  Re: Alignment requirement of basic types Richard Damon <Richard@Damon-Family.org> - 2015-04-03 12:05 -0400
    Re: Alignment requirement of basic types glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-04-03 16:48 +0000
  Re: Alignment requirement of basic types Kaz Kylheku <kaz@kylheku.com> - 2015-04-03 16:46 +0000
    Re: Alignment requirement of basic types Keith Thompson <kst-u@mib.org> - 2015-04-03 11:06 -0700
      Re: Alignment requirement of basic types Robert Wessel <robertwessel2@yahoo.com> - 2015-04-05 22:22 -0500
  Re: Alignment requirement of basic types Waldek Hebisch <hebisch@antispam.uni.wroc.pl> - 2015-04-04 23:15 +0000

csiph-web