diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-08-30 07:07:16 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-08-30 07:07:16 +0000 |
commit | dd0ee2e1022843c6a296a9141b7cab7ea74eec28 (patch) | |
tree | 540fab065032d56a49c05c3787e50500e40bc87d /libio/iofdopen.c | |
parent | b7fc6d07afa8956c5a18d28db02a52d63a70acb8 (diff) | |
download | glibc-dd0ee2e1022843c6a296a9141b7cab7ea74eec28.tar.gz glibc-dd0ee2e1022843c6a296a9141b7cab7ea74eec28.tar.xz glibc-dd0ee2e1022843c6a296a9141b7cab7ea74eec28.zip |
Update.
2002-08-29 Ulrich Drepper <drepper@redhat.com> * libio/fileops.c (_IO_new_file_fopen): Recognize new mode specifier 'm' to enable mmap I/O. * libio/libio.h (_IO_FILE): Rename _blksize field to _flags2. The former wasn't used (anymore?). (_IO_FLAGS2_MMAP): New define. * libio/genops.c (_IO_no_init): Initialize _flags2 field. * libio/iofopen.c (__fopen_maybe_mmap): Use mmap callbacks only if _IO_FLAGS2_MMAP bit is set. * libio/iofdopen.c (_IO_new_fdopen): Recognize 'm' mode specifier. Enable mmap-using mode only if 'm' was set.
Diffstat (limited to 'libio/iofdopen.c')
-rw-r--r-- | libio/iofdopen.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/libio/iofdopen.c b/libio/iofdopen.c index 2fb493e785..e122562f48 100644 --- a/libio/iofdopen.c +++ b/libio/iofdopen.c @@ -59,8 +59,10 @@ _IO_new_fdopen (fd, mode) struct _IO_wide_data wd; } *new_f; int fd_flags; + int i; + int use_mmap = 0; - switch (*mode++) + switch (*mode) { case 'r': read_write = _IO_NO_WRITES; @@ -76,8 +78,26 @@ _IO_new_fdopen (fd, mode) MAYBE_SET_EINVAL; return NULL; } - if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+')) - read_write &= _IO_IS_APPENDING; + for (i = 1; i < 5; ++i) + { + switch (*++mode) + { + case '\0': + break; + case '+': + read_write &= _IO_IS_APPENDING; + break; + case 'm': + use_mmap = 1; + continue; + case 'x': + case 'b': + default: + /* Ignore */ + continue; + } + break; + } #ifdef F_GETFL fd_flags = _IO_fcntl (fd, F_GETFL); #ifndef O_ACCMODE @@ -129,12 +149,13 @@ _IO_new_fdopen (fd, mode) call _IO_file_attach or else it will allocate a buffer immediately. */ _IO_no_init (&new_f->fp.file, 0, 0, &new_f->wd, #ifdef _G_HAVE_MMAP - (read_write & _IO_NO_WRITES) ? &_IO_wfile_jumps_maybe_mmap : + (use_mmap && (read_write & _IO_NO_WRITES)) + ? &_IO_wfile_jumps_maybe_mmap : #endif &INTUSE(_IO_wfile_jumps)); _IO_JUMPS (&new_f->fp) = #ifdef _G_HAVE_MMAP - (read_write & _IO_NO_WRITES) ? &_IO_file_jumps_maybe_mmap : + (use_mmap && (read_write & _IO_NO_WRITES)) ? &_IO_file_jumps_maybe_mmap : #endif &INTUSE(_IO_file_jumps); INTUSE(_IO_file_init) (&new_f->fp); |