diff --git a/doc/arithmetic.html b/doc/arithmetic.html index 0383fad..fac718c 100644 --- a/doc/arithmetic.html +++ b/doc/arithmetic.html @@ -213,126 +213,126 @@ enum class align {no, yes}; class endian_arithmetic; -

Typedefs, such as big_int32_t, provide convenient naming +

Typedefs, such as big_int32_ut, provide convenient naming conventions for common use cases:

- + - - - - - - - - - - - - - - - - - - - - - - + - + - + - - - - - - - - - - - - - - - - - - - - - - + - + - + - - - - - - - - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -346,15 +346,16 @@ Code that uses aligned types is possibly non-portable because alignment requirements vary between hardware architectures and because alignment may be affected by compiler switches or pragmas. For example, alignment of an 64-bit integer may be to a 32-bit boundary on a 32-bit machine. Furthermore, aligned types -are only available on architectures with 16, 32, and 64-bit integer types.

+are only available on architectures with 8, 16, 32, and 64-bit integer types.

+

Recommendation: Prefer unaligned endian types.

Recommendation: Protect yourself against alignment ills. For example:

static_assert(sizeof(containing_struct) == 12, "sizeof(containing_struct) is wrong"); 
-

Note: One-byte types -have identical -functionality. They are provided to improve code readability and searchability.

+

Note: One-byte big and little buffer types +never actually reverse endianness. They are provided to enable generic code, and +to improve code readability and searchability.

Class template endian_arithmetic

An endian is an integer byte-holder with user-specified endianness, value type, size, and alignment. The @@ -443,21 +444,25 @@ usual operations on integers are supplied.

typedef endian<order::little, double, 64, align::no> little_float64_ut; // aligned big endian signed integer types + typedef endian<order::big, int8_t, 8, align::yes> big_int8_t; typedef endian<order::big, int16_t, 16, align::yes> big_int16_t; typedef endian<order::big, int32_t, 32, align::yes> big_int32_t; typedef endian<order::big, int64_t, 64, align::yes> big_int64_t; // aligned big endian unsigned integer types + typedef endian<order::big, uint8_t, 8, align::yes> big_uint8_t; typedef endian<order::big, uint16_t, 16, align::yes> big_uint16_t; typedef endian<order::big, uint32_t, 32, align::yes> big_uint32_t; typedef endian<order::big, uint64_t, 64, align::yes> big_uint64_t; // aligned little endian signed integer types + typedef endian<order::little, int8_t, 8, align::yes> little_int8_t; typedef endian<order::little, int16_t, 16, align::yes> little_int16_t; typedef endian<order::little, int32_t, 32, align::yes> little_int32_t; typedef endian<order::little, int64_t, 64, align::yes> little_int64_t; // aligned little endian unsigned integer types + typedef endian<order::little, uint8_t, 8, align::yes> little_uint8_t; typedef endian<order::little, uint16_t, 16, align::yes> little_uint16_t; typedef endian<order::little, uint32_t, 32, align::yes> little_uint32_t; typedef endian<order::little, uint64_t, 64, align::yes> little_uint64_t; @@ -682,7 +687,7 @@ differs from endian representation size. Vicente Botet and other reviewers suggested supporting floating point types.


Last revised: -25 January, 2015

+12 February, 2015

© Copyright Beman Dawes, 2006-2009, 2013

Distributed under the Boost Software License, Version 1.0. See www.boost.org/ LICENSE_1_0.txt

diff --git a/doc/buffers.html b/doc/buffers.html index a424dd0..3481035 100644 --- a/doc/buffers.html +++ b/doc/buffers.html @@ -200,128 +200,128 @@ enum class align {no, yes}; class endian_buffer; -

Typedefs, such as big_int32_buf_t, provide convenient naming +

Typedefs, such as big_int32_buf_ut, provide convenient naming conventions for common use cases:

NameEndianness AlignmentEndianness Sign Sizes in bits (n)
big_intn_tbigyessigned16,32,64
big_uintn_tbigyesunsigned16,32,64
big_floatn_tbigyessigned32,64
big_intn_utbig nobig signed 8,16,24,32,40,48,56,64
big_uintn_utbig nobig unsigned 8,16,24,32,40,48,56,64
big_floatn_utbig nobig signed 32,64
little_intn_tlittleyessigned16,32,64
little_uintn_tlittleyesunsigned16,32,64
little_floatn_tlittleyessigned32,64
little_intn_utlittle nolittle signed 8,16,24,32,40,48,56,64
little_uintn_utlittle nolittle unsigned 8,16,24,32,40,48,56,64
little_floatn_utlittle nolittle signed 32,64
native_floatn_tnativeyessigned32,64
native_intn_utnative nonative signed 8,16,24,32,40,48,56,64
native_uintn_utnative nonative unsigned 8,16,24,32,40,48,56,64
native_floatn_utnative nonativesigned32,64
big_intn_tyesbigsigned8,16,32,64
big_uintn_tyesbigunsigned8,16,32,64
big_floatn_tyesbigsigned32,64
little_intn_tyeslittlesigned8,16,32,64
little_uintn_tyeslittleunsigned8,16,32,64
little_floatn_tyeslittlesigned32,64
native_floatn_tyesnative signed 32,64
+ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - + - - + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameAlignment Endianness Sign Sizes in bits (n)Alignment
big_intn_buf_utnobigsigned8,16,24,32,40,48,56,64
big_uintn_buf_utnobigunsigned8,16,24,32,40,48,56,64
big_floatn_buf_utnobigsigned32,64
little_intn_buf_utnolittlesigned8,16,24,32,40,48,56,64
little_uintn_buf_utnolittleunsigned8,16,24,32,40,48,56,64
little_floatn_buf_utnolittlesigned32,64
native_intn_buf_utnonativesigned8,16,24,32,40,48,56,64
native_uintn_buf_utnonativeunsigned8,16,24,32,40,48,56,64
native_floatn_buf_utnonativesigned32,64
big_intn_buf_tyes big signed16,32,64yes8,16,32,64
big_uintn_buf_tyes big unsigned16,32,64yes8,16,32,64
big_floatn_buf_tyes big signed 32,64yes
big_intn_buf_utbigsigned8,16,24,32,40,48,56,64no
big_uintn_buf_utbigunsigned8,16,24,32,40,48,56,64no
big_floatn_buf_utbigsigned32,64no
little_intn_buf_tyes little signed16,32,64yes8,16,32,64
little_uintn_buf_tyes little unsigned16,32,64yes8,16,32,64
little_floatn_buf_tlittlesigned32,64 yes
little_intn_buf_utlittlesigned8,16,24,32,40,48,56,64no
little_uintn_buf_utlittleunsigned8,16,24,32,40,48,56,64no
little_floatn_buf_ut little signed 32,64no
native_floatn_buf_tnativesigned32,64 yes
native_intn_buf_utnativesigned8,16,24,32,40,48,56,64no
native_uintn_buf_utnativeunsigned8,16,24,32,40,48,56,64no
native_floatn_buf_ut native signed 32,64no
@@ -333,15 +333,16 @@ Code that uses aligned types is possibly non-portable because alignment requirements vary between hardware architectures and because alignment may be affected by compiler switches or pragmas. For example, alignment of an 64-bit integer may be to a 32-bit boundary on a 32-bit machine. Furthermore, aligned types -are only available on architectures with 16, 32, and 64-bit integer types.

+are only available on architectures with 8, 16, 32, and 64-bit integer types.

+

Recommendation: Prefer unaligned endian types.

Recommendation: Protect yourself against alignment ills. For example:

static_assert(sizeof(containing_struct) == 12, "sizeof(containing_struct) is wrong"); 

Note: One-byte big and little buffer types -have identical -functionality. They are provided to improve code readability and searchability.

+never actually reverse endianness. They are provided to enable generic code, and +to improve code readability and searchability.

Class template endian_buffer

An endian_buffer is an integer byte-holder with user-specified endianness, value type, size, and alignment. The @@ -655,7 +656,7 @@ any Boost object libraries.


Last revised: -25 January, 2015

+12 February, 2015

© Copyright Beman Dawes, 2006-2009, 2013

Distributed under the Boost Software License, Version 1.0. See www.boost.org/ LICENSE_1_0.txt

diff --git a/include/boost/endian/arithmetic.hpp b/include/boost/endian/arithmetic.hpp index 0cda700..6944ab9 100644 --- a/include/boost/endian/arithmetic.hpp +++ b/include/boost/endian/arithmetic.hpp @@ -96,21 +96,25 @@ namespace endian typedef endian_arithmetic little_float64_ut; // big endian signed integer aligned types + typedef endian_arithmetic big_int8_t; typedef endian_arithmetic big_int16_t; typedef endian_arithmetic big_int32_t; typedef endian_arithmetic big_int64_t; // big endian unsigned integer aligned types + typedef endian_arithmetic big_uint8_t; typedef endian_arithmetic big_uint16_t; typedef endian_arithmetic big_uint32_t; typedef endian_arithmetic big_uint64_t; // little endian signed integer aligned types + typedef endian_arithmetic little_int8_t; typedef endian_arithmetic little_int16_t; typedef endian_arithmetic little_int32_t; typedef endian_arithmetic little_int64_t; // little endian unsigned integer aligned types + typedef endian_arithmetic little_uint8_t; typedef endian_arithmetic little_uint16_t; typedef endian_arithmetic little_uint32_t; typedef endian_arithmetic little_uint64_t; diff --git a/include/boost/endian/buffers.hpp b/include/boost/endian/buffers.hpp index 99dd185..da353b4 100644 --- a/include/boost/endian/buffers.hpp +++ b/include/boost/endian/buffers.hpp @@ -93,21 +93,25 @@ namespace endian typedef endian_buffer little_float64_buf_ut; // aligned big endian signed integer buffers + typedef endian_buffer big_int8_buf_t; typedef endian_buffer big_int16_buf_t; typedef endian_buffer big_int32_buf_t; typedef endian_buffer big_int64_buf_t; // aligned big endian unsigned integer buffers + typedef endian_buffer big_uint8_buf_t; typedef endian_buffer big_uint16_buf_t; typedef endian_buffer big_uint32_buf_t; typedef endian_buffer big_uint64_buf_t; // aligned little endian signed integer buffers + typedef endian_buffer little_int8_buf_t; typedef endian_buffer little_int16_buf_t; typedef endian_buffer little_int32_buf_t; typedef endian_buffer little_int64_buf_t; // aligned little endian unsigned integer buffers + typedef endian_buffer little_uint8_buf_t; typedef endian_buffer little_uint16_buf_t; typedef endian_buffer little_uint32_buf_t; typedef endian_buffer little_uint64_buf_t; diff --git a/test/buffer_test.cpp b/test/buffer_test.cpp index 0ddbf8f..5ea61fd 100644 --- a/test/buffer_test.cpp +++ b/test/buffer_test.cpp @@ -98,18 +98,22 @@ namespace BOOST_TEST_EQ(sizeof(native_uint56_buf_ut), 7u); BOOST_TEST_EQ(sizeof(native_uint64_buf_ut), 8u); + BOOST_TEST_EQ(sizeof(big_int8_buf_t), 1u); BOOST_TEST_EQ(sizeof(big_int16_buf_t), 2u); BOOST_TEST_EQ(sizeof(big_int32_buf_t), 4u); BOOST_TEST_EQ(sizeof(big_int64_buf_t), 8u); + BOOST_TEST_EQ(sizeof(big_uint8_buf_t), 1u); BOOST_TEST_EQ(sizeof(big_uint16_buf_t), 2u); BOOST_TEST_EQ(sizeof(big_uint32_buf_t), 4u); BOOST_TEST_EQ(sizeof(big_uint64_buf_t), 8u); + BOOST_TEST_EQ(sizeof(little_int8_buf_t), 1u); BOOST_TEST_EQ(sizeof(little_int16_buf_t), 2u); BOOST_TEST_EQ(sizeof(little_int32_buf_t), 4u); BOOST_TEST_EQ(sizeof(little_int64_buf_t), 8u); + BOOST_TEST_EQ(sizeof(little_uint8_buf_t), 1u); BOOST_TEST_EQ(sizeof(little_uint16_buf_t), 2u); BOOST_TEST_EQ(sizeof(little_uint32_buf_t), 4u); BOOST_TEST_EQ(sizeof(little_uint64_buf_t), 8u); diff --git a/test/endian_test.cpp b/test/endian_test.cpp index 8848be8..9687773 100644 --- a/test/endian_test.cpp +++ b/test/endian_test.cpp @@ -402,19 +402,23 @@ namespace VERIFY_SIZE( sizeof( native_uint56_ut ), 7 ); VERIFY_SIZE( sizeof( native_uint64_ut ), 8 ); - VERIFY_SIZE( sizeof( big_int16_t ), 2 ); + VERIFY_SIZE(sizeof(big_int8_t), 1); + VERIFY_SIZE(sizeof(big_int16_t), 2); VERIFY_SIZE( sizeof( big_int32_t ), 4 ); VERIFY_SIZE( sizeof( big_int64_t ), 8 ); - VERIFY_SIZE( sizeof( big_uint16_t ), 2 ); + VERIFY_SIZE(sizeof(big_uint8_t), 1); + VERIFY_SIZE(sizeof(big_uint16_t), 2); VERIFY_SIZE( sizeof( big_uint32_t ), 4 ); VERIFY_SIZE( sizeof( big_uint64_t ), 8 ); - VERIFY_SIZE( sizeof( little_int16_t ), 2 ); + VERIFY_SIZE(sizeof(little_int8_t), 1); + VERIFY_SIZE(sizeof(little_int16_t), 2); VERIFY_SIZE( sizeof( little_int32_t ), 4 ); VERIFY_SIZE( sizeof( little_int64_t ), 8 ); - VERIFY_SIZE( sizeof( little_uint16_t ), 2 ); + VERIFY_SIZE(sizeof(little_uint8_t), 1); + VERIFY_SIZE(sizeof(little_uint16_t), 2); VERIFY_SIZE( sizeof( little_uint32_t ), 4 ); VERIFY_SIZE( sizeof( little_uint64_t ), 8 ); } // check_size