aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
Commit message (Collapse)AuthorAgeFilesLines
* io.c: use PRI_OFFT_PREFIX for off_tnobu2016-05-151-9/+2
| | | | | | | * io.c (do_io_advise): use configured PRI_OFFT_PREFIX instead of PRI_OFF_T_PREFIX to format off_t properly on Cygwin. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: remove extra declarationsnobu2016-03-071-1/+0
| | | | | | | * io.c (rb_io_set_encoding): remove extra declarations, rb_std{in,out,err} are defined in this file. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: fix output of Array [ci skip]nobu2016-03-061-1/+1
| | | | | | | * io.c (rb_obj_display): [DOC] fix output of Array, as Array#to_s is same as Array#inspect since 1.9. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse without $.nobu2016-02-241-14/+29
| | | | | | | | | | | | * io.c (rb_io_gets_internal): read one line from an IO without setting ARGF.lineno. * parse.y (lex_io_gets): use rb_io_gets_internal not to affect $. global variable. * ruby.c (load_file): no longer reset $. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: rb_io_open_genericnobu2016-01-311-4/+21
| | | | | | | | | | * io.c (rb_io_open_generic): split from rb_io_open without argument conversions. * io.c (rb_io_s_binread): get rid of unnecessary object creation and conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: constifynobu2016-01-311-3/+6
| | | | | | | * io.c (rb_file_open_generic, pipe_open, pipe_open_s): constify convconfig parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: suppress warningnobu2016-01-191-3/+4
| | | | | | * io.c (rb_update_max_fd): get rid of unused-value warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: remove obsolete rb_deferr global variablenormal2016-01-101-2/+1
| | | | | | | | | | | | | This was made obsolete by r4190 back in July 2003. Furthermore, this existed less than 3 months as it was only introduced in r3782. So with absolutely no references to rb_deferr, I doubt any vim plugin would care anymore. ChangeLog: fixup indent of my previous commit, oops :X git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* IO#readpartial rejects bad argsnormal2015-12-271-1/+1
| | | | | | | | | | | Sometimes a sleepy developer will want to swap read_nonblock for readpartial forget to remove "exception: false" * io.c (io_getpartial): remove unused kwarg from template * test/ruby/test_io.rb (test_readpartial_bad_args): new [Bug #11885] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rb_readwrite_syserr_failnobu2015-12-231-8/+12
| | | | | | | * io.c (rb_readwrite_syserr_fail): works with the given errno than thread local errno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* prefer rb_syserr_failnobu2015-12-231-23/+26
| | | | | | | | * 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
* * enum.c: fix a typo in documentation.hsbt2015-12-141-2/+2
| | | | | | | | | | | | [ci skip][fix GH-1140] Patch by @jutaz * io.c: ditto. * iseq.c: ditto. * numeric.c: ditto. * process.c: ditto. * string.c: ditto. * vm_trace.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c: fix typos.hsbt2015-12-141-1/+1
| | | | | | | | | | | | | [ci skip][fix GH-1140] Patch by @jutaz * dir.c: ditto. * gc.c: ditto. * io.c: ditto. * node.h: ditto. * thread_pthread.c: ditto. * vm_insnhelper.c: ditto. * vsnprintf.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: encoding in warningsnobu2015-12-131-12/+15
| | | | | | | * io.c (parse_mode_enc): preserve encoding of mode string in warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: BOM with non-UTFnobu2015-12-131-25/+22
| | | | | | | | * io.c (io_encname_bom_p): check BOM prefix only, not including UTF prefix. * io.c (parse_mode_enc): warn BOM with non-UTF encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: fix stack smashingnobu2015-12-131-3/+5
| | | | | | * io.c (parse_mode_enc): fix buffer overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* IO#advise should not raise Errno::ENOSYSnormal2015-12-111-1/+1
| | | | | | | | | | | | | | | As it is just a hint the kernel is free to ignore, IO#advise already succeeds when posix_fadvise is not available build time at all. Following that, if posix_fadvise was available at build time but not implemented in the running kernel, we should also ignore it. * io.c (do_io_advise): do not raise on ENOSYS * test/ruby/test_io.rb (test_advise): do not skip on Errno::ENOSYS (test_advise_pipe): ditto [ruby-core:72066] [Feature #11806] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c, io.c: use rb_id_encodingnobu2015-12-091-1/+1
| | | | | | | | | * dir.c (dir_initialize): rb_id_encoding() returns same ID with caching. * io.c (Init_IO): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * *.c (*_memsize): do not check ptr.ko12015-12-091-1/+0
| | | | | | | | | | NULL checking is finished Before call of memsize functions. See r52979. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: try to_io firstnobu2015-11-251-36/+39
| | | | | | | * io.c (copy_stream_body): try to_io conversion before read, readpartial, and write methods. [ruby-dev:49008] [Bug #11199] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (argf_getpartial): should not resize str if the secondshugo2015-11-251-1/+3
| | | | | | | argument is not given. [ruby-core:71668] [Bug #11738] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Drop support for BeOSnobu2015-11-241-8/+2
| | | | | | | * beos: Drop support for BeOS now that Haiku is stable. [Fix GH-1112] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use rb_gc_for_fd for more callersnormal2015-11-231-1/+1
| | | | | | | | | | | | | | | | * dir.c (dir_initialize): use rb_gc_for_fd for ENOMEM * ext/socket/init.c (rsock_socket): ditto * ext/socket/socket.c (rsock_socketpair): ditto * internal.h (rb_gc_for_fd): prototype * io.c (rb_gc_for_fd): remove static [ruby-core:71623] [Feature #11727] Manpages for opendir(2), socket(2), and socketpair(3posix) describe ENOMEM as a possible error for each of these; handle it consistently with our existing wrappers for open(2)/pipe(2) etc... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (rb_gc_for_fd): wrapper for retrying FD creationnormal2015-11-231-11/+18
| | | | | | | | | | | | | | | | | | | | | | | This simplifies callers and makes error handling more consistent between our pipe, open, fdopen, and dup wrappers. This adds missing ENOMEM handling as documented in the open(2), pipe(2freebsd), and fdopen(3posix) manpages on my system. We also avoid repeatedly accessing `errno` which is implemented in TLS on GNU/Linux systems and more expensive to read than a local variable. We may export this in internal.h for ext/socket/* and dir.c, too. * io.c (rb_gc_for_fd): new helper function (ruby_dup): use rb_gc_for_fd (rb_sysopen): ditto (rb_fdopen): ditto (rb_pipe): ditto [ruby-core:71623] [Feature #11727] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Haiku now best effort supportnobu2015-11-231-2/+2
| | | | | | | | | | * configure.in: remove obsolete workarounds for Haiku. * dln.c, file.c, io.c: remove obsolete Haiku workarounds. * thread_pthread.c: add stack bounds detection for Haiku. * signal.c: get stack pointer from signal context on Haiku. [ruby-core:67923] [Bug #10811] [Fix GH-1109] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: avoid kwarg parsing in C APInormal2015-11-121-130/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * benchmark/bm_io_nonblock_noex2.rb: new benchmark based on bm_io_nonblock_noex.rb * io.c (io_read_nonblock): move documentation to prelude.rb (io_write_nonblock): ditto (Init_io): private, internal methods for prelude.rb use only * prelude.rb (IO#read_nonblock): wrapper + documentation (IO#write_nonblock): ditto [ruby-core:71439] [Feature #11339] rb_scan_args and hash lookups for kwargs in the C API are clumsy and slow. Instead of improving the C API for performance, use Ruby instead :) Implement IO#read_nonblock and IO#write_nonblock in prelude.rb to avoid argument parsing via rb_scan_args and hash lookups. This speeds up IO#write_nonblock and IO#read_nonblock benchmarks in both cases, including the original non-idiomatic case where the `exception: false' hash is pre-allocated to avoid GC pressure. Now, writing the kwargs in natural, idiomatic Ruby is fastest. I've added the noex2 benchmark to show this. 2015-11-12 01:41:12 +0000 target 0: a (ruby 2.3.0dev (2015-11-11 trunk 52540) [x86_64-linux]) target 1: b (ruby 2.3.0dev (2015-11-11 avoid-kwarg-capi 52540) ----------------------------------------------------------- benchmark results: minimum results in each 10 measurements. Execution time (sec) name a b io_nonblock_noex 2.508 2.382 io_nonblock_noex2 2.950 1.882 Speedup ratio: compare with the result of `a' (greater is better) name b io_nonblock_noex 1.053 io_nonblock_noex2 1.567 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: [DOC] IO#gets [skip ci]nobu2015-11-081-0/+2
| | | | | | * io.c (rb_io_gets_m): [DOC] add example using limit argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: [DOC] IO#gets [skip ci]nobu2015-11-081-2/+2
| | | | | | | * io.c (rb_io_gets_m): [DOC] fix class name and reword as "multibyte". [Fix GH-1085] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: [DOC] IO#gets [skip ci]nobu2015-11-081-0/+10
| | | | | | | * io.c (rb_io_gets_m): Update IO#gets doc for characters more than 1 byte. [Fix GH-1085] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: fix typo [ci skip]nobu2015-10-251-1/+1
| | | | | | | * io.c (io_readpartial): fix typo, "later" to "latter". [ruby-core:71181] [Bug #11619] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: check ARGV element typenobu2015-10-221-11/+13
| | | | | | | * io.c (argf_next_argv): check ARGV element type, and try conversion if necessary. [ruby-core:71140] [Bug #11610] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix compile errorkosaki2015-10-181-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ChangeLog: Good-bye OS/2.kosaki2015-10-181-3/+2
| | | | | | | | | | | | | | | | | | | | * common.mk: ditto. * configure.in: ditto. * dln_find.c: ditto. * ext/Setup.emx: ditto. * ext/extmk.rb: ditto. * ext/socket/extconf.rb: ditto. * ext/zlib/extconf.rb: ditto. * file.c: ditto. * include/ruby/defines.h: ditto. * io.c: ditto. * lib/mkmf.rb: ditto. * missing/os2.c: ditto. * process.c: ditto. * ruby.c: ditto. * NEWS: announce OS/2 is no longer supported. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re-commit r52152kosaki2015-10-181-1/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert r52154kosaki2015-10-181-6/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (fptr_finalize): don't release gvl if fptr is not writable.kosaki2015-10-171-1/+6
| | | | | | | | | | | writable fd may block on close(2) when it's on NFS. But readonly fd doesn't. [Bug #11559] result: make benchmark OPTS="-p bm_require_t -e ruby-trunk -e ruby-2.2.2" build-ruby: 0.171 ruby 2.3.0dev(r52151): 0.659 ruby 2.2.0p95 (r50295): 0.834 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c: conflicting O_NONBLOCKnobu2015-10-171-1/+1
| | | | | | | * ruby.c (load_file_internal): do not use O_NONBLOCK when conflicting with O_ACCMODE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* encindex.h: ENCINDEXnobu2015-09-151-0/+1
| | | | | | * encindex.h: separate encoding index constants from internal.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: sys/wait.hnobu2015-09-091-0/+4
| | | | | | * io.c: BSDs need sys/wait.h for WNOHANG. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: no wait when killednobu2015-09-081-7/+29
| | | | | | | * io.c (rb_io_s_popen): do not wait the child process during being killed. [ruby-core:70671] [Bug #11510] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: initialize variablenobu2015-08-191-0/+1
| | | | | | | * io.c (rb_io_each_codepoint): fix use of uninitialized variable. [Bug #11444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: raise at incomplete charnobu2015-08-171-3/+6
| | | | | | | * io.c (rb_io_each_codepoint): raise an exception at incomplete character before EOF when conversion takes place. [Bug #11444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: read more datanobu2015-08-151-0/+17
| | | | | | | * io.c (rb_io_each_codepoint): read more data when read partially. [ruby-core:70379] [Bug #11444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_extract_modeenc): add option parameter `flags'naruse2015-07-291-12/+24
| | | | | | | to append extra oflags to normal mode. [Feature #11253] [ruby-core:69539] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: IO.copy_stream uses poll on Linuxnormal2015-07-201-1/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | poll and ppoll have a superior API which doesn't require the kernel to scan a potentially large bitmap to find a high-numbered FD [ruby-core:35572]. So favor using poll in case IO.copy_stream encounters a non-blocking FD. We cannot reliably use poll on most OSes, because file types (e.g. FIFOs) which work with select may not work with poll. Fortunately, Linux uses a common notification mechanism between all select/poll/epoll variants, so all file types are equally supported between the notification mechanisms. Verified by watching strace on the following scripts: *** maygvl_copy_stream_wait_read *** require 'io/nonblock' r, w = IO.pipe r.nonblock = true IO.copy_stream(r, "/dev/null") *** nogvl_copy_stream_wait_write *** require 'io/nonblock' r, w = IO.pipe w.nonblock = true IO.copy_stream("/dev/zero", w) * io.c (nogvl_wait_for_single_fd): new function for Linux (maygvl_copy_stream_wait_read): Linux-specific version (nogvl_copy_stream_wait_write): use nogvl_wait_for_single_fd [ruby-core:70051] [Feature #11377] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (argf_read_nonblock): support `exception: false'normal2015-07-171-12/+27
| | | | | | | | | | | | | | | | | This is a preparation for [ruby-core:69892] ("io.c: avoid kwarg parsing in C API") since I noticed ARGF.read_nonblock did not properly catch up to the `exception: false' change. * io.c (argf_read_nonblock): support `exception: false' (io_nonblock_eof): new function (io_read_nonblock): use io_nonblock_eof (argf_getpartial): accept kwargs hash for `exception: false' * test/ruby/test_argf.rb (test_read_nonblock): new test [ruby-core:70000] [Feature #11358] * NEWS: add item for ARGF.read_nonblock git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/socket/basicsocket.c: [DOC] typo (Errno::AGAIN -> Errno::EAGAIN)sorah2015-07-121-2/+2
| | | | | | | | | | | | | | * ext/socket/socket.c: ditto * ext/socket/tcpserver.c: ditto * ext/socket/udpsocket.c: ditto * ext/socket/unixserver.c: ditto * io.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* delay `exception: false' checks for minor speedupnormal2015-07-021-34/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Delay hash lookups until we are about to hit an exception. This gives a minor speedup ratio of 2-3% in the new bm_io_nonblock_noex benchmark as well as reducing code. * benchmark/bm_io_nonblock_noex.rb: new benchmark * ext/openssl/ossl_ssl.c (no_exception_p): new function (ossl_start_ssl): adjust for no_exception_p (ossl_ssl_connect): adjust ossl_start_ssl call (ossl_ssl_connect_nonblock): ditto (ossl_ssl_accept): ditto (ossl_ssl_accept_nonblock): ditto (ossl_ssl_read_internal): adjust for no_exception_p (ossl_ssl_write_internal): ditto (ossl_ssl_write): adjust ossl_write_internal call (ossl_ssl_write_nonblock): ditto * ext/stringio/stringio.c (strio_read_nonblock): delay exception check * io.c (no_exception_p): new function (io_getpartial): call no_exception_p (io_readpartial): adjust for io_getpartial (get_kwargs_exception): remove (io_read_nonblock): adjust for io_getpartial, check no_exception_p on EOF (io_write_nonblock): call no_exception_p (rb_io_write_nonblock): do not check `exception: false' (argf_getpartial): adjust for io_getpartial [ruby-core:69778] [Feature #11318] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: remove unnecessary sharednobu2015-06-301-1/+1
| | | | | | | * io.c (rb_io_reopen): FilePathValue() ensures the path NUL-terminated and frozen, so it is unnecessary to make it shared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ensure paths NUL-terminatednobu2015-06-301-0/+1
| | | | | | | | * dir.c (check_dirname): ensure path name NUL-terminated for SHARABLE_MIDDLE_SUBSTRING. * io.c (rb_sysopen): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e