summaryrefslogtreecommitdiff
path: root/ext/socket/ifaddr.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-17 13:04:17 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-17 13:04:17 +0000
commit9d099423e784be8a5df88db9b6ea839db99c4765 (patch)
tree785de34b60221af3a2c1774ff48bceffb318dc05 /ext/socket/ifaddr.c
parent24acab6543933e1e0c6a02af3c35f57867150548 (diff)
* ext/socket/ifaddr.c: Use unsigned LONG_LONG to represent flags
because SunOS 5.11 (OpenIndiana) defines ifa_flags as uint64_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/ifaddr.c')
-rw-r--r--ext/socket/ifaddr.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/ext/socket/ifaddr.c b/ext/socket/ifaddr.c
index 2e9d354..5783dfc 100644
--- a/ext/socket/ifaddr.c
+++ b/ext/socket/ifaddr.c
@@ -1,6 +1,21 @@
#include "rubysocket.h"
#ifdef HAVE_GETIFADDRS
+
+/*
+ * ifa_flags is usually unsigned int.
+ * However it is uint64_t on SunOS 5.11 (OpenIndiana).
+ */
+#ifdef HAVE_LONG_LONG
+typedef unsigned LONG_LONG ifa_flags_t;
+#define PRIxIFAFLAGS PRI_LL_PREFIX"x"
+#define IFAFLAGS2NUM(flags) ULL2NUM(flags)
+#else
+typedef unsigned int ifa_flags_t;
+#define PRIxIFAFLAGS "x"
+#define IFAFLAGS2NUM(flags) UINT2NUM(flags)
+#endif
+
VALUE rb_cSockIfaddr;
typedef struct rb_ifaddr_tag rb_ifaddr_t;
@@ -163,7 +178,7 @@ ifaddr_flags(VALUE self)
{
rb_ifaddr_t *rifaddr = get_ifaddr(self);
struct ifaddrs *ifa = rifaddr->ifaddr;
- return UINT2NUM(ifa->ifa_flags);
+ return IFAFLAGS2NUM(ifa->ifa_flags);
}
/*
@@ -239,11 +254,11 @@ ifaddr_dstaddr(VALUE self)
}
static void
-ifaddr_inspect_flags(unsigned int flags, VALUE result)
+ifaddr_inspect_flags(ifa_flags_t flags, VALUE result)
{
const char *sep = " ";
#define INSPECT_BIT(bit, name) \
- if (flags & (bit)) { rb_str_catf(result, "%s" name, sep); flags &= ~(bit); sep = ","; }
+ if (flags & (bit)) { rb_str_catf(result, "%s" name, sep); flags &= ~(ifa_flags_t)(bit); sep = ","; }
#ifdef IFF_UP
INSPECT_BIT(IFF_UP, "UP")
#endif
@@ -303,7 +318,7 @@ ifaddr_inspect_flags(unsigned int flags, VALUE result)
#endif
#undef INSPECT_BIT
if (flags) {
- rb_str_catf(result, "%s%#x", sep, flags);
+ rb_str_catf(result, "%s%#"PRIxIFAFLAGS, sep, flags);
}
}