mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
3 changed files with 15 additions and 7 deletions
|
@ -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>
|
||||
|
||||
* 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)
|
||||
{
|
||||
if (RSTRING_LEN(data) == sizeof(struct timeval)) {
|
||||
struct timeval s;
|
||||
struct timeval tv;
|
||||
time_t time;
|
||||
struct tm tm;
|
||||
char buf[32];
|
||||
memcpy((char*)&s, RSTRING_PTR(data), sizeof(s));
|
||||
tm = *localtime(&s.tv_sec);
|
||||
memcpy((char*)&tv, RSTRING_PTR(data), sizeof(tv));
|
||||
time = tv.tv_sec;
|
||||
tm = *localtime(&time);
|
||||
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;
|
||||
}
|
||||
else {
|
||||
|
@ -790,7 +792,7 @@ ancillary_inspect(VALUE self)
|
|||
# if defined(SOL_SOCKET)
|
||||
case SOL_SOCKET:
|
||||
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;
|
||||
# endif
|
||||
# if defined(SCM_RIGHTS) /* 4.4BSD */
|
||||
|
|
|
@ -274,12 +274,12 @@ class TestSocket < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
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")
|
||||
stamp = nil
|
||||
Addrinfo.udp("127.0.0.1", 0).bind {|s1|
|
||||
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
|
||||
msg, addr, rflags, stamp = s1.recvmsg
|
||||
assert_equal("a", msg)
|
||||
|
|
Loading…
Reference in a new issue