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:
parent
b58ab508f9
commit
2eeb289c2f
4 changed files with 27 additions and 0 deletions
|
@ -85,3 +85,22 @@ std::string srs_dns_resolve(std::string host)
|
||||||
return ipv4;
|
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);
|
extern std::string srs_replace(std::string str, std::string old_str, std::string new_str);
|
||||||
// dns resolve utility, return the resolved ip address.
|
// dns resolve utility, return the resolved ip address.
|
||||||
extern std::string srs_dns_resolve(std::string host);
|
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
|
* disable copy constructor of class
|
||||||
|
|
|
@ -30,6 +30,9 @@ SrsStream::SrsStream()
|
||||||
{
|
{
|
||||||
p = bytes = NULL;
|
p = bytes = NULL;
|
||||||
size = 0;
|
size = 0;
|
||||||
|
|
||||||
|
// TODO: support both little and big endian.
|
||||||
|
srs_assert(srs_is_little_endian());
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStream::~SrsStream()
|
SrsStream::~SrsStream()
|
||||||
|
|
|
@ -53,6 +53,9 @@ void handler(int signo)
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
// TODO: support both little and big endian.
|
||||||
|
srs_assert(srs_is_little_endian());
|
||||||
|
|
||||||
#ifdef SRS_GPERF_MP
|
#ifdef SRS_GPERF_MP
|
||||||
HeapProfilerStart("gperf.srs.gmp");
|
HeapProfilerStart("gperf.srs.gmp");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue