2015-03-03 00:38:33 +08:00
|
|
|
/****************************************************************************
|
2017-01-27 01:05:12 +08:00
|
|
|
** Copyright (c) 2017, Fougue Ltd. <http://www.fougue.pro>
|
2016-07-05 18:46:22 +08:00
|
|
|
** All rights reserved.
|
2015-03-03 00:38:33 +08:00
|
|
|
**
|
2016-07-05 18:46:22 +08:00
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
2015-03-03 00:38:33 +08:00
|
|
|
**
|
2016-07-05 18:46:22 +08:00
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
**
|
|
|
|
** 2. Redistributions in binary form must reproduce the above
|
|
|
|
** copyright notice, this list of conditions and the following
|
|
|
|
** disclaimer in the documentation and/or other materials provided
|
|
|
|
** with the distribution.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2015-03-03 00:38:33 +08:00
|
|
|
****************************************************************************/
|
|
|
|
|
2015-03-05 01:25:51 +08:00
|
|
|
/*! \file endian.h
|
|
|
|
* Architecture endianness
|
2015-09-09 17:44:34 +08:00
|
|
|
*
|
|
|
|
* \addtogroup gmio_core
|
|
|
|
* @{
|
2015-03-05 01:25:51 +08:00
|
|
|
*/
|
|
|
|
|
2017-01-30 18:41:20 +08:00
|
|
|
#pragma once
|
2014-03-28 23:33:35 +08:00
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
|
2017-01-09 17:52:06 +08:00
|
|
|
/*! Common endianness (byte order) of computer memory */
|
2014-03-28 23:33:35 +08:00
|
|
|
enum gmio_endianness
|
|
|
|
{
|
2015-04-02 16:50:34 +08:00
|
|
|
/*! Other (unknown) byte-order */
|
|
|
|
GMIO_ENDIANNESS_UNKNOWN = 0,
|
|
|
|
|
2015-03-30 15:15:20 +08:00
|
|
|
/*! The least significant byte is stored at the lowest address. The other
|
|
|
|
* bytes follow in increasing order of significance */
|
2015-04-02 15:45:02 +08:00
|
|
|
GMIO_ENDIANNESS_LITTLE,
|
2015-03-30 15:15:20 +08:00
|
|
|
|
|
|
|
/*! The most significant byte is stored at the lowest address. The other
|
|
|
|
* bytes follow in decreasing order of significance */
|
2015-04-02 15:45:02 +08:00
|
|
|
GMIO_ENDIANNESS_BIG,
|
2014-03-28 23:33:35 +08:00
|
|
|
|
2015-03-20 15:53:20 +08:00
|
|
|
#ifdef GMIO_HOST_IS_BIG_ENDIAN
|
2015-04-02 15:45:02 +08:00
|
|
|
GMIO_ENDIANNESS_HOST = GMIO_ENDIANNESS_BIG
|
2015-03-20 15:53:20 +08:00
|
|
|
#else
|
2017-01-09 17:52:06 +08:00
|
|
|
/*! Endianness(byte order) used by the host computer for storing data in
|
|
|
|
* memory.
|
2015-03-20 16:07:02 +08:00
|
|
|
*
|
2017-01-09 17:52:06 +08:00
|
|
|
* Set at configure-time to either GMIO_ENDIANNESS_LITTLE or
|
|
|
|
* GMIO_ENDIANNESS_BIG */
|
2015-04-02 15:45:02 +08:00
|
|
|
GMIO_ENDIANNESS_HOST = GMIO_ENDIANNESS_LITTLE
|
2015-03-20 15:53:20 +08:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2015-03-13 18:07:07 +08:00
|
|
|
GMIO_C_LINKAGE_BEGIN
|
|
|
|
|
2014-03-28 23:33:35 +08:00
|
|
|
/*! Returns endianness (byte order) of the host's CPU architecture */
|
2016-03-11 19:43:30 +08:00
|
|
|
GMIO_API enum gmio_endianness gmio_host_endianness();
|
2014-03-28 23:33:35 +08:00
|
|
|
|
|
|
|
GMIO_C_LINKAGE_END
|
|
|
|
|
2015-09-09 17:44:34 +08:00
|
|
|
/*! @} */
|