summaryrefslogtreecommitdiff
path: root/util.c
AgeCommit message (Collapse)Author
2021-03-13merge revision(s) ↵NARUSE, Yui
63abb5c227e5c20d18d0debf699251da93ca64b5,34d02631e71209b12abb69d0114601027e485bc9,2adbf01ae14c0a4cf190b7c969b91726966a0e0f,3acc81d9e41b18380b9e0168fe2b5e5e0c727256: [Backport #17612] dtoa.c: make compilable independently Except for `-Dxmalloc=malloc -Dxfree=free`. --- missing/dtoa.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) dtoa.c: constified clang seems to locate never modified local data in the const segment implicitly. --- missing/dtoa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) dtoa.c: make thread-safe by using atomic CAS --- common.mk | 2 ++ missing/dtoa.c | 75 ++++++++++++++++++++++++++++++++++++++++++---------------- util.c | 1 + 3 files changed, 57 insertions(+), 21 deletions(-) Fixed race in dtoa [Bug #17612] Fixed the race condition when replacing `freelist` entry with its chained next element. At acquiring an entry, hold the entry once with the special value, then release by replacing it with the next element again after acquired. If another thread is holding the same entry at that time, spinning until the entry gets released. Co-Authored-By: Koichi Sasada <ko1@atdot.net> --- bootstraptest/test_ractor.rb | 11 +++++++++++ missing/dtoa.c | 13 ++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-)
2020-05-11sed -i 's|ruby/impl|ruby/internal|'卜部昌平
To fix build failures. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11sed -i s|ruby/3|ruby/impl|g卜部昌平
This shall fix compile errors. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-04-08Merge pull request #2991 from shyouhei/ruby.h卜部昌平
Split ruby.h Notes: Merged-By: shyouhei <shyouhei@ruby-lang.org>
2019-12-26decouple internal.h headers卜部昌平
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). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-02-07Split dtoa.cnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-15suppress integer overflow warningsshyouhei
* util.c: annotate as NO_SANITIZE * bignum.c: avoid (size_t)-- * marshal.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-13suppress integer overflow warningsshyouhei
* random.c: annotate rb_hash_start with NO_SANITIZE (seed.key.hash + h overflows and that seems intentional) * bignum.c: avoid (size_t)-- * cont.c: ditto * util.c: ditto * vm_insnhelper.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-09util.c: suppress warningsshyouhei
These functions handle overflows correctly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08avoid (size_t)-- (2nd try)shyouhei
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
2018-11-08svn merge -r 65625:65623 .shyouhei
Was breaking make test-all git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08avoid (size_t)--shyouhei
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
2018-09-26yet another -Wparentheses tweakshyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-10util.c: removed extra #endif [Bug #15091]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-10util.c: fix ruby_qsort with qsort_snobu
* 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
2018-09-10there is no such predefined macro. check build before commit!usa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-09util.c: qsort_s in C11nobu
* 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
2018-01-04define NO_LONG_LONG appropriatelyshyouhei
as documented above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-23Drop to support NaCl platform.hsbt
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
2017-05-19Merge latest dtoa.c [Bug #13545]naruse
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
2017-05-18potential memory leaknobu
* dir.c (rb_dir_getwd): get rid of potential memory leak. * util.c (ruby_getcwd): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-03fix for mingw64nobu
* util.c: define MINGW_HAS_SECURE_API for qsort_s on recent mingw64. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-04util.c: round to evennobu
* util.c (ruby_dtoa): round to even, instead of rounding to nearest. [ruby-core:77864] [Bug #12889] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-15util.c: do not underflownobu
* 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
2016-07-10util.c: round nearly middle valuenobu
* 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
2016-05-11util.c: qsort_snobu
* 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
2016-05-08* gc.c (rb_gc_unprotect_logging): throw rb_memerror when it cannotnaruse
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
2015-12-23prefer rb_syserr_failnobu
* 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
2015-09-15util.c: BSD qsort_rnobu
* util.c (ruby_qsort): use BSD-style qsort_r if available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-17util.c: fix off-by-one errornobu
* 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
2015-05-29parse.y: check NTH_REF rangenobu
* 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
2015-02-13util.c: hexdigitnobu
* util.c (hexdigit): extract identical constants. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15* internal.h: Include ruby.h and ruby/encoding.h to beakr
includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-16util.c: let getcwd allocate buffernobu
* 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
2014-02-08* configure.in: check qsort_r(3) and whether it is GNU version.glass
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
2013-12-14util.c: bump stack size in ruby_qsort()nobu
* 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
2013-11-22util.c: more precisionnobu
* util.c (ruby_strtod): BigMath requires more precision. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-22util.c: ignore too long fraction partnobu
* 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
2013-07-03* internal.h (ruby_digit36_to_number_table): Declared.akr
* util.c (ruby_digit36_to_number_table): Moved from scan_digits. * bignum.c (conv_digit): Use ruby_digit36_to_number_table. * pack.c (hex2num): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-01util.c: constifynobu
* util.c (scan_digits): constify readonly table. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-22* util.c (ruby_hdtoa): revert r29729.naruse
If you want ruby to behave as before on x86, specify to use SSE like -msse2 -mfpmath=sse for gcc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-17Imports Ruby's port to NativeClient (a.k.a NaCl).yugui
Patch by Google Inc. [ruby-core:45073]. * configure.in (RUBY_NACL): New M4 func to configure variables for NaCl. (RUBY_NACL_CHECK_PEPPER_TYPES): New M4 func to check the old names of Pepper interface types. (BTESTRUBY): New variable to specify which ruby should be run on "make btest". NaCl can run the built binary by sel_ldr, but it need rbconfig.rb. So this variable is distinguished from $MINIRUBY. * thread_pthread.c: Disabled some features on NaCl. * io.c: ditto. * process.c: ditto. * signal.c: ditto. * file.c: ditto. * missing/flock.c: ditto. * nacl/pepper_main.c: An example implementation of Pepper application that embeds Ruby. * nacl/example.html: An example of web page that uses the Pepper application. * nacl/nacl-config.rb: Detects variants of NaCl SDK. * nacl/GNUmakefile.in: Makefile template for NaCl specific build process. * nacl/package.rb: script for packaging a NaCl-Ruby embedding application. * nacl/reate_nmf.rb: Wrapper script of create_nmf.py * dln.c (dln_load): Added a hack to call on NaCl. * util.c (ruby_getcwd): Path to the current directort is not available on NaCl. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15* util.c (ruby_strtod): no need to check same digit for hexdigitnobu
twice. [ruby-dev:45363][Bug #6146] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-22* ext/bigdecimal/bigdecimal.h: add satisfy cc-mode comment.kazu
* util.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-20* util.c (mmprepare): fix for fragmental size.nobu
* util.c (mmswap_, mmrot3_): portability improvement. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-03* util.c, include/ruby/util.h (ruby_add_suffix): remove the function.usa
[Bug #5153] [ruby-core:38736] * io.c (argf_next_argv): remove the call of above function. * ext/-test-/add_suffix, test/-ext-/test_add_suffix.rb: remove the test extension module because this is only for testsing ruby_add_suffix(). * LEGAL: remove the mention about a part of util.c, because now we removed the part. * io.c (argf_next_argv): now the new filename is not guranteed to use, so should check the return value of rename(2). * test/ruby/test_argf.rb (TestArgf#test_inplace_rename_impossible): now we expect same result with other platforms on no_safe_rename platforms (=Windows). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10* thread_pthread.c (mutex_debug): use exit(EXIT_FAILURE) instad ofkosaki
exit(1). * thread_pthread.c (add_signal_thread_list): ditto. * thread.c (rb_thread_call_with_gvl): ditto. * util.c (Bug): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18* internal.h: declare more internal functions.akr
* iseq.h (rb_method_get_iseq): declared. * compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c, ruby.c, time.c, util.c, vm.c: don't declare internal functions. * eval.c, parse.y, thread_pthread.c: non-existing function declarations removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-10* util.c: parenthesize macro arguments.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-09* util.c (ruby_strtod): this code uses FPU's rounding system.naruse
But x86's FPU calculates double precision floating-point numbers in 80bit precision, so it fails to round the value. So ensure the value is assigned a variable. [ruby-dev:42551] see also [ruby-math:00802] http://www.shudo.net/java-grandprix99/strictfp/ git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e