* strftime.c (rb_strftime_with_timespec): append formatted results
to the given string with expanding, and also deal with NUL chars.
* strftime.c (rb_strftime, rb_strftime_timespec): return formatted
string, not the length put in the given buffer.
* time.c (rb_strftime_alloc): no longer needs to retry with
reallocating buffers.
* time.c (time_strftime): no longer needs to split by NUL chars.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
are valid pointers.
maybe checking them in wdivmod0() is better manner, but I guess that
passing real dummy pointers may be faster than checking and branching
in wdivmod0().
this commit fixes SEGV on 32bit and LLP64 platforms.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (wmul): use MUL_OVERFLOW_FIXWV_P and only switch.
* time.c (wmul): use mul which has Fixnum optimization.
* time.c (rb_time_magnify): If WIDEVALUE_IS_WIDER, wmul() has the same
optimized logic, else mul() has also the similar logic for Fixnum.
* time.c (rb_time_unmagnify): almost ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (wquo): use quo which has Fixnum optimization.
* time.c (wdivmod0): added for WIDEVALUE_IS_WIDER.
* time.c (wdivmod): use wdivmod0 and divmodv.
divmodv has Fixnum optimization.
* time.c (wdiv): use wdivmod0 and div to avoid the use of divmodv which
calls id_quo whose return value is array.
* time.c (wmod): use wdivmod0 and mod to avoid the use of divmodv which
calls id_quo whose return value is array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
x == FIXNUM_MIN && y == -1. This must be a rare case and it is
expected compiler to handle well.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (quo): c can be Fixnum except a == FIXNUM_MIN && b == -1.
Such case can be optimized out because quo()'s argument is constant.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
but LONG_LONG is always defined as 64bit), or there's int128_t.
* internal.h (DL2NUM): defined if DLONG is defined.
* internal.h (rb_fix_mul_fix): defined for `Fixnum * Fixnum`.
* insns.def (opt_mul): use rb_fix_mul_fix().
* numeric.c (fix_mul): ditto.
* time.c (mul): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
define _BSD_SOURCE for time.h to define struct tm.tm_gmtoff.
* time.c: define _BSD_SOURCE at the top.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This recovers and improves performance of Marshal.dump/load on
Time objects compared to when we implemented generic ivars
entirely using st_table.
This also recovers some performance on other generic ivar objects,
but does not bring bring Marshal.dump/load performance up to
previous speeds.
benchmark results:
minimum results in each 10 measurements.
Execution time (sec)
name trunk geniv after
marshal_dump_flo 0.343 0.334 0.335
marshal_dump_load_geniv 0.487 0.527 0.495
marshal_dump_load_time 1.262 1.401 1.257
Speedup ratio: compare with the result of `trunk' (greater is better)
name geniv after
marshal_dump_flo 1.026 1.023
marshal_dump_load_geniv 0.925 0.985
marshal_dump_load_time 0.901 1.004
* include/ruby/intern.h (rb_generic_ivar_table): deprecate
* internal.h (rb_attr_delete): declare
* marshal.c (has_ivars): use rb_ivar_foreach
(w_ivar): ditto
(w_object): update for new interface
* time.c (time_mload): use rb_attr_delete
* variable.c (generic_ivar_delete): implement
(rb_ivar_delete): ditto
(rb_attr_delete): ditto
[ruby-core:69323] [Feature #11170]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* win32/rtname.cmd: support vcruntime140.dll.
* time.c (localtime_with_gmtoff_zone): MSVC14 doesn't have tzname and
daylight but have _tzname and _daylight.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (time_zone_name): should be US-ASCII only if all 7-bits,
otherwise locale encoding. [ruby-core:68230] [Bug #10887]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
VTM_ISDST_INITVAL. This bug is introduced at packing struct
vtm (r45155).
[ruby-core:67345] [Bug #10698] Reported by Boris Ruf.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
patch is from Kenichi Kamiya.
[ruby-dev:47539] [Bug #8679]
* test/ruby/test_time.rb: test for above.
patch is from Kenichi Kamiya.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
test/ruby/test_float.rb (test_sleep_with_Float) causes tv_nsec
to hit 1000000000 exactly. This bug is currently hidden from
our test by the platform-dependent native_cond_timeout
functions, but a future native_cond_timedwait implementation may
prefer relative timeouts to match ConditionVariable#wait
semantics more closely.
[Bug #10144]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
The removed comment is useful to understand the behind idea to
solve the year 2038 problem.
The broken link is replaced to refer the internet archive.
0eed69757d (commitcomment-7166665)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
and will output at least 4 digits as the year. Reported by Yury
Trofimenko [Bug #8941]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
reproduced in a few years. Reported by Federico Builes [Bug #10071]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (time_zone_name): remove unnecessary encoding and
conversion if it is 7bit-ascii only.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (vtm_add_offset): get rid of underflow of unsigned
integers. fix up r45155.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* time.c (month_arg, time_strftime): RSTRING_PTR() may not be
NUL-terminated.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We need to prevent vtm.zone from pointing to a GC-ed string buffer.
The rb_copy_generic_ivar call misses it because get_attr deleted it.
Thanks to nobu for the rb_str_new_frozen suggestion.
* time.c (time_mload): freeze and preserve marshal-loaded time zone
* test/ruby/test_time.rb: add test for GC on loaded object
[Bug #9652]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
add links to `Object#hash` to each #`hash` methods rdocs.
[Fixes GH-567]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e