aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
Commit message (Collapse)AuthorAgeFilesLines
* * internal.h: Include ruby.h and ruby/encoding.h to beakr2014-11-151-2/+1
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * win32/win32.c, include/win32/win32.h (rb_w32_set_nonblock): newusa2014-11-101-0/+6
| | | | | | | | | | | | | | | | | | | | function to support nonblock-mode of pipes. * win32/win32.c (rb_w32_read): nonblock-mode pipe returns ERROR_NO_DATA if there is no data, but also returns it if remote-end is closed. * win32/win32.c (rb_w32_write): if cannot to write any data, it may be blocking. * io.c (rb_io_set_nonblock): use rb_w32_set_nonblock for Windows. * ext/io/nonblock/nonblock.c (rb_io_nonblock_set): use ruby's API when setting nonblock-mode. * test/ruby/test_io.rb: test nonblock pipes on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (io_binwrite_string): Test writev() failure.akr2014-10-251-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: enclose statements by ifdefnobu2014-10-201-1/+1
| | | | | | | * io.c (maygvl_copy_stream_read): enclose following statements by ifdef, not only a case label. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fixes build failures on Portable Native Client.yugui2014-10-111-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note: Some of the fixes are for newlib in general but not NaCl-specific. * include/ruby/intern.h (rb_fd_select): declare struct timeval, or the struct gets local to the function in C99. * file.c (#include): add nacl/stat.h for PNaCl. (utimes): added a declaration for PNaCl. (stat_atimespec): stat::st_atimensec is long long but timespec::tv_nsec is long in PNaCl. (stat_mtimespec, stat_ctimespec): ditto. (rb_group_member): disable getgroups unless HAVE_GETGROUPS. (eaccess): unify the fallback to generic defined(USE_GETEUID). * io.c: include sys/time.h for struct timeval. (rb_close_before_exec): nothing we can do if F_GETFD is not available. (ioctl): pnacl newlib actually doesn't have ioctl. * process.c (maxgroups): it is used iff defined(_SC_NGROUPS_MAX) || defined(NGROUPS_MAX) but not defined(HAVE_GETGROUPS) || defined(HAVE_SETGROUPS). (obj2gid): fail unless the object is a Fixnum if getgrnam is not available. (disable_child_handler_fork_child): sigaction is not available in PNaCl newlib. * configure.in (warnflags, strict_warnflags): avoid -ansi for strlcpy. (rb_cv_gcc_atomic_builtins): also check __atomic_or_etch because it is used in ruby_atomic.h. (rb_cv_gcc_sync_builtins): ditto. (HAVE_GETGRNAM): added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c: fix issues in the last two commits. don't disable cloexec foryugui2014-10-111-4/+5
| | | | | | | | | | | platforms other than NativeClient. * ChangeLog: ditto. add entries for the last two commits. Sat Oct 11 11:12:00 2014 Yuki Yugui Sonoda <yugui@yugui.jp> * signal.c (install_signalhandler, init_sigchld): allow failure because it always fails with ENOSYS on NaCl. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Allow failure of sighandler installation on NativeClient.yugui2014-10-111-0/+3
| | | | | | | * signal.c (install_signalhandler, init_sigchld): allow failure because it always fails with ENOSYS on NaCl. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merges a patch form naclports.yugui2014-10-111-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | * configure.in (RUBY_NACL and others): Supports PNaCl. * dln.c: replace the old hacky dynamic loading over HTTP with nacl_io. * file.c: tenatively use access(2) instead of eaccess. (rb_file_load_ok): weaken with attribute but not by postprocess. * io.c (socket.h): now NaCl has socket.h (flock): disable here instead of nacl/ioctl.h * nacl/GNUmakefile.in (CC, LD, NM, AR, AS, RANLIB, OBJDUMP, OBJCOPY): respect path to them if they are absolute. This helps naclports to build ruby in their source tree. (PROGRAM_NMF, .SUFFIXES): support .pnexe for PNaCl. (ruby.o, file.o): move the hack to attributes in ruby.c and file.c * nacl/ioctl.h: removed. move the hack to io.c. * nacl/nacl-config.rb: support arm, pnacl and others. * nacl/pepper_main.c: support build in a naclports tree. * ruby.c (rb_load_file): weaken with attribute but not by postprocess. The patch is by sbc@google.com and the Native Client Authors. It is available at: * https://chromium.googlesource.com/external/naclports.git/+/873ca4910a5f9d4206306aacb4ed79c587c6a5f3/ports/ruby/nacl.patch git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: fix typonobu2014-10-101-1/+1
| | | | | | * io.c (rb_io_make_open_file): remove useless backslash. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: move RFile initializationnobu2014-10-101-0/+54
| | | | | | | * io.c (rb_io_make_open_file): move from include/ruby/io.h, and hide too detailed implementations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: ID instead of Symbolnobu2014-10-051-4/+4
| | | | | | | * io.c (get_kwargs_exception): rb_get_kwargs() expects IDs, but not Symbols. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (fptr_finalize): free memory before GC sweepnormal2014-10-011-0/+6
| | | | | | | | | | | | | | | | | | This releases memory on explict calls to rb_io_close, reducing pressure on the GC. Final massif snapshot shows reduced heap usage after RubyGems load (valgrind --tool=massif ./ruby -e exit) before: mem_heap_B=4821992 mem_heap_extra_B=1302952 after: mem_heap_B=4791056 mem_heap_extra_B=1192440 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: common function to free IO buffersnormal2014-09-251-12/+12
| | | | | | | | | | | | 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
* trivial packing for on-stack structsnormal2014-09-151-2/+2
| | | | | | | | | | * 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
* * configure.in: Use AC_FUNC_FORK.akr2014-09-021-19/+19
| | | | | | | | | | * 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
* io.c: fix uninitialized variablenobu2014-08-281-1/+2
| | | | | | | * 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
* io.c: preserve encodingsnobu2014-08-281-10/+11
| | | | | | * 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
* io.c: preserve encodingsnobu2014-08-281-3/+3
| | | | | | | * 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
* io.c: preserve encodingsnobu2014-08-281-3/+1
| | | | | | * 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
* io.c: preserve encodingsnobu2014-08-281-2/+2
| | | | | | * 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
* io.c: do not swallow exceptions at end of blocknobu2014-08-261-6/+26
| | | | | | | | * 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
* introduce ZALLOC{,_N} to replace ALLOC{,_N}+MEMZERO usenormal2014-07-251-2/+1
| | | | | | | | | | | | | | | | | | | | 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
* io.c: fix rdoc of append modenobu2014-07-191-5/+5
| | | | | | | * 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
* * io.c: Improve Documentation by @dapplebeforedawn.hsbt2014-07-111-14/+17
| | | | | | [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
* io.c: refine error messagenobu2014-07-091-1/+13
| | | | | | * 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
* constify parametersnobu2014-06-181-4/+4
| | | | | | | | * 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
* configure.in: disable posix_fadvisenobu2014-06-081-4/+1
| | | | | | | * 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
* io.c (rb_io_advise): AIX currently does not support a 32-bit call tokanemoto2014-06-081-1/+4
| | | | | | | | 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
* io.c: truncate before appendingnobu2014-06-071-0/+4
| | | | | | | | * 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
* io.c: not shorten buffer unless succeedednobu2014-06-061-4/+4
| | | | | | | * 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
* configure.in, missing.h: jemalloc manglingnobu2014-06-051-0/+1
| | | | | | | | | | | | * 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
* * io.c (pipe_open): Close pipes when rb_execarg_fixup() raisesakr2014-05-291-1/+17
| | | | | | | | | 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
* * io.c (rb_io_s_pipe): Close pipes if io_encoding_set() raises anakr2014-05-291-1/+28
| | | | | | | | | exception. (io_encoding_set_v): New function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_autoclose_p): Don't raise on frozen IO.akr2014-05-271-2/+2
| | | | | | | | * 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
* io.c: no error on frozen IOnobu2014-05-271-3/+3
| | | | | | | * 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
* io.c: update ARGF examplesnobu2014-05-181-2/+2
| | | | | | | | * 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
* io.c: buffer must be modifiablenobu2014-05-171-1/+1
| | | | | | | * 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
* * io.c (io_{read,write}_nonblock): use rb_get_kwargs instead oftadf2014-05-061-2/+15
| | | | | | | rb_hash_aref. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c: constifynobu2014-03-171-3/+1
| | | | | | * 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
* * enumerator.c (enumerator_block_call): use PARRAY_CONST_PTR()ko12014-03-171-1/+1
| | | | | | | | | | | | 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
* * io.c (rb_io_fsync): need to fsync even if on Windows. fixed mistake ofusa2014-03-021-2/+0
| | | | | | | r45254 and r45256. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_fsync): revert a part of r45254. explicit fsync should updateusa2014-03-021-0/+4
| | | | | | | the metadata. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_flush_raw, rb_io_fsync): [EXPERIMENTAL] remove forceusa2014-03-021-9/+0
| | | | | | | | | 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
* adjust indent and stylenobu2014-02-271-6/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (rb_f_backquote): trade volatile for manual recyclenormal2014-02-161-1/+3
| | | | | | | * 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
* * include/ruby/intern.h,akr2014-02-141-24/+0
| | | | | | | | | | | | | | | | | | | | | 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
* * io.c (SMALLBUF): Unused macro removed.akr2014-02-081-2/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (rb_io_syswrite): add RB_GC_GUARDnormal2014-02-011-0/+1
| | | | | | | * 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
* io.c: check socket on other than linuxnobu2014-01-291-0/+4
| | | | | | | | * 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
* io.c: remove socket checknormal2014-01-291-2/+0
| | | | | | | * 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