mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
(libretro-db) Start using retro_endian.h functions directly
This commit is contained in:
parent
c21df1eb7d
commit
0d16768688
@ -16,13 +16,8 @@
|
||||
| (((uint64_t)(val) & 0xff00000000000000ULL) >> 56))
|
||||
#endif
|
||||
|
||||
|
||||
#define httobe64(x) (is_little_endian() ? swap64(x) : (x))
|
||||
#define httobe32(x) (is_little_endian() ? SWAP32(x) : (x))
|
||||
#define httobe16(x) (is_little_endian() ? SWAP16(x) : (x))
|
||||
|
||||
#define betoht16(x) httobe16(x)
|
||||
#define betoht32(x) httobe32(x)
|
||||
#define betoht64(x) httobe64(x)
|
||||
|
||||
#endif
|
||||
|
@ -103,7 +103,7 @@ int rmsgpack_write_array_header(RFILE *fd, uint32_t size)
|
||||
{
|
||||
if (retro_fwrite(fd, &MPF_ARRAY16, sizeof(MPF_ARRAY16)) == -1)
|
||||
goto error;
|
||||
tmp_i16 = httobe16(size);
|
||||
tmp_i16 = swap_if_little16(size);
|
||||
if (retro_fwrite(fd, (void *)(&tmp_i16), sizeof(uint16_t)) == -1)
|
||||
goto error;
|
||||
return sizeof(int8_t) + sizeof(uint16_t);
|
||||
@ -112,7 +112,7 @@ int rmsgpack_write_array_header(RFILE *fd, uint32_t size)
|
||||
if (retro_fwrite(fd, &MPF_ARRAY32, sizeof(MPF_ARRAY32)) == -1)
|
||||
goto error;
|
||||
|
||||
tmp_i32 = httobe32(size);
|
||||
tmp_i32 = swap_if_little32(size);
|
||||
|
||||
if (retro_fwrite(fd, (void *)(&tmp_i32), sizeof(uint32_t)) == -1)
|
||||
goto error;
|
||||
@ -139,13 +139,13 @@ int rmsgpack_write_map_header(RFILE *fd, uint32_t size)
|
||||
{
|
||||
if (retro_fwrite(fd, &MPF_MAP16, sizeof(MPF_MAP16)) == -1)
|
||||
goto error;
|
||||
tmp_i16 = httobe16(size);
|
||||
tmp_i16 = swap_if_little16(size);
|
||||
if (retro_fwrite(fd, (void *)(&tmp_i16), sizeof(uint16_t)) == -1)
|
||||
goto error;
|
||||
return sizeof(uint8_t) + sizeof(uint16_t);
|
||||
}
|
||||
|
||||
tmp_i32 = httobe32(size);
|
||||
tmp_i32 = swap_if_little32(size);
|
||||
if (retro_fwrite(fd, &MPF_MAP32, sizeof(MPF_MAP32)) == -1)
|
||||
goto error;
|
||||
if (retro_fwrite(fd, (void *)(&tmp_i32), sizeof(uint32_t)) == -1)
|
||||
@ -182,7 +182,7 @@ int rmsgpack_write_string(RFILE *fd, const char *s, uint32_t len)
|
||||
{
|
||||
if (retro_fwrite(fd, &MPF_STR16, sizeof(MPF_STR16)) == -1)
|
||||
goto error;
|
||||
tmp_i16 = httobe16(len);
|
||||
tmp_i16 = swap_if_little16(len);
|
||||
if (retro_fwrite(fd, &tmp_i16, sizeof(uint16_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint16_t);
|
||||
@ -191,7 +191,7 @@ int rmsgpack_write_string(RFILE *fd, const char *s, uint32_t len)
|
||||
{
|
||||
if (retro_fwrite(fd, &MPF_STR32, sizeof(MPF_STR32)) == -1)
|
||||
goto error;
|
||||
tmp_i32 = httobe32(len);
|
||||
tmp_i32 = swap_if_little32(len);
|
||||
if (retro_fwrite(fd, &tmp_i32, sizeof(uint32_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint32_t);
|
||||
@ -226,7 +226,7 @@ int rmsgpack_write_bin(RFILE *fd, const void *s, uint32_t len)
|
||||
{
|
||||
if (retro_fwrite(fd, &MPF_BIN16, sizeof(MPF_BIN16)) == -1)
|
||||
goto error;
|
||||
tmp_i16 = httobe16(len);
|
||||
tmp_i16 = swap_if_little16(len);
|
||||
if (retro_fwrite(fd, &tmp_i16, sizeof(uint16_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint16_t);
|
||||
@ -235,7 +235,7 @@ int rmsgpack_write_bin(RFILE *fd, const void *s, uint32_t len)
|
||||
{
|
||||
if (retro_fwrite(fd, &MPF_BIN32, sizeof(MPF_BIN32)) == -1)
|
||||
goto error;
|
||||
tmp_i32 = httobe32(len);
|
||||
tmp_i32 = swap_if_little32(len);
|
||||
if (retro_fwrite(fd, &tmp_i32, sizeof(uint32_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint32_t);
|
||||
@ -307,7 +307,7 @@ int rmsgpack_write_int(RFILE *fd, int64_t value)
|
||||
if (retro_fwrite(fd, &MPF_INT16, sizeof(MPF_INT16)) == -1)
|
||||
goto error;
|
||||
|
||||
tmp_i16 = httobe16(value);
|
||||
tmp_i16 = swap_if_little16(value);
|
||||
if (retro_fwrite(fd, &tmp_i16, sizeof(int16_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(int16_t);
|
||||
@ -317,7 +317,7 @@ int rmsgpack_write_int(RFILE *fd, int64_t value)
|
||||
if (retro_fwrite(fd, &MPF_INT32, sizeof(MPF_INT32)) == -1)
|
||||
goto error;
|
||||
|
||||
tmp_i32 = httobe32(value);
|
||||
tmp_i32 = swap_if_little32(value);
|
||||
if (retro_fwrite(fd, &tmp_i32, sizeof(int32_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(int32_t);
|
||||
@ -359,7 +359,7 @@ int rmsgpack_write_uint(RFILE *fd, uint64_t value)
|
||||
if (retro_fwrite(fd, &MPF_UINT16, sizeof(MPF_UINT16)) == -1)
|
||||
goto error;
|
||||
|
||||
tmp_i16 = httobe16(value);
|
||||
tmp_i16 = swap_if_little16(value);
|
||||
if (retro_fwrite(fd, &tmp_i16, sizeof(uint16_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint16_t);
|
||||
@ -369,7 +369,7 @@ int rmsgpack_write_uint(RFILE *fd, uint64_t value)
|
||||
if (retro_fwrite(fd, &MPF_UINT32, sizeof(MPF_UINT32)) == -1)
|
||||
goto error;
|
||||
|
||||
tmp_i32 = httobe32(value);
|
||||
tmp_i32 = swap_if_little32(value);
|
||||
if (retro_fwrite(fd, &tmp_i32, sizeof(uint32_t)) == -1)
|
||||
goto error;
|
||||
written += sizeof(uint32_t);
|
||||
@ -403,10 +403,10 @@ static int read_uint(RFILE *fd, uint64_t *out, size_t size)
|
||||
*out = *(uint8_t *)(&tmp);
|
||||
break;
|
||||
case 2:
|
||||
*out = betoht16(tmp);
|
||||
*out = swap_if_little16(tmp);
|
||||
break;
|
||||
case 4:
|
||||
*out = betoht32(tmp);
|
||||
*out = swap_if_little32(tmp);
|
||||
break;
|
||||
case 8:
|
||||
*out = betoht64(tmp);
|
||||
@ -433,11 +433,11 @@ static int read_int(RFILE *fd, int64_t *out, size_t size)
|
||||
*out = *((int8_t *)(&tmp64));
|
||||
break;
|
||||
case 2:
|
||||
tmp16 = betoht16(tmp64);
|
||||
tmp16 = swap_if_little16(tmp64);
|
||||
*out = *((int16_t *)(&tmp16));
|
||||
break;
|
||||
case 4:
|
||||
tmp32 = betoht32(tmp64);
|
||||
tmp32 = swap_if_little32(tmp64);
|
||||
*out = *((int32_t *)(&tmp32));
|
||||
break;
|
||||
case 8:
|
||||
|
Loading…
x
Reference in New Issue
Block a user