[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little
From: |
Shaun Jackman |
Subject: |
[lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little or big endian? |
Date: |
Thu, 09 Jan 2003 01:09:19 -0000 |
Having to redefine every constant for each architecture does not sit
well with me. Are you certain you can't coerce your compiler to
optimise away constants? I thought most every compiler does this.
Rod's code snippet will not produce compiler errors so long as the
xtoxx() calls are macros. eg
case ntohs( ETHTYPE_IP):
evaluates to
case (ETHTYPE_IP << 8) | (ETHTYPE_IP >> 8):
which is constant, thus good C.
Unless you're *very* constrained (in code space or time), I would not
sweat the little things such as where and how byte swapping is done.
I believe it has very little effect on the overall performance of the
stack, although I'd be interested to hear if someone disagrees. If
the call is implemented as a macro, the majority of calls will be
eliminated when they're called on a constant. When the call is on a
variable, the function is so simple that the compiler should produce
near-perfect assembler.
Cheers,
Shaun
> Thanks for the input. This looks like a good idea, but the compiler
> I'm using would then insert byte-swapping code for each use of
> ETHTYPE_ARP or ETHTYPE_IP, and it wouldn't be optimized out, and it
> ends up being more code than the current approach. Would other C
> compilers really optimize this away? Anyways, this particular code
> snippet would produce compile errors in any C compiler since a case
> statement must contain a constant. It would compile with an if then
> else statement, but might result in two byte swaps taking place
> instead of one ...
[This message was sent through the lwip discussion list.]
- [lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little or big endian?, John C. Toman, 2003/01/08
- [lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little or big endian?, John C. Toman, 2003/01/08
- [lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little or big endian?, Shaun Jackman, 2003/01/09
- [lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little or big endian?, Rod Boyce, 2003/01/09
- [lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little or big endian?, John C. Toman, 2003/01/09
- [lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little or big endian?, John C. Toman, 2003/01/09
- [lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little or big endian?, Rod Boyce, 2003/01/09
- [lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little or big endian?,
Shaun Jackman <=
- [lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little or big endian?, John C. Toman, 2003/01/09
- [lwip-users] RE: [lwip] Anyone Using An Architecture That Isn't little or big endian?, Earle Clubb, 2003/01/09
- [lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little or big endian?, Shaun Jackman, 2003/01/09
- [lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little or big endian?, John C. Toman, 2003/01/09
- [lwip-users] Re: [lwip] Anyone Using An Architecture That Isn't little or big endian?, Shaun Jackman, 2003/01/09
- [lwip-users] RE: [lwip] Anyone Using An Architecture That Isn't little or big endian?, Earle Clubb, 2003/01/09