mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
24acab6543
commit
9d099423e7
2 changed files with 24 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Fri May 17 22:02:15 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/socket/ifaddr.c: Use unsigned LONG_LONG to represent flags
|
||||||
|
because SunOS 5.11 (OpenIndiana) defines ifa_flags as uint64_t.
|
||||||
|
|
||||||
Fri May 17 21:47:00 2013 Zachary Scott <zachary@zacharyscott.net>
|
Fri May 17 21:47:00 2013 Zachary Scott <zachary@zacharyscott.net>
|
||||||
|
|
||||||
* cont.c: Typo in constant MAX_MACHINE_STACK_CACHE from '..MAHINE..'
|
* cont.c: Typo in constant MAX_MACHINE_STACK_CACHE from '..MAHINE..'
|
||||||
|
|
|
@ -1,6 +1,21 @@
|
||||||
#include "rubysocket.h"
|
#include "rubysocket.h"
|
||||||
|
|
||||||
#ifdef HAVE_GETIFADDRS
|
#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;
|
VALUE rb_cSockIfaddr;
|
||||||
|
|
||||||
typedef struct rb_ifaddr_tag rb_ifaddr_t;
|
typedef struct rb_ifaddr_tag rb_ifaddr_t;
|
||||||
|
@ -163,7 +178,7 @@ ifaddr_flags(VALUE self)
|
||||||
{
|
{
|
||||||
rb_ifaddr_t *rifaddr = get_ifaddr(self);
|
rb_ifaddr_t *rifaddr = get_ifaddr(self);
|
||||||
struct ifaddrs *ifa = rifaddr->ifaddr;
|
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
|
static void
|
||||||
ifaddr_inspect_flags(unsigned int flags, VALUE result)
|
ifaddr_inspect_flags(ifa_flags_t flags, VALUE result)
|
||||||
{
|
{
|
||||||
const char *sep = " ";
|
const char *sep = " ";
|
||||||
#define INSPECT_BIT(bit, name) \
|
#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
|
#ifdef IFF_UP
|
||||||
INSPECT_BIT(IFF_UP, "UP")
|
INSPECT_BIT(IFF_UP, "UP")
|
||||||
#endif
|
#endif
|
||||||
|
@ -303,7 +318,7 @@ ifaddr_inspect_flags(unsigned int flags, VALUE result)
|
||||||
#endif
|
#endif
|
||||||
#undef INSPECT_BIT
|
#undef INSPECT_BIT
|
||||||
if (flags) {
|
if (flags) {
|
||||||
rb_str_catf(result, "%s%#x", sep, flags);
|
rb_str_catf(result, "%s%#"PRIxIFAFLAGS, sep, flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue