From: Grant Edwards <grante@visi.com>
To: ecos-discuss@sources.redhat.com
Subject: [ECOS] CGY_SWAP16() seems broken to me.
Date: Sat, 22 Sep 2007 02:56:00 -0000 [thread overview]
Message-ID: <fd2091$bnn$1@sea.gmane.org> (raw)
unsigned u = CYG_SWAP16(0x1234);
What would a reasonable person (who hasn't looked at
hal_endian.h) expect u to be?
I certainly expected it to be 0x3412.
But it's not. It's 0x123412.
IMO, that's just plain broken.
Here's the definition from hal_endian.h:
# define CYG_SWAP16(_x_) \
({ cyg_uint16 _x = (_x_); ((_x << 8) | (_x >> 8)); })
Why isn't it this?
# define CYG_SWAP16(_x_) \
({ cyg_uint16 _x = (_x_); (cyg_uint16)((_x << 8) | (_x >> 8)); })
Why would anybody expect a macro named CYG_SWAP16() to return a
"24-bit value" when passed a "16-bit value"?
--
Grant Edwards grante Yow! Ha ha Ha ha Ha ha
at Ha Ha Ha Ha -- When will I
visi.com EVER stop HAVING FUN?!!
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
next reply other threads:[~2007-09-22 2:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-22 2:56 Grant Edwards [this message]
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
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='fd2091$bnn$1@sea.gmane.org' \
--to=grante@visi.com \
--cc=ecos-discuss@sources.redhat.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).