Skip to content

Commit

Permalink
For #1547, remove the SRS_OSX macro in code
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jan 20, 2020
1 parent 024433f commit a6fe4e8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 110 deletions.
2 changes: 1 addition & 1 deletion trunk/auto/depends.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function Ubuntu_prepare()
if [[ $SRS_VALGRIND == YES ]]; then
if [[ ! -f /usr/include/valgrind/valgrind.h ]]; then
echo "Installing valgrind-dev."
require_sudoer "sudo apt-get install -y --force-yes valgrind-dev"
require_sudoer "sudo apt-get install -y --force-yes valgrind-dbg"
sudo apt-get install -y --force-yes valgrind-dev; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "The valgrind-dev is installed."
fi
Expand Down
92 changes: 6 additions & 86 deletions trunk/src/app/srs_app_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
#include <sys/wait.h>
#include <netdb.h>

#ifdef SRS_OSX
#include <sys/sysctl.h>
#endif
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
Expand Down Expand Up @@ -329,7 +326,6 @@ SrsProcSystemStat* srs_get_system_proc_stat()

bool get_proc_system_stat(SrsProcSystemStat& r)
{
#ifndef SRS_OSX
FILE* f = fopen("/proc/stat", "r");
if (f == NULL) {
srs_warn("open system cpu stat failed, ignore");
Expand Down Expand Up @@ -359,18 +355,14 @@ bool get_proc_system_stat(SrsProcSystemStat& r)
}

fclose(f);
#else
// TODO: FIXME: impelments it.
#endif


r.ok = true;

return true;
}

bool get_proc_self_stat(SrsProcSelfStat& r)
{
#ifndef SRS_OSX
FILE* f = fopen("/proc/self/stat", "r");
if (f == NULL) {
srs_warn("open self cpu stat failed, ignore");
Expand All @@ -397,10 +389,7 @@ bool get_proc_self_stat(SrsProcSelfStat& r)
&r.guest_time, &r.cguest_time);

fclose(f);
#else
// TODO: FIXME: impelments it.
#endif


r.ok = true;

return true;
Expand Down Expand Up @@ -495,7 +484,6 @@ SrsDiskStat* srs_get_disk_stat()

bool srs_get_disk_vmstat_stat(SrsDiskStat& r)
{
#ifndef SRS_OSX
FILE* f = fopen("/proc/vmstat", "r");
if (f == NULL) {
srs_warn("open vmstat failed, ignore");
Expand All @@ -515,10 +503,7 @@ bool srs_get_disk_vmstat_stat(SrsDiskStat& r)
}

fclose(f);
#else
// TODO: FIXME: impelments it.
#endif


r.ok = true;

return true;
Expand All @@ -535,7 +520,6 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r)
return true;
}

#ifndef SRS_OSX
FILE* f = fopen("/proc/diskstats", "r");
if (f == NULL) {
srs_warn("open vmstat failed, ignore");
Expand Down Expand Up @@ -600,10 +584,7 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r)
}

fclose(f);
#else
// TODO: FIXME: impelments it.
#endif


r.ok = true;

return true;
Expand Down Expand Up @@ -695,7 +676,6 @@ void srs_update_meminfo()
{
SrsMemInfo& r = _srs_system_meminfo;

#ifndef SRS_OSX
FILE* f = fopen("/proc/meminfo", "r");
if (f == NULL) {
srs_warn("open meminfo failed, ignore");
Expand All @@ -721,10 +701,7 @@ void srs_update_meminfo()
}

fclose(f);
#else
// TODO: FIXME: impelments it.
#endif


r.sample_time = srsu2ms(srs_get_system_time());
r.MemActive = r.MemTotal - r.MemFree;
r.RealInUse = r.MemActive - r.Buffers - r.Cached;
Expand Down Expand Up @@ -791,7 +768,6 @@ void srs_update_platform_info()

r.srs_startup_time = srsu2ms(srs_get_system_startup_time());

#ifndef SRS_OSX
if (true) {
FILE* f = fopen("/proc/uptime", "r");
if (f == NULL) {
Expand Down Expand Up @@ -820,43 +796,6 @@ void srs_update_platform_info()

fclose(f);
}
#else
// man 3 sysctl
if (true) {
struct timeval tv;
size_t len = sizeof(timeval);

int mib[2];
mib[0] = CTL_KERN;
mib[1] = KERN_BOOTTIME;
if (sysctl(mib, 2, &tv, &len, NULL, 0) < 0) {
srs_warn("sysctl boottime failed, ignore");
return;
}

time_t bsec = tv.tv_sec;
time_t csec = ::time(NULL);
r.os_uptime = difftime(csec, bsec);
}

// man 3 sysctl
if (true) {
struct loadavg la;
size_t len = sizeof(loadavg);

int mib[2];
mib[0] = CTL_VM;
mib[1] = VM_LOADAVG;
if (sysctl(mib, 2, &la, &len, NULL, 0) < 0) {
srs_warn("sysctl loadavg failed, ignore");
return;
}

r.load_one_minutes = (double)la.ldavg[0] / la.fscale;
r.load_five_minutes = (double)la.ldavg[1] / la.fscale;
r.load_fifteen_minutes = (double)la.ldavg[2] / la.fscale;
}
#endif

r.ok = true;
}
Expand Down Expand Up @@ -903,7 +842,6 @@ int srs_get_network_devices_count()

void srs_update_network_devices()
{
#ifndef SRS_OSX
if (true) {
FILE* f = fopen("/proc/net/dev", "r");
if (f == NULL) {
Expand Down Expand Up @@ -940,9 +878,6 @@ void srs_update_network_devices()

fclose(f);
}
#else
// TODO: FIXME: impelments it.
#endif
}

SrsNetworkRtmpServer::SrsNetworkRtmpServer()
Expand Down Expand Up @@ -990,7 +925,6 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps)
int nb_tcp_mem = 0;
int nb_udp4 = 0;

#ifndef SRS_OSX
if (true) {
FILE* f = fopen("/proc/net/sockstat", "r");
if (f == NULL) {
Expand Down Expand Up @@ -1020,20 +954,9 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps)

fclose(f);
}
#else
// TODO: FIXME: impelments it.
nb_socks = 0;
nb_tcp4_hashed = 0;
nb_tcp_orphans = 0;
nb_tcp_tws = 0;
nb_tcp_total = 0;
nb_tcp_mem = 0;
nb_udp4 = 0;
#endif

int nb_tcp_estab = 0;

#ifndef SRS_OSX
if (true) {
FILE* f = fopen("/proc/net/snmp", "r");
if (f == NULL) {
Expand Down Expand Up @@ -1063,10 +986,7 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps)

fclose(f);
}
#else
// TODO: FIXME: impelments it.
#endif


// @see: https://github.com/shemminger/iproute2/blob/master/misc/ss.c
// TODO: FIXME: ignore the slabstat, @see: get_slabstat()
if (true) {
Expand Down
15 changes: 2 additions & 13 deletions trunk/src/main/srs_main_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,6 @@ void show_macro_features()
if (true) {
stringstream ss;
ss << "SRS on ";
#ifdef SRS_OSX
ss << "OSX";
#endif
#ifdef SRS_PI
ss << "RespberryPi";
#endif
#ifdef SRS_CUBIE
ss << "CubieBoard";
#endif

#if defined(__amd64__)
ss << " amd64";
#endif
Expand All @@ -258,9 +248,8 @@ void show_macro_features()
#if defined(__arm__)
ss << "arm";
#endif

#ifndef SRS_OSX
ss << ", glibc" << (int)__GLIBC__ << "." << (int)__GLIBC_MINOR__;
#if defined(__aarch64__)
ss << " aarch64";
#endif

ss << ", conf:" << _srs_config->config() << ", limit:" << _srs_config->get_max_connections()
Expand Down
5 changes: 0 additions & 5 deletions trunk/src/utest/srs_utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,18 @@ ISrsThreadContext* _srs_context = new ISrsThreadContext();
SrsConfig* _srs_config = NULL;
SrsServer* _srs_server = NULL;

// Disable coroutine test for OSX.
#if !defined(SRS_OSX)
#include <srs_app_st.hpp>
#endif

// Initialize global settings.
srs_error_t prepare_main() {
srs_error_t err = srs_success;

#if !defined(SRS_OSX)
if ((err = srs_st_init()) != srs_success) {
return srs_error_wrap(err, "init st");
}

srs_freep(_srs_context);
_srs_context = new SrsThreadContext();
#endif

return err;
}
Expand Down
5 changes: 0 additions & 5 deletions trunk/src/utest/srs_utest_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ using namespace std;
#include <srs_kernel_error.hpp>
#include <srs_app_fragment.hpp>

// Disable coroutine test for OSX.
#if !defined(SRS_OSX)

#include <srs_app_st.hpp>

VOID TEST(AppCoroutineTest, Dummy)
Expand Down Expand Up @@ -375,5 +372,3 @@ VOID TEST(AppFragmentTest, CheckDuration)
}
}

#endif

0 comments on commit a6fe4e8

Please sign in to comment.