Directory reorg to follow Boost Git practice.

This commit is contained in:
Beman committed 2013-03-18 14:57:23 -04:00
1 parent d549e3bdd3
commit d131123327
27 files changed

No files matched your search

-19
View File
@@ -1,19 +0,0 @@
Installation of a review candidate
==================================
1) Download the .zip distribution file. Move it to, say, /temp, and unzip it there.
That will result in a directory in /temp named endian-rc#, where # is the number of the
review candidate.
2) If you haven't already done so, install a current version of Boost.
Since Boost.Endian is a header only library, there is no need to run a build.
3) Copy the endian files to your Boost installation (replace MY-BOOST with its path):
Windows: xcopy /s /i \temp\endian-rc#\* MY-BOOST
POSIX: cp -r /temp/endian-rc#/* MY-BOOST
4) Run the tests (as a confidence builder that the install went OK):
cd MY-BOOST/endian/libs/endian/test
bjam
-169
View File
@@ -1,169 +0,0 @@
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Boost Endian Conversion Functions</title>
<link rel="stylesheet" type="text/css" href="../../../doc/src/minimal.css">
</head>
<body>
<table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="933">
<tr>
<td width="277">
<a href="../../../index.html">
<img src="../../../boost.png" alt="boost.png (6897 bytes)" align="middle" width="277" height="86" border="0"></a></td>
<td width="636" align="middle">
<font size="7">Endian Conversion Functions</font></td>
</tr>
</table>
<table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#D7EEFF" width="100%">
<tr>
<td><b><a href="../../../index.htm">Boost Home</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="index.html">Endian Home</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="conversion.html">Conversion Functions</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="integers.html">Integer Types</a>&nbsp;&nbsp;&nbsp;&nbsp; Tutorial</b></td>
</tr>
</table>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" align="right">
<tr>
<td width="100%" bgcolor="#D7EEFF" align="center">
<i><b>Contents</b></i></td>
</tr>
<tr>
<td width="100%" bgcolor="#E8F5FF">
<a href="#Introduction">Introduction</a><br>
<a href="#Reference">Reference</a><br>
&nbsp;&nbsp;&nbsp; <a href="#Synopsis">Synopsis</a><br>
&nbsp;&nbsp;&nbsp; <a href="#Members">Members</a><br>
<a href="#Acknowledgements">Acknowledgements</a></td>
</tr>
<tr>
<td width="100%" bgcolor="#D7EEFF" align="center">
<b><i>Headers</i></b></td>
</tr>
<tr>
<td width="100%" bgcolor="#E8F5FF">
<a href="../../../boost/endian/conversion.hpp">&lt;boost/endian/conversion.hpp&gt;</a><br>
<a href="../../../boost/endian/integers.hpp">&lt;boost/endian/integers.hpp&gt;</a></td>
</tr>
</table>
<h2><a name="Introduction">Introduction</a></h2>
<p>Header <a href="../../../boost/endian/conversion.hpp">boost/endian/conversion.hpp</a>
provides functions that convert built-in
integers between native byte ordering and <a href="index.html#definition">big or little endian</a> byte
ordering.</p>
<h2><a name="Reference">Reference</a></h2>
<h3>
<a name="Synopsis">Synopsis</a></h3>
<pre>namespace boost
{
namespace endian
{
// unconditional modifying (i.e. in-place) reverse byte order
inline void reorder(int16_t&amp; x);
inline void reorder(int32_t&amp; x);
inline void reorder(int64_t&amp; x);
inline void reorder(uint16_t&amp; x);
inline void reorder(uint32_t&amp; x);
inline void reorder(uint64_t&amp; x);
// unconditional non-modifying reverse byte order copy
inline void reorder(int16_t source, int16_t&amp; target);
inline void reorder(int32_t source, int32_t&amp; target);
inline void reorder(int64_t source, int64_t&amp; target);
inline void reorder(uint16_t source, uint16_t&amp; target);
inline void reorder(uint32_t source, uint32_t&amp; target);
inline void reorder(uint64_t source, uint64_t&amp; target);
// conditional modifying (i.e. in-place) reverse byte order
template &lt;class T&gt; void native_to_big(T&amp; x);
template &lt;class T&gt; void native_to_little(T&amp; x);
template &lt;class T&gt; void big_to_native(T&amp; x);
template &lt;class T&gt; void little_to_native(T&amp; x);
// non-modifying conditional reverse byte order copy
template &lt;class T&gt; void native_to_big(T source, T&amp; target);
template &lt;class T&gt; void native_to_little(T source, T&amp; target);
template &lt;class T&gt; void big_to_native(T source, T&amp; target);
template &lt;class T&gt; void little_to_native(T source, T&amp; target);
} // namespace endian
} // namespace boost</pre>
<h3 dir="ltr"><a name="Members">Members</a></h3>
<pre dir="ltr">inline void reorder(int16_t&amp; x);
inline void reorder(int32_t&amp; x);
inline void reorder(int64_t&amp; x);
inline void reorder(uint16_t&amp; x);
inline void reorder(uint32_t&amp; x);
inline void reorder(uint64_t&amp; x);</pre>
<blockquote>
<p dir="ltr"><i>Effects:</i> Reverses the byte order of <i><code>x</code></i>.</p>
</blockquote>
<pre dir="ltr">inline void reorder(int16_t source, int16_t&amp; target);
inline void reorder(int32_t source, int32_t&amp; target);
inline void reorder(int64_t source, int64_t&amp; target);
inline void reorder(uint16_t source, uint16_t&amp; target);
inline void reorder(uint32_t source, uint32_t&amp; target);
inline void reorder(uint64_t source, uint64_t&amp; target);</pre>
<blockquote>
<p dir="ltr"><i>Effects:</i> Copies <code>source</code> to <code>target</code>,
reversing the byte order.</p>
</blockquote>
<pre dir="ltr">template &lt;class T&gt; void native_to_big(T&amp; x);
template &lt;class T&gt; void native_to_little(T&amp; x);
template &lt;class T&gt; void big_to_native(T&amp; x);
template &lt;class T&gt; void little_to_native(T&amp; x);</pre>
<blockquote>
<p dir="ltr"><i>Effects:</i> If the native byte ordering and byte
ordering indicated by the function name are different, <code>reorder(x)</code>, otherwise no effect.</p>
<p dir="ltr"><i>Example:</i></p>
<blockquote>
<pre>int32_t x = <b><i>some-value</i></b>;
native_to_big(x); // converts x to big-endian unless
// the native representation is already big-endian</pre>
</blockquote>
</blockquote>
<pre dir="ltr">template &lt;class T&gt; void native_to_big(T source, T&amp; target);
template &lt;class T&gt; void native_to_little(T source, T&amp; target);
template &lt;class T&gt; void big_to_native(T source, T&amp; target);
template &lt;class T&gt; void little_to_native(T source, T&amp; target);</pre>
<blockquote>
<p dir="ltr"><i>Effects:</i> If the native byte ordering and byte
ordering indicated by the function name are different, <code>reorder(source, target)</code>, otherwise <code>
target = source</code>.</p>
<p dir="ltr"><i>Example:</i></p>
<blockquote>
<pre>int32_t x;
<i>... read an external little-endian value into x ...</i>
int32_t y;
little_to_native(x, y); // if native ordering is big-endian, reorder(x, y),
// otherwise y = x</pre>
</blockquote>
</blockquote>
<h2><a name="Acknowledgements">Acknowledgements</a></h2>
<p>Tomas Puverle was instrumental in identifying and articulating the need to
support endian conversion as separate from endian types.</p>
<hr>
<p>Last revised:
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05 September, 2011<!--webbot bot="Timestamp" endspan i-checksum="39338" --></p>
<p>© Copyright Beman Dawes, 2011</p>
<p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p>
</body>
</html>
-275
View File
@@ -1,275 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Endian Library Do List</title>
</head>
<body>
<h1>Endian Library Do List</h1>
<h2>To Do</h2>
<ul>
<li>Re-read all messages, and extract Acknowledgements and revise TODO list.</li>
<li>Develop the use-cases example programs, using plain integers and UDT's.
</li>
<li>Apply revised conversion functions to the example programs. Iterate until
happy.</li>
<li>Apply the integers to the example programs, and also see if using<br>
the revised conversion functions to implement some or all of the<br>
integers.</li>
<li>Apply mockups of the buffers to the example programs, to get a<br>
firmer idea if the buffer idea actually seems to do be worthwhile in<br>
practice.</li>
<li>Post work-in-progress for feedback.</li>
<li>Finalize and hold mini-review.</li>
</ul>
<h2>Format Review Comments</h2>
<h3 dir="ltr">Votes</h3>
<ul>
<li dir="ltr">
<p dir="ltr">John Filo - &quot;Absolutely. I'd like to see support for float and
double, but<br>
even without those additions, I still vote yes.&quot; &quot;For those who deal with
non-native endian data, this library is<br>
extremely useful. It automatically eliminates a whole class of common<br>
programming errors when dealing with such data.&quot;<br>
&nbsp;</li>
<li dir="ltr">
<p dir="ltr">Hartmut Kaiser - &quot;Even if this is not a full review, I would like
to vote YES to include this <br>
library into Boost.
<p>Boost.Spirit is using (and shipping) with an older version of this library
<br>
for several years now and we never had any problems with its usage in <br>
Spirit. It is used as the underlying framework for the binary parsers and <br>
generators and it is functioning as advertised.</p>
<p>As a quick test I replaced the internal (older) version of Boost.Endian in
<br>
Spirit with the reviewed version. All of Spirits regression tests still <br>
pass. &quot;<br>
&nbsp;</li>
<li dir="ltr">
<p dir="ltr">Robert Stewart - &quot;There are issues that keep me from saying yes
at this time. &nbsp;There are too many suggested variations and ideas under
consideration to accept the library in its present state. &nbsp;However, a
mini-review should be sufficient to evaluate the final form, once Beman
determines a course of action, and determine whether to accept it or not.&quot;<br>
&nbsp;</li>
<li dir="ltr">
<p dir="ltr">Tim Blechmann - &quot;the library should be accepted, if<br>
<br>
(a) the interface of the conversion functions is changed<br>
(b) the performance can be improved<br>
(c) the documentation integrates better with the rest of the boost<br>
&nbsp; &nbsp;documentation.&quot;<br>
&nbsp;</li>
<li dir="ltr">
<p dir="ltr">Vicente J. Botet Escriba - &quot;No in its current state.<br>
Once the library takes in account the requested modification (that Beman has
already accepted) a mini-review will be necessary to improve the library
before release.&quot;</li>
</ul>
<h3>Executive summary</h3>
<ul>
<li>Common use case scenarios should be developed.</li>
<li>Example programs should be developed for the common use case scenarios.</li>
<li>Documentation should illuminate the differences between endian
integer/float type and endian conversion approaches to the common use case
scenarios, and provide guidelines for choosing the most appropriate approach
for user's applications.</li>
<li>Conversion functions supplying results via <code>return</code> should be
provided.</li>
<li>Platform specific performance enhancements such as use of compiler
intrinsics or relaxed alignment requirements should be supported.</li>
<li>Endian integer (and floating) types should be implemented via the
conversion functions. If that can't be done efficiently, consideration should
be given to expanding the conversion function signatures to resolve the
inefficiencies.</li>
<li>Benchmarks that measure performance should be provided. It should be
possible to compare platform specific performance enhancements against
portable base implementations, and to compare endian integer approaches
against endian conversion approaches for the common use case scenarios.</li>
<li>Float (32-bits) and double (64-bits) should be supported. IEEE 754 is the
primary use case.</li>
<li>Support for user defined types (UDTs) is desirable, and should be
supported where there would be no conflict with the other concerns.</li>
<li>There is some concern that endian integer/float arithmetic operations
might used
inadvertently or inappropriately. The impact of adding an endian_buffer class without arithmetic
operations should be investigated.</li>
<li>Stream insertion and extraction of the endian integer/float types should
be documented and included in the test coverage.</li>
<li>Binary I/O support that was investigated during development of the Endian
library should be put up for min-review for inclusion in the Boost I/O
library.</li>
</ul>
<h3>Docs</h3>
<ul>
<li>Document use of endian integers with stream inserters and extractors.</li>
<li>Either add tutorial or remove from menu bar.</li>
<li>Conversion in note mention similarity to htonl() , etc.</li>
<li>Conversion: add discussion of alignment, packing, etc. Bottom line; use at
your own risk. Use Phil's example:<br>
struct S {<br>
&nbsp;uint16_t a;<br>
&nbsp;uint32_t b;<br>
} __attribute__ ((packed));</li>
<li>Requirements for template parameters. </li>
<li>UDTs<ul>
<li>Integers</li>
<li>Conversion</li>
</ul>
</li>
<li>Distinguish use cases and recommendations for which approach (integers vs
conversion) is appropriate.<ul>
<li><a href="http://lists.boost.org/Archives/boost/2011/09/185698.php">
http://lists.boost.org/Archives/boost/2011/09/185698.php</a></li>
</ul>
</li>
<li>&gt; section `experience': this section gives no insights for people who use
or<br>
&gt; read the code. it mainly tells: &quot;we are not the first and the domain of the<br>
&gt; library is important.&quot;. imo this section can be removed (maybe the part that<br>
&gt; it is not related to any c library can go to the `design considerations'<br>
&gt;<br>
&gt; section &quot;motivating use cases&quot;: this is more a marketing blurb/testimonial.<br>
&gt; maybe this could be changed to a section about possible use cases, listing<br>
&gt; `communicating between different devices' and `reading/writing of binary
file<br>
&gt; formats'.</li>
<li>one other point ... the help file seems to directly link to the c++
headers.<br>
this should be changed:<br>
<br>
* some browsers (at least chromium) will not display the header when clicking<br>
&nbsp;the link, but will save them on disk.<br>
<br>
* providing a direct link to the source code from the docs implies that the<br>
&nbsp;user will get some information that are necessary to use the library by<br>
&nbsp;reading the sources. imo, this is not the case for using boost.endian.<br>
<br>
* if a user opens integer.hpp, the first 60 lines just contain copyright, some<br>
&nbsp;historical notes, compiler-specific stuff, includes and ifdefs. imo, this is<br>
&nbsp;the implementation part, which should not be exposed to a user.<br>
<br>
so i'd suggest to completely remove the links to the c++ headers.<br>
&nbsp;</li>
<li>
<div class="im">
&gt; explaining the other builting types are not considered. Why only
big/little<br>
&gt; endianness has been taken in account?</div>
<p>I'll add FAQ and/or add more entries to the final docs.<br>
<br>
Only big/little endianness is taken into account because these are the<br>
only endian schemes that have any practical value. All the others are<br>
just historical curiosities.</li>
</ul>
<h3>Code</h3>
<p>Also change docs if applicable.</p>
<ul>
<li><span style="background-color: #FFCCFF">Beman: TODO</span><span style="background-color: #FFCCFF">:
</span><span style="background-color: #FFCCFF">Google</span><span style="background-color: #FFCCFF">
&quot;unaligned integer&quot;, look at various entries. For example, http://</span><span style="background-color: #FFCCFF">infocenter.arm.com</span><span style="background-color: #FFCCFF">/help/</span><span style="background-color: #FFCCFF">index.jsp?topic</span><span style="background-color: #FFCCFF">=/</span><span style="background-color: #FFCCFF">com.arm.doc.faqs</span><span style="background-color: #FFCCFF">/ka3544.html</span></li>
<li>Merge conversion2 into conversion.hpp</li>
<li>Use builtins where applicable (GCC, possibly others)</li>
<li>Endian integer types should use the conversion functions where applicable.</li>
<li>Beman: Some platforms (compiler/processor taken together) don't require
alignment for the conversion functions if code is inlined, although speed may
suffer. (test to verify this assertion). On those platforms, conversion
functions (perhaps in-place) can be used to implement unaligned integers.<ul>
<li>Microsoft <a href="http://msdn.microsoft.com/en-us/library/ms253978.aspx">
UNALIGNED / __unaligned</a> keywords for pointers. Also
<a href="http://msdn.microsoft.com/en-us/library/ms253935.aspx">Packing
Structures</a>.</li>
<li>GCC
<a href="http://www.mailinglistarchive.com/gcc@gcc.gnu.org/msg21079.html">
http://www.mailinglistarchive.com/gcc@gcc.gnu.org/msg21079.html</a></li>
<li>Intel performs well on simple unaligned test. See
<a href="../test/unaligned_test.cpp">../test/unaligned_test.cpp</a></li>
</ul>
</li>
<li>Beman: Does the use of the unrolling templates get in the way of processor
specific optimization code?</li>
<li>Test use of endian integers with stream inserters and extractors.</li>
<li>Continue work on benchmarks and timings. Consider using use-case example
programs as benchmarks.</li>
<li>
<div class="im">
&gt; The reorder fuction should provide both reorder in place and returned.</div>
<p>Interesting, but providing two ways of doing something is often<br>
considered the not best design practice. And the tests I've run so far<br>
don't indicate any efficiency concern. Once all other aspects of the<br>
interface and implementation are settled, let's revisit that question.<br>
&nbsp;</li>
<li>&gt; The endianness scoped enum native should be replaced so it is defined<br>
&gt; depending on the endianess of the platform.<br>
&gt;<br>
&gt; &nbsp;BOOST_SCOPED_ENUM_START(<wbr />endianness) { big, little, native=(big or
little)<br>
&gt; }; BOOST_SCOPED_ENUM_END<br>
&gt;<br>
&gt; This will have the advantage to reduce of 1/3 the number of specializations.<br>
<br>
Does this work?<br>
&nbsp;</li>
<li dir="ltr">
<div class="im">
&gt; The library should provide in addition endian conversion functions that
have<br>
&gt; the endiannes as template parameters to make possible generic functions.</div>
<p dir="ltr">Compile time dispatch on an endianness enum was also requested in<br>
another review. That's fine with me, but I haven't had a chance to<br>
figure out the interface details.</li>
</ul>
<h3>Infrastructure</h3>
<ul>
<li>Remove scoped_enum_emulation_test stuff.</li>
<li>Remove timer stuff.</li>
<li>Use Boost.Timer.</li>
<li>
<div class="im">
&gt; endian_operations_test.cpp and endian_in_union_test.cpp ... maybe rename
from<br>
&gt; _test.cpp to _compile_test.cpp? they don't seem to do any run-time tests.
they<br>
&gt; also should not include &lt;cassert&gt; since no assertion statement is needed,
this<br>
&gt; might speed up the compilation time of the testsuite by something like
50ms ;)</div>
<p>Will do.</li>
<li>Make the bin() functionality available</li>
</ul>
<h3>Performance</h3>
<p>&nbsp;</p>
<h3>Acknowledge</h3>
<p>Gordon Woodhull, Hartmut Kaiser, Phil Endecott, tymofey, Giovanni Piero Deretta, Pyry Jahkola,
John Filo, Vitaly Budovski, Tomas Puverle, Vicente J. Botet Escriba, Tim
Blechmann, Daniel James, Mathias Gaunard, Adder, Tim Moore</p>
<p>Paul Bristow docs help </p>
<h2>Floating Point Support</h2>
<p>* Because FP formats vary, just dealing with endianness doesn't ensure<br>
portability.<br>
* The endianness of FP and integer values differs on some platforms,<br>
so we will have to build up a config file with separate entries for<br>
each platform, and that will take time to mature.<br>
* Ditto FP sizes.<br>
* I'm only willing to provide conversion.hpp FP support. Providing<br>
types that mimic FP types is far beyond my knowledge of how to deal<br>
with floating point's notorious arithmetic issues.</p>
<p>Support IEEE754 format (32 bit, 64 bit) only.</p>
<div class="im">
<br>
&nbsp;</div>
<p>&nbsp;</p>
</body>
</html>
-173
View File
@@ -1,173 +0,0 @@
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Boost Endian Library</title>
<link rel="stylesheet" type="text/css" href="../../../doc/src/minimal.css">
</head>
<body>
<table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="710">
<tr>
<td width="277">
<a href="../../../index.html">
<img src="../../../boost.png" alt="boost.png (6897 bytes)" align="middle" border="0" width="277" height="86"></a></td>
<td width="413" align="middle">
<font size="7">Endian Library</font></td>
</tr>
</table>
<table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#D7EEFF" width="100%">
<tr>
<td><b><a href="../../../index.htm">Boost Home</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="index.html">Endian Home</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="conversion.html">Conversion Functions</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="integers.html">Integer Types</a>&nbsp;&nbsp;&nbsp;&nbsp; Tutorial</b></td>
</tr>
</table>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" align="right">
<tr>
<td width="100%" bgcolor="#D7EEFF" align="center">
<i><b>Contents</b></i></td>
</tr>
<tr>
<td width="100%" bgcolor="#E8F5FF">
<a href="#Abstract">Abstract</a><br>
<a href="#Introduction-to-endianness">Introduction to endianness</a><br>
<a href="#Introduction">Introduction to the Boost.Endian library</a><br>
<a href="#Acknowledgements">Acknowledgements</a></td>
</tr>
<tr>
<td width="100%" bgcolor="#D7EEFF" align="center">
<b><i>Headers</i></b></td>
</tr>
<tr>
<td width="100%" bgcolor="#E8F5FF">
<a href="../../../boost/endian/conversion.hpp">&lt;boost/endian/conversion.hpp&gt;</a><br>
<a href="../../../boost/endian/integers.hpp">&lt;boost/endian/integers.hpp&gt;</a></td>
</tr>
</table>
<h2><a name="Abstract">Abstract</a></h2>
<p>Boost.Endian provides facilities to manipulate the byte ordering of integers.</p>
<ul>
<li>The primary use case is binary I/O of integers for portable exchange with
other systems, via either file or network transmission.<br>
&nbsp;</li>
<li>A secondary use case is minimizing storage size via integers of sizes
and/or alignments not supported by the built-in types. Integers 1, 2, 3, 4, 5,
6, 7, and 8 bytes in length are supported.<br>
&nbsp;</li>
<li>Two distinct approaches to byte ordering are provided. Each approach has a
long history of successful use, and each approach has use cases where it is
superior to the other approach.<br>
&nbsp;<ul>
<li>The explicit approach provides <a href="conversion.html">conversion
functions</a> to reorder bytes. All four combinations of non-modifying or
modifying, and unconditional or conditional, functions are provided.<br>
&nbsp;</li>
<li>The implicit approach provides <a href="integers.html">integer types</a>
that mimic the built-in integers, implicitly handling all byte reordering.</li>
</ul>
</li>
</ul>
<h2><a name="Introduction-to-endianness">Introduction to endianness</a></h2>
<p>Consider the following code:</p>
<blockquote>
<pre>int16_t i = 0x0102;
FILE * file = fopen(&quot;test&quot;, &quot;wb&quot;); // MUST BE BINARY
fwrite(&amp;i, sizeof(int16_t), 1, file);
fclose(file);</pre>
</blockquote>
<p>On a modern Apple, Linux, or Windows computer with an Intel CPU, a hex dump
of the &quot;test&quot; output file produces:</p>
<blockquote>
<p><code>0201</code></p>
</blockquote>
<p>On a Oracle/Sun Solaris computer with a SPARC CPU, a hex dump of the &quot;test&quot;
output file produces:</p>
<blockquote>
<p><code>0102</code></p>
</blockquote>
<p>What's happening here is that Intel CPU's order the bytes of an integer with
the least-significant byte first, while SPARC CPU's place the most-significant
byte first. Some CPU's, such as the PowerPC, allow the operating system to
choose which ordering applies.</p>
<p><a name="definition"></a>Most-significant-byte-first ordering is traditionally called &quot;big endian&quot;
ordering and the least-significant-byte-first is traditionally called
&quot;little-endian&quot; ordering. The names are derived from
<a href="http://en.wikipedia.org/wiki/Jonathan_Swift" title="Jonathan Swift">
Jonathan Swift</a>'s satirical novel <i>
<a href="http://en.wikipedia.org/wiki/Gulliver's_Travels" title="Gulliver's Travels">
Gulliver’s Travels</a></i>, where rival kingdoms opened their soft-boiled eggs
at different ends.</p>
<p>See the Wikipedia's
<a href="http://en.wikipedia.org/wiki/Endianness">Endianness</a> article for an
extensive discussion of endianness.</p>
<p>Except for reading an occasional core dump, most programmers can ignore
endianness. But when exchanging binary integers with other computer systems, whether by
file transfers or over a network, programmers have to deal with endianness. </p>
<h2><a name="Introduction">Introduction</a> to the Boost.Endian library</h2>
<p>The Boost.Endian library provides facilities to deal with integer endianness.</p>
<p>The library provides two approaches to dealing with integer endianness:</p>
<blockquote>
<p><b><a href="conversion.html">Endian conversions</a> for native integers -</b> The application uses the
built-in integer types, and calls the provided conversion functions to convert
byte ordering as needed. Both mutating and non-mutating conversions are supplied, and
each comes in unconditional and conditional variants. This approach is simple
and usually more efficient, but is less flexible in terms of size and alignment, can be
hard-to-manage and error-prone in code with many logical paths involving endianness transitions,
and can foster very hard to debug logic errors. </p>
<p><b><a href="integers.html">Endian integer types</a> -</b> The application uses the provided endian types
which mimic the
built-in integer types. For example, <code>big32_t</code> or <code>little64_t</code>.
This approach is also simple, but can be less efficient. Types with lengths of
1-8 bytes are supported, rather than just 1, 2, 4, and 8 bytes. Strict alignment
requirements are avoided, and this may allow data to be packed more tightly.</p>
</blockquote>
<p>Boost Endian is a header-only library.</p>
<h2><a name="Acknowledgements">Acknowledgements</a></h2>
<p>Comments and suggestions were
received from
Benaka Moorthi,
Christopher Kohlhoff,
Cliff Green,
Gennaro Proto,
Giovanni Piero Deretta, dizzy, Jeff Flinn,
John Maddock,
Kim Barrett,
Marsh Ray,
Martin Bonner,
Matias Capeletto,
Neil Mayhew, Phil Endecott, Rene Rivera,
Roland Schwarz, Scott McMurray,
Sebastian Redl,
Tomas Puverle, Vincente Botet, and
Yuval Ronen.</p>
<hr>
<p>Last revised:
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->04 September, 2011<!--webbot bot="Timestamp" endspan i-checksum="39336" --></p>
<p>© Copyright Beman Dawes, 2011</p>
<p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p>
<p>&nbsp;</p>
</body>
</html>
-587
View File
@@ -1,587 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Boost Endian Integers</title>
<link rel="stylesheet" type="text/css" href="../../../doc/src/minimal.css">
</head>
<body>
<table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="710">
<tr>
<td width="277">
<a href="../../../index.html">
<img src="../../../boost.png" alt="boost.png (6897 bytes)" align="middle" width="277" height="86" border="0"></a></td>
<td width="413" align="middle">
<font size="7">Endian Integer Types</font>
</td>
</tr>
</table>
<table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#D7EEFF" width="100%">
<tr>
<td><b><a href="../../../index.htm">Boost Home</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="index.html">Endian Home</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="conversion.html">Conversion Functions</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="integers.html">Integer Types</a>&nbsp;&nbsp;&nbsp;&nbsp; Tutorial</b></td>
</tr>
</table>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" align="right">
<tr>
<td width="100%" bgcolor="#D7EEFF" align="center">
<i><b>Contents</b></i></td>
</tr>
<tr>
<td width="100%" bgcolor="#E8F5FF">
<a href="#Introduction">Introduction</a><br>
<a href="#Example">Example</a><br>
<a href="#Limitations">Limitations</a><br>
<a href="#Feature-set">Feature set</a><br>
<a href="#Types">Typedefs</a><br>
&nbsp;&nbsp;&nbsp; <a href="#Comment-on-naming">Comment on naming</a><br>
<a href="#Class_template_endian">Class template <code>endian</code></a><br>
&nbsp;&nbsp;&nbsp;
<a href="#Synopsis">Synopsis</a><br>
&nbsp;&nbsp;&nbsp; <a href="#Members">Members</a><br>
<a href="#FAQ">FAQ</a><br>
<a href="#Design">Design</a><br>
<a href="#Experience">Experience</a><br>
<a href="#Motivating-use-cases">Motivating use cases</a><br>
<a href="#C++0x">C++0x</a><br>
<a href="#Compilation">Compilation</a><br>
<a href="#Acknowledgements">Acknowledgements</a>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#D7EEFF" align="center">
<b><i>Headers</i></b></td>
</tr>
<tr>
<td width="100%" bgcolor="#E8F5FF">
<a href="../../../boost/endian/conversion.hpp">&lt;boost/endian/conversion.hpp&gt;</a><br>
<a href="../../../boost/endian/integers.hpp">&lt;boost/endian/integers.hpp&gt;</a></td>
</tr>
</table>
<h2><a name="Introduction">Introduction</a></h2>
<p>Header <a href="file:///D:/endian/boost/endian/integers.hpp">&lt;boost/endian/integers.hpp&gt;</a> provides
integer-like byte-holder binary types with explicit control over
byte order, value type, size, and alignment. Typedefs provide easy-to-use names
for common configurations.</p>
<p>These types provide portable byte-holders for integer data, independent of
particular computer architectures. Use cases almost always involve I/O, either via files or
network connections. Although data portability is the primary motivation, these
integer byte-holders may
also be used to reduce memory use, file size, or network activity since they
provide binary integer sizes not otherwise available.</p>
<p>Such integer byte-holder types are traditionally called <b><i>
endian</i></b> types. See the <a href="http://en.wikipedia.org/wiki/Endian">Wikipedia</a> for
a full
exploration of <b><i>endianness</i></b>, including definitions of <i><b>big
endian</b></i> and <i><b>little endian</b></i>.</p>
<p>Boost endian integers provide the same full set of C++ assignment,
arithmetic, and relational operators&nbsp;as C++ standard integral types, with
the standard semantics.</p>
<p>Unary arithmetic operators are <code>+</code>, <code>-</code>, <code>~</code>,
<code>!</code>, prefix and postfix <code>--</code> and <code>++</code>. Binary
arithmetic operators are <code>+</code>, <code>+=</code>, <code>-</code>, <code>
-=</code>, <code>*</code>, <code>*=</code>, <code>/</code>, <code>/=</code>,
<code>%/ %=</code>, <code>&amp;</code>, <code>&amp;=</code>, <code>|</code>, <code>|=</code>,
<code>^</code>, <code>^=</code>, <code>&lt;&lt;</code>, <code>&lt;&lt;=</code>, <code>&gt;&gt;</code>,
<code>&gt;&gt;=</code>. Binary relational operators are <code>==</code>, <code>!=</code>,
<code>&lt;</code>, <code>&lt;=</code>, <code>&gt;</code>, <code>&gt;=</code>.</p>
<p>Automatic conversion is provided to the underlying integer value type.</p>
<h2><a name="Example">Example</a></h2>
<p>The <a href="../example/endian_example.cpp">endian_example.cpp</a> program writes a
binary file containing four byte big-endian and little-endian integers:</p>
<blockquote>
<pre>#include &lt;iostream&gt;
#include &lt;cstdio&gt;
#include &lt;boost/endian/integers.hpp&gt;
#include &lt;boost/static_assert.hpp&gt;
using namespace boost::endian;
namespace
{
// This is an extract from a very widely used GIS file format. I have no idea
// why a designer would mix big and little endians in the same file - but
// this is a real-world format and users wishing to write low level code
// manipulating these files have to deal with the mixed endianness.
struct header
{
big32_t file_code;
big32_t file_length;
little32_t version;
little32_t shape_type;
};
const char * filename = &quot;test.dat&quot;;
}
int main()
{
BOOST_STATIC_ASSERT( sizeof( header ) == 16U ); // check requirement
header h;
h.file_code = 0x01020304;
h.file_length = sizeof( header );
h.version = -1;
h.shape_type = 0x01020304;
// Low-level I/O such as POSIX read/write or &lt;cstdio&gt; fread/fwrite is sometimes
// used for binary file operations when ultimate efficiency is important.
// Such I/O is often performed in some C++ wrapper class, but to drive home the
// point that endian integers are often used in fairly low-level code that
// does bulk I/O operations, &lt;cstdio&gt; fopen/fwrite is used for I/O in this example.
std::FILE * fi;
if ( !(fi = std::fopen( filename, &quot;wb&quot; )) ) // MUST BE BINARY
{
std::cout &lt;&lt; &quot;could not open &quot; &lt;&lt; filename &lt;&lt; '\n';
return 1;
}
if ( std::fwrite( &amp;h, sizeof( header ), 1, fi ) != 1 )
{
std::cout &lt;&lt; &quot;write failure for &quot; &lt;&lt; filename &lt;&lt; '\n';
return 1;
}
std::fclose( fi );
std::cout &lt;&lt; &quot;created file &quot; &lt;&lt; filename &lt;&lt; '\n';
return 0;
}</pre>
</blockquote>
<p>After compiling and executing <a href="endian_example.cpp">endian_example.cpp</a>,
a hex dump of <code>test.dat</code> shows:</p>
<blockquote>
<pre>0102 0304 0000 0010 ffff ffff 0403 0201</pre>
</blockquote>
<h2><a name="Limitations">Limitations</a></h2>
<p>Requires <code>&lt;climits&gt;</code> <code>CHAR_BIT == 8</code>. If <code>CHAR_BIT</code>
is some other value, compilation will result in an <code>#error</code>. This
restriction is in place because the design, implementation, testing, and
documentation has only considered issues related to 8-bit bytes, and there have
been no real-world use cases presented for other sizes.</p>
<p>In C++03, <code>endian</code> does not meet the requirements for POD types
because it has constructors, private data members, and a base class. This means
that common use cases are relying on unspecified behavior in that the C++
Standard does not guarantee memory layout for non-POD types. This has not been a
problem in practice since all known C++ compilers do layout memory as if <code>
endian</code> were a POD type. In C++0x, it will be possible to specify the
default constructor as trivial, and private data members and base classes will
no longer disqualify a type from being a POD. Thus under C++0x, <code>endian</code>
will no longer be relying on unspecified behavior.</p>
<h2><a name="Feature-set">Feature set</a></h2>
<ul>
<li>Big endian| little endian | native endian byte ordering.</li>
<li>Signed | unsigned</li>
<li>Unaligned | aligned</li>
<li>1-8 byte (unaligned) | 2, 4, 8 byte (aligned)</li>
<li>Choice of integer value type</li>
</ul>
<h2><a name="Types">Typedefs</a></h2>
<p>One class template is provided:</p>
<blockquote>
<pre>template &lt;<a href="#endianness">endianness</a>::enum_t E, typename T, std::size_t n_bytes,
<a href="#alignment">alignment</a>::enum_t A = alignment::unaligned&gt;
class endian;
</pre>
</blockquote>
<p>Sixty typedefs, such as <code>big32_t</code>, provide convenient naming
conventions for common use cases:</p>
<blockquote>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="49%">
<tr>
<td width="18%" align="center"><b><i>Name</i></b></td>
<td width="10%" align="center"><b><i>Endianness</i></b></td>
<td width="10%" align="center"><b><i>Sign</i></b></td>
<td width="15%" align="center"><b><i>Sizes in bits (n)</i></b></td>
<td width="49%" align="center"><b><i>Alignment</i></b></td>
</tr>
<tr>
<td width="18%"><code>big</code><b><i>n</i></b><code>_t</code></td>
<td width="10%"><code>big</code></td>
<td width="10%">signed</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
<td width="49%"><code>unaligned</code></td>
</tr>
<tr>
<td width="18%"><code>ubig</code><i><b>n</b></i><code>_t</code></td>
<td width="10%"><code>big</code></td>
<td width="10%">unsigned</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
<td width="49%"><code>unaligned</code></td>
</tr>
<tr>
<td width="18%"><code>little</code><i><b>n</b></i><code>_t</code></td>
<td width="10%"><code>little</code></td>
<td width="10%">signed</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
<td width="49%"><code>unaligned</code></td>
</tr>
<tr>
<td width="18%"><code>ulittle</code><i><b>n</b></i><code>_t</code></td>
<td width="10%"><code>little</code></td>
<td width="10%">unsigned</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
<td width="49%"><code>unaligned</code></td>
</tr>
<tr>
<td width="18%"><code>native</code><i><b>n</b></i><code>_t</code></td>
<td width="10%"><code>native</code></td>
<td width="10%">signed</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
<td width="49%"><code>unaligned</code></td>
</tr>
<tr>
<td width="18%"><code>unative</code><i><b>n</b></i><code>_t</code></td>
<td width="10%"><code>native</code></td>
<td width="10%">unsigned</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
<td width="49%"><code>unaligned</code></td>
</tr>
<tr>
<td width="18%"><code>aligned_big</code><i><b>n</b></i><code>_t</code></td>
<td width="10%"><code>big</code></td>
<td width="10%">signed</td>
<td width="15%">16,32,64</td>
<td width="49%"><code>aligned</code></td>
</tr>
<tr>
<td width="18%"><code>aligned_ubig</code><i><b>n</b></i><code>_t</code></td>
<td width="10%"><code>big</code></td>
<td width="10%">unsigned</td>
<td width="15%">16,32,64</td>
<td width="49%"><code>aligned</code></td>
</tr>
<tr>
<td width="18%"><code>aligned_little</code><i><b>n</b></i><code>_t</code></td>
<td width="10%"><code>little</code></td>
<td width="10%">signed</td>
<td width="15%">16,32,64</td>
<td width="49%"><code>aligned</code></td>
</tr>
<tr>
<td width="18%"><code>aligned_ulittle</code><i><b>n</b></i><code>_t</code></td>
<td width="10%"><code>little</code></td>
<td width="10%">unsigned</td>
<td width="15%">16,32,64</td>
<td width="49%"><code>aligned</code></td>
</tr>
</table>
</blockquote>
<p>The unaligned types do not cause compilers to insert padding bytes in classes
and structs. This is an important characteristic that can be exploited to minimize wasted space in
memory, files, and network transmissions. </p>
<p><font color="#FF0000"><b><i><span style="background-color: #FFFFFF">Warning:</span></i></b></font><span style="background-color: #FFFFFF">
Code that uses a</span>ligned types is inherently non-portable because alignment
requirements vary between hardware architectures and because alignment may be
affected by compiler switches or pragmas. Furthermore, aligned types
are only available on architectures with 16, 32, and 64-bit integer types.</p>
<p><b><i>Note:</i></b> One-byte big-endian, little-endian, and native-endian types provide identical
functionality. All three names are provided to improve code readability and searchability.</p>
<h3><a name="Comment-on-naming">Comment on naming</a></h3>
<p>When first exposed to endian types, programmers often fit them into a mental model
based on the <code>&lt;cstdint&gt;</code> types. Using that model, it is natural to
expect a 56-bit big-endian signed integer to be named <code>int_big56_t</code>
rather than <code>big56_t</code>.</p>
<p>As experience using these type grows, the realization creeps in that they are
lousy arithmetic integers - they are really byte holders that for convenience
support arithmetic operations - and for use in internal interfaces or
anything more than trivial arithmetic computations it is far better to convert
values of these endian types to traditional integer types.</p>
<p>That seems to lead to formation of a new mental model specific to endian byte-holder types. In that model, the endianness
is the key feature, and the integer aspect is downplayed.
Once that mental transition is made, a name like <code>big56_t</code> is a good
reflection of the mental model</p>
<h2><a name="Class_template_endian">Class template <code>endian</code></a></h2>
<p>An endian is an integer byte-holder with user-specified <a href="#endianness">
endianness</a>, value type, size, and <a href="#alignment">alignment</a>. The
usual operations on integers are supplied.</p>
<h3><a name="Synopsis">Synopsis</a></h3>
<pre>namespace boost
{
namespace endian
{
enum class <a name="endianness">endianness</a> { big, little, native }; // scoped enum emulated on C++03
enum class <a name="alignment">alignment</a> { unaligned, aligned }; // scoped enum emulated on C++03
template &lt;endianness E, typename T, std::size_t n_bits,
alignment A = alignment::unaligned&gt;
class endian : <a href="../../../boost/endian/detail/cover_operators.hpp">cover_operators</a>&lt; endian&lt;E, T, n_bits, A&gt;, T &gt;
{
public:
typedef T value_type;
// if BOOST_ENDIAN_FORCE_PODNESS is defined &amp;&amp; C++0x POD's are not
// available then these two constructors will not be present
<a href="#endian">endian</a>() = default; // = default replaced by {} on C++03
explicit <a href="#explicit-endian">endian</a>(T v);
endian&amp; <a href="#operator-eq">operator=</a>(T v);
<a href="#operator-T">operator T</a>() const;
const char* <a href="#data">data</a>() const;
};
// unaligned big endian signed integer types
typedef endian&lt; endianness::big, int_least8_t, 8 &gt; big8_t;
typedef endian&lt; endianness::big, int_least16_t, 16 &gt; big16_t;
typedef endian&lt; endianness::big, int_least32_t, 24 &gt; big24_t;
typedef endian&lt; endianness::big, int_least32_t, 32 &gt; big32_t;
typedef endian&lt; endianness::big, int_least64_t, 40 &gt; big40_t;
typedef endian&lt; endianness::big, int_least64_t, 48 &gt; big48_t;
typedef endian&lt; endianness::big, int_least64_t, 56 &gt; big56_t;
typedef endian&lt; endianness::big, int_least64_t, 64 &gt; big64_t;
// unaligned big endian unsigned integer types
typedef endian&lt; endianness::big, uint_least8_t, 8 &gt; ubig8_t;
typedef endian&lt; endianness::big, uint_least16_t, 16 &gt; ubig16_t;
typedef endian&lt; endianness::big, uint_least32_t, 24 &gt; ubig24_t;
typedef endian&lt; endianness::big, uint_least32_t, 32 &gt; ubig32_t;
typedef endian&lt; endianness::big, uint_least64_t, 40 &gt; ubig40_t;
typedef endian&lt; endianness::big, uint_least64_t, 48 &gt; ubig48_t;
typedef endian&lt; endianness::big, uint_least64_t, 56 &gt; ubig56_t;
typedef endian&lt; endianness::big, uint_least64_t, 64 &gt; ubig64_t;
// unaligned little endian signed integer types
typedef endian&lt; endianness::little, int_least8_t, 8 &gt; little8_t;
typedef endian&lt; endianness::little, int_least16_t, 16 &gt; little16_t;
typedef endian&lt; endianness::little, int_least32_t, 24 &gt; little24_t;
typedef endian&lt; endianness::little, int_least32_t, 32 &gt; little32_t;
typedef endian&lt; endianness::little, int_least64_t, 40 &gt; little40_t;
typedef endian&lt; endianness::little, int_least64_t, 48 &gt; little48_t;
typedef endian&lt; endianness::little, int_least64_t, 56 &gt; little56_t;
typedef endian&lt; endianness::little, int_least64_t, 64 &gt; little64_t;
// unaligned little endian unsigned integer types
typedef endian&lt; endianness::little, uint_least8_t, 8 &gt; ulittle8_t;
typedef endian&lt; endianness::little, uint_least16_t, 16 &gt; ulittle16_t;
typedef endian&lt; endianness::little, uint_least32_t, 24 &gt; ulittle24_t;
typedef endian&lt; endianness::little, uint_least32_t, 32 &gt; ulittle32_t;
typedef endian&lt; endianness::little, uint_least64_t, 40 &gt; ulittle40_t;
typedef endian&lt; endianness::little, uint_least64_t, 48 &gt; ulittle48_t;
typedef endian&lt; endianness::little, uint_least64_t, 56 &gt; ulittle56_t;
typedef endian&lt; endianness::little, uint_least64_t, 64 &gt; ulittle64_t;
// unaligned native endian signed integer types
typedef endian&lt; endianness::native, int_least8_t, 8 &gt; native8_t;
typedef endian&lt; endianness::native, int_least16_t, 16 &gt; native16_t;
typedef endian&lt; endianness::native, int_least32_t, 24 &gt; native24_t;
typedef endian&lt; endianness::native, int_least32_t, 32 &gt; native32_t;
typedef endian&lt; endianness::native, int_least64_t, 40 &gt; native40_t;
typedef endian&lt; endianness::native, int_least64_t, 48 &gt; native48_t;
typedef endian&lt; endianness::native, int_least64_t, 56 &gt; native56_t;
typedef endian&lt; endianness::native, int_least64_t, 64 &gt; native64_t;
// unaligned native endian unsigned integer types
typedef endian&lt; endianness::native, uint_least8_t, 8 &gt; unative8_t;
typedef endian&lt; endianness::native, uint_least16_t, 16 &gt; unative16_t;
typedef endian&lt; endianness::native, uint_least32_t, 24 &gt; unative24_t;
typedef endian&lt; endianness::native, uint_least32_t, 32 &gt; unative32_t;
typedef endian&lt; endianness::native, uint_least64_t, 40 &gt; unative40_t;
typedef endian&lt; endianness::native, uint_least64_t, 48 &gt; unative48_t;
typedef endian&lt; endianness::native, uint_least64_t, 56 &gt; unative56_t;
typedef endian&lt; endianness::native, uint_least64_t, 64 &gt; unative64_t;
// These types only present if platform has exact size integers:
// aligned big endian signed integer types
typedef endian&lt; endianness::big, int16_t, 16, alignment::aligned &gt; aligned_big16_t;
typedef endian&lt; endianness::big, int32_t, 32, alignment::aligned &gt; aligned_big32_t;
typedef endian&lt; endianness::big, int64_t, 64, alignment::aligned &gt; aligned_big64_t;
// aligned big endian unsigned integer types
typedef endian&lt; endianness::big, uint16_t, 16, alignment::aligned &gt; aligned_ubig16_t;
typedef endian&lt; endianness::big, uint32_t, 32, alignment::aligned &gt; aligned_ubig32_t;
typedef endian&lt; endianness::big, uint64_t, 64, alignment::aligned &gt; aligned_ubig64_t;
// aligned little endian signed integer types
typedef endian&lt; endianness::little, int16_t, 16, alignment::aligned &gt; aligned_little2_t;
typedef endian&lt; endianness::little, int32_t, 32, alignment::aligned &gt; aligned_little4_t;
typedef endian&lt; endianness::little, int64_t, 64, alignment::aligned &gt; aligned_little8_t;
// aligned little endian unsigned integer types
typedef endian&lt; endianness::little, uint16_t, 16, alignment::aligned &gt; aligned_ulittle2_t;
typedef endian&lt; endianness::little, uint32_t, 32, alignment::aligned &gt; aligned_ulittle4_t;
typedef endian&lt; endianness::little, uint64_t, 64, alignment::aligned &gt; aligned_ulittle8_t;
// aligned native endian typedefs are not provided because
// &lt;cstdint&gt; types are superior for this use case
} // namespace endian
} // namespace boost</pre>
<h3><a name="Members">Members</a></h3>
<p><code><a name="endian">endian</a>() = default;&nbsp; // C++03: endian(){}</code></p>
<blockquote>
<p><i>Effects:</i> Constructs an object of type <code>endian&lt;E, T, n_bits, A&gt;</code>.</p>
</blockquote>
<p><code><a name="explicit-endian">explicit endian</a>(T v);</code></p>
<blockquote>
<p><i>Effects:</i> Constructs an object of type <code>endian&lt;E, T, n_bits, A&gt;</code>.</p>
<p><i>Postcondition:</i> <code>x == v,</code> where <code>x</code> is the
constructed object.</p>
</blockquote>
<p><code>endian&amp; <a name="operator-eq">operator=</a>(T v);</code></p>
<blockquote>
<p><i>Postcondition:</i> <code>x == v,</code> where <code>x</code> is the
constructed object.</p>
<p><i>Returns:</i> <code>*this</code>.</p>
</blockquote>
<p><code><a name="operator-T">operator T</a>() const;</code></p>
<blockquote>
<p><i>Returns:</i> The current value stored in <code>*this</code>, converted to
<code>value_type</code>.</p>
</blockquote>
<p><code>const char* <a name="data">data</a>() const;</code></p>
<blockquote>
<p><i>Returns:</i> A pointer to the first byte of the endian binary value stored
in <code>*this</code>.</p>
</blockquote>
<h3>Other operators</h3>
<p>Other operators on endian objects are forwarded to the equivalent
operator on <code>value_type</code>.</p>
<h2><a name="FAQ">FAQ</a></h2>
<p><b>Why bother with endian types?</b> External data portability and both speed
and space efficiency. Availability
of additional binary integer sizes and alignments is important in some
applications.</p>
<p><b>Why not just use Boost.Serialization?</b> Serialization involves a
conversion for every object involved in I/O. Endian integers require no
conversion or copying. They are already in the desired format for binary I/O.
Thus they can be read or written in bulk.</p>
<p><b>Why bother with binary I/O? Why not just use C++ Standard Library stream
inserters and extractors?</b> Using binary rather than character representations
can be more space efficient, with a side benefit of faster I/O. CPU time is
minimized because conversions to and from string are eliminated.
Furthermore, binary integers are fixed size, and so fixed-size disk records
are possible, easing sorting and allowing direct access. Disadvantages, such as the inability to use
text utilities on the resulting files, limit usefulness to applications where
the
binary I/O advantages are paramount.</p>
<p><b>Do these types have any uses outside of I/O?</b> Native endianness can be used for fine grained control over size and
alignment, so may be used to save memory in applications not related to I/O.</p>
<p><b>Is there is a performance hit when doing arithmetic using these types?</b> Yes, for sure,
compared to arithmetic operations on native integer types. However, these types
are usually be faster, and sometimes much faster, for I/O compared to stream
inserters and extractors, or to serialization.</p>
<p><b>Are endian types POD's?</b> Yes for C++0x. No for C++03, although several
<a href="#Compilation">macros</a> are available to force PODness in all cases.</p>
<p><b>What are the implications endian integer types not being POD's with C++03
compilers?</b> They
can't be used in unions. Also, compilers aren't required to align or lay
out storage in portable ways, although this potential problem hasn't prevented
use of Boost.Endian with
real compilers.</p>
<p><b>Which is better, big-endian or little-endian?</b> Big-endian tends to be a
bit more of an industry standard, but little-endian may be preferred for
applications that run primarily on x86 (Intel/AMD) and other little-endian
CPU's. The <a href="http://en.wikipedia.org/wiki/Endian">Wikipedia</a> article
gives more pros and cons.</p>
<p><b>What good is <i>native </i>endianness?</b> It provides alignment and
size guarantees not available from the built-in types. It eases generic
programming.</p>
<p><b>Why bother with the aligned endian types?</b> Aligned integer operations
may be faster (20 times, in one measurement) if the endianness and alignment of
the type matches the endianness and alignment requirements of the machine. On
common CPU architectures, that optimization is only available for aligned types.
That allows I/O of maximally efficient types on an application's primary
platform, yet produces data files are portable to all platforms. The code,
however, is
likely to be more fragile and less portable than with the unaligned types.</p>
<p><b>These types are really just byte-holders. Why provide the arithmetic
operations at all?</b> Providing a full set of operations reduces program
clutter and makes code both easier to write and to read. Consider
incrementing a variable in a record. It is very convenient to write:</p>
<pre wrap> ++record.foo;</pre>
<p wrap>Rather than:</p>
<pre wrap> int temp(record.foo);
++temp;
record.foo = temp;</pre>
<h2><a name="Design">Design</a> considerations for Boost.Endian integers</h2>
<ul>
<li>Must be suitable for I/O - in other words, must be memcpyable.</li>
<li>Must provide exactly the size and internal byte ordering specified.</li>
<li>Must work correctly when the internal integer representation has more bits
that the sum of the bits in the external byte representation. Sign extension
must work correctly when the internal integer representation type has more
bits than the sum of the bits in the external bytes. For example, using
a 64-bit integer internally to represent 40-bit (5 byte) numbers must work for
both positive and negative values.</li>
<li>Must work correctly (including using the same defined external
representation) regardless of whether a compiler treats char as signed or
unsigned.</li>
<li>Unaligned types must not cause compilers to insert padding bytes.</li>
<li>The implementation should supply optimizations only in very limited
circumstances. Experience has shown that optimizations of endian
integers often become pessimizations. While this may be obvious when changing
machines or compilers, it also happens when changing compiler switches,
compiler versions, or CPU models of the same architecture.</li>
<li>It is better software engineering if the same implementation works regardless
of the CPU endianness. In other words, #ifdefs should be avoided where
possible.</li>
</ul>
<h2><a name="Experience">Experience</a></h2>
<p>Classes with similar functionality have been independently developed by
several Boost programmers and used very successful in high-value, high-use
applications for many years. These independently developed endian libraries
often evolved from C libraries that were also widely used. Endian integers have proven widely useful across a wide
range of computer architectures and applications.</p>
<h2><a name="Motivating-use-cases">Motivating use cases</a></h2>
<p>Neil Mayhew writes: &quot;I can also provide a meaningful use-case for this
library: reading TrueType font files from disk and processing the contents. The
data format has fixed endianness (big) and has unaligned values in various
places. Using Boost.Endian simplifies and cleans the code wonderfully.&quot;</p>
<h2><a name="C++0x">C++0x</a></h2>
<p>The availability of the C++0x
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm">
Defaulted Functions</a> feature is detected automatically, and will be used if
present to ensure that objects of <code>class endian</code> are trivial, and
thus POD's.</p>
<h2><a name="Compilation">Compilation</a></h2>
<p>Boost.Endian is implemented entirely within headers, with no need to link to
any Boost object libraries.</p>
<p>Several macros allow user control over features:</p>
<ul>
<li>BOOST_ENDIAN_NO_CTORS causes <code>class endian</code> to have no
constructors. The intended use is for compiling user code that must be
portable between compilers regardless of C++0x
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm">
Defaulted Functions</a> support. Use of constructors will always fail, <br>
&nbsp;</li>
<li>BOOST_ENDIAN_FORCE_PODNESS causes BOOST_ENDIAN_NO_CTORS to be defined if
the compiler does not support C++0x
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm">
Defaulted Functions</a>. This is ensures that , and so can be used in unions.
In C++0x, <code>class endian</code> objects are POD's even though they have
constructors.</li>
</ul>
<h2><a name="Acknowledgements">Acknowledgements</a></h2>
<p>Original design developed by Darin Adler based on classes developed by Mark
Borgerding. Four original class templates combined into a single <code>endian</code>
class template by Beman Dawes, who put the library together, provided
documentation, added the typedefs, and also added the <code>unrolled_byte_loops</code>
sign partial specialization to correctly extend the sign when cover integer size
differs from endian representation size.</p>
<hr>
<p>Last revised:
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05 September, 2011<!--webbot bot="Timestamp" endspan i-checksum="39338" --></p>
<p>© Copyright Beman Dawes, 2006-2009</p>
<p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p>
</body>
</html>
-77
View File
@@ -1,77 +0,0 @@
// endian_example.cpp -------------------------------------------------------//
// Copyright Beman Dawes, 2006
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/endian
//----------------------------------------------------------------------------//
#define _CRT_SECURE_NO_DEPRECATE // quiet VC++ 8.0 foolishness
#include <boost/endian/detail/disable_warnings.hpp>
#include <iostream>
#include <cstdio>
#include <boost/endian/integers.hpp>
#include <boost/static_assert.hpp>
using namespace boost::endian;
namespace
{
// This is an extract from a very widely used GIS file format. I have no idea
// why a designer would mix big and little endians in the same file - but
// this is a real-world format and users wishing to write low level code
// manipulating these files have to deal with the mixed endianness.
struct header
{
big32_t file_code;
big32_t file_length;
little32_t version;
little32_t shape_type;
};
const char * filename = "test.dat";
}
int main(int, char * [])
{
BOOST_STATIC_ASSERT( sizeof( header ) == 16U ); // check requirement
header h;
h.file_code = 0x01020304;
h.file_length = sizeof( header );
h.version = -1;
h.shape_type = 0x01020304;
// Low-level I/O such as POSIX read/write or <cstdio> fread/fwrite is sometimes
// used for binary file operations when ultimate efficiency is important.
// Such I/O is often performed in some C++ wrapper class, but to drive home the
// point that endian integers are often used in fairly low-level code that
// does bulk I/O operations, <cstdio> fopen/fwrite is used for I/O in this example.
std::FILE * fi = std::fopen( filename, "wb" ); // MUST BE BINARY
if ( !fi )
{
std::cout << "could not open " << filename << '\n';
return 1;
}
if ( std::fwrite( &h, sizeof( header ), 1, fi ) != 1 )
{
std::cout << "write failure for " << filename << '\n';
return 1;
}
std::fclose( fi );
std::cout << "created file " << filename << '\n';
return 0;
}
-14
View File
@@ -1,14 +0,0 @@
<html>
<head>
<meta http-equiv="refresh" content="0; URL=doc/index.html">
</head>
<body>
Automatic redirection failed, please go to
<a href="doc/index.html">doc/index.html</a>.&nbsp;<hr>
<p><font size="2">© Copyright Beman Dawes, 2001</font></p>
<p><font size="2">Distributed under the Boost Software License, Version 1.0.
(See <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)
</font>
</p>
</body>
</html>
-19
View File
@@ -1,19 +0,0 @@
# Boost Endian Library test Jamfile
# Copyright Beman Dawes 2006
# Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt
# See library home page at http://www.boost.org/libs/endian
import testing ;
test-suite "endian"
:
[ run endian_test.cpp ]
[ run endian_operations_test.cpp
: : : <toolset>gcc:<cxxflags>-Wno-sign-compare ]
[ run endian_in_union_test.cpp ]
[ run conversion_test.cpp ]
;
-209
View File
@@ -1,209 +0,0 @@
// benchmark.cpp ---------------------------------------------------------------------//
// Copyright Beman Dawes 2011
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#define _CRT_SECURE_NO_WARNINGS
#include <cstdlib>
#include <boost/endian/conversion.hpp>
#include <boost/random.hpp>
#include <boost/cstdint.hpp>
#include <boost/endian/support/timer.hpp>
#include <iostream>
#include <string>
using namespace boost;
using std::cout;
using std::cerr;
using std::endl;
using std::vector;
namespace
{
std::string command_args;
long long n;
int places = 2;
bool verbose (false);
#ifndef BOOST_TWO_ARG
typedef int32_t (*timee_func)(int32_t);
#else
typedef void (*timee_func)(int32_t, int32_t&);
#endif
endian::microsecond_t benchmark(timee_func timee, const char* msg,
endian::microsecond_t overhead = 0)
{
if (verbose)
cout << "\nRunning benchmark..." << endl;
int64_t sum = 0;
endian::times_t times;
endian::microsecond_t cpu_time;
endian::run_timer t(places);
for (long long i = n; i; --i)
{
# ifndef BOOST_TWO_ARG
sum += timee(static_cast<int32_t>(i)) ;
# else
int32_t y;
timee(static_cast<int32_t>(i), y);
sum += y;
# endif
}
times = t.stop();
cpu_time = (times.system + times.user) - overhead;
const long double sec = 1000000.0L;
cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
cout.precision(places);
cout << msg << " " << cpu_time / sec << endl;
if (verbose)
{
t.report();
cout << " Benchmark complete\n"
" sum is " << sum << endl;
}
return cpu_time;
}
void process_command_line(int argc, char * argv[])
{
for (int a = 0; a < argc; ++a)
{
command_args += argv[a];
if (a != argc-1)
command_args += ' ';
}
cout << command_args << '\n';;
if (argc >=2)
#ifndef _MSC_VER
n = std::atoll(argv[1]);
#else
n = _atoi64(argv[1]);
#endif
for (; argc > 2; ++argv, --argc)
{
if ( *(argv[2]+1) == 'p' )
places = atoi( argv[2]+2 );
else if ( *(argv[2]+1) == 'v' )
verbose = true;
else
{
cout << "Error - unknown option: " << argv[2] << "\n\n";
argc = -1;
break;
}
}
if (argc < 2)
{
cout << "Usage: benchmark n [Options]\n"
" The argument n specifies the number of test cases to run\n"
" Options:\n"
" -v Verbose messages\n"
" -p# Decimal places for times; default -p" << places << "\n";
return std::exit(1);
}
}
inline void in_place(int32_t& x)
{
x = (static_cast<uint32_t>(x) << 24)
| ((static_cast<uint32_t>(x) << 8) & 0x00ff0000)
| ((static_cast<uint32_t>(x) >> 8) & 0x0000ff00)
| (static_cast<uint32_t>(x) >> 24);
}
inline int32_t by_return(int32_t x)
{
return (static_cast<uint32_t>(x) << 24)
| ((static_cast<uint32_t>(x) << 8) & 0x00ff0000)
| ((static_cast<uint32_t>(x) >> 8) & 0x0000ff00)
| (static_cast<uint32_t>(x) >> 24);
}
inline int32_t by_return_pyry(int32_t x)
{
uint32_t step16;
step16 = static_cast<uint32_t>(x) << 16 | static_cast<uint32_t>(x) >> 16;
return
((static_cast<uint32_t>(step16) << 8) & 0xff00ff00)
| ((static_cast<uint32_t>(step16) >> 8) & 0x00ff00ff);
}
inline int32_t two_operand(int32_t x, int32_t& y)
{
return y = ((x << 24) & 0xff000000) | ((x << 8) & 0x00ff0000) | ((x >> 24) & 0x000000ff)
| ((x >> 8) & 0x0000ff00);
}
int32_t modify_noop(int32_t x)
{
int32_t v(x);
return v;
}
int32_t modify_in_place(int32_t x)
{
int32_t v(x);
in_place(v);
return v;
}
int32_t modify_by_return(int32_t x)
{
int32_t v(x);
return by_return(v);
}
int32_t modify_by_return_pyry(int32_t x)
{
int32_t v(x);
return by_return_pyry(v);
}
void non_modify_assign(int32_t x, int32_t& y)
{
y = x;
}
void non_modify_two_operand(int32_t x, int32_t& y)
{
two_operand(x, y);
}
void non_modify_by_return(int32_t x, int32_t& y)
{
y = by_return(x);
}
} // unnamed namespace
//-------------------------------------- main() ---------------------------------------//
int main(int argc, char * argv[])
{
process_command_line(argc, argv);
endian::microsecond_t overhead;
#ifndef BOOST_TWO_ARG
overhead = benchmark(modify_noop, "modify no-op");
benchmark(modify_in_place, "modify in place", overhead);
benchmark(modify_by_return, "modify by return", overhead);
benchmark(modify_by_return_pyry, "modify by return", overhead);
#else
overhead = benchmark(non_modify_assign, "non_modify_assign ");
benchmark(non_modify_two_operand, "non_modify_two_operand", overhead);
benchmark(non_modify_by_return, "non_modify_by_return ", overhead);
#endif
return 0;
}
-165
View File
@@ -1,165 +0,0 @@
// conversion_test.cpp ---------------------------------------------------------------//
// Copyright Beman Dawes 2010
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
//--------------------------------------------------------------------------------------//
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/conversion2.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <iostream>
namespace be = boost::endian2;
namespace
{
void test_reorder()
{
std::cout << "test_reorder...\n";
boost::int64_t i64 = 0x0102030405060708LL;
BOOST_TEST_EQ(be::reorder(i64), 0x0807060504030201LL);
BOOST_TEST_EQ(be::reorder(be::reorder(i64)), i64);
i64 = 0xfefdfcfbfaf9f8f7LL;
BOOST_TEST_EQ(be::reorder(i64), static_cast<boost::int64_t>(0xf7f8f9fafbfcfdfeULL));
BOOST_TEST_EQ(be::reorder(be::reorder(i64)), i64);
boost::int32_t i32 = 0x01020304;
BOOST_TEST_EQ(be::reorder(i32), 0x04030201);
BOOST_TEST_EQ(be::reorder(be::reorder(i32)), i32);
i32 = 0xfefdfcfb;
BOOST_TEST_EQ(be::reorder(i32), static_cast<boost::int32_t>(0xfbfcfdfe));
BOOST_TEST_EQ(be::reorder(be::reorder(i32)), i32);
boost::int16_t i16 = 0x0102;
BOOST_TEST_EQ(be::reorder(i16), 0x0201);
BOOST_TEST_EQ(be::reorder(be::reorder(i16)), i16);
i16 = static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfefd));
BOOST_TEST_EQ(be::reorder(i16), static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfdfe)));
BOOST_TEST_EQ(be::reorder(be::reorder(i16)), i16);
boost::uint64_t ui64 = 0x0102030405060708ULL;
BOOST_TEST_EQ(be::reorder(ui64), 0x0807060504030201ULL);
BOOST_TEST_EQ(be::reorder(be::reorder(ui64)), ui64);
boost::uint32_t ui32 = 0x01020304;
BOOST_TEST_EQ(be::reorder(ui32), static_cast<boost::uint32_t>(0x04030201));
BOOST_TEST_EQ(be::reorder(be::reorder(ui32)), ui32);
boost::uint16_t ui16 = 0x0102;
BOOST_TEST_EQ(be::reorder(ui16), 0x0201);
BOOST_TEST_EQ(be::reorder(be::reorder(ui16)), ui16);
std::cout << " test_reorder complete\n";
}
const boost::int64_t ni64 = 0x0102030405060708LL;
# ifdef BOOST_BIG_ENDIAN
const boost::int64_t bi64 = 0x0102030405060708LL;
const boost::int64_t li64 = 0x0807060504030201LL;
# else
const boost::int64_t bi64 = 0x0807060504030201LL;
const boost::int64_t li64 = 0x0102030405060708LL;
# endif
const boost::int32_t ni32 = 0x01020304;
# ifdef BOOST_BIG_ENDIAN
const boost::int32_t bi32 = 0x01020304;
const boost::int32_t li32 = 0x04030201;
# else
const boost::int32_t bi32 = 0x04030201;
const boost::int32_t li32 = 0x01020304;
# endif
const boost::int16_t ni16 = 0x0102;
# ifdef BOOST_BIG_ENDIAN
const boost::int16_t bi16 = 0x0102;
const boost::int16_t li16 = 0x0201;
# else
const boost::int16_t bi16 = 0x0201;
const boost::int16_t li16 = 0x0102;
# endif
const boost::uint64_t nui64 = 0x0102030405060708ULL;
# ifdef BOOST_BIG_ENDIAN
const boost::uint64_t bui64 = 0x0102030405060708ULL;
const boost::uint64_t lui64 = 0x0807060504030201ULL;
# else
const boost::uint64_t bui64 = 0x0807060504030201ULL;
const boost::uint64_t lui64 = 0x0102030405060708ULL;
# endif
const boost::uint32_t nui32 = 0x01020304;
# ifdef BOOST_BIG_ENDIAN
const boost::uint32_t bui32 = 0x01020304;
const boost::uint32_t lui32 = 0x04030201;
# else
const boost::uint32_t bui32 = 0x04030201;
const boost::uint32_t lui32 = 0x01020304;
# endif
const boost::uint16_t nui16 = 0x0102;
# ifdef BOOST_BIG_ENDIAN
const boost::uint16_t bui16 = 0x0102;
const boost::uint16_t lui16 = 0x0201;
# else
const boost::uint16_t bui16 = 0x0201;
const boost::uint16_t lui16 = 0x0102;
# endif
void test_conditional_reorder()
{
std::cout << "test_conditional_reorder...\n";
BOOST_TEST_EQ(be::big(ni64), bi64);
BOOST_TEST_EQ(be::big(ni32), bi32);
BOOST_TEST_EQ(be::big(ni16), bi16);
BOOST_TEST_EQ(be::big(nui64), bui64);
BOOST_TEST_EQ(be::big(nui32), bui32);
BOOST_TEST_EQ(be::big(nui16), bui16);
BOOST_TEST_EQ(be::little(ni64), li64);
BOOST_TEST_EQ(be::little(ni32), li32);
BOOST_TEST_EQ(be::little(ni16), li16);
BOOST_TEST_EQ(be::little(nui64), lui64);
BOOST_TEST_EQ(be::little(nui32), lui32);
BOOST_TEST_EQ(be::little(nui16), lui16);
BOOST_TEST_EQ(be::big(be::big(ni64)), ni64);
BOOST_TEST_EQ(be::big(be::big(ni32)), ni32);
BOOST_TEST_EQ(be::big(be::big(ni16)), ni16);
BOOST_TEST_EQ(be::big(be::big(nui64)), nui64);
BOOST_TEST_EQ(be::big(be::big(nui32)), nui32);
BOOST_TEST_EQ(be::big(be::big(nui16)), nui16);
BOOST_TEST_EQ(be::little(be::little(ni64)), ni64);
BOOST_TEST_EQ(be::little(be::little(ni32)), ni32);
BOOST_TEST_EQ(be::little(be::little(ni16)), ni16);
BOOST_TEST_EQ(be::little(be::little(nui64)), nui64);
BOOST_TEST_EQ(be::little(be::little(nui32)), nui32);
BOOST_TEST_EQ(be::little(be::little(nui16)), nui16);
std::cout << " test_conditional_reorder complete\n";
}
} // unnamed namespace
int cpp_main(int, char * [])
{
std::cerr << std::hex;
test_reorder();
test_conditional_reorder();
return ::boost::report_errors();
}
#include <boost/endian/detail/disable_warnings_pop.hpp>
-442
View File
@@ -1,442 +0,0 @@
// conversion_test.cpp ---------------------------------------------------------------//
// Copyright Beman Dawes 2010
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
//--------------------------------------------------------------------------------------//
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/conversion.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <iostream>
namespace be = boost::endian;
namespace
{
void test_in_place_reorder()
{
std::cout << "test_in_place_reorder...\n";
boost::int64_t i64 = 0x0102030405060708LL;
be::reorder(i64);
BOOST_TEST_EQ(i64, 0x0807060504030201LL);
be::reorder(i64);
BOOST_TEST_EQ(i64, 0x0102030405060708LL);
i64 = 0xfefdfcfbfaf9f8f7LL;
be::reorder(i64);
BOOST_TEST_EQ(i64, static_cast<boost::int64_t>(0xf7f8f9fafbfcfdfeULL));
be::reorder(i64);
BOOST_TEST_EQ(i64, static_cast<boost::int64_t>(0xfefdfcfbfaf9f8f7ULL));
boost::int32_t i32 = 0x01020304;
be::reorder(i32);
BOOST_TEST_EQ(i32, 0x04030201);
be::reorder(i32);
BOOST_TEST_EQ(i32, 0x01020304);
i32 = 0xfefdfcfb;
be::reorder(i32);
BOOST_TEST_EQ(i32, static_cast<boost::int32_t>(0xfbfcfdfe));
be::reorder(i32);
BOOST_TEST_EQ(i32, static_cast<boost::int32_t>(0xfefdfcfb));
boost::int16_t i16 = 0x0102;
be::reorder(i16);
BOOST_TEST_EQ(i16, 0x0201);
be::reorder(i16);
BOOST_TEST_EQ(i16, 0x0102);
i16 = static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfefd));
be::reorder(i16);
BOOST_TEST_EQ(i16, static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfdfe)));
be::reorder(i16);
BOOST_TEST_EQ(i16, static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfefd)));
boost::uint64_t ui64 = 0x0102030405060708ULL;
be::reorder(ui64);
BOOST_TEST_EQ(ui64, 0x0807060504030201ULL);
be::reorder(ui64);
BOOST_TEST_EQ(ui64, 0x0102030405060708ULL);
boost::uint32_t ui32 = 0x01020304;
be::reorder(ui32);
BOOST_TEST_EQ(ui32, static_cast<boost::uint32_t>(0x04030201));
be::reorder(ui32);
BOOST_TEST_EQ(ui32, static_cast<boost::uint32_t>(0x01020304));
boost::uint16_t ui16 = 0x0102;
be::reorder(ui16);
BOOST_TEST_EQ(ui16, 0x0201);
be::reorder(ui16);
BOOST_TEST_EQ(ui16, static_cast<boost::uint16_t>(0x0102));
std::cout << " test_in_place_reorder complete\n";
}
void test_copying_reorder()
{
std::cout << "test_copying_reorder...\n";
boost::int64_t i64 = 0x0102030405060708LL, j64, k64;
be::reorder(i64, j64);
BOOST_TEST_EQ(j64, 0x0807060504030201LL);
BOOST_TEST_EQ(i64, 0x0102030405060708LL);
be::reorder(j64, k64);
BOOST_TEST_EQ(k64, 0x0102030405060708LL);
i64 = 0xfefdfcfbfaf9f8f7LL;
be::reorder(i64, j64);
BOOST_TEST_EQ(j64, static_cast<boost::int64_t>(0xf7f8f9fafbfcfdfeLL));
be::reorder(j64, k64);
BOOST_TEST_EQ(k64, static_cast<boost::int64_t>(0xfefdfcfbfaf9f8f7LL));
boost::int32_t i32 = 0x01020304, j32, k32;
be::reorder(i32, j32);
BOOST_TEST_EQ(j32, 0x04030201);
be::reorder(j32, k32);
BOOST_TEST_EQ(k32, 0x01020304);
i32 = 0xfefdfcfb;
be::reorder(i32, j32);
BOOST_TEST_EQ(j32, static_cast<boost::int32_t>(0xfbfcfdfe));
be::reorder(j32, k32);
BOOST_TEST_EQ(k32, static_cast<boost::int32_t>(0xfefdfcfb));
boost::int16_t i16 = 0x0102, j16, k16;
be::reorder(i16, j16);
BOOST_TEST_EQ(j16, 0x0201);
be::reorder(j16, k16);
BOOST_TEST_EQ(k16, 0x0102);
i16 = static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfefd));
be::reorder(i16, j16);
BOOST_TEST_EQ(j16, static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfdfe)));
be::reorder(j16, k16);
BOOST_TEST_EQ(k16, static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfefd)));
boost::uint64_t ui64 = 0x0102030405060708ULL, uj64, uk64;
be::reorder(ui64, uj64);
BOOST_TEST_EQ(uj64, 0x0807060504030201ULL);
be::reorder(uj64, uk64);
BOOST_TEST_EQ(uk64, 0x0102030405060708ULL);
boost::uint32_t ui32 = 0x01020304, uj32, uk32;
be::reorder(ui32, uj32);
BOOST_TEST_EQ(uj32, static_cast<boost::uint32_t>(0x04030201));
be::reorder(uj32, uk32);
BOOST_TEST_EQ(uk32, static_cast<boost::uint32_t>(0x01020304));
boost::uint16_t ui16 = 0x0102, uj16, uk16;
be::reorder(ui16, uj16);
BOOST_TEST_EQ(uj16, 0x0201);
be::reorder(uj16, uk16);
BOOST_TEST_EQ(uk16, 0x0102);
std::cout << " test_copying_reorder complete\n";
}
const boost::int64_t ni64 = 0x0102030405060708LL;
# ifdef BOOST_BIG_ENDIAN
const boost::int64_t bi64 = 0x0102030405060708LL;
const boost::int64_t li64 = 0x0807060504030201LL;
# else
const boost::int64_t bi64 = 0x0807060504030201LL;
const boost::int64_t li64 = 0x0102030405060708LL;
# endif
const boost::int32_t ni32 = 0x01020304;
# ifdef BOOST_BIG_ENDIAN
const boost::int32_t bi32 = 0x01020304;
const boost::int32_t li32 = 0x04030201;
# else
const boost::int32_t bi32 = 0x04030201;
const boost::int32_t li32 = 0x01020304;
# endif
const boost::int16_t ni16 = 0x0102;
# ifdef BOOST_BIG_ENDIAN
const boost::int16_t bi16 = 0x0102;
const boost::int16_t li16 = 0x0201;
# else
const boost::int16_t bi16 = 0x0201;
const boost::int16_t li16 = 0x0102;
# endif
const boost::uint64_t nui64 = 0x0102030405060708ULL;
# ifdef BOOST_BIG_ENDIAN
const boost::uint64_t bui64 = 0x0102030405060708ULL;
const boost::uint64_t lui64 = 0x0807060504030201ULL;
# else
const boost::uint64_t bui64 = 0x0807060504030201ULL;
const boost::uint64_t lui64 = 0x0102030405060708ULL;
# endif
const boost::uint32_t nui32 = 0x01020304;
# ifdef BOOST_BIG_ENDIAN
const boost::uint32_t bui32 = 0x01020304;
const boost::uint32_t lui32 = 0x04030201;
# else
const boost::uint32_t bui32 = 0x04030201;
const boost::uint32_t lui32 = 0x01020304;
# endif
const boost::uint16_t nui16 = 0x0102;
# ifdef BOOST_BIG_ENDIAN
const boost::uint16_t bui16 = 0x0102;
const boost::uint16_t lui16 = 0x0201;
# else
const boost::uint16_t bui16 = 0x0201;
const boost::uint16_t lui16 = 0x0102;
# endif
void test_in_place_conditional_reorder()
{
std::cout << "test_in_place_conditional_reorder...\n";
boost::int64_t i64;
i64 = ni64;
be::native_to_big(i64);
BOOST_TEST_EQ(i64, bi64);
i64 = ni64;
be::native_to_little(i64);
BOOST_TEST_EQ(i64, li64);
i64 = bi64;
be::big_to_native(i64);
BOOST_TEST_EQ(i64, ni64);
i64 = li64;
be::little_to_native(i64);
BOOST_TEST_EQ(i64, ni64);
boost::uint64_t ui64;
ui64 = nui64;
be::native_to_big(ui64);
BOOST_TEST_EQ(ui64, bui64);
ui64 = nui64;
be::native_to_little(ui64);
BOOST_TEST_EQ(ui64, lui64);
ui64 = bui64;
be::big_to_native(ui64);
BOOST_TEST_EQ(ui64, nui64);
ui64 = lui64;
be::little_to_native(ui64);
BOOST_TEST_EQ(ui64, nui64);
boost::int32_t i32;
i32 = ni32;
be::native_to_big(i32);
BOOST_TEST_EQ(i32, bi32);
i32 = ni32;
be::native_to_little(i32);
BOOST_TEST_EQ(i32, li32);
i32 = bi32;
be::big_to_native(i32);
BOOST_TEST_EQ(i32, ni32);
i32 = li32;
be::little_to_native(i32);
BOOST_TEST_EQ(i32, ni32);
boost::uint32_t ui32;
ui32 = nui32;
be::native_to_big(ui32);
BOOST_TEST_EQ(ui32, bui32);
ui32 = nui32;
be::native_to_little(ui32);
BOOST_TEST_EQ(ui32, lui32);
ui32 = bui32;
be::big_to_native(ui32);
BOOST_TEST_EQ(ui32, nui32);
ui32 = lui32;
be::little_to_native(ui32);
BOOST_TEST_EQ(ui32, nui32);
boost::int16_t i16;
i16 = ni16;
be::native_to_big(i16);
BOOST_TEST_EQ(i16, bi16);
i16 = ni16;
be::native_to_little(i16);
BOOST_TEST_EQ(i16, li16);
i16 = bi16;
be::big_to_native(i16);
BOOST_TEST_EQ(i16, ni16);
i16 = li16;
be::little_to_native(i16);
BOOST_TEST_EQ(i16, ni16);
boost::uint16_t ui16;
ui16 = nui16;
be::native_to_big(ui16);
BOOST_TEST_EQ(ui16, bui16);
ui16 = nui16;
be::native_to_little(ui16);
BOOST_TEST_EQ(ui16, lui16);
ui16 = bui16;
be::big_to_native(ui16);
BOOST_TEST_EQ(ui16, nui16);
ui16 = lui16;
be::little_to_native(ui16);
BOOST_TEST_EQ(ui16, nui16);
std::cout << " test_in_place_conditional_reorder complete\n";
}
void test_copying_conditional_reorder()
{
std::cout << "test_copying_conditional_reorder...\n";
boost::int64_t i64, ti64;
i64 = ni64;
be::native_to_big(i64, ti64);
BOOST_TEST_EQ(ti64, bi64);
i64 = ni64;
be::native_to_little(i64, ti64);
BOOST_TEST_EQ(ti64, li64);
i64 = bi64;
be::big_to_native(i64, ti64);
BOOST_TEST_EQ(ti64, ni64);
i64 = li64;
be::little_to_native(i64, ti64);
BOOST_TEST_EQ(ti64, ni64);
boost::uint64_t ui64, tui64;
ui64 = nui64;
be::native_to_big(ui64, tui64);
BOOST_TEST_EQ(tui64, bui64);
ui64 = nui64;
be::native_to_little(ui64, tui64);
BOOST_TEST_EQ(tui64, lui64);
ui64 = bui64;
be::big_to_native(ui64, tui64);
BOOST_TEST_EQ(tui64, nui64);
ui64 = lui64;
be::little_to_native(ui64, tui64);
BOOST_TEST_EQ(tui64, nui64);
boost::int32_t i32, ti32;
i32 = ni32;
be::native_to_big(i32, ti32);
BOOST_TEST_EQ(ti32, bi32);
i32 = ni32;
be::native_to_little(i32, ti32);
BOOST_TEST_EQ(ti32, li32);
i32 = bi32;
be::big_to_native(i32, ti32);
BOOST_TEST_EQ(ti32, ni32);
i32 = li32;
be::little_to_native(i32, ti32);
BOOST_TEST_EQ(ti32, ni32);
boost::uint32_t ui32, tui32;
ui32 = nui32;
be::native_to_big(ui32, tui32);
BOOST_TEST_EQ(tui32, bui32);
ui32 = nui32;
be::native_to_little(ui32, tui32);
BOOST_TEST_EQ(tui32, lui32);
ui32 = bui32;
be::big_to_native(ui32, tui32);
BOOST_TEST_EQ(tui32, nui32);
ui32 = lui32;
be::little_to_native(ui32, tui32);
BOOST_TEST_EQ(tui32, nui32);
boost::int16_t i16, ti16;
i16 = ni16;
be::native_to_big(i16, ti16);
BOOST_TEST_EQ(ti16, bi16);
i16 = ni16;
be::native_to_little(i16, ti16);
BOOST_TEST_EQ(ti16, li16);
i16 = bi16;
be::big_to_native(i16, ti16);
BOOST_TEST_EQ(ti16, ni16);
i16 = li16;
be::little_to_native(i16, ti16);
BOOST_TEST_EQ(ti16, ni16);
boost::uint16_t ui16, tui16;
ui16 = nui16;
be::native_to_big(ui16, tui16);
BOOST_TEST_EQ(tui16, bui16);
ui16 = nui16;
be::native_to_little(ui16, tui16);
BOOST_TEST_EQ(tui16, lui16);
ui16 = bui16;
be::big_to_native(ui16, tui16);
BOOST_TEST_EQ(tui16, nui16);
ui16 = lui16;
be::little_to_native(ui16, tui16);
BOOST_TEST_EQ(tui16, nui16);
std::cout << " test_copying_conditional_reorder complete\n";
}
} // unnamed namespace
int cpp_main(int, char * [])
{
std::cerr << std::hex;
test_in_place_reorder();
test_copying_reorder();
test_in_place_conditional_reorder();
test_copying_conditional_reorder();
return ::boost::report_errors();
}
#include <boost/endian/detail/disable_warnings_pop.hpp>
-86
View File
@@ -1,86 +0,0 @@
// endian_in_union_test.cpp -------------------------------------------------//
// Copyright Beman Dawes 2008
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See library home page at http://www.boost.org/libs/endian
//----------------------------------------------------------------------------//
#define BOOST_ENDIAN_FORCE_PODNESS
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/integers.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <cassert>
using namespace boost::endian;
union U
{
big8_t big8;
big16_t big16;
big24_t big24;
big32_t big32;
big40_t big40;
big48_t big48;
big56_t big56;
big64_t big64;
ubig8_t ubig8;
ubig16_t ubig16;
ubig24_t ubig24;
ubig32_t ubig32;
ubig40_t ubig40;
ubig48_t ubig48;
ubig56_t ubig56;
ubig64_t ubig64;
little8_t little8;
little16_t little16;
little24_t little24;
little32_t little32;
little40_t little40;
little48_t little48;
little56_t little56;
little64_t little64;
ulittle8_t ulittle8;
ulittle16_t ulittle16;
ulittle24_t ulittle24;
ulittle32_t ulittle32;
ulittle40_t ulittle40;
ulittle48_t ulittle48;
ulittle56_t ulittle56;
ulittle64_t ulittle64;
native8_t native8;
native16_t native16;
native24_t native24;
native32_t native32;
native40_t native40;
native48_t native48;
native56_t native56;
native64_t native64;
unative8_t unative8;
unative16_t unative16;
unative24_t unative24;
unative32_t unative32;
unative40_t unative40;
unative48_t unative48;
unative56_t unative56;
unative64_t unative64;
};
U foo;
int cpp_main(int, char * [])
{
return 0;
}
-382
View File
@@ -1,382 +0,0 @@
// endian_operations_test.cpp ----------------------------------------------//
// Copyright Beman Dawes 2008
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See library home page at http://www.boost.org/libs/endian
//----------------------------------------------------------------------------//
// This test probes operator overloading, including interaction between
// operand types.
// See endian_test for tests of endianess correctness, size, and value.
//----------------------------------------------------------------------------//
#define BOOST_ENDIAN_LOG
#include <boost/endian/detail/disable_warnings.hpp>
#ifdef _MSC_VER
# pragma warning( disable : 4242 ) // conversion ..., possible loss of data
# pragma warning( disable : 4244 ) // conversion ..., possible loss of data
# pragma warning( disable : 4018 ) // signed/unsigned mismatch
# pragma warning( disable : 4365 ) // signed/unsigned mismatch
# pragma warning( disable : 4389 ) // signed/unsigned mismatch
#endif
#include <boost/endian/integers.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <cassert>
#include <iostream>
namespace be = boost::endian;
template <class T1, class T2>
struct default_construct
{
static void test()
{
T1 o1;
o1 = 1; // quiet warnings
if (o1) return; // quiet warnings
}
};
template <class T1, class T2>
struct construct
{
static void test()
{
T2 o2(1);
T1 o1(o2);
++o1; // quiet gcc unused variable warning
}
};
template <class T1, class T2>
struct initialize
{
static void test()
{
T1 o2(2);
T1 o1 = o2;
++o1; // quiet gcc unused variable warning
}
};
template <class T1, class T2>
struct assign
{
static void test()
{
T2 o2;
o2 = 1;
T1 o1;
o1 = o2;
if (o1) return; // quiet warnings
}
};
template <class T1, class T2>
struct relational
{
static void test()
{
T1 o1(1);
T2 o2(2);
if ( o1 == o2 ) return;
if ( o1 != o2 ) return;
if ( o1 < o2 ) return;
if ( o1 <= o2 ) return;
if ( o1 > o2 ) return;
if ( o1 >= o2 ) return;
}
};
template <class T1, class T2>
struct op_plus
{
static void test()
{
T1 o1(1);
T2 o2(2);
T1 o3;
o3 = +o1;
o3 = o1 + o2;
o1 += o2;
if (o3) return; // quiet warnings
}
};
template <class T1, class T2>
struct op_star
{
static void test()
{
T1 o1(1);
T2 o2(2);
T1 o3;
o3 = o1 * o2;
o1 *= o2;
if (o3) return; // quiet warnings
}
};
template <template<class, class> class Test, class T1>
void op_test_aux()
{
#ifdef BOOST_SHORT_ENDIAN_TEST
Test<T1, int>::test();
Test<T1, unsigned int>::test();
Test<T1, be::big16_t>::test();
Test<T1, be::ubig64_t>::test();
#else
Test<T1, char>::test();
Test<T1, unsigned char>::test();
Test<T1, signed char>::test();
Test<T1, short>::test();
Test<T1, unsigned short>::test();
Test<T1, int>::test();
Test<T1, unsigned int>::test();
Test<T1, long>::test();
Test<T1, unsigned long>::test();
Test<T1, long long>::test();
Test<T1, unsigned long long>::test();
Test<T1, be::big8_t>::test();
Test<T1, be::big16_t>::test();
Test<T1, be::big24_t>::test();
Test<T1, be::big32_t>::test();
Test<T1, be::big40_t>::test();
Test<T1, be::big48_t>::test();
Test<T1, be::big56_t>::test();
Test<T1, be::big64_t>::test();
Test<T1, be::ubig8_t>::test();
Test<T1, be::ubig16_t>::test();
Test<T1, be::ubig24_t>::test();
Test<T1, be::ubig32_t>::test();
Test<T1, be::ubig40_t>::test();
Test<T1, be::ubig48_t>::test();
Test<T1, be::ubig56_t>::test();
Test<T1, be::ubig64_t>::test();
Test<T1, be::little8_t>::test();
Test<T1, be::little16_t>::test();
Test<T1, be::little24_t>::test();
Test<T1, be::little32_t>::test();
Test<T1, be::little40_t>::test();
Test<T1, be::little48_t>::test();
Test<T1, be::little56_t>::test();
Test<T1, be::little64_t>::test();
Test<T1, be::ulittle8_t>::test();
Test<T1, be::ulittle16_t>::test();
Test<T1, be::ulittle24_t>::test();
Test<T1, be::ulittle32_t>::test();
Test<T1, be::ulittle40_t>::test();
Test<T1, be::ulittle48_t>::test();
Test<T1, be::ulittle56_t>::test();
Test<T1, be::ulittle64_t>::test();
Test<T1, be::native8_t>::test();
Test<T1, be::native16_t>::test();
Test<T1, be::native24_t>::test();
Test<T1, be::native32_t>::test();
Test<T1, be::native40_t>::test();
Test<T1, be::native48_t>::test();
Test<T1, be::native56_t>::test();
Test<T1, be::native64_t>::test();
Test<T1, be::unative8_t>::test();
Test<T1, be::unative16_t>::test();
Test<T1, be::unative24_t>::test();
Test<T1, be::unative32_t>::test();
Test<T1, be::unative40_t>::test();
Test<T1, be::unative48_t>::test();
Test<T1, be::unative56_t>::test();
Test<T1, be::unative64_t>::test();
#endif
}
template <template<class, class> class Test>
void op_test()
{
#ifdef BOOST_SHORT_ENDIAN_TEST
op_test_aux<Test, unsigned short>();
op_test_aux<Test, int>();
op_test_aux<Test, be::big32_t>();
op_test_aux<Test, be::ubig32_t>();
op_test_aux<Test, be::little48_t>();
#else
op_test_aux<Test, char>();
op_test_aux<Test, unsigned char>();
op_test_aux<Test, signed char>();
op_test_aux<Test, short>();
op_test_aux<Test, unsigned short>();
op_test_aux<Test, int>();
op_test_aux<Test, unsigned int>();
op_test_aux<Test, long>();
op_test_aux<Test, unsigned long>();
op_test_aux<Test, long long>();
op_test_aux<Test, unsigned long long>();
op_test_aux<Test, be::big8_t>();
op_test_aux<Test, be::big16_t>();
op_test_aux<Test, be::big24_t>();
op_test_aux<Test, be::big32_t>();
op_test_aux<Test, be::big40_t>();
op_test_aux<Test, be::big48_t>();
op_test_aux<Test, be::big56_t>();
op_test_aux<Test, be::big64_t>();
op_test_aux<Test, be::ubig8_t>();
op_test_aux<Test, be::ubig16_t>();
op_test_aux<Test, be::ubig24_t>();
op_test_aux<Test, be::ubig32_t>();
op_test_aux<Test, be::ubig40_t>();
op_test_aux<Test, be::ubig48_t>();
op_test_aux<Test, be::ubig56_t>();
op_test_aux<Test, be::ubig64_t>();
op_test_aux<Test, be::little8_t>();
op_test_aux<Test, be::little16_t>();
op_test_aux<Test, be::little24_t>();
op_test_aux<Test, be::little32_t>();
op_test_aux<Test, be::little40_t>();
op_test_aux<Test, be::little48_t>();
op_test_aux<Test, be::little56_t>();
op_test_aux<Test, be::little64_t>();
op_test_aux<Test, be::ulittle8_t>();
op_test_aux<Test, be::ulittle16_t>();
op_test_aux<Test, be::ulittle24_t>();
op_test_aux<Test, be::ulittle32_t>();
op_test_aux<Test, be::ulittle40_t>();
op_test_aux<Test, be::ulittle48_t>();
op_test_aux<Test, be::ulittle56_t>();
op_test_aux<Test, be::ulittle64_t>();
op_test_aux<Test, be::native8_t>();
op_test_aux<Test, be::native16_t>();
op_test_aux<Test, be::native24_t>();
op_test_aux<Test, be::native32_t>();
op_test_aux<Test, be::native40_t>();
op_test_aux<Test, be::native48_t>();
op_test_aux<Test, be::native56_t>();
op_test_aux<Test, be::native64_t>();
op_test_aux<Test, be::unative8_t>();
op_test_aux<Test, be::unative16_t>();
op_test_aux<Test, be::unative24_t>();
op_test_aux<Test, be::unative32_t>();
op_test_aux<Test, be::unative40_t>();
op_test_aux<Test, be::unative48_t>();
op_test_aux<Test, be::unative56_t>();
op_test_aux<Test, be::unative64_t>();
#endif
}
// main ------------------------------------------------------------------------------//
int cpp_main(int, char * [])
{
be::endian_log = false;
// make sure some simple things work
be::big32_t o1(1);
be::big32_t o2(2L);
be::big32_t o3(3LL);
be::big64_t o4(1);
// use cases; if BOOST_ENDIAN_LOG is defined, will output to clog info on
// what overloads and conversions are actually being performed.
be::endian_log = true;
std::clog << "set up test values\n";
be::big32_t big(12345);
be::ulittle16_t ulittle(10);
be::big64_t result;
std::clog << "\nresult = +big\n";
result = +big;
std::clog << "\nresult = -big\n";
result = -big;
std::clog << "\n++big\n";
++big;
std::clog << "\nresult = big++\n";
result = big++;
std::clog << "\n--big\n";
--big;
std::clog << "\nbig--\n";
big--;
std::clog << "\nresult = big * big\n";
result = big * big;
std::clog << "\nresult = big * big\n";
result = big * big;
std::clog << "\nresult = big * ulittle\n";
result = big * ulittle;
std::clog << "\nbig *= ulittle\n";
big *= ulittle;
std::clog << "\nresult = ulittle * big\n";
result = ulittle * big;
std::clog << "\nresult = big * 5\n";
result = big * 5;
std::clog << "\nbig *= 5\n";
big *= 5;
std::clog << "\nresult = 5 * big\n";
result = 5 * big;
std::clog << "\nresult = ulittle * 5\n";
result = ulittle * 5;
std::clog << "\nresult = 5 * ulittle\n";
result = 5 * ulittle;
std::clog << "\nresult = 5 * 10\n";
result = 5 * 10;
std::clog << "\n";
be::endian_log = false;
// test from Roland Schwarz that detected ambiguities
unsigned u;
be::ulittle32_t u1;
be::ulittle32_t u2;
u = 1;
u1 = 1;
u2 = u1 + u;
// one more wrinkle
be::ulittle16_t u3(3);
u3 = 3;
u2 = u1 + u3;
// perform the indicated test on ~60*60 operand types
op_test<default_construct>();
op_test<construct>(); // includes copy construction
op_test<initialize>();
op_test<assign>();
op_test<relational>();
op_test<op_plus>();
op_test<op_star>();
return 0;
}
-782
View File
@@ -1,782 +0,0 @@
// endian_test.cpp ---------------------------------------------------------//
// Copyright Beman Dawes 1999-2008
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/endian
//----------------------------------------------------------------------------//
// This test probes for correct endianess, size, and value.
// See endian_operations_test for tests of operator correctness and interaction
// between operand types.
//----------------------------------------------------------------------------//
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/integers.hpp>
#include <boost/cstdint.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <iostream>
#include <limits>
#include <climits>
#include <cstdlib> // for atoi(), exit()
#include <cstring> // for memcmp()
using namespace std; // Not the best programming practice, but I
using namespace boost; // want to verify this combination of using
using namespace boost::endian; // namespaces works. See endian_operations_test
// // for tests that don't do "using namespace".
#define VERIFY(predicate) verify( predicate, __LINE__ )
#define VERIFY_SIZE(actual, expected) verify_size( actual, expected, __LINE__ )
#define VERIFY_VALUE_AND_OPS(endian_t,expected_t,expected) verify_value_and_ops<endian_t, expected_t>( expected, __LINE__ )
#define VERIFY_BIG_REPRESENTATION(t) verify_representation<t>( true, __LINE__ )
#define VERIFY_LITTLE_REPRESENTATION(t) verify_representation<t>( false, __LINE__ )
#define VERIFY_NATIVE_REPRESENTATION(t) verify_native_representation<t>( __LINE__ )
namespace
{
int err_count;
void verify( bool x, int line )
{
if ( x ) return;
++err_count;
cout << "Error: verify failed on line " << line << endl;
}
void verify_size( size_t actual, size_t expected, int line )
{
if ( actual == expected ) return;
++err_count;
cout << "Error: verify size failed on line " << line << endl;
cout << " A structure with an expected sizeof() " << expected
<< " had an actual sizeof() " << actual
<< "\n This will cause common uses of <boost/endian.hpp> to fail\n";
}
template <class Endian, class Base>
void verify_value_and_ops( const Base & expected, int line )
{
Endian v( expected );
verify( v == expected, line );
Endian v2;
v2.operator=( expected );
verify( v2 == expected, line );
++v; // verify integer_cover_operators being applied to this type -
// will fail to compile if no endian<> specialization is present
v+v;
}
const char * big_rep = "\x12\x34\x56\x78\x9A\xBC\xDE\xF0";
const char * little_rep = "\xF0\xDE\xBC\x9A\x78\x56\x34\x12";
template <class Endian>
void verify_representation( bool is_big, int line )
{
int silence = 0;
Endian x ( static_cast<typename Endian::value_type>
(0x123456789abcdef0LL + silence) ); // will truncate
if ( is_big )
verify( memcmp( &x,
reinterpret_cast<const char*>(big_rep)+8-sizeof(Endian),
sizeof(Endian) ) == 0, line );
else
verify( memcmp( &x, little_rep, sizeof(Endian) ) == 0, line );
}
template <class Endian>
inline void verify_native_representation( int line )
{
# ifdef BOOST_BIG_ENDIAN
verify_representation<Endian>( true, line );
# else
verify_representation<Endian>( false, line );
# endif
}
// detect_endianness -----------------------------------------------------//
void detect_endianness()
{
union View
{
long long i;
unsigned char c[8];
};
View v = { 0x0102030405060708LL }; // initialize v.i
if ( memcmp( v.c, "\10\7\6\5\4\3\2\1", 8) == 0 )
{
cout << "This machine is little-endian.\n";
# ifdef BOOST_BIG_INTEGER_OPERATORS
cout << "yet boost/detail/endian.hpp defines BOOST_BIG_INTEGER_OPERATORS.\n"
"You must fix boost/detail/endian.hpp for boost/endian.hpp to work correctly.\n"
"Please report the fix to the Boost mailing list.\n";
exit(1);
# endif
}
else if ( memcmp( v.c, "\1\2\3\4\5\6\7\10", 8) == 0 )
{
cout << "This machine is big-endian.\n";
# ifdef BOOST_LITTLE_INTEGER_OPERATORS
cout << "yet boost/detail/endian.hpp defines BOOST__LITTLE_INTEGER_OPERATORS.\n"
"You must fix boost/detail/endian.hpp for boost/endian.hpp to work correctly.\n"
"Please report the fix to the Boost mailing list.\n";
exit(1);
# endif
}
else
{
cout << "This machine is neither strict big-endian nor strict little-endian\n"
"You must modify boost/endian.hpp for it to work correctly.\n";
exit(1);
}
cout << "That should not matter and is presented for your information only.\n";
} // detect_endianness
// check_data ------------------------------------------------------------//
void check_data()
{
big8_t big8;
big16_t big16;
big24_t big24;
big32_t big32;
big40_t big40;
big48_t big48;
big56_t big56;
big64_t big64;
ubig8_t ubig8;
ubig16_t ubig16;
ubig24_t ubig24;
ubig32_t ubig32;
ubig40_t ubig40;
ubig48_t ubig48;
ubig56_t ubig56;
ubig64_t ubig64;
little8_t little8;
little16_t little16;
little24_t little24;
little32_t little32;
little40_t little40;
little48_t little48;
little56_t little56;
little64_t little64;
ulittle8_t ulittle8;
ulittle16_t ulittle16;
ulittle24_t ulittle24;
ulittle32_t ulittle32;
ulittle40_t ulittle40;
ulittle48_t ulittle48;
ulittle56_t ulittle56;
ulittle64_t ulittle64;
native8_t native8;
native16_t native16;
native24_t native24;
native32_t native32;
native40_t native40;
native48_t native48;
native56_t native56;
native64_t native64;
unative8_t unative8;
unative16_t unative16;
unative24_t unative24;
unative32_t unative32;
unative40_t unative40;
unative48_t unative48;
unative56_t unative56;
unative64_t unative64;
aligned_big16_t aligned_big16;
aligned_big32_t aligned_big32;
aligned_big64_t aligned_big64;
aligned_ubig16_t aligned_ubig16;
aligned_ubig32_t aligned_ubig32;
aligned_ubig64_t aligned_ubig64;
aligned_little16_t aligned_little16;
aligned_little32_t aligned_little32;
aligned_little64_t aligned_little64;
aligned_ulittle16_t aligned_ulittle16 ;
aligned_ulittle32_t aligned_ulittle32 ;
aligned_ulittle64_t aligned_ulittle64 ;
VERIFY(big8.data() == reinterpret_cast<const char *>(&big8));
VERIFY(big16.data() == reinterpret_cast<const char *>(&big16));
VERIFY(big24.data() == reinterpret_cast<const char *>(&big24));
VERIFY(big32.data() == reinterpret_cast<const char *>(&big32));
VERIFY(big40.data() == reinterpret_cast<const char *>(&big40));
VERIFY(big48.data() == reinterpret_cast<const char *>(&big48));
VERIFY(big56.data() == reinterpret_cast<const char *>(&big56));
VERIFY(big64.data() == reinterpret_cast<const char *>(&big64));
VERIFY(ubig8.data() == reinterpret_cast<const char *>(&ubig8));
VERIFY(ubig16.data() == reinterpret_cast<const char *>(&ubig16));
VERIFY(ubig24.data() == reinterpret_cast<const char *>(&ubig24));
VERIFY(ubig32.data() == reinterpret_cast<const char *>(&ubig32));
VERIFY(ubig40.data() == reinterpret_cast<const char *>(&ubig40));
VERIFY(ubig48.data() == reinterpret_cast<const char *>(&ubig48));
VERIFY(ubig56.data() == reinterpret_cast<const char *>(&ubig56));
VERIFY(ubig64.data() == reinterpret_cast<const char *>(&ubig64));
VERIFY(little8.data() == reinterpret_cast<const char *>(&little8));
VERIFY(little16.data() == reinterpret_cast<const char *>(&little16));
VERIFY(little24.data() == reinterpret_cast<const char *>(&little24));
VERIFY(little32.data() == reinterpret_cast<const char *>(&little32));
VERIFY(little40.data() == reinterpret_cast<const char *>(&little40));
VERIFY(little48.data() == reinterpret_cast<const char *>(&little48));
VERIFY(little56.data() == reinterpret_cast<const char *>(&little56));
VERIFY(little64.data() == reinterpret_cast<const char *>(&little64));
VERIFY(ulittle8.data() == reinterpret_cast<const char *>(&ulittle8));
VERIFY(ulittle16.data() == reinterpret_cast<const char *>(&ulittle16));
VERIFY(ulittle24.data() == reinterpret_cast<const char *>(&ulittle24));
VERIFY(ulittle32.data() == reinterpret_cast<const char *>(&ulittle32));
VERIFY(ulittle40.data() == reinterpret_cast<const char *>(&ulittle40));
VERIFY(ulittle48.data() == reinterpret_cast<const char *>(&ulittle48));
VERIFY(ulittle56.data() == reinterpret_cast<const char *>(&ulittle56));
VERIFY(ulittle64.data() == reinterpret_cast<const char *>(&ulittle64));
VERIFY(native8.data() == reinterpret_cast<const char *>(&native8));
VERIFY(native16.data() == reinterpret_cast<const char *>(&native16));
VERIFY(native24.data() == reinterpret_cast<const char *>(&native24));
VERIFY(native32.data() == reinterpret_cast<const char *>(&native32));
VERIFY(native40.data() == reinterpret_cast<const char *>(&native40));
VERIFY(native48.data() == reinterpret_cast<const char *>(&native48));
VERIFY(native56.data() == reinterpret_cast<const char *>(&native56));
VERIFY(native64.data() == reinterpret_cast<const char *>(&native64));
VERIFY(unative8.data() == reinterpret_cast<const char *>(&unative8));
VERIFY(unative16.data() == reinterpret_cast<const char *>(&unative16));
VERIFY(unative24.data() == reinterpret_cast<const char *>(&unative24));
VERIFY(unative32.data() == reinterpret_cast<const char *>(&unative32));
VERIFY(unative40.data() == reinterpret_cast<const char *>(&unative40));
VERIFY(unative48.data() == reinterpret_cast<const char *>(&unative48));
VERIFY(unative56.data() == reinterpret_cast<const char *>(&unative56));
VERIFY(unative64.data() == reinterpret_cast<const char *>(&unative64));
VERIFY(aligned_big16.data() == reinterpret_cast<const char *>(&aligned_big16));
VERIFY(aligned_big32.data() == reinterpret_cast<const char *>(&aligned_big32));
VERIFY(aligned_big64.data() == reinterpret_cast<const char *>(&aligned_big64));
VERIFY(aligned_ubig16.data() == reinterpret_cast<const char *>(&aligned_ubig16));
VERIFY(aligned_ubig32.data() == reinterpret_cast<const char *>(&aligned_ubig32));
VERIFY(aligned_ubig64.data() == reinterpret_cast<const char *>(&aligned_ubig64));
VERIFY(aligned_little16.data() == reinterpret_cast<const char *>(&aligned_little16));
VERIFY(aligned_little32.data() == reinterpret_cast<const char *>(&aligned_little32));
VERIFY(aligned_little64.data() == reinterpret_cast<const char *>(&aligned_little64));
VERIFY(aligned_ulittle16.data() == reinterpret_cast<const char *>(&aligned_ulittle16));
VERIFY(aligned_ulittle32.data() == reinterpret_cast<const char *>(&aligned_ulittle32));
VERIFY(aligned_ulittle64.data() == reinterpret_cast<const char *>(&aligned_ulittle64));
}
// check_size ------------------------------------------------------------//
void check_size()
{
VERIFY( numeric_limits<signed char>::digits == 7 );
VERIFY( numeric_limits<unsigned char>::digits == 8 );
VERIFY_SIZE( sizeof( big8_t ), 1 );
VERIFY_SIZE( sizeof( big16_t ), 2 );
VERIFY_SIZE( sizeof( big24_t ), 3 );
VERIFY_SIZE( sizeof( big32_t ), 4 );
VERIFY_SIZE( sizeof( big40_t ), 5 );
VERIFY_SIZE( sizeof( big48_t ), 6 );
VERIFY_SIZE( sizeof( big56_t ), 7 );
VERIFY_SIZE( sizeof( big64_t ), 8 );
VERIFY_SIZE( sizeof( ubig8_t ), 1 );
VERIFY_SIZE( sizeof( ubig16_t ), 2 );
VERIFY_SIZE( sizeof( ubig24_t ), 3 );
VERIFY_SIZE( sizeof( ubig32_t ), 4 );
VERIFY_SIZE( sizeof( ubig40_t ), 5 );
VERIFY_SIZE( sizeof( ubig48_t ), 6 );
VERIFY_SIZE( sizeof( ubig56_t ), 7 );
VERIFY_SIZE( sizeof( ubig64_t ), 8 );
VERIFY_SIZE( sizeof( little8_t ), 1 );
VERIFY_SIZE( sizeof( little16_t ), 2 );
VERIFY_SIZE( sizeof( little24_t ), 3 );
VERIFY_SIZE( sizeof( little32_t ), 4 );
VERIFY_SIZE( sizeof( little40_t ), 5 );
VERIFY_SIZE( sizeof( little48_t ), 6 );
VERIFY_SIZE( sizeof( little56_t ), 7 );
VERIFY_SIZE( sizeof( little64_t ), 8 );
VERIFY_SIZE( sizeof( ulittle8_t ), 1 );
VERIFY_SIZE( sizeof( ulittle16_t ), 2 );
VERIFY_SIZE( sizeof( ulittle24_t ), 3 );
VERIFY_SIZE( sizeof( ulittle32_t ), 4 );
VERIFY_SIZE( sizeof( ulittle40_t ), 5 );
VERIFY_SIZE( sizeof( ulittle48_t ), 6 );
VERIFY_SIZE( sizeof( ulittle56_t ), 7 );
VERIFY_SIZE( sizeof( ulittle64_t ), 8 );
VERIFY_SIZE( sizeof( native8_t ), 1 );
VERIFY_SIZE( sizeof( native16_t ), 2 );
VERIFY_SIZE( sizeof( native24_t ), 3 );
VERIFY_SIZE( sizeof( native32_t ), 4 );
VERIFY_SIZE( sizeof( native40_t ), 5 );
VERIFY_SIZE( sizeof( native48_t ), 6 );
VERIFY_SIZE( sizeof( native56_t ), 7 );
VERIFY_SIZE( sizeof( native64_t ), 8 );
VERIFY_SIZE( sizeof( unative8_t ), 1 );
VERIFY_SIZE( sizeof( unative16_t ), 2 );
VERIFY_SIZE( sizeof( unative24_t ), 3 );
VERIFY_SIZE( sizeof( unative32_t ), 4 );
VERIFY_SIZE( sizeof( unative40_t ), 5 );
VERIFY_SIZE( sizeof( unative48_t ), 6 );
VERIFY_SIZE( sizeof( unative56_t ), 7 );
VERIFY_SIZE( sizeof( unative64_t ), 8 );
VERIFY_SIZE( sizeof( aligned_big16_t ), 2 );
VERIFY_SIZE( sizeof( aligned_big32_t ), 4 );
VERIFY_SIZE( sizeof( aligned_big64_t ), 8 );
VERIFY_SIZE( sizeof( aligned_ubig16_t ), 2 );
VERIFY_SIZE( sizeof( aligned_ubig32_t ), 4 );
VERIFY_SIZE( sizeof( aligned_ubig64_t ), 8 );
VERIFY_SIZE( sizeof( aligned_little16_t ), 2 );
VERIFY_SIZE( sizeof( aligned_little32_t ), 4 );
VERIFY_SIZE( sizeof( aligned_little64_t ), 8 );
VERIFY_SIZE( sizeof( aligned_ulittle16_t ), 2 );
VERIFY_SIZE( sizeof( aligned_ulittle32_t ), 4 );
VERIFY_SIZE( sizeof( aligned_ulittle64_t ), 8 );
} // check_size
// check_alignment -------------------------------------------------------//
void check_alignment()
{
// structs with offsets % 2 == 1 for type of size > 1 to ensure no alignment
// bytes added for any size > 1
struct big_struct
{
big8_t v0;
big16_t v1;
big24_t v3;
char v6;
big32_t v7;
big40_t v11;
char v16;
big48_t v17;
big56_t v23;
char v30;
big64_t v31;
};
struct ubig_struct
{
ubig8_t v0;
ubig16_t v1;
ubig24_t v3;
char v6;
ubig32_t v7;
ubig40_t v11;
char v16;
ubig48_t v17;
ubig56_t v23;
char v30;
ubig64_t v31;
};
struct little_struct
{
little8_t v0;
little16_t v1;
little24_t v3;
char v6;
little32_t v7;
little40_t v11;
char v16;
little48_t v17;
little56_t v23;
char v30;
little64_t v31;
};
struct ulittle_struct
{
ulittle8_t v0;
ulittle16_t v1;
ulittle24_t v3;
char v6;
ulittle32_t v7;
ulittle40_t v11;
char v16;
ulittle48_t v17;
ulittle56_t v23;
char v30;
ulittle64_t v31;
};
struct native_struct
{
native8_t v0;
native16_t v1;
native24_t v3;
char v6;
native32_t v7;
native40_t v11;
char v16;
native48_t v17;
native56_t v23;
char v30;
native64_t v31;
};
struct unative_struct
{
unative8_t v0;
unative16_t v1;
unative24_t v3;
char v6;
unative32_t v7;
unative40_t v11;
char v16;
unative48_t v17;
unative56_t v23;
char v30;
unative64_t v31;
};
int saved_err_count = err_count;
VERIFY_SIZE( sizeof(big_struct), 39 );
VERIFY_SIZE( sizeof(ubig_struct), 39 );
VERIFY_SIZE( sizeof(little_struct), 39 );
VERIFY_SIZE( sizeof(ulittle_struct), 39 );
VERIFY_SIZE( sizeof(native_struct), 39 );
VERIFY_SIZE( sizeof(unative_struct), 39 );
if ( saved_err_count == err_count )
{
cout <<
"Size and alignment for structures of endian types are as expected.\n";
}
} // check_alignment
// check_representation_and_range_and_ops --------------------------------//
void check_representation_and_range_and_ops()
{
VERIFY_BIG_REPRESENTATION( big8_t );
VERIFY_VALUE_AND_OPS( big8_t, int_least8_t, 0x7f );
VERIFY_VALUE_AND_OPS( big8_t, int_least8_t, -0x80 );
VERIFY_BIG_REPRESENTATION( big16_t );
VERIFY_VALUE_AND_OPS( big16_t, int_least16_t, 0x7fff );
VERIFY_VALUE_AND_OPS( big16_t, int_least16_t, -0x8000 );
VERIFY_BIG_REPRESENTATION( big24_t );
VERIFY_VALUE_AND_OPS( big24_t, int_least32_t, 0x7fffff );
VERIFY_VALUE_AND_OPS( big24_t, int_least32_t, -0x800000 );
VERIFY_BIG_REPRESENTATION( big32_t );
VERIFY_VALUE_AND_OPS( big32_t, int_least32_t, 0x7fffffff );
VERIFY_VALUE_AND_OPS( big32_t, int_least32_t, -0x7fffffff-1 );
VERIFY_BIG_REPRESENTATION( big40_t );
VERIFY_VALUE_AND_OPS( big40_t, int_least64_t, 0x7fffffffffLL );
VERIFY_VALUE_AND_OPS( big40_t, int_least64_t, -0x8000000000LL );
VERIFY_BIG_REPRESENTATION( big48_t );
VERIFY_VALUE_AND_OPS( big48_t, int_least64_t, 0x7fffffffffffLL );
VERIFY_VALUE_AND_OPS( big48_t, int_least64_t, -0x800000000000LL );
VERIFY_BIG_REPRESENTATION( big56_t );
VERIFY_VALUE_AND_OPS( big56_t, int_least64_t, 0x7fffffffffffffLL );
VERIFY_VALUE_AND_OPS( big56_t, int_least64_t, -0x80000000000000LL );
VERIFY_BIG_REPRESENTATION( big64_t );
VERIFY_VALUE_AND_OPS( big64_t, int_least64_t, 0x7fffffffffffffffLL );
VERIFY_VALUE_AND_OPS( big64_t, int_least64_t, -0x7fffffffffffffffLL-1 );
VERIFY_BIG_REPRESENTATION( ubig8_t );
VERIFY_VALUE_AND_OPS( ubig8_t, uint_least8_t, 0xff );
VERIFY_BIG_REPRESENTATION( ubig16_t );
VERIFY_VALUE_AND_OPS( ubig16_t, uint_least16_t, 0xffff );
VERIFY_BIG_REPRESENTATION( ubig24_t );
VERIFY_VALUE_AND_OPS( ubig24_t, uint_least32_t, 0xffffff );
VERIFY_BIG_REPRESENTATION( ubig32_t );
VERIFY_VALUE_AND_OPS( ubig32_t, uint_least32_t, 0xffffffff );
VERIFY_BIG_REPRESENTATION( ubig40_t );
VERIFY_VALUE_AND_OPS( ubig40_t, uint_least64_t, 0xffffffffffLL );
VERIFY_BIG_REPRESENTATION( ubig48_t );
VERIFY_VALUE_AND_OPS( ubig48_t, uint_least64_t, 0xffffffffffffLL );
VERIFY_BIG_REPRESENTATION( ubig56_t );
VERIFY_VALUE_AND_OPS( ubig56_t, uint_least64_t, 0xffffffffffffffLL );
VERIFY_BIG_REPRESENTATION( ubig64_t );
VERIFY_VALUE_AND_OPS( ubig64_t, uint_least64_t, 0xffffffffffffffffULL );
VERIFY_LITTLE_REPRESENTATION( little8_t );
VERIFY_VALUE_AND_OPS( little8_t, int_least8_t, 0x7f );
VERIFY_VALUE_AND_OPS( little8_t, int_least8_t, -0x80 );
VERIFY_LITTLE_REPRESENTATION( little16_t );
VERIFY_VALUE_AND_OPS( little16_t, int_least16_t, 0x7fff );
VERIFY_VALUE_AND_OPS( little16_t, int_least16_t, -0x8000 );
VERIFY_LITTLE_REPRESENTATION( little24_t );
VERIFY_VALUE_AND_OPS( little24_t, int_least32_t, 0x7fffff );
VERIFY_VALUE_AND_OPS( little24_t, int_least32_t, -0x800000 );
VERIFY_LITTLE_REPRESENTATION( little32_t );
VERIFY_VALUE_AND_OPS( little32_t, int_least32_t, 0x7fffffff );
VERIFY_VALUE_AND_OPS( little32_t, int_least32_t, -0x7fffffff-1 );
VERIFY_LITTLE_REPRESENTATION( little40_t );
VERIFY_VALUE_AND_OPS( little40_t, int_least64_t, 0x7fffffffffLL );
VERIFY_VALUE_AND_OPS( little40_t, int_least64_t, -0x8000000000LL );
VERIFY_LITTLE_REPRESENTATION( little48_t );
VERIFY_VALUE_AND_OPS( little48_t, int_least64_t, 0x7fffffffffffLL );
VERIFY_VALUE_AND_OPS( little48_t, int_least64_t, -0x800000000000LL );
VERIFY_LITTLE_REPRESENTATION( little56_t );
VERIFY_VALUE_AND_OPS( little56_t, int_least64_t, 0x7fffffffffffffLL );
VERIFY_VALUE_AND_OPS( little56_t, int_least64_t, -0x80000000000000LL );
VERIFY_LITTLE_REPRESENTATION( little64_t );
VERIFY_VALUE_AND_OPS( little64_t, int_least64_t, 0x7fffffffffffffffLL );
VERIFY_VALUE_AND_OPS( little64_t, int_least64_t, -0x7fffffffffffffffLL-1 );
VERIFY_LITTLE_REPRESENTATION( ulittle8_t );
VERIFY_VALUE_AND_OPS( ulittle8_t, uint_least8_t, 0xff );
VERIFY_LITTLE_REPRESENTATION( ulittle16_t );
VERIFY_VALUE_AND_OPS( ulittle16_t, uint_least16_t, 0xffff );
VERIFY_LITTLE_REPRESENTATION( ulittle24_t );
VERIFY_VALUE_AND_OPS( ulittle24_t, uint_least32_t, 0xffffff );
VERIFY_LITTLE_REPRESENTATION( ulittle32_t );
VERIFY_VALUE_AND_OPS( ulittle32_t, uint_least32_t, 0xffffffff );
VERIFY_LITTLE_REPRESENTATION( ulittle40_t );
VERIFY_VALUE_AND_OPS( ulittle40_t, uint_least64_t, 0xffffffffffLL );
VERIFY_LITTLE_REPRESENTATION( ulittle48_t );
VERIFY_VALUE_AND_OPS( ulittle48_t, uint_least64_t, 0xffffffffffffLL );
VERIFY_LITTLE_REPRESENTATION( ulittle56_t );
VERIFY_VALUE_AND_OPS( ulittle56_t, uint_least64_t, 0xffffffffffffffLL );
VERIFY_LITTLE_REPRESENTATION( ulittle64_t );
VERIFY_VALUE_AND_OPS( ulittle64_t, uint_least64_t, 0xffffffffffffffffULL );
VERIFY_NATIVE_REPRESENTATION( native8_t );
VERIFY_VALUE_AND_OPS( native8_t, int_least8_t, 0x7f );
VERIFY_VALUE_AND_OPS( native8_t, int_least8_t, -0x80 );
VERIFY_NATIVE_REPRESENTATION( native16_t );
VERIFY_VALUE_AND_OPS( native16_t, int_least16_t, 0x7fff );
VERIFY_VALUE_AND_OPS( native16_t, int_least16_t, -0x8000 );
VERIFY_NATIVE_REPRESENTATION( native24_t );
VERIFY_VALUE_AND_OPS( native24_t, int_least32_t, 0x7fffff );
VERIFY_VALUE_AND_OPS( native24_t, int_least32_t, -0x800000 );
VERIFY_NATIVE_REPRESENTATION( native32_t );
VERIFY_VALUE_AND_OPS( native32_t, int_least32_t, 0x7fffffff );
VERIFY_VALUE_AND_OPS( native32_t, int_least32_t, -0x7fffffff-1 );
VERIFY_NATIVE_REPRESENTATION( native40_t );
VERIFY_VALUE_AND_OPS( native40_t, int_least64_t, 0x7fffffffffLL );
VERIFY_VALUE_AND_OPS( native40_t, int_least64_t, -0x8000000000LL );
VERIFY_NATIVE_REPRESENTATION( native48_t );
VERIFY_VALUE_AND_OPS( native48_t, int_least64_t, 0x7fffffffffffLL );
VERIFY_VALUE_AND_OPS( native48_t, int_least64_t, -0x800000000000LL );
VERIFY_NATIVE_REPRESENTATION( native56_t );
VERIFY_VALUE_AND_OPS( native56_t, int_least64_t, 0x7fffffffffffffLL );
VERIFY_VALUE_AND_OPS( native56_t, int_least64_t, -0x80000000000000LL );
VERIFY_NATIVE_REPRESENTATION( native64_t );
VERIFY_VALUE_AND_OPS( native64_t, int_least64_t, 0x7fffffffffffffffLL );
VERIFY_VALUE_AND_OPS( native64_t, int_least64_t, -0x7fffffffffffffffLL-1 );
VERIFY_NATIVE_REPRESENTATION( unative8_t );
VERIFY_VALUE_AND_OPS( unative8_t, uint_least8_t, 0xff );
VERIFY_NATIVE_REPRESENTATION( unative16_t );
VERIFY_VALUE_AND_OPS( unative16_t, uint_least16_t, 0xffff );
VERIFY_NATIVE_REPRESENTATION( unative24_t );
VERIFY_VALUE_AND_OPS( unative24_t, uint_least32_t, 0xffffff );
VERIFY_NATIVE_REPRESENTATION( unative32_t );
VERIFY_VALUE_AND_OPS( unative32_t, uint_least32_t, 0xffffffff );
VERIFY_NATIVE_REPRESENTATION( unative40_t );
VERIFY_VALUE_AND_OPS( unative40_t, uint_least64_t, 0xffffffffffLL );
VERIFY_NATIVE_REPRESENTATION( unative48_t );
VERIFY_VALUE_AND_OPS( unative48_t, uint_least64_t, 0xffffffffffffLL );
VERIFY_NATIVE_REPRESENTATION( unative56_t );
VERIFY_VALUE_AND_OPS( unative56_t, uint_least64_t, 0xffffffffffffffLL );
VERIFY_NATIVE_REPRESENTATION( unative64_t );
VERIFY_VALUE_AND_OPS( unative64_t, uint_least64_t, 0xffffffffffffffffULL );
VERIFY_BIG_REPRESENTATION( aligned_big16_t );
VERIFY_VALUE_AND_OPS( aligned_big16_t, int_least16_t, 0x7fff );
VERIFY_VALUE_AND_OPS( aligned_big16_t, int_least16_t, -0x8000 );
VERIFY_BIG_REPRESENTATION( aligned_big32_t );
VERIFY_VALUE_AND_OPS( aligned_big32_t, int_least32_t, 0x7fffffff );
VERIFY_VALUE_AND_OPS( aligned_big32_t, int_least32_t, -0x7fffffff-1 );
VERIFY_BIG_REPRESENTATION( aligned_big64_t );
VERIFY_VALUE_AND_OPS( aligned_big64_t, int_least64_t, 0x7fffffffffffffffLL );
VERIFY_VALUE_AND_OPS( aligned_big64_t, int_least64_t, -0x7fffffffffffffffLL-1 );
VERIFY_BIG_REPRESENTATION( aligned_ubig16_t );
VERIFY_VALUE_AND_OPS( aligned_ubig16_t, uint_least16_t, 0xffff );
VERIFY_BIG_REPRESENTATION( aligned_ubig32_t );
VERIFY_VALUE_AND_OPS( aligned_ubig32_t, uint_least32_t, 0xffffffff );
VERIFY_BIG_REPRESENTATION( aligned_ubig64_t );
VERIFY_VALUE_AND_OPS( aligned_ubig64_t, uint_least64_t, 0xffffffffffffffffULL );
VERIFY_LITTLE_REPRESENTATION( aligned_little16_t );
VERIFY_VALUE_AND_OPS( aligned_little16_t, int_least16_t, 0x7fff );
VERIFY_VALUE_AND_OPS( aligned_little16_t, int_least16_t, -0x8000 );
VERIFY_LITTLE_REPRESENTATION( aligned_little32_t );
VERIFY_VALUE_AND_OPS( aligned_little32_t, int_least32_t, 0x7fffffff );
VERIFY_VALUE_AND_OPS( aligned_little32_t, int_least32_t, -0x7fffffff-1 );
VERIFY_LITTLE_REPRESENTATION( aligned_little64_t );
VERIFY_VALUE_AND_OPS( aligned_little64_t, int_least64_t, 0x7fffffffffffffffLL );
VERIFY_VALUE_AND_OPS( aligned_little64_t, int_least64_t, -0x7fffffffffffffffLL-1 );
VERIFY_LITTLE_REPRESENTATION( aligned_ulittle16_t );
VERIFY_VALUE_AND_OPS( aligned_ulittle16_t, uint_least16_t, 0xffff );
VERIFY_LITTLE_REPRESENTATION( aligned_ulittle32_t );
VERIFY_VALUE_AND_OPS( aligned_ulittle32_t, uint_least32_t, 0xffffffff );
VERIFY_LITTLE_REPRESENTATION( aligned_ulittle64_t );
VERIFY_VALUE_AND_OPS( aligned_ulittle64_t, uint_least64_t, 0xffffffffffffffffULL );
} // check_representation_and_range
class MyInt
{
int32_t mx;
public:
MyInt(int32_t x) : mx(x) {}
operator int32_t() const {return mx;}
//friend int32_t operator+(const MyInt& x) {return x;}
};
void check_udt()
{
typedef boost::endian::endian< endianness::big, MyInt, 32 > mybig32_t;
mybig32_t v(10);
cout << "+v is " << +v << endl;
v += 1;
cout << "v is " << +v << endl;
v -= 2;
cout << "v is " << +v << endl;
v *= 2;
cout << "v is " << +v << endl;
++v;
cout << "v is " << +v << endl;
--v;
cout << "v is " << +v << endl;
// cout << "v+v is " << +(v+v) << endl;
}
long iterations = 10000;
template< class Endian >
Endian timing_test( const char * s)
{
cout << s << " timing test, " << iterations << " iterations: ";
// progress_timer t;
Endian v = 1;
for ( long i = 0; i < iterations; ++i )
{
v += 1;
v *= 3;
++v;
v *= i;
if ( i == 0 ) VERIFY_VALUE_AND_OPS( Endian, typename Endian::value_type, 21 );
}
return v;
}
} // unnamed namespace
// main ------------------------------------------------------------------------------//
int cpp_main( int argc, char * argv[] )
{
cout << "Usage: "
<< argv[0] << " [#],\n where # specifies iteration count\n"
" default iteration count is " << iterations << endl;
if ( argc > 1 )
iterations = atol( argv[1] );
if ( iterations < 1 ) iterations = 1;
detect_endianness();
check_size();
check_alignment();
check_representation_and_range_and_ops();
check_data();
check_udt();
//timing_test<big32_t> ( "big32_t" );
//timing_test<aligned_big32_t>( "aligned_big32_t" );
//timing_test<little32_t> ( "little32_t" );
//timing_test<aligned_little32_t>( "aligned_little32_t" );
cout << "\n" << err_count << " errors detected\nTest "
<< (err_count==0 ? "passed\n\n" : "failed\n\n");
return err_count ? 1 : 0;
} // main
@@ -1,98 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C9FEAE75-4DD9-44F5-B302-9910559A91BE}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>benchmark</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BOOST_ALL_NO_LIB;BOOST_ALL_DYN_LINK;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>d:\endian\stage\lib</AdditionalLibraryDirectories>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 100</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>BOOST_ALL_NO_LIB;BOOST_ALL_DYN_LINK;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>d:\endian\stage\lib</AdditionalLibraryDirectories>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 100000</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\system\src\error_code.cpp" />
<ClCompile Include="..\..\..\support\run_timer.cpp" />
<ClCompile Include="..\..\..\support\run_timer_ctors.cpp" />
<ClCompile Include="..\..\..\support\timer.cpp" />
<ClCompile Include="..\..\benchmark.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
-18
View File
@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir>$(TEMP)\$(SolutionName)\$(Configuration)\</OutDir>
<IntDir>$(TEMP)\$(SolutionName)\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>EnableAllWarnings</WarningLevel>
</ClCompile>
<PostBuildEvent>
<Message>Executing test $(TargetName).exe...</Message>
<Command>"$(TargetDir)\$(TargetName).exe"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
</Project>
@@ -1,84 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6FAF820B-F436-46A2-A1DD-4A4B7025C3D0}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>conversion2_test</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\conversion2_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -1,91 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\conversion_test.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{9FA33B0B-2B00-49E8-A892-E049D86076A9}</ProjectGuid>
<RootNamespace>endian_flip_test</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
-62
View File
@@ -1,62 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C++ Express 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_test", "endian_test\endian_test.vcxproj", "{74C201F3-8308-40BE-BC0F-24974DEAF405}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_in_union_test", "endian_in_union_test\endian_in_union_test.vcxproj", "{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_operations_test", "endian_operations_test\endian_operations_test.vcxproj", "{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scoped_enum_emulation_test", "scoped_enum_emulation_test\scoped_enum_emulation_test.vcxproj", "{8420E151-B23B-4651-B526-6AB11EF1E278}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_example", "endian_example\endian_example.vcxproj", "{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "conversion_test", "conversion_test\conversion_test.vcxproj", "{9FA33B0B-2B00-49E8-A892-E049D86076A9}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "benchmark", "benchmark\benchmark.vcxproj", "{C9FEAE75-4DD9-44F5-B302-9910559A91BE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "conversion2_test", "conversion2_test\conversion2_test.vcxproj", "{6FAF820B-F436-46A2-A1DD-4A4B7025C3D0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{74C201F3-8308-40BE-BC0F-24974DEAF405}.Debug|Win32.ActiveCfg = Debug|Win32
{74C201F3-8308-40BE-BC0F-24974DEAF405}.Debug|Win32.Build.0 = Debug|Win32
{74C201F3-8308-40BE-BC0F-24974DEAF405}.Release|Win32.ActiveCfg = Release|Win32
{74C201F3-8308-40BE-BC0F-24974DEAF405}.Release|Win32.Build.0 = Release|Win32
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Debug|Win32.ActiveCfg = Debug|Win32
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Debug|Win32.Build.0 = Debug|Win32
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Release|Win32.ActiveCfg = Release|Win32
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Release|Win32.Build.0 = Release|Win32
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Debug|Win32.ActiveCfg = Debug|Win32
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Debug|Win32.Build.0 = Debug|Win32
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Release|Win32.ActiveCfg = Release|Win32
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Release|Win32.Build.0 = Release|Win32
{8420E151-B23B-4651-B526-6AB11EF1E278}.Debug|Win32.ActiveCfg = Debug|Win32
{8420E151-B23B-4651-B526-6AB11EF1E278}.Debug|Win32.Build.0 = Debug|Win32
{8420E151-B23B-4651-B526-6AB11EF1E278}.Release|Win32.ActiveCfg = Release|Win32
{8420E151-B23B-4651-B526-6AB11EF1E278}.Release|Win32.Build.0 = Release|Win32
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Debug|Win32.Build.0 = Debug|Win32
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Release|Win32.ActiveCfg = Release|Win32
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Release|Win32.Build.0 = Release|Win32
{9FA33B0B-2B00-49E8-A892-E049D86076A9}.Debug|Win32.ActiveCfg = Debug|Win32
{9FA33B0B-2B00-49E8-A892-E049D86076A9}.Debug|Win32.Build.0 = Debug|Win32
{9FA33B0B-2B00-49E8-A892-E049D86076A9}.Release|Win32.ActiveCfg = Release|Win32
{9FA33B0B-2B00-49E8-A892-E049D86076A9}.Release|Win32.Build.0 = Release|Win32
{C9FEAE75-4DD9-44F5-B302-9910559A91BE}.Debug|Win32.ActiveCfg = Debug|Win32
{C9FEAE75-4DD9-44F5-B302-9910559A91BE}.Debug|Win32.Build.0 = Debug|Win32
{C9FEAE75-4DD9-44F5-B302-9910559A91BE}.Release|Win32.ActiveCfg = Release|Win32
{C9FEAE75-4DD9-44F5-B302-9910559A91BE}.Release|Win32.Build.0 = Release|Win32
{6FAF820B-F436-46A2-A1DD-4A4B7025C3D0}.Debug|Win32.ActiveCfg = Debug|Win32
{6FAF820B-F436-46A2-A1DD-4A4B7025C3D0}.Debug|Win32.Build.0 = Debug|Win32
{6FAF820B-F436-46A2-A1DD-4A4B7025C3D0}.Release|Win32.ActiveCfg = Release|Win32
{6FAF820B-F436-46A2-A1DD-4A4B7025C3D0}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -1,91 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}</ProjectGuid>
<RootNamespace>endian_example</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\example\endian_example.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -1,90 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}</ProjectGuid>
<RootNamespace>endian_in_union_test</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\endian_in_union_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -1,92 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}</ProjectGuid>
<RootNamespace>endian_operations_test</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4552;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\endian_operations_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -1,91 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{74C201F3-8308-40BE-BC0F-24974DEAF405}</ProjectGuid>
<RootNamespace>endian_test</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\endian_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -1,91 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8420E151-B23B-4651-B526-6AB11EF1E278}</ProjectGuid>
<RootNamespace>scoped_enum_emulation_test</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\scoped_enum_emulation_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -1,46 +0,0 @@
// scoped_enum_emulation_test.cpp ----------------------------------------------------//
// Copyright Beman Dawes, 2009
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See documentation at http://www.boost.org/libs/utility/scoped_enum_emulation.html
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/detail/scoped_enum_emulation.hpp>
#include <boost/assert.hpp>
BOOST_SCOPED_ENUM_START(traffic_light) { red=0, yellow, green }; BOOST_SCOPED_ENUM_END
BOOST_SCOPED_ENUM_START(algae) { green=0, red, cyan }; BOOST_SCOPED_ENUM_END
struct color
{
BOOST_SCOPED_ENUM_START(value_t) { red, green, blue }; BOOST_SCOPED_ENUM_END
BOOST_SCOPED_ENUM(value_t) value;
};
void foo( BOOST_SCOPED_ENUM(algae) arg )
{
BOOST_ASSERT( arg == algae::cyan );
}
int main()
{
BOOST_SCOPED_ENUM(traffic_light) signal( traffic_light::red );
BOOST_SCOPED_ENUM(algae) sample( algae::red );
BOOST_ASSERT( signal == traffic_light::red );
BOOST_ASSERT( sample == algae::red );
foo( algae::cyan );
color tracker;
tracker.value = color::value_t::blue;
if (tracker.value == color::value_t::blue) return 0; // quiet warnings
return 0;
}
-42
View File
@@ -1,42 +0,0 @@
@echo off
echo Special version of boost_test for sandbox version of endian library.
xcopy /D %BOOST_TRUNK%\boost-build.jam ..\..\..\..
xcopy /D %BOOST_TRUNK%\boostcpp.jam ..\..\..\..
xcopy /D %BOOST_TRUNK%\Jamroot ..\..\..\..
set BOOST_BUILD_PATH=%BOOST_TRUNK%\tools\build\v2
if not $%1==$--help goto nohelp
echo Invoke: boost_test [-ts toolset] [bjam-options]
echo Default -ts is gcc-4.3,msvc-8.0,msvc-9.0express,msvc-10.0express
goto done
:nohelp
if $%1==$-ts goto toolset
echo Begin test processing...
bjam include=%BOOST_TRUNK% --v2 --dump-tests --toolset=gcc-4.3,msvc-8.0,msvc-9.0express,msvc-10.0express %* >bjam.log 2>&1
goto jam_log
:toolset
echo Begin test processing...
bjam include=%BOOST_TRUNK% --v2 --dump-tests --toolset=%2 %3 %4 %5 %6 %7 %8 %9 >bjam.log 2>&1
:jam_log
echo Begin log processing...
process_jam_log --v2 <bjam.log
start bjam.log
echo Begin compiler status processing...
call boost_relative_root
rem compiler_status barfs on a relative root, so convert it to absolute
dir %BOOST_RELATIVE_ROOT% | grep " Directory of " >%TEMP%\babsr.bat
%UTIL%\change %TEMP%\babsr.bat " Directory of " "set BOOST_TEST_ABS_ROOT=" >nul
%UTIL%\change %TEMP%\babsr.bat "C:" "c:" >nul
%UTIL%\change %TEMP%\babsr.bat "D:" "d:" >nul
%UTIL%\change %TEMP%\babsr.bat "E:" "e:" >nul
%UTIL%\change %TEMP%\babsr.bat "F:" "f:" >nul
call %TEMP%\babsr.bat
compiler_status --v2 %BOOST_TEST_ABS_ROOT% test_status.html test_links.html
start test_status.html
:done
-36
View File
@@ -1,36 +0,0 @@
echo create zip file...
echo must be run from libs\endian directory
if $%1 == $ goto error
rmdir /s \temp\%1 2>nul
pushd .
mkdir \temp\%1
cd \temp\%1
md boost\endian\detail
md libs\endian\doc
md libs\endian\example
md libs\endian\test
popd
copy ..\..\boost\endian\*.hpp \temp\%1\boost\endian
copy ..\..\boost\endian\detail\*.hpp \temp\%1\boost\endian\detail
copy ..\..\libs\endian\index.html \temp\%1\libs\endian
copy ..\..\libs\endian\INSTALL \temp\%1\libs\endian
copy ..\..\libs\endian\doc\*.html \temp\%1\libs\endian\doc
copy ..\..\libs\endian\example\*.cpp \temp\%1\libs\endian\example
copy ..\..\libs\endian\test\Jamfile.v2 \temp\%1\libs\endian\test
copy ..\..\libs\endian\test\*.cpp \temp\%1\libs\endian\test
pushd \temp
zip -r %1.zip %1
popd
move \temp\%1.zip .
goto done
:error
echo usage: zip-endian version
echo version will be used for both the .zip name and the highest level directory name
echo example: zip-endian endian-rc1
:done