summaryrefslogtreecommitdiff
path: root/io.c
AgeCommit message (Collapse)Author
2013-06-07* internal.h (numberof): Gathered from various files.akr
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c, load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c, error.c, ruby.c: Remove the definitions of numberof. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-02fill rdocsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-19fix typos. Patch by k_takata.ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* include/ruby/ruby.h: constify RBasic::klass and addko1
RBASIC_CLASS(obj) macro which returns a class of `obj'. This change is a part of RGENGC branch [ruby-trunk - Feature #8339]. * object.c: add new function rb_obj_reveal(). This function reveal interal (hidden) object by rb_obj_hide(). Note that do not change class before and after hiding. Only permitted example is: klass = RBASIC_CLASS(obj); rb_obj_hide(obj); .... rb_obj_reveal(obj, klass); TODO: API design. rb_obj_reveal() should be replaced with others. TODO: modify constified variables using cast may be harmful for compiler's analysis and optimizaton. Any idea to prohibt inserting RBasic::klass directly? If rename RBasic::klass and force to use RBASIC_CLASS(obj), then all codes such as `RBASIC(obj)->klass' will be compilation error. Is it acceptable? (We have similar experience at Ruby 1.9, for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)". * internal.h: add some macros. * RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal object. * RBASIC_SET_CLASS(obj, cls) set RBasic::klass. * RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS without write barrier (planned). * RCLASS_SET_SUPER(a, b) set super class of a. * array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c, file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c, parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c, string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c: Use above macros and functions to access RBasic::klass. * ext/coverage/coverage.c, ext/readline/readline.c, ext/socket/ancdata.c, ext/socket/init.c, * ext/zlib/zlib.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* *.c, parse.y, insns.def: use RARRAY_AREF/ASET macroko1
instead of using RARRAY_PTR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-08* io.c (rb_io_ext_int_to_encs): ignore internal encoding if externalnaruse
encoding is ASCII-8BIT. [Bug #8342] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-26fix typo (r40195, r40428)kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-25io.c: conversion from bom encodingnobu
* io.c (rb_io_ext_int_to_encs, parse_mode_enc): bom-prefixed name is not a real encoding name, just a fallback. so the proper conversion should take place even if if the internal encoding is equal to the bom-prefixed name, unless actual encoding is equal to the internal encoding. [ruby-core:54563] [Bug #8323] * io.c (io_set_encoding_by_bom): reset extenal encoding if no BOM found. [ruby-core:54569] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24* io.c (rb_fd_fix_cloexec): use rb_update_max_fd().kosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-23* Typo in defining EWOULDBLOCKWaitReadable on platforms whereheadius
EAGAIN != EWOULDBLOCK. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-09io.c: define EWOULDBLOCKnobu
* io.c (Init_IO): define EWOULDBLOCK alway as it is needed always. and turn runtime branch into preprocessor condition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-08Fix #6154 by introducing new EAGAIN/EWOULDBLOCK/EINPROGRESSheadius
subclasses that include WaitReadable or WaitWritable rather than extending them into the exception object each time. * error.c: Capture EGAIN, EWOULDBLOCK, EINPROGRESS exceptions and export them for use in WaitReadable/Writable exceptions. * io.c: Create versions of EAGAIN, EWOULDBLOCK, EINPROGRESS that include WaitReadable and WaitWritable. Add rb_readwrite_sys_fail for nonblocking failures using those exceptions. Use that function in io_getpartial and io_write_nonblock instead of rb_mod_sys_fail * ext/openssl/ossl_ssl.c: Add new SSLError subclasses that include WaitReadable and WaitWritable. Use those classes for write_would_block and read_would_block instead of rb_mod_sys_fail. * ext/socket/ancdata.c: Use rb_readwrite_sys_fail instead of rb_mod_sys_fail in bsock_sendmsg_internal and bsock_recvmsg_internal. * ext/socket/init.c: Use rb_readwrite_sys_fail instead of rb_mod_sys_fail in rsock_s_recvfrom_nonblock and rsock_s_connect_nonblock. * ext/socket/socket.c: Use rb_readwrite_sys_fail instead of rb_mod_sys_fail in sock_connect_nonblock. * include/ruby/ruby.h: Export rb_readwrite_sys_fail for use instead of rb_mod_sys_fail. Introduce new constants RB_IO_WAIT_READABLE and RB_IO_WAIT_WRITABLE for first arg to rb_readwrite_sys_fail. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-03* io.c (rb_io_seek_m): Accept :CUR, :END, :SET as "whence" argument.akr
(interpret_seek_whence): New function. [ruby-dev:45818] [Feature #6643] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-02update doc.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-29io.c: get rid of IOError when skipped while iterationnobu
* io.c (argf_next_argv): set init flag if succeeded to forward, after skipping. * io.c (argf_block_call_i, argf_block_call): no more forwarding if forwarded after skipping. [ruby-list:49185] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-29io.c: get rid of IOError when skipped while iterationnobu
* io.c (argf_close): deal with init flag. * io.c (argf_block_call_i, argf_block_call): forward next file if skipped while iteration, to get rid of IOError. [ruby-list:49185] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-19* io.c (linux_iocparm_len): enable only exist _IOC_SIZE().kosaki
Because musl libc doesn't have it. [Bug #8051] [ruby-core:53229] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-17* io.c (io_fillbuf): show fd number on failure to debug.naruse
http://c5632.rubyci.org/~chkbuild/ruby-trunk/log/20130316T050302Z.diff.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-16io.c: max_file_descriptornobu
* io.c (max_file_descriptor): rb_atomic_t for ATOMIC_CAS(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-16* include/ruby/missing.h (__syscall): moved to...kosaki
* io.c: here. because __syscall() is only used from io.c. * include/ruby/missing.h: move "#include <sys/type.h>" to .... * include/ruby/intern.h: here. because it was introduced for fixing NFDBITS issue. [ruby-core:05179]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-15file.c: rb_sys_fail_path_with_funcnobu
* file.c (rb_sys_fail_path_with_func): share same function, and path may be nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-14* file.c (rb_sys_fail_path): define & use rb_sys_fail_path0 like r39752naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-11* io.c (extract_binmode): raise error even if binmode and textmodenaruse
don't conflict. [Bug #5918] [ruby-core:42199] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10* io.c (rb_update_max_fd): use ATOMIC_CAS because this functionkosaki
is used from timer thread too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-09* io.c: Fix rdoc typo [Github fixes #256]marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-13io.c: FOREACH_ARGFnobu
* io.c (FOREACH_ARGF): loop for ARGF. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-13io.c: simplifynobu
* io.c (rb_io_getline_fast, rb_io_each_{byte,codepoint}): simplify loops. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-10add doc. for IO#close_on_exec=.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-15io.c: no envp if no spawnvenobu
* io.c (pipe_open): envp is not used if only spawnv is defined right now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-06* bootstraptest/test_io.c: add a test for [ruby-dev:46834].yugui
* io.c (rb_cloexec_fcntl_dupfd) Use an emulation with dup(2) when fcntl(2) and/or F_DUPFD is unavailable. Suggested by akr. * configure.in (HAVE_FCNTL): NativeClient does not provide fcntl(2). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-04* io.c (rb_cloexec_fcntl_dupfd): improve #ifdef condition.kosaki
* io.c (rb_maygvl_fd_fix_cloexec): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-03* io.c (rb_cloexec_fcntl_dupfd): Fix failures inyugui
bootstrap_test/test_io.rb. NativeClient does not support F_DUPFD but supports dup2(2). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29adjust stylenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-25error.c: rb_write_error_strnobu
* error.c (compile_err_append, compile_warn_print, warn_print): use rb_write_error_str() instead of writing to rb_stderr directly. * io.c (rb_write_error_str): a stopgap measure not to unblock GVL. warning from require seems to still have race condition errors. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-22Deprecate #{lines,bytes,chars,codepoints} of IO-likes.knu
* io.c (rb_io_lines, rb_io_bytes, rb_io_chars, rb_io_codepoints): Deprecate IO#{lines,bytes,chars,codepoints} and those of ARGF. [Feature #6670] * ext/stringio/stringio.c (strio_lines, strio_bytes, strio_chars) (strio_codepoints): Deprecate StringIO#{lines,bytes,chars,codepoints}. [Feature #6670] * ext/zlib/zlib.c (rb_gzreader_lines, rb_gzreader_bytes): Deprecate Zlib::GzipReader#{lines,bytes}. [Feature #6670] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-22* io.c (rb_io_wait_writable): use rb_thread_check_ints() insteadkosaki
of rb_thread_fd_writable(). * io.c (rb_io_wait_readable): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-18* io.c (rb_io_wait_writable): don't use rb_thread_wait_fd()kosaki
because it is for waiting until io readable. * io.c (rb_io_wait_writable): always use rb_thread_fd_writable() instaed of bare rb_wait_for_single_fd(). we shouldn't ignore return value. * io.c (rb_io_wait_readable): ditto. always use rb_thread_wait_fd(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-17* io.c (io_flush_buffer_sync2): avoid to return 0. becausekosaki
rb_thread_call_without_gvl2 uses 0 internally. * io.c (io_flush_buffer_async2): adapt the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15* io.c (finish_writeconv): uses rb_write_internal2 ifkosaki
fptr->write_lock have. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15* thread.c (rb_mutex_owned_p): remove static.kosaki
* io.c (io_flush_buffer): don't hold mutex if already have. Now recursive lock may occur when following scenario. fptr_finalize -> finish_writeconv_sync -> finish_writeconv -> io_fflush. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15* io.c (io_flush_buffer): uses io_flush_buffer_async2 instead ofkosaki
io_flush_buffer_async. * io.c (io_flush_buffer_async2): new helper function for io_flush_buffer. It uses rb_thread_call_without_gvl2() instead of rb_thread_io_blocking_region. * io.c (io_flush_buffer_sync2): new helper function for io_flush_buffer_async2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15* io.c (internal_write_func2): new helper function for rb_write_internal2().kosaki
* io.c (rb_write_internal2): new function. it uses rb_thread_call_without_gvl2() instaed of rb_thread_io_blocking_region(). * io.c (rb_binwrite_string): uses rb_write_internal2 instead of rb_write_internal. [Bug #7134] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15* io.c (rb_io_wait_writable): add to call rb_thread_wait_fd()kosaki
likes rb_io_wait_readable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15* io.c (rb_io_wait_writable): don't call rb_thread_fd_writable()kosaki
when EINTR. EINTR mean signal interrupt was happen. We don't need any wait. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-05* thread.c (rb_uninterruptible): helper function for providingkosaki
temporary async_interrupt_timing(Object => :defer) * io.c (rb_f_p): use rb_uninterruptible. * io.c (rb_f_p_internal): helper function for rb_f_p(). * io.c (struct rb_f_p_arg): new struct for rb_f_p_internal. * test/ruby/test_thread.rb (test_async_interrupt_and_p): test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-05* io.c (io_binwrite): check interrupt before io issue.kosaki
* test/ruby/test_thread.rb (test_async_interrupt_and_io): test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02* array.c, enum.c, insns.def, io.c, numeric.c, parse.y, process.c,ko1
range.c: use prepared IDs. A patch from charliesome (Charlie Somerville). [Bug #7495] * common.mk: add dependency to id.h. * common.mk: replace ID_H_INCLUDES with id.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01io.c: recurse for the argumentnobu
* io.c (rb_io_puts): recurse for the argument itself, not converted array elements. [ruby-core:42444] [Bug #5986] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* thread.c (struct rb_mutex_struct): add allow_trap field.kosaki
* internal.h (rb_mutex_allow_trap): added. * thread.c (rb_mutex_lock, rb_mutex_unlock): check mutex->allow_trap. * thread.c (mutex_sleep): remove trap check because it uses rb_mutex_lock and rb_mutex_unlock internally. * thread.c (rb_mutex_allow_trap): new helper function for the above. * io.c (io_binwrite): mark fptr->write_lock as writable in trap. * test/ruby/test_signal.rb (test_trap_puts): test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* io.c (FMODE_SYNCWRITE): removed unused macro.kosaki
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e