1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

assert system is little-endian

This commit is contained in:
winlin 2014-03-19 10:38:02 +08:00
parent b58ab508f9
commit 2eeb289c2f
4 changed files with 27 additions and 0 deletions

View file

@ -85,3 +85,22 @@ std::string srs_dns_resolve(std::string host)
return ipv4;
}
bool srs_is_little_endian()
{
// convert to network(big-endian) order, if not equals,
// the system is little-endian, so need to convert the int64
static int little_endian_check = -1;
if(little_endian_check == -1) {
union {
int32_t i;
int8_t c;
} little_check_union;
little_check_union.i = 0x01;
little_endian_check = little_check_union.c;
}
return (little_endian_check == 1);
}