summaryrefslogtreecommitdiff
path: root/io.c
AgeCommit message (Collapse)Author
2014-09-25io.c: common function to free IO buffersnormal
This also allows easier tracking of freed memory for systems without malloc_usable_size, and also makes future changes to freeing buffer memory easier-to-implement. * io.c (free_io_buffer): new function for a common pattern (clear_readconv): use free_io_buffer (rb_io_fptr_finalize): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-15trivial packing for on-stack structsnormal
* io.c (struct io_advise_struct): 32 => 24 bytes on 64-bit * io.c (struct io_internal_writev_struct): 24 => 16 bytes on 64-bit * process.c (struct waitpid_arg): ditto Slightly reduce stack pressure. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-02* configure.in: Use AC_FUNC_FORK.akr
* io.c: Use HAVE_WORKING_FORK instead of HAVE_FORK. * process.c: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-28io.c: fix uninitialized variablenobu
* io.c (argf_next_argv): fix uninitialized variable in skipping message when inplace edit without backup. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-28io.c: preserve encodingsnobu
* io.c (argf_next_argv): preserve encodings in warning messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-28io.c: preserve encodingsnobu
* io.c (rb_io_extract_encoding_option): preserve encodings in warning messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-28io.c: preserve encodingsnobu
* io.c (advice_arg_check): preserve encodings in warning messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-28io.c: preserve encodingsnobu
* io.c (rb_io_s_new): preserve encodings in warning messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-26io.c: do not swallow exceptions at end of blocknobu
* io.c (io_close): ignore only "closed stream" IOError and NoMethodError, do not swallow other exceptions at the end of block. [ruby-core:64463] [Bug #10153] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-25introduce ZALLOC{,_N} to replace ALLOC{,_N}+MEMZERO usenormal
Using calloc where possible reduces code and binary sizes. * include/ruby/ruby.h (ZALLOC, ZALLOC_N): implement (Data_Make_Struct, TypedData_Make_Struct): ZALLOC replaces ALLOC+memset * compile.c (iseq_seq_sequence): ZALLOC_N replaces ALLOC_N+MEMZERO * cont.c (fiber_t_alloc): ZALLOC replaces ALLOC+MEMZERO * io.c (rb_io_reopen): ditto * iseq.c (prepare_iseq_build): ditto * parse.y (new_args_tail_gen, parser_new, ripper_s_allocate): ditto * re.c (match_alloc): ditto * variable.c (rb_const_set): ditto * ext/socket/raddrinfo.c (get_addrinfo): ditto * ext/strscan/strscan.c (strscan_s_allocate): ditto * gc.c (rb_objspace_alloc): calloc replaces malloc+MEMZERO git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-19io.c: fix rdoc of append modenobu
* io.c (rb_io_initialize): [DOC] fix rdoc of append mode. it does not move the pointer at open. [ruby-core:63747] [Bug #10039] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-11* io.c: Improve Documentation by @dapplebeforedawn.hsbt
[fix GH-658] [ruby-core:63579] [Bug #10012] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-09io.c: refine error messagenobu
* io.c (do_io_advise): more precise error message, with arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18constify parametersnobu
* include/ruby/intern.h: constify `argv` parameters. * include/ruby/ruby.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-08configure.in: disable posix_fadvisenobu
* configure.in (posix_fadvise): disable use of posix_fadvise itself on 32-bit AIX. [ruby-core:62968] [Bug #9914] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-08io.c (rb_io_advise): AIX currently does not support a 32-bit call tokanemoto
posix_fadvise() if _LARGE_FILES is defined. Patch by Rei Odaira. [ruby-core:62968] [Bug #9914] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-07io.c: truncate before appendingnobu
* io.c (read_all): truncate the buffer before appending read data, instead of truncating before reading. [ruby-core:55951] [Bug #8625] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-06io.c: not shorten buffer unless succeedednobu
* io.c (io_setstrbuf, io_read): should not shorten the given buffer until read succeeds. [ruby-core:55951] [Bug #8625] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-05configure.in, missing.h: jemalloc manglingnobu
* configure.in (with-jemalloc): also check for header, for ABIs which JEMALLOC_MANGLE is needed, i.e., Mach-O and PE-COFF platforms. [ruby-core:62939] [Feature #9113] * include/ruby/missing.h: include alternative malloc header to replace memory management functions. * dln.c, io.c, parse.y, st.c: undef malloc family before re-definition to suppress warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-29* io.c (pipe_open): Close pipes when rb_execarg_fixup() raisesakr
an exception. (rb_execarg_fixup_v): New function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-29* io.c (rb_io_s_pipe): Close pipes if io_encoding_set() raises anakr
exception. (io_encoding_set_v): New function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-27* io.c (rb_io_autoclose_p): Don't raise on frozen IO.akr
* test/lib/minitest/unit.rb: IO#autoclose? may raise IOError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-27io.c: no error on frozen IOnobu
* io.c (rb_io_fileno, rb_io_inspect): non-modification does not error on frozen IO. [ruby-dev:48241] [Bug #9865] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18io.c: update ARGF examplesnobu
* io.c (argf_each_line, argf_inplace_mode_set): [DOC] Update ARGF documentation examples. `ARGF.lines` has been deprecated in favor of `ARGF.each_line`. [Fixes GH-615] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-17io.c: buffer must be modifiablenobu
* io.c (io_setstrbuf): always check if the buffer is modifiable. [ruby-core:62643] [Bug #9847] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-06 * io.c (io_{read,write}_nonblock): use rb_get_kwargs instead oftadf
rb_hash_aref. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-17process.c: constifynobu
* process.c (rb_execarg_new, rb_execarg_init): constify argv. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-17* enumerator.c (enumerator_block_call): use PARRAY_CONST_PTR()ko1
instead of RARRAY_PTR(). * io.c (rb_io_s_popen): ditto. * numeric.c (num_step_size): ditto. * vm_eval.c (rb_apply): ditto. * vm_eval.c (rb_eval_cmd): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02* io.c (rb_io_fsync): need to fsync even if on Windows. fixed mistake ofusa
r45254 and r45256. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02* io.c (rb_io_fsync): revert a part of r45254. explicit fsync should updateusa
the metadata. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02* io.c (rb_io_flush_raw, rb_io_fsync): [EXPERIMENTAL] remove forceusa
syncing for Win32 to speed up IO. this may break some tests, and they'll be fixed later. [ruby-core:58570] [Bug #9153] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27adjust indent and stylenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-16io.c (rb_f_backquote): trade volatile for manual recyclenormal
* io.c (rb_f_backquote): trade volatile for manual recycle rb_gc_force_recycle ensures object is visible until recycle git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-14* include/ruby/intern.h,akr
include/ruby/io.h, include/ruby/ruby.h, include/ruby/win32.h, include/ruby/backward/rubysig.h, bignum.c, gc.c, io.c, process.c, safe.c, struct.c, thread.c, ext/socket/rubysocket.h, ext/-test-/old_thread_select: Remove deprecated definitions [ruby-core:60581] [Feature #9502] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-08* io.c (SMALLBUF): Unused macro removed.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-01io.c (rb_io_syswrite): add RB_GC_GUARDnormal
* io.c (rb_io_syswrite): add RB_GC_GUARD [Bug #9472][ruby-core:60407] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-29io.c: check socket on other than linuxnobu
* io.c (nogvl_copy_stream_sendfile): check socket on other than linux, as sendfile(2) on non-socket fd works only on linux. [Feature #9427] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-29io.c: remove socket checknormal
* io.c (nogvl_copy_stream_sendfile): remove socket check [ruby-core:59856][Feature #9427] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-18* io.c (rb_update_max_fd): Return immediately if the given fd is smallakr
enough. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-18* io.c: Test O_CLOEXEC only once.akr
Patch by Eric Wong. [ruby-core:59419] [Feature #9328] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-15* io.c (io_binwrite): use writev(2) to avoid double write if available.glass
* configure.in: check writev(2) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-02* io.c (io_fwrite): freeze converted str.glass
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-31* io.c (io_fwrite): allocate frozen str only when str is not converted.glass
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29ruby/ruby.h: RB_BLOCK_CALL_FUNC_ARGLISTnobu
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): for declaration argument list of rb_block_call_func. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29ruby/ruby.h: add blockarg to rb_block_call_funcnobu
* include/ruby/ruby.h (rb_block_call_func): add blockarg. block function can take block argument, e.g., proc {|&blockarg| ...}. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-28win32.c: rb_w32_dup2nobu
* win32/win32.c (rb_w32_dup2): extract from rb_cloexec_dup2() and redirect_dup2(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09* io.c: [DOC] ARGF.gets may return nil [Bug #9029] patch by znzzzak
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-08* io.c (rb_io_open_with_args): use RARRAY_CONST_PTR().glass
* io.c (rb_scan_open_args): use const qualifier for above. * io.c (rb_open_file): ditto. * io.c (rb_io_open_with_args): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29* add RUBY_TYPED_FREE_IMMEDIATELY to data types which only useko1
safe functions during garbage collection such as xfree(). On default, T_DATA objects are freed at same points as fianlizers. This approach protects issues such as reported by [ruby-dev:35578]. However, freeing T_DATA objects immediately helps heap usage. Most of T_DATA (in other words, most of dfree functions) are safe. However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default for safety. * cont.c: ditto. * dir.c: ditto. * encoding.c: ditto. * enumerator.c: ditto. * error.c: ditto. * file.c: ditto. * gc.c: ditto. * io.c: ditto. * iseq.c: ditto. * marshal.c: ditto. * parse.y: ditto. * proc.c: ditto. * process.c: ditto. * random.c: ditto. * thread.c: ditto. * time.c: ditto. * transcode.c: ditto. * variable.c: ditto. * vm.c: ditto. * vm_backtrace.c: ditto. * vm_trace.c: ditto. * ext/bigdecimal/bigdecimal.c: ditto. * ext/objspace/objspace.c: ditto. * ext/stringio/stringio.c: ditto. * ext/strscan/strscan.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-20io.c: make IO#reopen("pathname") atomicnobu
* io.c (rb_io_reopen): create a new, temporary FD via rb_sysopen and call rb_cloexec_dup2 on it to atomically replace the file fptr->fd points to. This leaves no possible window where fptr->fd is invalid to userspace (even for any threads running w/o GVL). based on the patch by Eric Wong <normalperson@yhbt.net> at [ruby-core:57943]. [Bug #9036] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e