winlin

assert system is little-endian

... ... @@ -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);
}
... ...
... ... @@ -99,6 +99,8 @@ extern void srs_update_system_time_ms();
extern std::string srs_replace(std::string str, std::string old_str, std::string new_str);
// dns resolve utility, return the resolved ip address.
extern std::string srs_dns_resolve(std::string host);
// whether system is little endian
extern bool srs_is_little_endian();
/**
* disable copy constructor of class
... ...
... ... @@ -30,6 +30,9 @@ SrsStream::SrsStream()
{
p = bytes = NULL;
size = 0;
// TODO: support both little and big endian.
srs_assert(srs_is_little_endian());
}
SrsStream::~SrsStream()
... ...
... ... @@ -53,6 +53,9 @@ void handler(int signo)
int main(int argc, char** argv)
{
int ret = ERROR_SUCCESS;
// TODO: support both little and big endian.
srs_assert(srs_is_little_endian());
#ifdef SRS_GPERF_MP
HeapProfilerStart("gperf.srs.gmp");
... ...