Ref: https://github.com/ruby/ruby/pull/10872
These should be the last internal uses of the old `Data` API
inside Ruby itself. Some use remain in a couple default gems.
The current code would define ruby_qsort as a wrapper of qsort_s
when it is available. When both qsort_s and POSIX (GNU) qsort_r
are available, we should call qsort_r directly instead, and
the qsort_s wrapper is redundant.
Saves comitters' daily life by avoid #include-ing everything from
internal.h to make each file do so instead. This would significantly
speed up incremental builds.
We take the following inclusion order in this changeset:
1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very
first thing among everything).
2. RUBY_EXTCONF_H if any.
3. Standard C headers, sorted alphabetically.
4. Other system headers, maybe guarded by #ifdef
5. Everything else, sorted alphabetically.
Exceptions are those win32-related headers, which tend not be self-
containing (headers have inclusion order dependencies).
The decrements overflow and these variables remain ~0 when leaving the
while loops. They are not fatal by accident, but better replace with
ordinal for loops.
See also: https://travis-ci.org/ruby/ruby/jobs/452218871#L3246
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
The decrements overflow and these variables remain ~0 when leaving the
while loops. They are not fatal by accident, but better replace with
ordinal for loops.
See also: https://travis-ci.org/ruby/ruby/jobs/452218871#L3246
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c (ruby_qsort): __STDC_VERSION__ may not be defined even if it
is available. fixed duplicate definitions when qsort_s is available
on non-Windows platforms. [ruby-core:88921] [Bug #15091]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.ac: macro for C11 to use qsort_s.
* util.c (ruby_qsort): fix for C11 qsort_s. the comparison function
for MSVCRT qsort_s is compatible with BSD qsort_r, but not with C11
qsort_s, in spite of its name.
note that mingw defines __STDC_VERSION__ but uses qsort_s in MSVCRT,
so the MSVCRT block needs to preced the C11 block.
[ruby-core:88899] [Bug #15091]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Because NaCl and PNaCl are already sunset status.
see https://bugs.chromium.org/p/chromium/issues/detail?id=239656#c160
configure.ac: Patch for this file was provided by @nobu.
[Feature #14041][ruby-core:83497][fix GH-1726]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Apply some part of http://www.netlib.org/fp/dtoa.c with my eyes...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c (ruby_strtod): do not underflow only by preceeding zeros,
which may be canceled out by the exponent.
http://twitter.com/kazuho/status/753829998767714305
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c (ruby_dtoa): [EXPERIMENTAL] adjust the case that the
Float value is close to the exact but unrepresentable middle
value of two values in the given precision, as r55604.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c (ruby_qsort): use qsort_s if available, for Microsoft
Visual Studio 2005 (msvcr80.dll) and mingw.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
allocate memory. This is pointed out by Facebook's Infer.
* gc.c (gc_prof_setup_new_record): ditto.
* regparse.c (parse_regexp): ditto.
* util.c (MALLOC): use xmalloc and xfree like above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c, io.c, util.c: prefer rb_syserr_fail with saved errno
over setting errno then call rb_sys_fail, not to be clobbered
potentially and to reduce thread local errno accesses.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c (ruby_scan_digits): fix the return length off-by-one
error when the length is given and the last char is a digit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (iseq_compile_each): out of range NTH_REF is always
nil.
* parse.y (parse_numvar): check overflow of NTH_REF and range.
[ruby-core:69393] [Bug #11192]
* util.c (ruby_scan_digits): make public and add length parameter.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c (ruby_getcwd): POSIX.1-2001 extends getcwd(3) as it
allocates the buffer if the argument is NULL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
BSD version has different prototype.
* util.h: use qsort_r() as ruby_qsort() if it is GNU version.
* util.c: define ruby_qsort() if needed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c (ruby_qsort): fix potential stack overflow on a large
machine. based on the patch by Conrad Irwin <conrad.irwin AT
gmail.com> at [ruby-core:51816]. [Bug #7772]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c (ruby_strtod): ignore too long fraction part, which does not
affect the result.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e