diff --git a/arithmetic.html b/arithmetic.html index 0383fad..fac718c 100644 --- a/arithmetic.html +++ b/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:
- Name -Endianness Alignment +Endianness Sign Sizes in bits (n) - -- big_int
n_t
- big
- yes
signed -16,32,64 -- -- big_uint
n_t
- big
- yes
unsigned -16,32,64 -- - big_float
n_t
- big
- yes
signed -32,64 -- big_int
n_ut
big
+ no
big
signed 8,16,24,32,40,48,56,64 - big_uint
n_ut
big
+ no
big
unsigned 8,16,24,32,40,48,56,64 - - big_float
n_ut
big
+ no
big
signed 32,64 - -- little_int
n_t
- little
- yes
signed -16,32,64 -- -- little_uint
n_t
- little
- yes
unsigned -16,32,64 -- - little_float
n_t
- little
- yes
signed -32,64 -- little_int
n_ut
little
+ no
little
signed 8,16,24,32,40,48,56,64 - little_uint
n_ut
little
+ no
little
unsigned 8,16,24,32,40,48,56,64 - - little_float
n_ut
little
+ no
little
signed 32,64 - - native_float
n_t
- native
- yes
signed -32,64 -- native_int
n_ut
native
+ no
native
signed 8,16,24,32,40,48,56,64 - native_uint
n_ut
native
+ no
native
unsigned 8,16,24,32,40,48,56,64 + - native_float
n_ut
native
+ no
+ native
signed +32,64 ++ ++ big_int
n_t
+ yes
+ big
signed +8,16,32,64 ++ ++ big_uint
n_t
+ yes
+ big
unsigned +8,16,32,64 ++ ++ big_float
n_t
+ yes
+ big
signed +32,64 ++ ++ little_int
n_t
+ yes
+ little
signed +8,16,32,64 ++ ++ little_uint
n_t
+ yes
+ little
unsigned +8,16,32,64 ++ ++ little_float
n_t
+ yes
+ little
signed +32,64 ++ @@ -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. ++ native_float
n_t
+ yes
native
signed 32,64 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/buffers.html b/buffers.html index a424dd0..3481035 100644 --- a/buffers.html +++ b/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:@@ -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. +
+ Name +Alignment Endianness Sign Sizes in bits (n) -Alignment + ++ big_int
n_buf_ut
+ no
+ big
signed +8,16,24,32,40,48,56,64 ++ ++ big_uint
n_buf_ut
+ no
+ big
unsigned +8,16,24,32,40,48,56,64 ++ ++ big_float
n_buf_ut
+ no
+ big
signed +32,64 ++ ++ little_int
n_buf_ut
+ no
+ little
signed +8,16,24,32,40,48,56,64 ++ ++ little_uint
n_buf_ut
+ no
+ little
unsigned +8,16,24,32,40,48,56,64 ++ ++ little_float
n_buf_ut
+ no
+ little
signed +32,64 ++ ++ native_int
n_buf_ut
+ no
+ native
signed +8,16,24,32,40,48,56,64 ++ ++ native_uint
n_buf_ut
+ no
+ native
unsigned +8,16,24,32,40,48,56,64 ++ + native_float
n_buf_ut
+ no
+ native
signed +32,64 ++ big_int
n_buf_t
yes
big
signed -16,32,64 -+ yes
8,16,32,64 + big_uint
n_
buf_
t
yes
big
unsigned -16,32,64 -+ yes
8,16,32,64 - + big_float
n_
buf_
t
yes
big
signed 32,64 -yes
- -- big_int
n_
buf_
ut
- big
signed -8,16,24,32,40,48,56,64 -- no
- -- big_uint
n_
buf_
ut
- big
unsigned -8,16,24,32,40,48,56,64 -- no
- - big_float
n_
buf_
ut
- big
signed -32,64 -- no
+ little_int
n_
buf_
t
yes
little
signed -16,32,64 -+ yes
8,16,32,64 + little_uint
n_
buf_
t
yes
little
unsigned -16,32,64 -+ yes
8,16,32,64 - - little_float
n_
buf_
t
- little
signed -32,64 - yes
- -- little_int
n_
buf_
ut
- little
signed -8,16,24,32,40,48,56,64 -- no
- -- little_uint
n_
buf_
ut
- little
unsigned -8,16,24,32,40,48,56,64 -- no
- little_float
n_
buf_
ut
little
signed 32,64 -no
- - native_float
n_
buf_
t
- native
signed -32,64 - yes
- -- native_int
n_
buf_
ut
- native
signed -8,16,24,32,40,48,56,64 -- no
- -- native_uint
n_
buf_
ut
- native
unsigned -8,16,24,32,40,48,56,64 -- no
- native_float
n_
buf_
ut
native
signed 32,64 -no
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/index.html b/index.html index 9c99dc0..9f92ac5 100644 --- a/index.html +++ b/index.html @@ -118,7 +118,7 @@ the least-significant byte first, while SPARC CPUs place the most-significant byte first. Some CPUs, such as the PowerPC, allow the operating system to choose which ordering applies.Most-significant-byte-first ordering is traditionally called "big endian" -ordering and the least-significant-byte-first is traditionally called +ordering and least-significant-byte-first is traditionally called "little-endian" ordering. The names are derived from Jonathan Swift's satirical novel @@ -135,7 +135,7 @@ And programmers may also want to use the library when minimizing either internal external data sizes is advantageous.
Introduction to the Boost.Endian library
-The Boost.Endian library provides three different approaches to dealing with +
Boost.Endian provides three different approaches to dealing with endianness. All three approaches support integers, floating point types except
@@ -154,15 +154,22 @@ conditional variants.long double
, and user-define types (UDTs).Endian buffer types - The application uses the provided endian buffer types to hold values, and explicitly converts to and from the built-in integer and -floating point types to perform arithmetic. Buffer lengths of 1 through 8 bytes -are supported, rather than just 2, 4, and 8 bytes. The types may be aligned or -unaligned.
+floating point types. Buffer sizes of 8, 16, 24, 32, 40, 48, 56, and 64 bits (i.e. +1, 2, 3, 4, 5, 6, 7, and 8 bytes) are provided. Unaligned integer buffer types +are provided for all sizes, unaligned floating point buffer types are provided +for 32 and 64 bit sizes, and aligned buffer types are provided for 16, 32, and +64-bit sizes. The provided specific types are typedefs for a generic class +template that may be used directly for less common use cases. -Endian arithmetic types - The application uses the provided endian -arithmetic types, which supply the same operations as the built-in C++ -arithmetic types. All conversions are implicit. Arithmetic integer types with -lengths of 1 through 8 bytes are supported, rather than just 2, 4, and 8 byte -integers. The types may be aligned.
+Endian arithmetic types - The +application uses the provided endian arithmetic types, which supply the same +operations as the built-in C++ arithmetic types. All conversions are implicit. +Arithmetic sizes of 8, 16, 24, 32, 40, 48, 56, and 64 bits (i.e. 1, 2, 3, 4, 5, +6, 7, and 8 bytes) are provided. Unaligned integer types are provided for all +sizes, unaligned floating point types are provided for 32 and 64 bit sizes, and aligned +arithmetic types are provided for 16, 32, and 64-bit sizes. The provided +specific types are typedefs for a generic class template that may be used +directly for less common use cases.
@@ -178,15 +185,16 @@ Choosing the Approach page.Built-in support for Intrinsics
Most compilers, including GCC, Clang, and Visual C++, supply built-in support for byte swapping intrinsics. -The Endian library uses these intrinsics when available since they may result in smaller and faster generated code, particularly for release +The Endian library uses these intrinsics when available since they may result in smaller and faster generated code, particularly for +optimized builds.
Defining the macro
BOOST_ENDIAN_NO_INTRINSICS
will suppress use -of the intrinsics. Useful when intrinsic headers such as -byteswap.h
are not being found by your compiler, perhaps because it +of the intrinsics. This is useful when a compiler has no intrinsic support or +fails to locate the appropriate header, perhaps because it is an older release or has very limited supporting libraries.The macro
BOOST_ENDIAN_INTRINSIC_MSG
is defined as either"no byte swap intrinsics"
or a string describing the -particular set of intrinsics being used. Useful for eliminating missing +particular set of intrinsics being used. This is useful for eliminating missing intrinsics as a source of performance issues.Performance
@@ -385,8 +393,10 @@ setup.Does endianness have any uses outside of portable binary file or network I/O formats?
-Using the unaligned integer types to save internal or external -memory space is a minor secondary use.
+Using the unaligned integer types with a size tailored to the application's +needs is a minor secondary use that saves internal or external memory space. For +example, using
big_int40_buf_ut
orbig_int40_ut
in a +large array saves a lot of space compared to one of the 64-bit types.Why bother with binary I/O? Why not just use C++ Standard Library stream inserters and extractors?
@@ -583,7 +593,7 @@ Blechmann, Tim Moore, tymofey, Tomas Puverle, Vincente Botet, Yuval Ronen and Vitaly Budovsk. Apologies if anyone has been missed.
Last revised: -09 February, 2015
+12 February, 2015© Copyright Beman Dawes, 2011, 2013
Distributed under the Boost Software License, Version 1.0. See www.boost.org/ LICENSE_1_0.txt
diff --git a/styles.css b/styles.css index 9d89d77..2018ec0 100644 --- a/styles.css +++ b/styles.css @@ -8,8 +8,8 @@ body } ins {background-color: #CCFFCC;} del {background-color: #FFCACA;} - pre {background-color: #D7EEFF; font-size: 95%; font-family: courier, serif;} - code {font-size: 110%; font-family: courier, serif;} + pre {background-color: #D7EEFF; font-size: 95%; font-family: "courier new", courier, serif;} + code {font-size: 110%; font-family: "courier new", courier, serif;} table {font-size: 100%;} /*