Skip to content

Commit

Permalink
Support SunOS 121. Check for ifaddrs in wscript for SunOS build.
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jul 6, 2011
1 parent a845bf7 commit 111305c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/platform_sunos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ifaddrs.h>

#ifdef SUNOS_HAVE_IFADDRS
# include <ifaddrs.h>
#endif



Expand Down Expand Up @@ -297,6 +300,11 @@ int Platform::GetLoadAvg(Local<Array> *loads) {

Handle<Value> Platform::GetInterfaceAddresses() {
HandleScope scope;

#ifndef SUNOS_HAVE_IFADDRS
return ThrowException(Exception::Error(String::New(
"This version of sunos doesn't support getifaddrs")));
#else
struct ::ifaddrs *addrs, *ent;
struct ::sockaddr_in *in4;
struct ::sockaddr_in6 *in6;
Expand Down Expand Up @@ -355,6 +363,8 @@ Handle<Value> Platform::GetInterfaceAddresses() {
freeifaddrs(addrs);

return scope.Close(ret);

#endif // SUNOS_HAVE_IFADDRS
}


Expand Down
11 changes: 11 additions & 0 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,17 @@ def configure(conf):
conf.env.append_value('CPPFLAGS', '-DHAVE_MONOTONIC_CLOCK=0')

if sys.platform.startswith("sunos"):
code = """
#include <ifaddrs.h>
int main(void) {
struct ifaddrs hello;
return 0;
}
"""

if conf.check_cc(msg="Checking for ifaddrs on solaris", fragment=code):
conf.env.append_value('CPPFLAGS', '-DSUNOS_HAVE_IFADDRS')

if not conf.check(lib='socket', uselib_store="SOCKET"):
conf.fatal("Cannot find socket library")
if not conf.check(lib='nsl', uselib_store="NSL"):
Expand Down

0 comments on commit 111305c

Please sign in to comment.