BYTEORDER(9) | FreeBSD Kernel Developer's Manual | BYTEORDER(9) |
名称
bswap16, bswap32, bswap64, be16toh, be32toh, be64toh, htobe16, htobe32, htobe64, htole16, htole32, htole64, le16toh, le32toh, le64toh, be16enc, be16dec, be32enc, be32dec, be64enc, be64dec, le16enc, le16dec, le32enc, le32dec, le64enc, le64dec — バイト順序の操作書式
#include < sys/endian.h> uint16_t
bswap16( uint16_t int16);
uint32_t
bswap32( uint32_t int32);
uint64_t
bswap64( uint64_t int64);
uint16_t
be16toh( uint16_t big16);
uint32_t
be32toh( uint32_t big32);
uint64_t
be64toh( uint64_t big64);
uint16_t
htobe16( uint16_t host16);
uint32_t
htobe32( uint32_t host32);
uint64_t
htobe64( uint64_t host64);
uint16_t
htole16( uint16_t host16);
uint32_t
htole32( uint32_t host32);
uint64_t
htole64( uint64_t host64);
uint16_t
le16toh( uint16_t little16);
uint32_t
le32toh( uint32_t little32);
uint64_t
le64toh( uint64_t little64);
uint16_t
be16dec( const void *);
uint32_t
be32dec( const void *);
uint64_t
be64dec( const void *);
uint16_t
le16dec( const void *);
uint32_t
le32dec( const void *);
uint64_t
le64dec( const void *);
void
be16enc( void *, uint16_t);
void
be32enc( void *, uint32_t);
void
be64enc( void *, uint64_t);
void
le16enc( void *, uint16_t);
void
le32enc( void *, uint32_t);
void
le64enc( void *, uint64_t);
解説
bswap16(), bswap32() と bswap64() 関数は、バイト順序が交換された整数を返します。ビッグエンディアンのシステム上では、その数値は、リトルエンディアンのバイト順序に変換されます。リトルエンディアンのシステム上では、その数値は、ビッグエンディアンのバイト順序に変換されます。be16toh(), be32toh() と be64toh() 関数は、ビッグエンディアンのバイト順序の整数をシステムのネイティブなバイト順序に変換して返します。ビッグエンディアンのシステム上では、戻り値は、引数と同じになります。
le16toh(), le32toh() と le64toh() 関数は、リトルエンディアンのバイト順序の整数をシステムのネイティブなバイト順序に変換して返します。リトルエンディアンのシステム上では、戻り値は、引数と同じになります。
htobe16(), htobe32() と htobe64() 関数は、システムのネイティブなバイト順序の整数をビッグエンディアンのバイト順序に変換して返します。ビッグエンディアンのシステム上では、戻り値は、引数と同じになります。
htole16(), htole32() と htole64() 関数は、システムのネイティブなバイト順序の整数をリトルエンディアンのバイト順序に変換して返します。リトルエンディアンのシステム上では、戻り値は、引数と同じになります。
be16enc(), be16dec(), be32enc(), be32dec(), be64enc(), be64dec(), le16enc(), le16dec(), le32enc(), le32dec(), le64enc(), と le64dec() 関数は、ビッグ/リトルエンディアンのあらゆるアライメントの、整数からバイトストリングへエンコードおよびバイトコードから整数へデコードを行います。
関連項目
byteorder(3)歴史
hto*() と *toh() 関数は、 FreeBSD 5.0 ではじめて登場し、最初は NetBSD プロジェクトによって開発されました。エンコード/デコード関数は、 FreeBSD 5.1 ではじめて登場しました。
April 29, 2002 | FreeBSD |