* ext/socket/ancdata.c (inspect_timeval_as_abstime): use time_t
variable to avoid a warning on environments which use long as tv_sec as NetBSD. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1a1990df71
commit
a0e3e8e4d1
@ -1,3 +1,9 @@
|
|||||||
|
Mon Feb 23 20:18:49 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/socket/ancdata.c (inspect_timeval_as_abstime): use time_t
|
||||||
|
variable to avoid a warning on environments which use long as
|
||||||
|
tv_sec as NetBSD.
|
||||||
|
|
||||||
Mon Feb 23 15:53:30 2009 Akinori MUSHA <knu@iDaemons.org>
|
Mon Feb 23 15:53:30 2009 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
* array.c (rb_ary_index, rb_ary_rindex): We know that argc is not
|
* array.c (rb_ary_index, rb_ary_rindex): We know that argc is not
|
||||||
|
@ -705,13 +705,15 @@ static int
|
|||||||
inspect_timeval_as_abstime(int level, int optname, VALUE data, VALUE ret)
|
inspect_timeval_as_abstime(int level, int optname, VALUE data, VALUE ret)
|
||||||
{
|
{
|
||||||
if (RSTRING_LEN(data) == sizeof(struct timeval)) {
|
if (RSTRING_LEN(data) == sizeof(struct timeval)) {
|
||||||
struct timeval s;
|
struct timeval tv;
|
||||||
|
time_t time;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
char buf[32];
|
char buf[32];
|
||||||
memcpy((char*)&s, RSTRING_PTR(data), sizeof(s));
|
memcpy((char*)&tv, RSTRING_PTR(data), sizeof(tv));
|
||||||
tm = *localtime(&s.tv_sec);
|
time = tv.tv_sec;
|
||||||
|
tm = *localtime(&time);
|
||||||
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm);
|
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm);
|
||||||
rb_str_catf(ret, " %s.%06ld", buf, (long)s.tv_usec);
|
rb_str_catf(ret, " %s.%06ld", buf, (long)tv.tv_usec);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -790,7 +792,7 @@ ancillary_inspect(VALUE self)
|
|||||||
# if defined(SOL_SOCKET)
|
# if defined(SOL_SOCKET)
|
||||||
case SOL_SOCKET:
|
case SOL_SOCKET:
|
||||||
switch (type) {
|
switch (type) {
|
||||||
# if defined(SCM_TIMESTAMP) /* GNU/Linux, MacOS X, Solaris */
|
# if defined(SCM_TIMESTAMP) /* GNU/Linux, FreeBSD, NetBSD, OpenBSD, MacOS X, Solaris */
|
||||||
case SCM_TIMESTAMP: inspected = inspect_timeval_as_abstime(level, type, data, ret); break;
|
case SCM_TIMESTAMP: inspected = inspect_timeval_as_abstime(level, type, data, ret); break;
|
||||||
# endif
|
# endif
|
||||||
# if defined(SCM_RIGHTS) /* 4.4BSD */
|
# if defined(SCM_RIGHTS) /* 4.4BSD */
|
||||||
|
@ -274,12 +274,12 @@ class TestSocket < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_timestamp
|
def test_timestamp
|
||||||
return if /linux|solaris|darwin/ !~ RUBY_PLATFORM
|
return if /linux|freebsd|netbsd|openbsd|solaris|darwin/ !~ RUBY_PLATFORM
|
||||||
t1 = Time.now.strftime("%Y-%m-%d")
|
t1 = Time.now.strftime("%Y-%m-%d")
|
||||||
stamp = nil
|
stamp = nil
|
||||||
Addrinfo.udp("127.0.0.1", 0).bind {|s1|
|
Addrinfo.udp("127.0.0.1", 0).bind {|s1|
|
||||||
Addrinfo.udp("127.0.0.1", 0).bind {|s2|
|
Addrinfo.udp("127.0.0.1", 0).bind {|s2|
|
||||||
s1.setsockopt(:SOCKET, :SO_TIMESTAMP, true)
|
s1.setsockopt(:SOCKET, :TIMESTAMP, true)
|
||||||
s2.send "a", 0, s1.local_address
|
s2.send "a", 0, s1.local_address
|
||||||
msg, addr, rflags, stamp = s1.recvmsg
|
msg, addr, rflags, stamp = s1.recvmsg
|
||||||
assert_equal("a", msg)
|
assert_equal("a", msg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user