public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Sergei Gavrikov <w3sg@SoftHome.net>
To: Grant Edwards <grante@visi.com>
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS]  Re: CGY_SWAP16() seems broken to me.
Date: Sat, 22 Sep 2007 17:17:00 -0000	[thread overview]
Message-ID: <20070922171550.GA6762@ubuntu> (raw)
In-Reply-To: <fd3bsj$mep$1@sea.gmane.org>

On Sat, Sep 22, 2007 at 03:20:51PM +0000, Grant Edwards wrote:
> On 2007-09-22, Grant Edwards <grante@visi.com> wrote:
> 
> > My fix above should be completely transparent. if the value is
> > being assigned to a 16 bit lvalue, the compiler will generate
> > exactly the same code as when using the existing "broken"
> > macro. If the result from CYG_SWAP16() is being masked by the
> > user, the fixed macro will generate exactly the same code as
> > the existing macro.
> >
> > The only argument against my fix would be to claim that
> > CYG_SWAP16 is expected to return 24 bits in wider contexts, and
> > returning only 16 bits is going to break code or surprise a
> > user.
> 
> I've examined all uses of SWAP16 and the LE16/BE16 macros in my
> source tree (which is a few months out of date), and it doesn't
> look like any existing code depends on the fact that SWAP16()
> produces 24 bits instead of 16.

Today's score for CYG_SWAP16() is

CYG_SWAP16()      : 3 sources
CYG_CPU_TO_LE16() : 4 sources 

As you could see, ntohs(), htons() = swap16() in the little-endian world
(net/tcpip/current/include/sys/endian.h). There are tons of C lines are
using these net macros in the net stuff and at first, I just did think
about same strong rules for the HAL CYG_SWAP16() too, i.e. about type
casting (compiler care) + bit masking (CPU workaround).

I do see no criminal if you will provide a patch, which will set the
first barier - type casting. I vote for your patch. I did dislike that
0x123412.


	Sergei


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

      reply	other threads:[~2007-09-22 17:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-22  2:56 [ECOS] " Grant Edwards
2007-09-22 12:22 ` Sergei Gavrikov
2007-09-22 14:56   ` [ECOS] " Grant Edwards
2007-09-22 15:23     ` Grant Edwards
2007-09-22 17:17       ` Sergei Gavrikov [this message]

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=20070922171550.GA6762@ubuntu \
    --to=w3sg@softhome.net \
    --cc=ecos-discuss@sources.redhat.com \
    --cc=grante@visi.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).