mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (io_fwrite): avoid context switch before writing to stderr.
[ruby-dev:25080] * rubyio.h: refine deprecated declaration. * configure.in, file.c, io.c: remove useless check: fseeko, etc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
638bbb1946
commit
a435e52259
5 changed files with 24 additions and 98 deletions
|
@ -1,3 +1,12 @@
|
|||
Tue Dec 7 15:40:38 2004 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* io.c (io_fwrite): avoid context switch before writing to stderr.
|
||||
[ruby-dev:25080]
|
||||
|
||||
* rubyio.h: refine deprecated declaration.
|
||||
|
||||
* configure.in, file.c, io.c: remove useless check: fseeko, etc.
|
||||
|
||||
Tue Dec 7 13:42:07 2004 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* dir.c (dir_s_mkdir): win32 special processing doesn't need any
|
||||
|
|
65
configure.in
65
configure.in
|
@ -439,8 +439,6 @@ AC_TYPE_GETGROUPS
|
|||
AC_TYPE_SIGNAL
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_MEMCMP
|
||||
AC_FUNC_FSEEKO
|
||||
AC_CHECK_FUNCS(ftello)
|
||||
AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
|
||||
strchr strstr strtoul crypt flock vsnprintf\
|
||||
isnan finite isinf hypot acosh erf)
|
||||
|
@ -656,69 +654,6 @@ else
|
|||
fi
|
||||
fi
|
||||
|
||||
AC_DEFUN(RUBY_CHECK_IO_NEED,
|
||||
[AC_CACHE_CHECK(whether need to [$1], [$2],
|
||||
[AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET 0
|
||||
#endif
|
||||
#ifndef SEEK_CUR
|
||||
#define SEEK_CUR 1
|
||||
#endif
|
||||
#define before_seek(f) ]ifelse(index($2,flush_before_seek),-1,[fflush(f)],[(f,0)])[
|
||||
#define reset_rw(f) ]ifelse(index($2,seek_between_rw),-1,[do_seek(f,SEEK_CUR)],[(f,0)])[
|
||||
#define do_seek(f, w) (before_seek(f), fseek(f,0,w))
|
||||
|
||||
char *fn = "conftest.dat";
|
||||
char *wombat = "wombat\n";
|
||||
char *koara = "koara\n";
|
||||
char *kangaroo = "kangaroo\n";
|
||||
|
||||
int main()
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
FILE *f;
|
||||
int r = 1;
|
||||
|
||||
if (!(f = fopen(fn, "w+"))) return 1;
|
||||
fputs(wombat, f);
|
||||
do_seek(f, SEEK_SET);
|
||||
if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
|
||||
reset_rw(f);
|
||||
fputs(koara, f);
|
||||
fputs(kangaroo, f);
|
||||
do_seek(f, SEEK_SET);
|
||||
if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
|
||||
if (!fgets(buf, BUFSIZ, f) || strcmp(buf, koara)) goto fail;
|
||||
if (!fgets(buf, BUFSIZ, f) || strcmp(buf, kangaroo)) goto fail;
|
||||
do_seek(f, SEEK_SET);
|
||||
if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
|
||||
reset_rw(f);
|
||||
fputc('X', f);
|
||||
reset_rw(f);
|
||||
if (!fgets(buf, BUFSIZ, f) || strcmp(buf, koara+1)) goto fail;
|
||||
if (!fgets(buf, BUFSIZ, f) || strcmp(buf, kangaroo)) goto fail;
|
||||
do_seek(f, SEEK_SET);
|
||||
if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
|
||||
if (!fgets(buf, BUFSIZ, f) || buf[0] != 'X' || strcmp(buf+1, koara+1)) goto fail;
|
||||
if (!fgets(buf, BUFSIZ, f) || strcmp(buf, kangaroo)) goto fail;
|
||||
r = 0;
|
||||
fail:
|
||||
fclose(f);
|
||||
unlink(fn);
|
||||
return r;
|
||||
}
|
||||
], [$2]=no, [$2]=yes, [$2]=[$3])])])
|
||||
RUBY_CHECK_IO_NEED(seek between R/W, rb_cv_need_io_seek_between_rw, yes)
|
||||
if test "$rb_cv_need_io_seek_between_rw" = yes; then
|
||||
AC_DEFINE(NEED_IO_SEEK_BETWEEN_RW, 1)
|
||||
fi
|
||||
dnl RUBY_CHECK_IO_NEED(flush before seek, rb_cv_need_io_flush_before_seek, no)
|
||||
dnl if test "$rb_cv_need_io_flush_before_seek" = yes; then
|
||||
dnl AC_DEFINE(NEED_IO_FLUSH_BEFORE_SEEK, 1)
|
||||
dnl fi
|
||||
|
||||
AC_CACHE_CHECK([whether st_ino is huge], rb_cv_huge_st_ino,
|
||||
[AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([
|
||||
#include <sys/stat.h>
|
||||
|
|
3
file.c
3
file.c
|
@ -67,9 +67,6 @@ char *strrchr _((const char*,const char));
|
|||
#ifndef HAVE_LSTAT
|
||||
#define lstat(path,st) stat(path,st)
|
||||
#endif
|
||||
#if !HAVE_FSEEKO && !defined(fseeko)
|
||||
# define fseeko fseek
|
||||
#endif
|
||||
|
||||
VALUE rb_cFile;
|
||||
VALUE rb_mFileTest;
|
||||
|
|
12
io.c
12
io.c
|
@ -57,12 +57,6 @@
|
|||
#if !HAVE_OFF_T && !defined(off_t)
|
||||
# define off_t long
|
||||
#endif
|
||||
#if !HAVE_FSEEKO && !defined(fseeko)
|
||||
# define fseeko fseek
|
||||
#endif
|
||||
#if !HAVE_FTELLO && !defined(ftello)
|
||||
# define ftello ftell
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
@ -475,7 +469,7 @@ io_fwrite(str, fptr)
|
|||
(fptr->wbuf && fptr->wbuf_capa <= fptr->wbuf_len + len) ||
|
||||
((fptr->mode & FMODE_LINEBUF) && memchr(RSTRING(str)->ptr+offset, '\n', len))) {
|
||||
/* xxx: use writev to avoid double write if available */
|
||||
if (fptr->wbuf_len+len <= fptr->wbuf_capa) {
|
||||
if (fptr->wbuf_len && fptr->wbuf_len+len <= fptr->wbuf_capa) {
|
||||
if (fptr->wbuf_capa < fptr->wbuf_off+fptr->wbuf_len+len) {
|
||||
MEMMOVE(fptr->wbuf, fptr->wbuf+fptr->wbuf_off, char, fptr->wbuf_len);
|
||||
fptr->wbuf_off = 0;
|
||||
|
@ -488,7 +482,9 @@ io_fwrite(str, fptr)
|
|||
return -1L;
|
||||
if (n == 0)
|
||||
return len;
|
||||
if (!rb_thread_fd_writable(fptr->fd)) {
|
||||
/* avoid context switch between "a" and "\n" in STDERR.puts "a".
|
||||
[ruby-dev:25080] */
|
||||
if (fptr->f != stderr && !rb_thread_fd_writable(fptr->fd)) {
|
||||
rb_io_check_closed(fptr);
|
||||
}
|
||||
retry:
|
||||
|
|
33
rubyio.h
33
rubyio.h
|
@ -99,29 +99,18 @@ NORETURN(void rb_eof_error _((void)));
|
|||
void rb_io_read_check _((OpenFile*));
|
||||
int rb_io_read_pending _((OpenFile*));
|
||||
|
||||
int rb_getc _((FILE*))
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((deprecated))
|
||||
# if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
|
||||
# define DEPRECATED(x) x __attribute__ ((deprecated))
|
||||
# endif
|
||||
#endif
|
||||
;
|
||||
long rb_io_fread _((char *, long, FILE *))
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((deprecated))
|
||||
#ifndef DEPRECATED
|
||||
# define DEPRECATED(x) x
|
||||
#endif
|
||||
;
|
||||
long rb_io_fwrite _((const char *, long, FILE *))
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((deprecated))
|
||||
#endif
|
||||
;
|
||||
void rb_read_check _((FILE*))
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((deprecated))
|
||||
#endif
|
||||
;
|
||||
int rb_read_pending _((FILE*))
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((deprecated))
|
||||
#endif
|
||||
;
|
||||
|
||||
DEPRECATED(int rb_getc _((FILE*)));
|
||||
DEPRECATED(long rb_io_fread _((char *, long, FILE *)));
|
||||
DEPRECATED(long rb_io_fwrite _((const char *, long, FILE *)));
|
||||
DEPRECATED(void rb_read_check _((FILE*)));
|
||||
DEPRECATED(int rb_read_pending _((FILE*)));
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue