Skip to content

Commit 111305c

Browse files
committed
Support SunOS 121. Check for ifaddrs in wscript for SunOS build.
1 parent a845bf7 commit 111305c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/platform_sunos.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
#include <net/if.h>
3737
#include <netinet/in.h>
3838
#include <arpa/inet.h>
39-
#include <ifaddrs.h>
39+
40+
#ifdef SUNOS_HAVE_IFADDRS
41+
# include <ifaddrs.h>
42+
#endif
4043

4144

4245

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

298301
Handle<Value> Platform::GetInterfaceAddresses() {
299302
HandleScope scope;
303+
304+
#ifndef SUNOS_HAVE_IFADDRS
305+
return ThrowException(Exception::Error(String::New(
306+
"This version of sunos doesn't support getifaddrs")));
307+
#else
300308
struct ::ifaddrs *addrs, *ent;
301309
struct ::sockaddr_in *in4;
302310
struct ::sockaddr_in6 *in6;
@@ -355,6 +363,8 @@ Handle<Value> Platform::GetInterfaceAddresses() {
355363
freeifaddrs(addrs);
356364

357365
return scope.Close(ret);
366+
367+
#endif // SUNOS_HAVE_IFADDRS
358368
}
359369

360370

wscript

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,17 @@ def configure(conf):
351351
conf.env.append_value('CPPFLAGS', '-DHAVE_MONOTONIC_CLOCK=0')
352352

353353
if sys.platform.startswith("sunos"):
354+
code = """
355+
#include <ifaddrs.h>
356+
int main(void) {
357+
struct ifaddrs hello;
358+
return 0;
359+
}
360+
"""
361+
362+
if conf.check_cc(msg="Checking for ifaddrs on solaris", fragment=code):
363+
conf.env.append_value('CPPFLAGS', '-DSUNOS_HAVE_IFADDRS')
364+
354365
if not conf.check(lib='socket', uselib_store="SOCKET"):
355366
conf.fatal("Cannot find socket library")
356367
if not conf.check(lib='nsl', uselib_store="NSL"):

0 commit comments

Comments
 (0)