gmio_core: prefix values of gmio_endianness with GMIO_ENDIANNESS

This commit is contained in:
Hugues Delorme 2015-04-02 09:45:02 +02:00
parent 2929ea45c5
commit f09fcaec53
6 changed files with 21 additions and 18 deletions

View File

@ -31,9 +31,9 @@ gmio_endianness_t gmio_host_endianness()
conv.integer = 0x01020408;
if (conv.bytes[0] == 0x08 && conv.bytes[3] == 0x01)
return GMIO_LITTLE_ENDIAN;
return GMIO_ENDIANNESS_LITTLE;
if (conv.bytes[0] == 0x01 && conv.bytes[3] == 0x08)
return GMIO_BIG_ENDIAN;
return GMIO_OTHER_ENDIAN;
return GMIO_ENDIANNESS_BIG;
return GMIO_ENDIANNESS_OTHER;
}

View File

@ -27,25 +27,25 @@ enum gmio_endianness
{
/*! The least significant byte is stored at the lowest address. The other
* bytes follow in increasing order of significance */
GMIO_LITTLE_ENDIAN,
GMIO_ENDIANNESS_LITTLE,
/*! The most significant byte is stored at the lowest address. The other
* bytes follow in decreasing order of significance */
GMIO_BIG_ENDIAN,
GMIO_ENDIANNESS_BIG,
/*! Other (unknown) byte-order */
GMIO_OTHER_ENDIAN,
GMIO_ENDIANNESS_OTHER,
#ifdef GMIO_HOST_IS_BIG_ENDIAN
GMIO_HOST_ENDIANNESS = GMIO_BIG_ENDIAN
GMIO_ENDIANNESS_HOST = GMIO_ENDIANNESS_BIG
#else
/*! Defines the endianness(byte order) used by the host computer for
* storing data in memory.
*
* It is set at configure-time to either GMIO_LITTLE_ENDIAN or
* GMIO_BIG_ENDIAN
* It is set at configure-time to either GMIO_ENDIANNESS_LITTLE or
* GMIO_ENDIANNESS_BIG
*/
GMIO_HOST_ENDIANNESS = GMIO_LITTLE_ENDIAN
GMIO_ENDIANNESS_HOST = GMIO_ENDIANNESS_LITTLE
#endif
};

View File

@ -53,8 +53,11 @@ gmio_bool_t gmio_stlb_check_params(int *error,
if (trsf->buffer.size < GMIO_STLB_MIN_CONTENTS_SIZE)
*error = GMIO_INVALID_BUFFER_SIZE_ERROR;
if (byte_order != GMIO_LITTLE_ENDIAN && byte_order != GMIO_BIG_ENDIAN)
if (byte_order != GMIO_ENDIANNESS_LITTLE
&& byte_order != GMIO_ENDIANNESS_BIG)
{
*error = GMIO_STLB_UNSUPPORTED_BYTE_ORDER_ERROR;
}
return gmio_no_error(*error);
}

View File

@ -61,11 +61,11 @@ int gmio_stl_read(gmio_transfer_t *trsf, gmio_stl_mesh_creator_t *creator)
break;
}
case GMIO_STL_BINARY_BE_FORMAT: {
error = gmio_stlb_read(trsf, creator, GMIO_BIG_ENDIAN);
error = gmio_stlb_read(trsf, creator, GMIO_ENDIANNESS_BIG);
break;
}
case GMIO_STL_BINARY_LE_FORMAT: {
error = gmio_stlb_read(trsf, creator, GMIO_LITTLE_ENDIAN);
error = gmio_stlb_read(trsf, creator, GMIO_ENDIANNESS_LITTLE);
break;
}
case GMIO_STL_UNKNOWN_FORMAT: {

View File

@ -90,7 +90,7 @@ int gmio_stlb_read(
return error;
/* Initialize rparams */
if (byte_order != GMIO_HOST_ENDIANNESS)
if (byte_order != GMIO_ENDIANNESS_HOST)
rparams.fix_endian_func = gmio_stl_triangle_bswap;
/* Read header */
@ -108,7 +108,7 @@ int gmio_stlb_read(
}
memcpy(&total_facet_count, buffer_ptr, sizeof(uint32_t));
if (byte_order != GMIO_HOST_ENDIANNESS)
if (byte_order != GMIO_ENDIANNESS_HOST)
total_facet_count = gmio_uint32_bswap(total_facet_count);
/* Callback to notify triangle count and header data */

View File

@ -74,7 +74,7 @@ int gmio_stlb_write(
{
/* Constants */
const gmio_endianness_t byte_order =
options != NULL ? options->byte_order : GMIO_HOST_ENDIANNESS;
options != NULL ? options->byte_order : GMIO_ENDIANNESS_HOST;
const uint8_t* header_data =
options != NULL ? options->header_data : NULL;
const uint32_t facet_count =
@ -92,7 +92,7 @@ int gmio_stlb_write(
return error;
/* Initialize wparams */
if (byte_order != GMIO_HOST_ENDIANNESS)
if (byte_order != GMIO_ENDIANNESS_HOST)
wparams.fix_endian_func = gmio_stl_triangle_bswap;
wparams.facet_count = gmio_size_to_uint32(
trsf->buffer.size / GMIO_STLB_TRIANGLE_RAWSIZE);
@ -110,7 +110,7 @@ int gmio_stlb_write(
}
/* Write facet count */
if (byte_order == GMIO_LITTLE_ENDIAN)
if (byte_order == GMIO_ENDIANNESS_LITTLE)
gmio_encode_uint32_le(facet_count, buffer_ptr);
else
gmio_encode_uint32_be(facet_count, buffer_ptr);