public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Grant Edwards" <grante@visi.com>
To: Jonathan Larmour <jlarmour@redhat.com>
Cc: "Trenton D. Adams" <tadams@theone.dnsalias.com>,
	'Andrew Lunn' <andrew.lunn@ascom.ch>,
	'eCos discussion' <ecos-discuss@sources.redhat.com>
Subject: [ECOS] Re: Network programming for eCos under linux
Date: Wed, 08 Aug 2001 09:19:00 -0000	[thread overview]
Message-ID: <20010808161912.3576A7A926@visi.com> (raw)
In-Reply-To: <3B716392.17D4E08D@redhat.com>

Jonathan Larmour writes:

> "Trenton D. Adams" wrote:
>> 
>>   >
>>   > > So, how would one go about making a buffer word aligned or DWORD
>>   > aligned
>>   > > just to be safe?
>>   >
>>   > something along the lines of:
>>   >
>>   > char buffer[1024];
>>   > #define ALIGNMENT 8
>>   > #define ALIGNUP(_x_) (((char *)(_x_) + ALIGN-1) & ~(ALIGN-1))
>>   > int *foo = ALIGNUP(buffer);
>>   >
>>   > You could also use __alignof(int) to give the alignment but that's
>>   > obviously a GNU C-ism.
>>   > 
>> 
>> First of all, I assume your ALIGN is actually supposed to be ALIGNMENT!
> 
> Oops yes.
>  
>> I don't understand your macro.  Let's say _x_ happens to be memory
>> address 0x201 the macro formula would go like this 
>> 
>> = (0x201 + 7) & ~(7)
>> = 0x208 & 0xfffffff8
>> = 0x208 
>> 
>> So, now foo is pointing to an integer that is not at the beginning of
>> the buffer.  This would mean that I couldn't put anything at the
>> beginning of the buffer, correct?
> 
> If 8 byte alignment was the requirement then you certainly wouldn't want
> to. I suppose in that case you would make the buffer be 1031 bytes to
> ensure it could fit 1024 bytes post alignment.

Yup -- but that only fixes the problem at the start of the buffer or
if you're using an array of homogeneously sized data objects. 

If you're filling the buffer with a collection of packed, hetrogenous
data objects, you'll run into alignment problems somewhere else
in the buffer. 

-- 
Grant Edwards
grante@visi.com 

  reply	other threads:[~2001-08-08  9:19 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-07 15:41 [ECOS] " Trenton D. Adams
2001-08-08  0:35 ` Andrew Lunn
2001-08-08  6:27   ` Jonathan Larmour
2001-08-08  6:51     ` Andrew Lunn
2001-08-08  7:13       ` Grant Edwards
2001-08-08  7:52         ` Jonathan Larmour
2001-08-08  8:02           ` Andrew Lunn
2001-08-08  8:06           ` Trenton D. Adams
2001-08-08  8:14             ` Jonathan Larmour
2001-08-08  8:47               ` Trenton D. Adams
2001-08-08  8:58               ` Trenton D. Adams
2001-08-08  9:04                 ` Mark Salter
2001-08-08  9:06                 ` Jonathan Larmour
2001-08-08  9:19                   ` Grant Edwards [this message]
2001-08-08  9:07                 ` [ECOS] " Grant Edwards
2001-08-08  8:32             ` [ECOS] " Grant Edwards
2001-08-08  8:43               ` Trenton D. Adams
2001-08-08  8:57                 ` [ECOS] " Grant Edwards
2001-08-08  7:57   ` [ECOS] " Trenton D. Adams
2001-08-08  8:09     ` Grant Edwards
2001-08-08  8:14       ` Trenton D. Adams
2001-08-08  8:42         ` Grant Edwards
2001-08-08  8:21     ` Andrew Lunn
2001-08-08  8:27       ` Trenton D. Adams
2001-08-08  9:00       ` [ECOS] " Grant Edwards

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010808161912.3576A7A926@visi.com \
    --to=grante@visi.com \
    --cc=andrew.lunn@ascom.ch \
    --cc=ecos-discuss@sources.redhat.com \
    --cc=jlarmour@redhat.com \
    --cc=tadams@theone.dnsalias.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).