Re: [PATCH] 24-bit types: typedef and functions for accessing 3-bytearrays as integers

From: Boaz Harrosh
Date: Wed Sep 10 2008 - 08:57:46 EST

Chris Leech wrote:
> Both iSCSI and Fibre Channel make use of 24-bit big-endian values in
> frame headers. This patch defines __be24 and __le24 typedefs for a
> structure wrapped around a 3-byte array, and functions to convert back and
> forth to a 32-bit integer.
> The undefs in iscsi_proto.h are because of the different calling
> convention for the existing hton24 macro in the iSCSI code. iSCSI will
> be converted in a subsequent patch.
> Changes from last posting:
> Switched from preprocessor macros to inline functions. The generated assembly
> is the same with gcc 4.1.2 as long as the function is actually inlined. I
> applied the __always_inline attribute to all of these, after seeing that with
> one of my test kernel configurations they were not being inlined without it
> and the generated instructions in the iSCSI code could be considered a
> regression from the existing macro.
> Signed-off-by: Chris Leech <christopher.leech@xxxxxxxxx>
> ---
> include/linux/byteorder.h | 44 ++++++++++++++++++++++++++++++++++++
> include/linux/byteorder/generic.h | 45 +++++++++++++++++++++++++++++++++++++
> include/linux/types.h | 2 ++
> include/scsi/iscsi_proto.h | 2 ++
> 4 files changed, 93 insertions(+), 0 deletions(-)

Thanks! Personally I like this much better.

Sorry to be nit picking but again I hate that double implementation thing.
>From what I could see, and considering a few of the ARCHs you mentioned,
it looks to me like <linux/swab.h> is common to the two implementations,
(old and new). Perhaps put the "__xxx" implementations in swab.h and
only the xxx => __xxx switching in the double byteorder headers, which
fits better with the surrounding style of these headers.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at