mirror of
https://sourceware.org/git/glibc.git
synced 2025-06-16 17:41:01 +03:00
libio: Assume _LIBC, weak_alias, errno, (__set_)errno &c are defined
Do not define _POSIX_SOURCE.
This commit is contained in:
93
ChangeLog
93
ChangeLog
@ -1,3 +1,96 @@
|
|||||||
|
2017-08-31 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
|
* libio/fcloseall.c: Assume weak_alias is defined.
|
||||||
|
* libio/feof.c: Likewise.
|
||||||
|
* libio/fileno.c: Likewise.
|
||||||
|
* libio/fileops.c: Assume _LIBC, errno, __set_errno are defined.
|
||||||
|
(_POSIX_SOURCE, open, lseek, read, write): Remove macro
|
||||||
|
definitions.
|
||||||
|
(_IO_file_open): Call __open directly.
|
||||||
|
(_IO_new_file_sync): Assume ESPIPE is defined.
|
||||||
|
(_IO_file_seekoff_maybe_mmap): Call __read directly.
|
||||||
|
(_IO_new_file_write): Call __write directly.
|
||||||
|
* libio/ftello.c (__ftello): Assume EIO, EOVERFLOW are defined.
|
||||||
|
* libio/ftello64.c (__ftello64): Assume EIO is defined.
|
||||||
|
* libio/genops.c: Assume _LIBC is defined.
|
||||||
|
(save_for_backup): Remove internal_function.
|
||||||
|
* libio/getc.c: Assume weak_alias is defined.
|
||||||
|
* libio/getwc.c: Likewise.
|
||||||
|
* libio/iofclose.c: Assume _LIBC is defined.
|
||||||
|
* libio/iofdopen.c: Likewise.
|
||||||
|
(_IO_fcntl): Remove macro definition.
|
||||||
|
(_IO_new_fdopen): Assume F_GETFL, F_SETFL, O_ACCMODE are defined.
|
||||||
|
Call __fcntl directly.
|
||||||
|
* libio/iofflush.c: Assume weak_alias is defined.
|
||||||
|
* libio/iofgetpos.c (_IO_new_fgetpos): Assume EIO, EOVERFLOW are
|
||||||
|
defined.
|
||||||
|
* libio/iofgetpos64.c (_IO_new_fgetpos64): Assume EIO is defined.
|
||||||
|
* libio/iofgets.c: Likewise.
|
||||||
|
* libio/iofopen.c: Assume _LIBC is defined.
|
||||||
|
* libio/iofopen64.c: Assume _LIBC, weak_alias are defined.
|
||||||
|
* libio/iofputs.c: Assume weak_alias is defined.
|
||||||
|
* libio/iofread.c: Likewise.
|
||||||
|
* libio/iofsetpos.c (_IO_new_fsetpos): Assume EIO is defined.
|
||||||
|
* libio/iofsetpos64.c (_IO_new_fsetpos64): Likewise.
|
||||||
|
* libio/ioftell.c: Assume weak_alias is defined.
|
||||||
|
(_IO_ftell): Assume EIO, EOVERFLOW are defined.
|
||||||
|
* libio/iofwide.c: Assume _LIBC is defined.
|
||||||
|
(_IO_fwide): Drop SHARED conditional because it is implied by
|
||||||
|
SHLIB_COMPAT.
|
||||||
|
* libio/iofwrite.c: Assume weak_alias is defined.
|
||||||
|
* libio/iogetdelim.c: Likewise.
|
||||||
|
* libio/iogets.c: Assume _LIBC, weak_alias are defined.
|
||||||
|
* libio/iogetwline.c (wmemcpy): Remove macro definition.
|
||||||
|
(_IO_getwline): Call __wmemcpy directly.
|
||||||
|
* libio/iopopen.c: Assume _LIBC is defined.
|
||||||
|
(_POSIX_SOURCE, _IO_fork, _IO_dup2, _IO_waitpid, _IO_execl)
|
||||||
|
(_IO_close): Remove macro definitions.
|
||||||
|
(_IO_new_proc_open): Call __fork, __dup2, __close_nocancel, execl,
|
||||||
|
_exit directly.
|
||||||
|
(_IO_new_proc_close): Call __close_nocancel, __waitpid_nocancel
|
||||||
|
directly.
|
||||||
|
* libio/ioputs.c: Assume weak_alias is defined.
|
||||||
|
* libio/ioseekoff.c: Assume errno, __set_errno are defined.
|
||||||
|
* libio/iosetbuffer.c: Assume weak_alias is defined.
|
||||||
|
* libio/iosetvbuf.c: Likewise.
|
||||||
|
* libio/ioungetc.c: Likewise.
|
||||||
|
* libio/libioP.h: Assume _LIBC, __GLIBC__, libc_hidden_proto,
|
||||||
|
libc_hidden_def, libc_hidden_weak, NULL are defined.
|
||||||
|
(mmap, munmap, ftruncate, OS_FSTAT): Remove macro definitions.
|
||||||
|
* libio/oldfilepos.c: Assume _LIBC, errno, __set_errno are
|
||||||
|
defined.
|
||||||
|
(_POSIX_SOURCE, open, lseek, read, write): Remove macro
|
||||||
|
definitions.
|
||||||
|
(_IO_old_file_init_internal): Drop SHARED conditional because it
|
||||||
|
is implied by SHLIB_COMPAT.
|
||||||
|
(_IO_old_file_fopen): Call __open directly.
|
||||||
|
(_IO_old_file_sync): Assume ESPIPE is defined.
|
||||||
|
(_IO_old_file_write): Call __write directly.
|
||||||
|
* libio/oldfdopen.c (_IO_fcntl): Remove macro definition.
|
||||||
|
(_IO_old_fdopen): Assume F_GETFL, O_ACCMODE, F_SETFL are defined.
|
||||||
|
Call __fcntl directly.
|
||||||
|
* libio/oldiofgetpos.c: Assume weak_alias is defined.
|
||||||
|
(_IO_old_fgetpos): Assume EIO is defined.
|
||||||
|
* libio/oldiofgetpos64.c: Assume weak_alias is defined.
|
||||||
|
(_IO_old_fgetpos64): Assume EIO is defined.
|
||||||
|
* libio/oldiofsetpos.c: Assume weak_alias is defined.
|
||||||
|
(_IO_old_fsetpos): Assume EIO is defined.
|
||||||
|
* libio/oldiofsetpos64.c: Assume weak_alias is defined.
|
||||||
|
(_IO_old_fsetpos64): Assume EIO is defined.
|
||||||
|
* libio/oldiopopen.c: Assume _LIBC is defined.
|
||||||
|
(_POSIX_SOURCE, _IO_fork, _IO_dup2, _IO_waitpid, _IO_execl)
|
||||||
|
(_IO_close): Remove macro definitions.
|
||||||
|
(_IO_old_proc_open): Call __pipe, __close, __dup2, execl, _exit
|
||||||
|
directly.
|
||||||
|
(_IO_old_proc_close): Call __close, __waitpid directly.
|
||||||
|
* libio/put.c: Assume weak_alias is defined.
|
||||||
|
* libio/stdfiles.c: Assume _LIBC is defined.
|
||||||
|
* libio/stdio.c: Likewise.
|
||||||
|
* libio/wfileops.c: Likewise.
|
||||||
|
(_IO_wfile_sync): Assume ESPIPE is defined.
|
||||||
|
* libio/wgenops.c: Assume _LIBC is defined.
|
||||||
|
(save_for_wbackup): Remove internal_function.
|
||||||
|
|
||||||
2017-08-31 Florian Weimer <fweimer@redhat.com>
|
2017-08-31 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
* malloc/malloc.c (top_check): Change return type to void. Remove
|
* malloc/malloc.c (top_check): Change return type to void. Remove
|
||||||
|
@ -34,6 +34,4 @@ __fcloseall (void)
|
|||||||
return _IO_cleanup ();
|
return _IO_cleanup ();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (__fcloseall, fcloseall)
|
weak_alias (__fcloseall, fcloseall)
|
||||||
#endif
|
|
||||||
|
@ -40,11 +40,9 @@ _IO_feof (_IO_FILE *fp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_feof, feof)
|
weak_alias (_IO_feof, feof)
|
||||||
|
|
||||||
#ifndef _IO_MTSAFE_IO
|
#ifndef _IO_MTSAFE_IO
|
||||||
#undef feof_unlocked
|
#undef feof_unlocked
|
||||||
weak_alias (_IO_feof, feof_unlocked)
|
weak_alias (_IO_feof, feof_unlocked)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
@ -40,11 +40,9 @@ _IO_ferror (_IO_FILE *fp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_ferror, ferror)
|
weak_alias (_IO_ferror, ferror)
|
||||||
|
|
||||||
#ifndef _IO_MTSAFE_IO
|
#ifndef _IO_MTSAFE_IO
|
||||||
#undef ferror_unlocked
|
#undef ferror_unlocked
|
||||||
weak_alias (_IO_ferror, ferror_unlocked)
|
weak_alias (_IO_ferror, ferror_unlocked)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
@ -44,10 +44,8 @@ libc_hidden_def (__fileno)
|
|||||||
weak_alias (__fileno, fileno)
|
weak_alias (__fileno, fileno)
|
||||||
libc_hidden_weak (fileno)
|
libc_hidden_weak (fileno)
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
/* The fileno implementation for libio does not require locking because
|
/* The fileno implementation for libio does not require locking because
|
||||||
it only accesses once a single variable and this is already atomic
|
it only accesses once a single variable and this is already atomic
|
||||||
(at least at thread level). Therefore we don't test _IO_MTSAFE_IO here. */
|
(at least at thread level). Therefore we don't test _IO_MTSAFE_IO here. */
|
||||||
|
|
||||||
weak_alias (__fileno, fileno_unlocked)
|
weak_alias (__fileno, fileno_unlocked)
|
||||||
#endif
|
|
||||||
|
@ -26,9 +26,6 @@
|
|||||||
in files containing the exception. */
|
in files containing the exception. */
|
||||||
|
|
||||||
|
|
||||||
#ifndef _POSIX_SOURCE
|
|
||||||
# define _POSIX_SOURCE
|
|
||||||
#endif
|
|
||||||
#include "libioP.h"
|
#include "libioP.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -40,48 +37,14 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#if _LIBC
|
#include "../wcsmbs/wcsmbsload.h"
|
||||||
# include "../wcsmbs/wcsmbsload.h"
|
#include "../iconv/gconv_charset.h"
|
||||||
# include "../iconv/gconv_charset.h"
|
#include "../iconv/gconv_int.h"
|
||||||
# include "../iconv/gconv_int.h"
|
#include <shlib-compat.h>
|
||||||
# include <shlib-compat.h>
|
#include <not-cancel.h>
|
||||||
# include <not-cancel.h>
|
#include <kernel-features.h>
|
||||||
# include <kernel-features.h>
|
|
||||||
#endif
|
|
||||||
#ifndef errno
|
|
||||||
extern int errno;
|
|
||||||
#endif
|
|
||||||
#ifndef __set_errno
|
|
||||||
# define __set_errno(Val) errno = (Val)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _LIBC
|
|
||||||
# define open(Name, Flags, Prot) __open (Name, Flags, Prot)
|
|
||||||
# define lseek(FD, Offset, Whence) __lseek (FD, Offset, Whence)
|
|
||||||
# define read(FD, Buf, NBytes) __read (FD, Buf, NBytes)
|
|
||||||
# define write(FD, Buf, NBytes) __write (FD, Buf, NBytes)
|
|
||||||
#else
|
|
||||||
# define _IO_new_do_write _IO_do_write
|
|
||||||
# define _IO_new_file_attach _IO_file_attach
|
|
||||||
# define _IO_new_file_close_it _IO_file_close_it
|
|
||||||
# define _IO_new_file_finish _IO_file_finish
|
|
||||||
# define _IO_new_file_fopen _IO_file_fopen
|
|
||||||
# define _IO_new_file_init _IO_file_init
|
|
||||||
# define _IO_new_file_setbuf _IO_file_setbuf
|
|
||||||
# define _IO_new_file_sync _IO_file_sync
|
|
||||||
# define _IO_new_file_overflow _IO_file_overflow
|
|
||||||
# define _IO_new_file_seekoff _IO_file_seekoff
|
|
||||||
# define _IO_new_file_underflow _IO_file_underflow
|
|
||||||
# define _IO_new_file_write _IO_file_write
|
|
||||||
# define _IO_new_file_xsputn _IO_file_xsputn
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _LIBC
|
|
||||||
extern struct __gconv_trans_data __libio_translit attribute_hidden;
|
extern struct __gconv_trans_data __libio_translit attribute_hidden;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* An fstream can be in at most one of put mode, get mode, or putback mode.
|
/* An fstream can be in at most one of put mode, get mode, or putback mode.
|
||||||
Putback mode is a variant of get mode.
|
Putback mode is a variant of get mode.
|
||||||
@ -180,7 +143,6 @@ _IO_new_file_close_it (_IO_FILE *fp)
|
|||||||
? _IO_SYSCLOSE (fp) : 0);
|
? _IO_SYSCLOSE (fp) : 0);
|
||||||
|
|
||||||
/* Free buffer. */
|
/* Free buffer. */
|
||||||
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
|
|
||||||
if (fp->_mode > 0)
|
if (fp->_mode > 0)
|
||||||
{
|
{
|
||||||
if (_IO_have_wbackup (fp))
|
if (_IO_have_wbackup (fp))
|
||||||
@ -189,7 +151,6 @@ _IO_new_file_close_it (_IO_FILE *fp)
|
|||||||
_IO_wsetg (fp, NULL, NULL, NULL);
|
_IO_wsetg (fp, NULL, NULL, NULL);
|
||||||
_IO_wsetp (fp, NULL, NULL);
|
_IO_wsetp (fp, NULL, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
_IO_setb (fp, NULL, NULL, 0);
|
_IO_setb (fp, NULL, NULL, 0);
|
||||||
_IO_setg (fp, NULL, NULL, NULL);
|
_IO_setg (fp, NULL, NULL, NULL);
|
||||||
_IO_setp (fp, NULL, NULL);
|
_IO_setp (fp, NULL, NULL);
|
||||||
@ -221,15 +182,11 @@ _IO_file_open (_IO_FILE *fp, const char *filename, int posix_mode, int prot,
|
|||||||
int read_write, int is32not64)
|
int read_write, int is32not64)
|
||||||
{
|
{
|
||||||
int fdesc;
|
int fdesc;
|
||||||
#ifdef _LIBC
|
|
||||||
if (__glibc_unlikely (fp->_flags2 & _IO_FLAGS2_NOTCANCEL))
|
if (__glibc_unlikely (fp->_flags2 & _IO_FLAGS2_NOTCANCEL))
|
||||||
fdesc = __open_nocancel (filename,
|
fdesc = __open_nocancel (filename,
|
||||||
posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
|
posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
|
||||||
else
|
else
|
||||||
fdesc = open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
|
fdesc = __open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
|
||||||
#else
|
|
||||||
fdesc = open (filename, posix_mode, prot);
|
|
||||||
#endif
|
|
||||||
if (fdesc < 0)
|
if (fdesc < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
fp->_fileno = fdesc;
|
fp->_fileno = fdesc;
|
||||||
@ -260,10 +217,8 @@ _IO_new_file_fopen (_IO_FILE *fp, const char *filename, const char *mode,
|
|||||||
int oprot = 0666;
|
int oprot = 0666;
|
||||||
int i;
|
int i;
|
||||||
_IO_FILE *result;
|
_IO_FILE *result;
|
||||||
#ifdef _LIBC
|
|
||||||
const char *cs;
|
const char *cs;
|
||||||
const char *last_recognized;
|
const char *last_recognized;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (_IO_file_is_open (fp))
|
if (_IO_file_is_open (fp))
|
||||||
return 0;
|
return 0;
|
||||||
@ -287,9 +242,7 @@ _IO_new_file_fopen (_IO_FILE *fp, const char *filename, const char *mode,
|
|||||||
__set_errno (EINVAL);
|
__set_errno (EINVAL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#ifdef _LIBC
|
|
||||||
last_recognized = mode;
|
last_recognized = mode;
|
||||||
#endif
|
|
||||||
for (i = 1; i < 7; ++i)
|
for (i = 1; i < 7; ++i)
|
||||||
{
|
{
|
||||||
switch (*++mode)
|
switch (*++mode)
|
||||||
@ -299,20 +252,14 @@ _IO_new_file_fopen (_IO_FILE *fp, const char *filename, const char *mode,
|
|||||||
case '+':
|
case '+':
|
||||||
omode = O_RDWR;
|
omode = O_RDWR;
|
||||||
read_write &= _IO_IS_APPENDING;
|
read_write &= _IO_IS_APPENDING;
|
||||||
#ifdef _LIBC
|
|
||||||
last_recognized = mode;
|
last_recognized = mode;
|
||||||
#endif
|
|
||||||
continue;
|
continue;
|
||||||
case 'x':
|
case 'x':
|
||||||
oflags |= O_EXCL;
|
oflags |= O_EXCL;
|
||||||
#ifdef _LIBC
|
|
||||||
last_recognized = mode;
|
last_recognized = mode;
|
||||||
#endif
|
|
||||||
continue;
|
continue;
|
||||||
case 'b':
|
case 'b':
|
||||||
#ifdef _LIBC
|
|
||||||
last_recognized = mode;
|
last_recognized = mode;
|
||||||
#endif
|
|
||||||
continue;
|
continue;
|
||||||
case 'm':
|
case 'm':
|
||||||
fp->_flags2 |= _IO_FLAGS2_MMAP;
|
fp->_flags2 |= _IO_FLAGS2_MMAP;
|
||||||
@ -874,10 +821,8 @@ _IO_new_file_sync (_IO_FILE *fp)
|
|||||||
_IO_off64_t new_pos = _IO_SYSSEEK (fp, delta, 1);
|
_IO_off64_t new_pos = _IO_SYSSEEK (fp, delta, 1);
|
||||||
if (new_pos != (_IO_off64_t) EOF)
|
if (new_pos != (_IO_off64_t) EOF)
|
||||||
fp->_IO_read_end = fp->_IO_read_ptr;
|
fp->_IO_read_end = fp->_IO_read_ptr;
|
||||||
#ifdef ESPIPE
|
|
||||||
else if (errno == ESPIPE)
|
else if (errno == ESPIPE)
|
||||||
; /* Ignore error from unseekable devices. */
|
; /* Ignore error from unseekable devices. */
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
retval = EOF;
|
retval = EOF;
|
||||||
}
|
}
|
||||||
@ -1205,7 +1150,7 @@ _IO_file_read (_IO_FILE *fp, void *buf, _IO_ssize_t size)
|
|||||||
{
|
{
|
||||||
return (__builtin_expect (fp->_flags2 & _IO_FLAGS2_NOTCANCEL, 0)
|
return (__builtin_expect (fp->_flags2 & _IO_FLAGS2_NOTCANCEL, 0)
|
||||||
? __read_nocancel (fp->_fileno, buf, size)
|
? __read_nocancel (fp->_fileno, buf, size)
|
||||||
: read (fp->_fileno, buf, size));
|
: __read (fp->_fileno, buf, size));
|
||||||
}
|
}
|
||||||
libc_hidden_def (_IO_file_read)
|
libc_hidden_def (_IO_file_read)
|
||||||
|
|
||||||
@ -1252,7 +1197,7 @@ _IO_new_file_write (_IO_FILE *f, const void *data, _IO_ssize_t n)
|
|||||||
_IO_ssize_t count = (__builtin_expect (f->_flags2
|
_IO_ssize_t count = (__builtin_expect (f->_flags2
|
||||||
& _IO_FLAGS2_NOTCANCEL, 0)
|
& _IO_FLAGS2_NOTCANCEL, 0)
|
||||||
? __write_nocancel (f->_fileno, data, to_do)
|
? __write_nocancel (f->_fileno, data, to_do)
|
||||||
: write (f->_fileno, data, to_do));
|
: __write (f->_fileno, data, to_do));
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
{
|
{
|
||||||
f->_flags |= _IO_ERR_SEEN;
|
f->_flags |= _IO_ERR_SEEN;
|
||||||
@ -1307,12 +1252,7 @@ _IO_new_file_xsputn (_IO_FILE *f, const void *data, _IO_size_t n)
|
|||||||
{
|
{
|
||||||
if (count > to_do)
|
if (count > to_do)
|
||||||
count = to_do;
|
count = to_do;
|
||||||
#ifdef _LIBC
|
|
||||||
f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
|
f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
|
||||||
#else
|
|
||||||
memcpy (f->_IO_write_ptr, s, count);
|
|
||||||
f->_IO_write_ptr += count;
|
|
||||||
#endif
|
|
||||||
s += count;
|
s += count;
|
||||||
to_do -= count;
|
to_do -= count;
|
||||||
}
|
}
|
||||||
@ -1380,12 +1320,7 @@ _IO_file_xsgetn (_IO_FILE *fp, void *data, _IO_size_t n)
|
|||||||
{
|
{
|
||||||
if (have > 0)
|
if (have > 0)
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
s = __mempcpy (s, fp->_IO_read_ptr, have);
|
s = __mempcpy (s, fp->_IO_read_ptr, have);
|
||||||
#else
|
|
||||||
memcpy (s, fp->_IO_read_ptr, have);
|
|
||||||
s += have;
|
|
||||||
#endif
|
|
||||||
want -= have;
|
want -= have;
|
||||||
fp->_IO_read_ptr += have;
|
fp->_IO_read_ptr += have;
|
||||||
}
|
}
|
||||||
@ -1458,12 +1393,7 @@ _IO_file_xsgetn_mmap (_IO_FILE *fp, void *data, _IO_size_t n)
|
|||||||
{
|
{
|
||||||
if (__glibc_unlikely (_IO_in_backup (fp)))
|
if (__glibc_unlikely (_IO_in_backup (fp)))
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
s = __mempcpy (s, read_ptr, have);
|
s = __mempcpy (s, read_ptr, have);
|
||||||
#else
|
|
||||||
memcpy (s, read_ptr, have);
|
|
||||||
s += have;
|
|
||||||
#endif
|
|
||||||
n -= have;
|
n -= have;
|
||||||
_IO_switch_to_main_get_area (fp);
|
_IO_switch_to_main_get_area (fp);
|
||||||
read_ptr = fp->_IO_read_ptr;
|
read_ptr = fp->_IO_read_ptr;
|
||||||
@ -1488,12 +1418,7 @@ _IO_file_xsgetn_mmap (_IO_FILE *fp, void *data, _IO_size_t n)
|
|||||||
if (have != 0)
|
if (have != 0)
|
||||||
{
|
{
|
||||||
have = MIN (have, n);
|
have = MIN (have, n);
|
||||||
#ifdef _LIBC
|
|
||||||
s = __mempcpy (s, read_ptr, have);
|
s = __mempcpy (s, read_ptr, have);
|
||||||
#else
|
|
||||||
memcpy (s, read_ptr, have);
|
|
||||||
s += have;
|
|
||||||
#endif
|
|
||||||
fp->_IO_read_ptr = read_ptr + have;
|
fp->_IO_read_ptr = read_ptr + have;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1510,7 +1435,6 @@ _IO_file_xsgetn_maybe_mmap (_IO_FILE *fp, void *data, _IO_size_t n)
|
|||||||
return _IO_XSGETN (fp, data, n);
|
return _IO_XSGETN (fp, data, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _LIBC
|
|
||||||
versioned_symbol (libc, _IO_new_do_write, _IO_do_write, GLIBC_2_1);
|
versioned_symbol (libc, _IO_new_do_write, _IO_do_write, GLIBC_2_1);
|
||||||
versioned_symbol (libc, _IO_new_file_attach, _IO_file_attach, GLIBC_2_1);
|
versioned_symbol (libc, _IO_new_file_attach, _IO_file_attach, GLIBC_2_1);
|
||||||
versioned_symbol (libc, _IO_new_file_close_it, _IO_file_close_it, GLIBC_2_1);
|
versioned_symbol (libc, _IO_new_file_close_it, _IO_file_close_it, GLIBC_2_1);
|
||||||
@ -1524,7 +1448,6 @@ versioned_symbol (libc, _IO_new_file_seekoff, _IO_file_seekoff, GLIBC_2_1);
|
|||||||
versioned_symbol (libc, _IO_new_file_underflow, _IO_file_underflow, GLIBC_2_1);
|
versioned_symbol (libc, _IO_new_file_underflow, _IO_file_underflow, GLIBC_2_1);
|
||||||
versioned_symbol (libc, _IO_new_file_write, _IO_file_write, GLIBC_2_1);
|
versioned_symbol (libc, _IO_new_file_write, _IO_file_write, GLIBC_2_1);
|
||||||
versioned_symbol (libc, _IO_new_file_xsputn, _IO_file_xsputn, GLIBC_2_1);
|
versioned_symbol (libc, _IO_new_file_xsputn, _IO_file_xsputn, GLIBC_2_1);
|
||||||
#endif
|
|
||||||
|
|
||||||
const struct _IO_jump_t _IO_file_jumps libio_vtable =
|
const struct _IO_jump_t _IO_file_jumps libio_vtable =
|
||||||
{
|
{
|
||||||
|
@ -45,17 +45,13 @@ __ftello (_IO_FILE *fp)
|
|||||||
_IO_release_lock (fp);
|
_IO_release_lock (fp);
|
||||||
if (pos == _IO_pos_BAD)
|
if (pos == _IO_pos_BAD)
|
||||||
{
|
{
|
||||||
#ifdef EIO
|
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
__set_errno (EIO);
|
__set_errno (EIO);
|
||||||
#endif
|
|
||||||
return -1L;
|
return -1L;
|
||||||
}
|
}
|
||||||
if ((_IO_off64_t) (off_t) pos != pos)
|
if ((_IO_off64_t) (off_t) pos != pos)
|
||||||
{
|
{
|
||||||
#ifdef EOVERFLOW
|
|
||||||
__set_errno (EOVERFLOW);
|
__set_errno (EOVERFLOW);
|
||||||
#endif
|
|
||||||
return -1L;
|
return -1L;
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
|
@ -46,10 +46,8 @@ ftello64 (_IO_FILE *fp)
|
|||||||
_IO_release_lock (fp);
|
_IO_release_lock (fp);
|
||||||
if (pos == _IO_pos_BAD)
|
if (pos == _IO_pos_BAD)
|
||||||
{
|
{
|
||||||
#ifdef EIO
|
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
__set_errno (EIO);
|
__set_errno (EIO);
|
||||||
#endif
|
|
||||||
return -1L;
|
return -1L;
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
|
@ -30,9 +30,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#ifdef _LIBC
|
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _IO_MTSAFE_IO
|
#ifdef _IO_MTSAFE_IO
|
||||||
static _IO_lock_t list_all_lock = _IO_lock_initializer;
|
static _IO_lock_t list_all_lock = _IO_lock_initializer;
|
||||||
@ -233,16 +231,7 @@ __overflow (_IO_FILE *f, int ch)
|
|||||||
}
|
}
|
||||||
libc_hidden_def (__overflow)
|
libc_hidden_def (__overflow)
|
||||||
|
|
||||||
static int save_for_backup (_IO_FILE *fp, char *end_p)
|
|
||||||
#ifdef _LIBC
|
|
||||||
internal_function
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
#ifdef _LIBC
|
|
||||||
internal_function
|
|
||||||
#endif
|
|
||||||
save_for_backup (_IO_FILE *fp, char *end_p)
|
save_for_backup (_IO_FILE *fp, char *end_p)
|
||||||
{
|
{
|
||||||
/* Append [_IO_read_base..end_p] to backup area. */
|
/* Append [_IO_read_base..end_p] to backup area. */
|
||||||
@ -263,20 +252,11 @@ save_for_backup (_IO_FILE *fp, char *end_p)
|
|||||||
return EOF; /* FIXME */
|
return EOF; /* FIXME */
|
||||||
if (least_mark < 0)
|
if (least_mark < 0)
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
__mempcpy (__mempcpy (new_buffer + avail,
|
__mempcpy (__mempcpy (new_buffer + avail,
|
||||||
fp->_IO_save_end + least_mark,
|
fp->_IO_save_end + least_mark,
|
||||||
-least_mark),
|
-least_mark),
|
||||||
fp->_IO_read_base,
|
fp->_IO_read_base,
|
||||||
end_p - fp->_IO_read_base);
|
end_p - fp->_IO_read_base);
|
||||||
#else
|
|
||||||
memcpy (new_buffer + avail,
|
|
||||||
fp->_IO_save_end + least_mark,
|
|
||||||
-least_mark);
|
|
||||||
memcpy (new_buffer + avail - least_mark,
|
|
||||||
fp->_IO_read_base,
|
|
||||||
end_p - fp->_IO_read_base);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
memcpy (new_buffer + avail,
|
memcpy (new_buffer + avail,
|
||||||
@ -314,10 +294,8 @@ save_for_backup (_IO_FILE *fp, char *end_p)
|
|||||||
int
|
int
|
||||||
__underflow (_IO_FILE *fp)
|
__underflow (_IO_FILE *fp)
|
||||||
{
|
{
|
||||||
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
|
|
||||||
if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
|
if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
|
||||||
return EOF;
|
return EOF;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (fp->_mode == 0)
|
if (fp->_mode == 0)
|
||||||
_IO_fwide (fp, -1);
|
_IO_fwide (fp, -1);
|
||||||
@ -346,10 +324,8 @@ libc_hidden_def (__underflow)
|
|||||||
int
|
int
|
||||||
__uflow (_IO_FILE *fp)
|
__uflow (_IO_FILE *fp)
|
||||||
{
|
{
|
||||||
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
|
|
||||||
if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
|
if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
|
||||||
return EOF;
|
return EOF;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (fp->_mode == 0)
|
if (fp->_mode == 0)
|
||||||
_IO_fwide (fp, -1);
|
_IO_fwide (fp, -1);
|
||||||
@ -434,12 +410,7 @@ _IO_default_xsputn (_IO_FILE *f, const void *data, _IO_size_t n)
|
|||||||
count = more;
|
count = more;
|
||||||
if (count > 20)
|
if (count > 20)
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
|
f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
|
||||||
#else
|
|
||||||
memcpy (f->_IO_write_ptr, s, count);
|
|
||||||
f->_IO_write_ptr += count;
|
|
||||||
#endif
|
|
||||||
s += count;
|
s += count;
|
||||||
}
|
}
|
||||||
else if (count)
|
else if (count)
|
||||||
@ -483,12 +454,7 @@ _IO_default_xsgetn (_IO_FILE *fp, void *data, _IO_size_t n)
|
|||||||
count = more;
|
count = more;
|
||||||
if (count > 20)
|
if (count > 20)
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
s = __mempcpy (s, fp->_IO_read_ptr, count);
|
s = __mempcpy (s, fp->_IO_read_ptr, count);
|
||||||
#else
|
|
||||||
memcpy (s, fp->_IO_read_ptr, count);
|
|
||||||
s += count;
|
|
||||||
#endif
|
|
||||||
fp->_IO_read_ptr += count;
|
fp->_IO_read_ptr += count;
|
||||||
}
|
}
|
||||||
else if (count)
|
else if (count)
|
||||||
@ -633,7 +599,6 @@ _IO_no_init (_IO_FILE *fp, int flags, int orientation,
|
|||||||
{
|
{
|
||||||
_IO_old_init (fp, flags);
|
_IO_old_init (fp, flags);
|
||||||
fp->_mode = orientation;
|
fp->_mode = orientation;
|
||||||
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
|
|
||||||
if (orientation >= 0)
|
if (orientation >= 0)
|
||||||
{
|
{
|
||||||
fp->_wide_data = wd;
|
fp->_wide_data = wd;
|
||||||
@ -655,7 +620,6 @@ _IO_no_init (_IO_FILE *fp, int flags, int orientation,
|
|||||||
/* Cause predictable crash when a wide function is called on a byte
|
/* Cause predictable crash when a wide function is called on a byte
|
||||||
stream. */
|
stream. */
|
||||||
fp->_wide_data = (struct _IO_wide_data *) -1L;
|
fp->_wide_data = (struct _IO_wide_data *) -1L;
|
||||||
#endif
|
|
||||||
fp->_freeres_list = NULL;
|
fp->_freeres_list = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,11 +775,9 @@ _IO_flush_all_lockp (int do_lock)
|
|||||||
_IO_flockfile (fp);
|
_IO_flockfile (fp);
|
||||||
|
|
||||||
if (((fp->_mode <= 0 && fp->_IO_write_ptr > fp->_IO_write_base)
|
if (((fp->_mode <= 0 && fp->_IO_write_ptr > fp->_IO_write_base)
|
||||||
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
|
|
||||||
|| (_IO_vtable_offset (fp) == 0
|
|| (_IO_vtable_offset (fp) == 0
|
||||||
&& fp->_mode > 0 && (fp->_wide_data->_IO_write_ptr
|
&& fp->_mode > 0 && (fp->_wide_data->_IO_write_ptr
|
||||||
> fp->_wide_data->_IO_write_base))
|
> fp->_wide_data->_IO_write_base))
|
||||||
#endif
|
|
||||||
)
|
)
|
||||||
&& _IO_OVERFLOW (fp, EOF) == EOF)
|
&& _IO_OVERFLOW (fp, EOF) == EOF)
|
||||||
result = EOF;
|
result = EOF;
|
||||||
@ -892,9 +854,7 @@ _IO_flush_all_linebuffered (void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
libc_hidden_def (_IO_flush_all_linebuffered)
|
libc_hidden_def (_IO_flush_all_linebuffered)
|
||||||
#ifdef _LIBC
|
|
||||||
weak_alias (_IO_flush_all_linebuffered, _flushlbf)
|
weak_alias (_IO_flush_all_linebuffered, _flushlbf)
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* The following is a bit tricky. In general, we want to unbuffer the
|
/* The following is a bit tricky. In general, we want to unbuffer the
|
||||||
|
@ -44,7 +44,6 @@ _IO_getc (FILE *fp)
|
|||||||
|
|
||||||
#undef getc
|
#undef getc
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_getc, getc)
|
weak_alias (_IO_getc, getc)
|
||||||
weak_alias (_IO_getc, fgetc)
|
weak_alias (_IO_getc, fgetc)
|
||||||
|
|
||||||
@ -53,4 +52,3 @@ weak_alias (_IO_getc, fgetc)
|
|||||||
weak_alias (_IO_getc, getc_unlocked)
|
weak_alias (_IO_getc, getc_unlocked)
|
||||||
weak_alias (_IO_getc, fgetc_unlocked)
|
weak_alias (_IO_getc, fgetc_unlocked)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
@ -43,7 +43,5 @@ _IO_getwc (FILE *fp)
|
|||||||
|
|
||||||
#undef getwc
|
#undef getwc
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_getwc, getwc)
|
weak_alias (_IO_getwc, getwc)
|
||||||
weak_alias (_IO_getwc, fgetwc)
|
weak_alias (_IO_getwc, fgetwc)
|
||||||
#endif
|
|
||||||
|
@ -26,13 +26,8 @@
|
|||||||
|
|
||||||
#include "libioP.h"
|
#include "libioP.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#if _LIBC
|
#include "../iconv/gconv_int.h"
|
||||||
# include "../iconv/gconv_int.h"
|
#include <shlib-compat.h>
|
||||||
# include <shlib-compat.h>
|
|
||||||
#else
|
|
||||||
# define SHLIB_COMPAT(a, b, c) 0
|
|
||||||
# define _IO_new_fclose fclose
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
_IO_new_fclose (_IO_FILE *fp)
|
_IO_new_fclose (_IO_FILE *fp)
|
||||||
@ -62,7 +57,6 @@ _IO_new_fclose (_IO_FILE *fp)
|
|||||||
_IO_FINISH (fp);
|
_IO_FINISH (fp);
|
||||||
if (fp->_mode > 0)
|
if (fp->_mode > 0)
|
||||||
{
|
{
|
||||||
#if _LIBC
|
|
||||||
/* This stream has a wide orientation. This means we have to free
|
/* This stream has a wide orientation. This means we have to free
|
||||||
the conversion functions. */
|
the conversion functions. */
|
||||||
struct _IO_codecvt *cc = fp->_codecvt;
|
struct _IO_codecvt *cc = fp->_codecvt;
|
||||||
@ -71,7 +65,6 @@ _IO_new_fclose (_IO_FILE *fp)
|
|||||||
__gconv_release_step (cc->__cd_in.__cd.__steps);
|
__gconv_release_step (cc->__cd_in.__cd.__steps);
|
||||||
__gconv_release_step (cc->__cd_out.__cd.__steps);
|
__gconv_release_step (cc->__cd_out.__cd.__steps);
|
||||||
__libc_lock_unlock (__gconv_lock);
|
__libc_lock_unlock (__gconv_lock);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -87,8 +80,6 @@ _IO_new_fclose (_IO_FILE *fp)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _LIBC
|
|
||||||
versioned_symbol (libc, _IO_new_fclose, _IO_fclose, GLIBC_2_1);
|
versioned_symbol (libc, _IO_new_fclose, _IO_fclose, GLIBC_2_1);
|
||||||
strong_alias (_IO_new_fclose, __new_fclose)
|
strong_alias (_IO_new_fclose, __new_fclose)
|
||||||
versioned_symbol (libc, __new_fclose, fclose, GLIBC_2_1);
|
versioned_symbol (libc, __new_fclose, fclose, GLIBC_2_1);
|
||||||
#endif
|
|
||||||
|
@ -28,17 +28,7 @@
|
|||||||
#include "libioP.h"
|
#include "libioP.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#ifdef _LIBC
|
#include <shlib-compat.h>
|
||||||
# include <shlib-compat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _IO_fcntl
|
|
||||||
#ifdef _LIBC
|
|
||||||
#define _IO_fcntl __fcntl
|
|
||||||
#else
|
|
||||||
#define _IO_fcntl fcntl
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_IO_FILE *
|
_IO_FILE *
|
||||||
_IO_new_fdopen (int fd, const char *mode)
|
_IO_new_fdopen (int fd, const char *mode)
|
||||||
@ -95,11 +85,7 @@ _IO_new_fdopen (int fd, const char *mode)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef F_GETFL
|
int fd_flags = __fcntl (fd, F_GETFL);
|
||||||
int fd_flags = _IO_fcntl (fd, F_GETFL);
|
|
||||||
#ifndef O_ACCMODE
|
|
||||||
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
|
|
||||||
#endif
|
|
||||||
if (fd_flags == -1)
|
if (fd_flags == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -129,12 +115,9 @@ _IO_new_fdopen (int fd, const char *mode)
|
|||||||
if ((read_write & _IO_IS_APPENDING) && !(fd_flags & O_APPEND))
|
if ((read_write & _IO_IS_APPENDING) && !(fd_flags & O_APPEND))
|
||||||
{
|
{
|
||||||
do_seek = true;
|
do_seek = true;
|
||||||
#ifdef F_SETFL
|
if (__fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
|
||||||
if (_IO_fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
|
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
|
new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
|
||||||
if (new_f == NULL)
|
if (new_f == NULL)
|
||||||
|
@ -44,7 +44,6 @@ _IO_fflush (_IO_FILE *fp)
|
|||||||
}
|
}
|
||||||
libc_hidden_def (_IO_fflush)
|
libc_hidden_def (_IO_fflush)
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_fflush, fflush)
|
weak_alias (_IO_fflush, fflush)
|
||||||
libc_hidden_weak (fflush)
|
libc_hidden_weak (fflush)
|
||||||
|
|
||||||
@ -54,4 +53,3 @@ libc_hidden_def (__fflush_unlocked)
|
|||||||
weak_alias (_IO_fflush, fflush_unlocked)
|
weak_alias (_IO_fflush, fflush_unlocked)
|
||||||
libc_hidden_weak (fflush_unlocked)
|
libc_hidden_weak (fflush_unlocked)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
@ -56,17 +56,13 @@ _IO_new_fgetpos (_IO_FILE *fp, _IO_fpos_t *posp)
|
|||||||
{
|
{
|
||||||
/* ANSI explicitly requires setting errno to a positive value on
|
/* ANSI explicitly requires setting errno to a positive value on
|
||||||
failure. */
|
failure. */
|
||||||
#ifdef EIO
|
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
__set_errno (EIO);
|
__set_errno (EIO);
|
||||||
#endif
|
|
||||||
result = EOF;
|
result = EOF;
|
||||||
}
|
}
|
||||||
else if ((_IO_off64_t) (__typeof (posp->__pos)) pos != pos)
|
else if ((_IO_off64_t) (__typeof (posp->__pos)) pos != pos)
|
||||||
{
|
{
|
||||||
#ifdef EOVERFLOW
|
|
||||||
__set_errno (EOVERFLOW);
|
__set_errno (EOVERFLOW);
|
||||||
#endif
|
|
||||||
result = EOF;
|
result = EOF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -47,10 +47,8 @@ _IO_new_fgetpos64 (_IO_FILE *fp, _IO_fpos64_t *posp)
|
|||||||
{
|
{
|
||||||
/* ANSI explicitly requires setting errno to a positive value on
|
/* ANSI explicitly requires setting errno to a positive value on
|
||||||
failure. */
|
failure. */
|
||||||
# ifdef EIO
|
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
__set_errno (EIO);
|
__set_errno (EIO);
|
||||||
# endif
|
|
||||||
result = EOF;
|
result = EOF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -66,7 +66,6 @@ _IO_fgets (char *buf, int n, _IO_FILE *fp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_fgets, fgets)
|
weak_alias (_IO_fgets, fgets)
|
||||||
|
|
||||||
# ifndef _IO_MTSAFE_IO
|
# ifndef _IO_MTSAFE_IO
|
||||||
@ -75,4 +74,3 @@ libc_hidden_def (__fgets_unlocked)
|
|||||||
weak_alias (_IO_fgets, fgets_unlocked)
|
weak_alias (_IO_fgets, fgets_unlocked)
|
||||||
libc_hidden_weak (fgets_unlocked)
|
libc_hidden_weak (fgets_unlocked)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
|
||||||
|
@ -28,11 +28,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#ifdef _LIBC
|
#include <shlib-compat.h>
|
||||||
# include <shlib-compat.h>
|
|
||||||
#else
|
|
||||||
# define _IO_new_fopen fopen
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_IO_FILE *
|
_IO_FILE *
|
||||||
__fopen_maybe_mmap (_IO_FILE *fp)
|
__fopen_maybe_mmap (_IO_FILE *fp)
|
||||||
@ -73,11 +69,7 @@ __fopen_internal (const char *filename, const char *mode, int is32)
|
|||||||
#ifdef _IO_MTSAFE_IO
|
#ifdef _IO_MTSAFE_IO
|
||||||
new_f->fp.file._lock = &new_f->lock;
|
new_f->fp.file._lock = &new_f->lock;
|
||||||
#endif
|
#endif
|
||||||
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
|
|
||||||
_IO_no_init (&new_f->fp.file, 0, 0, &new_f->wd, &_IO_wfile_jumps);
|
_IO_no_init (&new_f->fp.file, 0, 0, &new_f->wd, &_IO_wfile_jumps);
|
||||||
#else
|
|
||||||
_IO_no_init (&new_f->fp.file, 1, 0, NULL, NULL);
|
|
||||||
#endif
|
|
||||||
_IO_JUMPS (&new_f->fp) = &_IO_file_jumps;
|
_IO_JUMPS (&new_f->fp) = &_IO_file_jumps;
|
||||||
_IO_new_file_init_internal (&new_f->fp);
|
_IO_new_file_init_internal (&new_f->fp);
|
||||||
#if !_IO_UNIFIED_JUMPTABLES
|
#if !_IO_UNIFIED_JUMPTABLES
|
||||||
@ -97,7 +89,6 @@ _IO_new_fopen (const char *filename, const char *mode)
|
|||||||
return __fopen_internal (filename, mode, 1);
|
return __fopen_internal (filename, mode, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _LIBC
|
|
||||||
strong_alias (_IO_new_fopen, __new_fopen)
|
strong_alias (_IO_new_fopen, __new_fopen)
|
||||||
versioned_symbol (libc, _IO_new_fopen, _IO_fopen, GLIBC_2_1);
|
versioned_symbol (libc, _IO_new_fopen, _IO_fopen, GLIBC_2_1);
|
||||||
versioned_symbol (libc, __new_fopen, fopen, GLIBC_2_1);
|
versioned_symbol (libc, __new_fopen, fopen, GLIBC_2_1);
|
||||||
@ -106,4 +97,3 @@ versioned_symbol (libc, __new_fopen, fopen, GLIBC_2_1);
|
|||||||
weak_alias (_IO_new_fopen, _IO_fopen64)
|
weak_alias (_IO_new_fopen, _IO_fopen64)
|
||||||
weak_alias (_IO_new_fopen, fopen64)
|
weak_alias (_IO_new_fopen, fopen64)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* iofopen.c defines _IO_fopen64/fopen64 as aliases if O_LARGEFILE==0. */
|
/* iofopen.c defines _IO_fopen64/fopen64 as aliases if O_LARGEFILE==0. */
|
||||||
#if !defined _LIBC || (defined O_LARGEFILE && O_LARGEFILE != 0)
|
#if defined O_LARGEFILE && O_LARGEFILE != 0
|
||||||
|
|
||||||
_IO_FILE *
|
_IO_FILE *
|
||||||
_IO_fopen64 (const char *filename, const char *mode)
|
_IO_fopen64 (const char *filename, const char *mode)
|
||||||
@ -37,8 +37,6 @@ _IO_fopen64 (const char *filename, const char *mode)
|
|||||||
return __fopen_internal (filename, mode, 0);
|
return __fopen_internal (filename, mode, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_fopen64, fopen64)
|
weak_alias (_IO_fopen64, fopen64)
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,7 +42,6 @@ _IO_fputs (const char *str, _IO_FILE *fp)
|
|||||||
}
|
}
|
||||||
libc_hidden_def (_IO_fputs)
|
libc_hidden_def (_IO_fputs)
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_fputs, fputs)
|
weak_alias (_IO_fputs, fputs)
|
||||||
|
|
||||||
# ifndef _IO_MTSAFE_IO
|
# ifndef _IO_MTSAFE_IO
|
||||||
@ -51,4 +50,3 @@ libc_hidden_def (__fputs_unlocked)
|
|||||||
weak_alias (_IO_fputs, fputs_unlocked)
|
weak_alias (_IO_fputs, fputs_unlocked)
|
||||||
libc_hidden_ver (_IO_fputs, fputs_unlocked)
|
libc_hidden_ver (_IO_fputs, fputs_unlocked)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
|
||||||
|
@ -41,7 +41,6 @@ _IO_fread (void *buf, _IO_size_t size, _IO_size_t count, _IO_FILE *fp)
|
|||||||
}
|
}
|
||||||
libc_hidden_def (_IO_fread)
|
libc_hidden_def (_IO_fread)
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_fread, fread)
|
weak_alias (_IO_fread, fread)
|
||||||
|
|
||||||
# ifndef _IO_MTSAFE_IO
|
# ifndef _IO_MTSAFE_IO
|
||||||
@ -49,4 +48,3 @@ strong_alias (_IO_fread, __fread_unlocked)
|
|||||||
libc_hidden_def (__fread_unlocked)
|
libc_hidden_def (__fread_unlocked)
|
||||||
weak_alias (_IO_fread, fread_unlocked)
|
weak_alias (_IO_fread, fread_unlocked)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
|
||||||
|
@ -49,10 +49,8 @@ _IO_new_fsetpos (_IO_FILE *fp, const _IO_fpos_t *posp)
|
|||||||
{
|
{
|
||||||
/* ANSI explicitly requires setting errno to a positive value on
|
/* ANSI explicitly requires setting errno to a positive value on
|
||||||
failure. */
|
failure. */
|
||||||
#ifdef EIO
|
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
__set_errno (EIO);
|
__set_errno (EIO);
|
||||||
#endif
|
|
||||||
result = EOF;
|
result = EOF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -41,10 +41,8 @@ _IO_new_fsetpos64 (_IO_FILE *fp, const _IO_fpos64_t *posp)
|
|||||||
{
|
{
|
||||||
/* ANSI explicitly requires setting errno to a positive value on
|
/* ANSI explicitly requires setting errno to a positive value on
|
||||||
failure. */
|
failure. */
|
||||||
#ifdef EIO
|
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
__set_errno (EIO);
|
__set_errno (EIO);
|
||||||
#endif
|
|
||||||
result = EOF;
|
result = EOF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -44,23 +44,17 @@ _IO_ftell (_IO_FILE *fp)
|
|||||||
_IO_release_lock (fp);
|
_IO_release_lock (fp);
|
||||||
if (pos == _IO_pos_BAD)
|
if (pos == _IO_pos_BAD)
|
||||||
{
|
{
|
||||||
#ifdef EIO
|
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
__set_errno (EIO);
|
__set_errno (EIO);
|
||||||
#endif
|
|
||||||
return -1L;
|
return -1L;
|
||||||
}
|
}
|
||||||
if ((_IO_off64_t) (long int) pos != pos)
|
if ((_IO_off64_t) (long int) pos != pos)
|
||||||
{
|
{
|
||||||
#ifdef EOVERFLOW
|
|
||||||
__set_errno (EOVERFLOW);
|
__set_errno (EOVERFLOW);
|
||||||
#endif
|
|
||||||
return -1L;
|
return -1L;
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
libc_hidden_def (_IO_ftell)
|
libc_hidden_def (_IO_ftell)
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_ftell, ftell)
|
weak_alias (_IO_ftell, ftell)
|
||||||
#endif
|
|
||||||
|
154
libio/iofwide.c
154
libio/iofwide.c
@ -25,22 +25,18 @@
|
|||||||
in files containing the exception. */
|
in files containing the exception. */
|
||||||
|
|
||||||
#include <libioP.h>
|
#include <libioP.h>
|
||||||
#ifdef _LIBC
|
#include <dlfcn.h>
|
||||||
# include <dlfcn.h>
|
#include <wchar.h>
|
||||||
# include <wchar.h>
|
|
||||||
#endif
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef _LIBC
|
#include <langinfo.h>
|
||||||
# include <langinfo.h>
|
#include <locale/localeinfo.h>
|
||||||
# include <locale/localeinfo.h>
|
#include <wcsmbs/wcsmbsload.h>
|
||||||
# include <wcsmbs/wcsmbsload.h>
|
#include <iconv/gconv_int.h>
|
||||||
# include <iconv/gconv_int.h>
|
#include <shlib-compat.h>
|
||||||
# include <shlib-compat.h>
|
#include <sysdep.h>
|
||||||
# include <sysdep.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes of libio's codecvt functions. */
|
/* Prototypes of libio's codecvt functions. */
|
||||||
@ -90,8 +86,7 @@ _IO_fwide (_IO_FILE *fp, int mode)
|
|||||||
/* Normalize the value. */
|
/* Normalize the value. */
|
||||||
mode = mode < 0 ? -1 : (mode == 0 ? 0 : 1);
|
mode = mode < 0 ? -1 : (mode == 0 ? 0 : 1);
|
||||||
|
|
||||||
#if defined SHARED && defined _LIBC \
|
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
|
||||||
&& SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
|
|
||||||
if (__builtin_expect (&_IO_stdin_used == NULL, 0)
|
if (__builtin_expect (&_IO_stdin_used == NULL, 0)
|
||||||
&& (fp == _IO_stdin || fp == _IO_stdout || fp == _IO_stderr))
|
&& (fp == _IO_stdin || fp == _IO_stdout || fp == _IO_stderr))
|
||||||
/* This is for a stream in the glibc 2.0 format. */
|
/* This is for a stream in the glibc 2.0 format. */
|
||||||
@ -114,7 +109,6 @@ _IO_fwide (_IO_FILE *fp, int mode)
|
|||||||
|
|
||||||
/* Get the character conversion functions based on the currently
|
/* Get the character conversion functions based on the currently
|
||||||
selected locale for LC_CTYPE. */
|
selected locale for LC_CTYPE. */
|
||||||
#ifdef _LIBC
|
|
||||||
{
|
{
|
||||||
/* Clear the state. We start all over again. */
|
/* Clear the state. We start all over again. */
|
||||||
memset (&fp->_wide_data->_IO_state, '\0', sizeof (__mbstate_t));
|
memset (&fp->_wide_data->_IO_state, '\0', sizeof (__mbstate_t));
|
||||||
@ -145,41 +139,6 @@ _IO_fwide (_IO_FILE *fp, int mode)
|
|||||||
= __GCONV_IS_LAST | __GCONV_TRANSLIT;
|
= __GCONV_IS_LAST | __GCONV_TRANSLIT;
|
||||||
cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state;
|
cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
# ifdef _GLIBCPP_USE_WCHAR_T
|
|
||||||
{
|
|
||||||
/* Determine internal and external character sets.
|
|
||||||
|
|
||||||
XXX For now we make our life easy: we assume a fixed internal
|
|
||||||
encoding (as most sane systems have; hi HP/UX!). If somebody
|
|
||||||
cares about systems which changing internal charsets they
|
|
||||||
should come up with a solution for the determination of the
|
|
||||||
currently used internal character set. */
|
|
||||||
const char *internal_ccs = _G_INTERNAL_CCS;
|
|
||||||
const char *external_ccs = NULL;
|
|
||||||
|
|
||||||
# ifdef HAVE_NL_LANGINFO
|
|
||||||
external_ccs = nl_langinfo (CODESET);
|
|
||||||
# endif
|
|
||||||
if (external_ccs == NULL)
|
|
||||||
external_ccs = "ISO-8859-1";
|
|
||||||
|
|
||||||
cc->__cd_in = iconv_open (internal_ccs, external_ccs);
|
|
||||||
if (cc->__cd_in != (iconv_t) -1)
|
|
||||||
cc->__cd_out = iconv_open (external_ccs, internal_ccs);
|
|
||||||
|
|
||||||
if (cc->__cd_in == (iconv_t) -1 || cc->__cd_out == (iconv_t) -1)
|
|
||||||
{
|
|
||||||
if (cc->__cd_in != (iconv_t) -1)
|
|
||||||
iconv_close (cc->__cd_in);
|
|
||||||
/* XXX */
|
|
||||||
abort ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# else
|
|
||||||
# error "somehow determine this from LC_CTYPE"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* From now on use the wide character callback functions. */
|
/* From now on use the wide character callback functions. */
|
||||||
_IO_JUMPS_FILE_plus (fp) = fp->_wide_data->_wide_vtable;
|
_IO_JUMPS_FILE_plus (fp) = fp->_wide_data->_wide_vtable;
|
||||||
@ -200,7 +159,6 @@ do_out (struct _IO_codecvt *codecvt, __mbstate_t *statep,
|
|||||||
{
|
{
|
||||||
enum __codecvt_result result;
|
enum __codecvt_result result;
|
||||||
|
|
||||||
#ifdef _LIBC
|
|
||||||
struct __gconv_step *gs = codecvt->__cd_out.__cd.__steps;
|
struct __gconv_step *gs = codecvt->__cd_out.__cd.__steps;
|
||||||
int status;
|
int status;
|
||||||
size_t dummy;
|
size_t dummy;
|
||||||
@ -240,28 +198,6 @@ do_out (struct _IO_codecvt *codecvt, __mbstate_t *statep,
|
|||||||
result = __codecvt_error;
|
result = __codecvt_error;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
# ifdef _GLIBCPP_USE_WCHAR_T
|
|
||||||
size_t res;
|
|
||||||
const char *from_start_copy = (const char *) from_start;
|
|
||||||
size_t from_len = from_end - from_start;
|
|
||||||
char *to_start_copy = to_start;
|
|
||||||
size_t to_len = to_end - to_start;
|
|
||||||
res = iconv (codecvt->__cd_out, &from_start_copy, &from_len,
|
|
||||||
&to_start_copy, &to_len);
|
|
||||||
|
|
||||||
if (res == 0 || from_len == 0)
|
|
||||||
result = __codecvt_ok;
|
|
||||||
else if (to_len < codecvt->__codecvt_do_max_length (codecvt))
|
|
||||||
result = __codecvt_partial;
|
|
||||||
else
|
|
||||||
result = __codecvt_error;
|
|
||||||
|
|
||||||
# else
|
|
||||||
/* Decide what to do. */
|
|
||||||
result = __codecvt_error;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -273,7 +209,6 @@ do_unshift (struct _IO_codecvt *codecvt, __mbstate_t *statep,
|
|||||||
{
|
{
|
||||||
enum __codecvt_result result;
|
enum __codecvt_result result;
|
||||||
|
|
||||||
#ifdef _LIBC
|
|
||||||
struct __gconv_step *gs = codecvt->__cd_out.__cd.__steps;
|
struct __gconv_step *gs = codecvt->__cd_out.__cd.__steps;
|
||||||
int status;
|
int status;
|
||||||
size_t dummy;
|
size_t dummy;
|
||||||
@ -310,25 +245,6 @@ do_unshift (struct _IO_codecvt *codecvt, __mbstate_t *statep,
|
|||||||
result = __codecvt_error;
|
result = __codecvt_error;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
# ifdef _GLIBCPP_USE_WCHAR_T
|
|
||||||
size_t res;
|
|
||||||
char *to_start_copy = (char *) to_start;
|
|
||||||
size_t to_len = to_end - to_start;
|
|
||||||
|
|
||||||
res = iconv (codecvt->__cd_out, NULL, NULL, &to_start_copy, &to_len);
|
|
||||||
|
|
||||||
if (res == 0)
|
|
||||||
result = __codecvt_ok;
|
|
||||||
else if (to_len < codecvt->__codecvt_do_max_length (codecvt))
|
|
||||||
result = __codecvt_partial;
|
|
||||||
else
|
|
||||||
result = __codecvt_error;
|
|
||||||
# else
|
|
||||||
/* Decide what to do. */
|
|
||||||
result = __codecvt_error;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -341,7 +257,6 @@ do_in (struct _IO_codecvt *codecvt, __mbstate_t *statep,
|
|||||||
{
|
{
|
||||||
enum __codecvt_result result;
|
enum __codecvt_result result;
|
||||||
|
|
||||||
#ifdef _LIBC
|
|
||||||
struct __gconv_step *gs = codecvt->__cd_in.__cd.__steps;
|
struct __gconv_step *gs = codecvt->__cd_in.__cd.__steps;
|
||||||
int status;
|
int status;
|
||||||
size_t dummy;
|
size_t dummy;
|
||||||
@ -381,30 +296,6 @@ do_in (struct _IO_codecvt *codecvt, __mbstate_t *statep,
|
|||||||
result = __codecvt_error;
|
result = __codecvt_error;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
# ifdef _GLIBCPP_USE_WCHAR_T
|
|
||||||
size_t res;
|
|
||||||
const char *from_start_copy = (const char *) from_start;
|
|
||||||
size_t from_len = from_end - from_start;
|
|
||||||
char *to_start_copy = (char *) from_start;
|
|
||||||
size_t to_len = to_end - to_start;
|
|
||||||
|
|
||||||
res = iconv (codecvt->__cd_in, &from_start_copy, &from_len,
|
|
||||||
&to_start_copy, &to_len);
|
|
||||||
|
|
||||||
if (res == 0)
|
|
||||||
result = __codecvt_ok;
|
|
||||||
else if (to_len == 0)
|
|
||||||
result = __codecvt_partial;
|
|
||||||
else if (from_len < codecvt->__codecvt_do_max_length (codecvt))
|
|
||||||
result = __codecvt_partial;
|
|
||||||
else
|
|
||||||
result = __codecvt_error;
|
|
||||||
# else
|
|
||||||
/* Decide what to do. */
|
|
||||||
result = __codecvt_error;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -413,7 +304,6 @@ do_in (struct _IO_codecvt *codecvt, __mbstate_t *statep,
|
|||||||
static int
|
static int
|
||||||
do_encoding (struct _IO_codecvt *codecvt)
|
do_encoding (struct _IO_codecvt *codecvt)
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
/* See whether the encoding is stateful. */
|
/* See whether the encoding is stateful. */
|
||||||
if (codecvt->__cd_in.__cd.__steps[0].__stateful)
|
if (codecvt->__cd_in.__cd.__steps[0].__stateful)
|
||||||
return -1;
|
return -1;
|
||||||
@ -425,10 +315,6 @@ do_encoding (struct _IO_codecvt *codecvt)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return codecvt->__cd_in.__cd.__steps[0].__min_needed_from;
|
return codecvt->__cd_in.__cd.__steps[0].__min_needed_from;
|
||||||
#else
|
|
||||||
/* Worst case scenario. */
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -444,7 +330,6 @@ do_length (struct _IO_codecvt *codecvt, __mbstate_t *statep,
|
|||||||
const char *from_start, const char *from_end, _IO_size_t max)
|
const char *from_start, const char *from_end, _IO_size_t max)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
#ifdef _LIBC
|
|
||||||
const unsigned char *cp = (const unsigned char *) from_start;
|
const unsigned char *cp = (const unsigned char *) from_start;
|
||||||
wchar_t to_buf[max];
|
wchar_t to_buf[max];
|
||||||
struct __gconv_step *gs = codecvt->__cd_in.__cd.__steps;
|
struct __gconv_step *gs = codecvt->__cd_in.__cd.__steps;
|
||||||
@ -466,23 +351,6 @@ do_length (struct _IO_codecvt *codecvt, __mbstate_t *statep,
|
|||||||
&dummy, 0, 0));
|
&dummy, 0, 0));
|
||||||
|
|
||||||
result = cp - (const unsigned char *) from_start;
|
result = cp - (const unsigned char *) from_start;
|
||||||
#else
|
|
||||||
# ifdef _GLIBCPP_USE_WCHAR_T
|
|
||||||
const char *from_start_copy = (const char *) from_start;
|
|
||||||
size_t from_len = from_end - from_start;
|
|
||||||
wchar_t to_buf[max];
|
|
||||||
size_t res;
|
|
||||||
char *to_start = (char *) to_buf;
|
|
||||||
|
|
||||||
res = iconv (codecvt->__cd_in, &from_start_copy, &from_len,
|
|
||||||
&to_start, &max);
|
|
||||||
|
|
||||||
result = from_start_copy - (char *) from_start;
|
|
||||||
# else
|
|
||||||
/* Decide what to do. */
|
|
||||||
result = 0;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -491,9 +359,5 @@ do_length (struct _IO_codecvt *codecvt, __mbstate_t *statep,
|
|||||||
static int
|
static int
|
||||||
do_max_length (struct _IO_codecvt *codecvt)
|
do_max_length (struct _IO_codecvt *codecvt)
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
return codecvt->__cd_in.__cd.__steps[0].__max_needed_from;
|
return codecvt->__cd_in.__cd.__steps[0].__max_needed_from;
|
||||||
#else
|
|
||||||
return MB_CUR_MAX;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,6 @@ _IO_fwrite (const void *buf, _IO_size_t size, _IO_size_t count, _IO_FILE *fp)
|
|||||||
}
|
}
|
||||||
libc_hidden_def (_IO_fwrite)
|
libc_hidden_def (_IO_fwrite)
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
weak_alias (_IO_fwrite, fwrite)
|
weak_alias (_IO_fwrite, fwrite)
|
||||||
libc_hidden_weak (fwrite)
|
libc_hidden_weak (fwrite)
|
||||||
@ -57,4 +56,3 @@ libc_hidden_weak (fwrite)
|
|||||||
weak_alias (_IO_fwrite, fwrite_unlocked)
|
weak_alias (_IO_fwrite, fwrite_unlocked)
|
||||||
libc_hidden_weak (fwrite_unlocked)
|
libc_hidden_weak (fwrite_unlocked)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
|
||||||
|
@ -123,7 +123,5 @@ unlock_return:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_getdelim, __getdelim)
|
weak_alias (_IO_getdelim, __getdelim)
|
||||||
weak_alias (_IO_getdelim, getdelim)
|
weak_alias (_IO_getdelim, getdelim)
|
||||||
#endif
|
|
||||||
|
@ -67,10 +67,6 @@ unlock_return:
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_gets, gets)
|
weak_alias (_IO_gets, gets)
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _LIBC
|
|
||||||
link_warning (gets, "the `gets' function is dangerous and should not be used.")
|
link_warning (gets, "the `gets' function is dangerous and should not be used.")
|
||||||
#endif
|
|
||||||
|
@ -28,10 +28,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#ifdef _LIBC
|
|
||||||
# define wmemcpy __wmemcpy
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_IO_size_t
|
_IO_size_t
|
||||||
_IO_getwline (_IO_FILE *fp, wchar_t *buf, _IO_size_t n, wint_t delim,
|
_IO_getwline (_IO_FILE *fp, wchar_t *buf, _IO_size_t n, wint_t delim,
|
||||||
int extract_delim)
|
int extract_delim)
|
||||||
@ -98,12 +94,12 @@ _IO_getwline_info (_IO_FILE *fp, wchar_t *buf, _IO_size_t n, wint_t delim,
|
|||||||
if (extract_delim > 0)
|
if (extract_delim > 0)
|
||||||
++len;
|
++len;
|
||||||
}
|
}
|
||||||
wmemcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr,
|
__wmemcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr,
|
||||||
len);
|
len);
|
||||||
fp->_wide_data->_IO_read_ptr = t;
|
fp->_wide_data->_IO_read_ptr = t;
|
||||||
return old_len + len;
|
return old_len + len;
|
||||||
}
|
}
|
||||||
wmemcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr, len);
|
__wmemcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr, len);
|
||||||
fp->_wide_data->_IO_read_ptr += len;
|
fp->_wide_data->_IO_read_ptr += len;
|
||||||
ptr += len;
|
ptr += len;
|
||||||
n -= len;
|
n -= len;
|
||||||
|
@ -25,63 +25,17 @@
|
|||||||
This exception applies to code released by its copyright holders
|
This exception applies to code released by its copyright holders
|
||||||
in files containing the exception. */
|
in files containing the exception. */
|
||||||
|
|
||||||
#ifndef _POSIX_SOURCE
|
|
||||||
# define _POSIX_SOURCE
|
|
||||||
#endif
|
|
||||||
#include "libioP.h"
|
#include "libioP.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifdef _LIBC
|
#include <shlib-compat.h>
|
||||||
# include <shlib-compat.h>
|
#include <not-cancel.h>
|
||||||
# include <not-cancel.h>
|
|
||||||
#endif
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <kernel-features.h>
|
#include <kernel-features.h>
|
||||||
|
|
||||||
#ifndef _IO_fork
|
|
||||||
#ifdef _LIBC
|
|
||||||
#define _IO_fork __fork
|
|
||||||
#else
|
|
||||||
#define _IO_fork fork /* defined in libiberty, if needed */
|
|
||||||
#endif
|
|
||||||
extern _IO_pid_t _IO_fork (void) __THROW;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _IO_dup2
|
|
||||||
#ifdef _LIBC
|
|
||||||
#define _IO_dup2 __dup2
|
|
||||||
#else
|
|
||||||
#define _IO_dup2 dup2
|
|
||||||
#endif
|
|
||||||
extern int _IO_dup2 (int fd, int fd2) __THROW;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _IO_waitpid
|
|
||||||
#ifdef _LIBC
|
|
||||||
#define _IO_waitpid __waitpid_nocancel
|
|
||||||
#else
|
|
||||||
#define _IO_waitpid waitpid
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _IO_execl
|
|
||||||
#define _IO_execl execl
|
|
||||||
#endif
|
|
||||||
#ifndef _IO__exit
|
|
||||||
#define _IO__exit _exit
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _IO_close
|
|
||||||
#ifdef _LIBC
|
|
||||||
#define _IO_close __close_nocancel
|
|
||||||
#else
|
|
||||||
#define _IO_close close
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct _IO_proc_file
|
struct _IO_proc_file
|
||||||
{
|
{
|
||||||
struct _IO_FILE_plus file;
|
struct _IO_FILE_plus file;
|
||||||
@ -165,14 +119,14 @@ _IO_new_proc_open (_IO_FILE *fp, const char *command, const char *mode)
|
|||||||
read_or_write = _IO_NO_READS;
|
read_or_write = _IO_NO_READS;
|
||||||
}
|
}
|
||||||
|
|
||||||
((_IO_proc_file *) fp)->pid = child_pid = _IO_fork ();
|
((_IO_proc_file *) fp)->pid = child_pid = __fork ();
|
||||||
if (child_pid == 0)
|
if (child_pid == 0)
|
||||||
{
|
{
|
||||||
int child_std_end = do_read ? 1 : 0;
|
int child_std_end = do_read ? 1 : 0;
|
||||||
struct _IO_proc_file *p;
|
struct _IO_proc_file *p;
|
||||||
|
|
||||||
if (child_end != child_std_end)
|
if (child_end != child_std_end)
|
||||||
_IO_dup2 (child_end, child_std_end);
|
__dup2 (child_end, child_std_end);
|
||||||
else
|
else
|
||||||
/* The descriptor is already the one we will use. But it must
|
/* The descriptor is already the one we will use. But it must
|
||||||
not be marked close-on-exec. Undo the effects. */
|
not be marked close-on-exec. Undo the effects. */
|
||||||
@ -188,16 +142,16 @@ _IO_new_proc_open (_IO_FILE *fp, const char *command, const char *mode)
|
|||||||
child_std_end, it has been already closed by the dup2 syscall
|
child_std_end, it has been already closed by the dup2 syscall
|
||||||
above. */
|
above. */
|
||||||
if (fd != child_std_end)
|
if (fd != child_std_end)
|
||||||
_IO_close (fd);
|
__close_nocancel (fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
_IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0);
|
execl ("/bin/sh", "sh", "-c", command, (char *) 0);
|
||||||
_IO__exit (127);
|
_exit (127);
|
||||||
}
|
}
|
||||||
_IO_close (child_end);
|
__close_nocancel (child_end);
|
||||||
if (child_pid < 0)
|
if (child_pid < 0)
|
||||||
{
|
{
|
||||||
_IO_close (parent_end);
|
__close_nocancel (parent_end);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +238,7 @@ _IO_new_proc_close (_IO_FILE *fp)
|
|||||||
_IO_cleanup_region_end (0);
|
_IO_cleanup_region_end (0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (status < 0 || _IO_close (_IO_fileno(fp)) < 0)
|
if (status < 0 || __close_nocancel (_IO_fileno(fp)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
/* POSIX.2 Rationale: "Some historical implementations either block
|
/* POSIX.2 Rationale: "Some historical implementations either block
|
||||||
or ignore the signals SIGINT, SIGQUIT, and SIGHUP while waiting
|
or ignore the signals SIGINT, SIGQUIT, and SIGHUP while waiting
|
||||||
@ -292,7 +246,7 @@ _IO_new_proc_close (_IO_FILE *fp)
|
|||||||
described in POSIX.2, such implementations are not conforming." */
|
described in POSIX.2, such implementations are not conforming." */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
wait_pid = _IO_waitpid (((_IO_proc_file *) fp)->pid, &wstatus, 0);
|
wait_pid = __waitpid_nocancel (((_IO_proc_file *) fp)->pid, &wstatus, 0);
|
||||||
}
|
}
|
||||||
while (wait_pid == -1 && errno == EINTR);
|
while (wait_pid == -1 && errno == EINTR);
|
||||||
if (wait_pid == -1)
|
if (wait_pid == -1)
|
||||||
|
@ -45,6 +45,4 @@ _IO_puts (const char *str)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_puts, puts)
|
weak_alias (_IO_puts, puts)
|
||||||
#endif
|
|
||||||
|
@ -27,12 +27,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <libioP.h>
|
#include <libioP.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifndef errno
|
|
||||||
extern int errno;
|
|
||||||
#endif
|
|
||||||
#ifndef __set_errno
|
|
||||||
# define __set_errno(Val) errno = (Val)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_IO_off64_t
|
_IO_off64_t
|
||||||
_IO_seekoff_unlocked (_IO_FILE *fp, _IO_off64_t offset, int dir, int mode)
|
_IO_seekoff_unlocked (_IO_FILE *fp, _IO_off64_t offset, int dir, int mode)
|
||||||
|
@ -42,6 +42,4 @@ _IO_setbuffer (_IO_FILE *fp, char *buf, _IO_size_t size)
|
|||||||
}
|
}
|
||||||
libc_hidden_def (_IO_setbuffer)
|
libc_hidden_def (_IO_setbuffer)
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_setbuffer, setbuffer)
|
weak_alias (_IO_setbuffer, setbuffer)
|
||||||
#endif
|
|
||||||
|
@ -95,6 +95,4 @@ unlock_return:
|
|||||||
}
|
}
|
||||||
libc_hidden_def (_IO_setvbuf)
|
libc_hidden_def (_IO_setvbuf)
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_setvbuf, setvbuf)
|
weak_alias (_IO_setvbuf, setvbuf)
|
||||||
#endif
|
|
||||||
|
@ -41,6 +41,4 @@ _IO_ungetc (int c, _IO_FILE *fp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_ungetc, ungetc)
|
weak_alias (_IO_ungetc, ungetc)
|
||||||
#endif
|
|
||||||
|
@ -35,31 +35,12 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifndef __set_errno
|
#include <libc-lock.h>
|
||||||
# define __set_errno(Val) errno = (Val)
|
|
||||||
#endif
|
|
||||||
#if defined __GLIBC__ && __GLIBC__ >= 2
|
|
||||||
# include <libc-lock.h>
|
|
||||||
#else
|
|
||||||
/*# include <comthread.h>*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <math_ldbl_opt.h>
|
#include <math_ldbl_opt.h>
|
||||||
|
|
||||||
#include "iolibio.h"
|
#include "iolibio.h"
|
||||||
|
|
||||||
/* Control of exported symbols. Used in glibc. By default we don't
|
|
||||||
do anything. */
|
|
||||||
#ifndef libc_hidden_proto
|
|
||||||
# define libc_hidden_proto(name)
|
|
||||||
#endif
|
|
||||||
#ifndef libc_hidden_def
|
|
||||||
# define libc_hidden_def(name)
|
|
||||||
#endif
|
|
||||||
#ifndef libc_hidden_weak
|
|
||||||
# define libc_hidden_weak(name)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -89,14 +70,12 @@ extern "C" {
|
|||||||
* object being acted on (i.e. the 'this' parameter).
|
* object being acted on (i.e. the 'this' parameter).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef _LIBC
|
#include <shlib-compat.h>
|
||||||
# include <shlib-compat.h>
|
#if !SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
|
||||||
# if !SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
|
/* Setting this macro disables the use of the _vtable_offset bias in
|
||||||
/* Setting this macro disables the use of the _vtable_offset
|
_IO_JUMPS_FUNCS, below. That is only needed if we want to
|
||||||
bias in _IO_JUMPS_FUNCS, below. That is only needed if we
|
support old binaries (see oldfileops.c). */
|
||||||
want to support old binaries (see oldfileops.c). */
|
|
||||||
# define _G_IO_NO_BACKWARD_COMPAT 1
|
# define _G_IO_NO_BACKWARD_COMPAT 1
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (!defined _IO_USE_OLD_IO_FILE \
|
#if (!defined _IO_USE_OLD_IO_FILE \
|
||||||
@ -524,19 +503,13 @@ extern int _IO_old_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *);
|
|||||||
extern void _IO_old_init (_IO_FILE *fp, int flags) __THROW;
|
extern void _IO_old_init (_IO_FILE *fp, int flags) __THROW;
|
||||||
|
|
||||||
|
|
||||||
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
|
#define _IO_do_flush(_f) \
|
||||||
# define _IO_do_flush(_f) \
|
|
||||||
((_f)->_mode <= 0 \
|
((_f)->_mode <= 0 \
|
||||||
? _IO_do_write(_f, (_f)->_IO_write_base, \
|
? _IO_do_write(_f, (_f)->_IO_write_base, \
|
||||||
(_f)->_IO_write_ptr-(_f)->_IO_write_base) \
|
(_f)->_IO_write_ptr-(_f)->_IO_write_base) \
|
||||||
: _IO_wdo_write(_f, (_f)->_wide_data->_IO_write_base, \
|
: _IO_wdo_write(_f, (_f)->_wide_data->_IO_write_base, \
|
||||||
((_f)->_wide_data->_IO_write_ptr \
|
((_f)->_wide_data->_IO_write_ptr \
|
||||||
- (_f)->_wide_data->_IO_write_base)))
|
- (_f)->_wide_data->_IO_write_base)))
|
||||||
#else
|
|
||||||
# define _IO_do_flush(_f) \
|
|
||||||
_IO_do_write(_f, (_f)->_IO_write_base, \
|
|
||||||
(_f)->_IO_write_ptr-(_f)->_IO_write_base)
|
|
||||||
#endif
|
|
||||||
#define _IO_old_do_flush(_f) \
|
#define _IO_old_do_flush(_f) \
|
||||||
_IO_old_do_write(_f, (_f)->_IO_write_base, \
|
_IO_old_do_write(_f, (_f)->_IO_write_base, \
|
||||||
(_f)->_IO_write_ptr-(_f)->_IO_write_base)
|
(_f)->_IO_write_ptr-(_f)->_IO_write_base)
|
||||||
@ -719,18 +692,6 @@ extern _IO_off64_t _IO_seekpos_unlocked (_IO_FILE *, _IO_off64_t, int)
|
|||||||
#ifndef EOF
|
#ifndef EOF
|
||||||
# define EOF (-1)
|
# define EOF (-1)
|
||||||
#endif
|
#endif
|
||||||
#ifndef NULL
|
|
||||||
# if defined __GNUG__ && \
|
|
||||||
(__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
|
|
||||||
# define NULL (__null)
|
|
||||||
# else
|
|
||||||
# if !defined(__cplusplus)
|
|
||||||
# define NULL ((void*)0)
|
|
||||||
# else
|
|
||||||
# define NULL (0)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if _G_HAVE_MMAP
|
#if _G_HAVE_MMAP
|
||||||
|
|
||||||
@ -750,19 +711,6 @@ extern _IO_off64_t _IO_seekpos_unlocked (_IO_FILE *, _IO_off64_t, int)
|
|||||||
|
|
||||||
#endif /* _G_HAVE_MMAP */
|
#endif /* _G_HAVE_MMAP */
|
||||||
|
|
||||||
#if _G_HAVE_MMAP
|
|
||||||
|
|
||||||
# ifdef _LIBC
|
|
||||||
/* When using this code in the GNU libc we must not pollute the name space. */
|
|
||||||
# define mmap __mmap
|
|
||||||
# define munmap __munmap
|
|
||||||
# define ftruncate __ftruncate
|
|
||||||
# endif
|
|
||||||
#endif /* _G_HAVE_MMAP */
|
|
||||||
|
|
||||||
#ifndef OS_FSTAT
|
|
||||||
# define OS_FSTAT fstat
|
|
||||||
#endif
|
|
||||||
extern int _IO_vscanf (const char *, _IO_va_list) __THROW;
|
extern int _IO_vscanf (const char *, _IO_va_list) __THROW;
|
||||||
|
|
||||||
/* _IO_pos_BAD is an _IO_off64_t value indicating error, unknown, or EOF. */
|
/* _IO_pos_BAD is an _IO_off64_t value indicating error, unknown, or EOF. */
|
||||||
@ -790,19 +738,11 @@ extern int _IO_vscanf (const char *, _IO_va_list) __THROW;
|
|||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
|
||||||
0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock }
|
0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock }
|
||||||
# else
|
# else
|
||||||
# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
|
|
||||||
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
|
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
|
||||||
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
|
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
|
||||||
0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\
|
0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\
|
||||||
NULL, WDP, 0 }
|
NULL, WDP, 0 }
|
||||||
# else
|
|
||||||
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
|
|
||||||
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
|
|
||||||
0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\
|
|
||||||
0 }
|
|
||||||
# endif
|
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# ifdef _IO_USE_OLD_IO_FILE
|
# ifdef _IO_USE_OLD_IO_FILE
|
||||||
@ -811,19 +751,11 @@ extern int _IO_vscanf (const char *, _IO_va_list) __THROW;
|
|||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
|
||||||
0, _IO_pos_BAD }
|
0, _IO_pos_BAD }
|
||||||
# else
|
# else
|
||||||
# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
|
|
||||||
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
|
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
|
||||||
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
|
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
|
||||||
0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \
|
0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \
|
||||||
NULL, WDP, 0 }
|
NULL, WDP, 0 }
|
||||||
# else
|
|
||||||
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
|
|
||||||
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
|
|
||||||
0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \
|
|
||||||
0 }
|
|
||||||
# endif
|
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -30,9 +30,6 @@
|
|||||||
#include <shlib-compat.h>
|
#include <shlib-compat.h>
|
||||||
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
|
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
|
||||||
|
|
||||||
#ifndef _POSIX_SOURCE
|
|
||||||
# define _POSIX_SOURCE
|
|
||||||
#endif
|
|
||||||
#define _IO_USE_OLD_IO_FILE
|
#define _IO_USE_OLD_IO_FILE
|
||||||
#include "libioP.h"
|
#include "libioP.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -42,21 +39,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#ifndef errno
|
|
||||||
extern int errno;
|
|
||||||
#endif
|
|
||||||
#ifndef __set_errno
|
|
||||||
# define __set_errno(Val) errno = (Val)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _LIBC
|
|
||||||
# define open(Name, Flags, Prot) __open (Name, Flags, Prot)
|
|
||||||
# define close(FD) __close (FD)
|
|
||||||
# define lseek(FD, Offset, Whence) __lseek (FD, Offset, Whence)
|
|
||||||
# define read(FD, Buf, NBytes) __read (FD, Buf, NBytes)
|
|
||||||
# define write(FD, Buf, NBytes) __write (FD, Buf, NBytes)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* An fstream can be in at most one of put mode, get mode, or putback mode.
|
/* An fstream can be in at most one of put mode, get mode, or putback mode.
|
||||||
Putback mode is a variant of get mode.
|
Putback mode is a variant of get mode.
|
||||||
@ -127,7 +109,6 @@ _IO_old_file_init_internal (struct _IO_FILE_plus *fp)
|
|||||||
- (int) sizeof (struct _IO_FILE_complete));
|
- (int) sizeof (struct _IO_FILE_complete));
|
||||||
fp->file._fileno = -1;
|
fp->file._fileno = -1;
|
||||||
|
|
||||||
#if defined SHARED && defined _LIBC
|
|
||||||
if (__builtin_expect (&_IO_stdin_used != NULL, 1)
|
if (__builtin_expect (&_IO_stdin_used != NULL, 1)
|
||||||
|| (fp != (struct _IO_FILE_plus *) _IO_stdin
|
|| (fp != (struct _IO_FILE_plus *) _IO_stdin
|
||||||
&& fp != (struct _IO_FILE_plus *) _IO_stdout
|
&& fp != (struct _IO_FILE_plus *) _IO_stdout
|
||||||
@ -135,7 +116,6 @@ _IO_old_file_init_internal (struct _IO_FILE_plus *fp)
|
|||||||
/* The object is dynamically allocated and large enough. Initialize
|
/* The object is dynamically allocated and large enough. Initialize
|
||||||
the _mode element as well. */
|
the _mode element as well. */
|
||||||
((struct _IO_FILE_complete *) fp)->_mode = -1;
|
((struct _IO_FILE_complete *) fp)->_mode = -1;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -221,7 +201,7 @@ _IO_old_file_fopen (_IO_FILE *fp, const char *filename, const char *mode)
|
|||||||
omode = O_RDWR;
|
omode = O_RDWR;
|
||||||
read_write &= _IO_IS_APPENDING;
|
read_write &= _IO_IS_APPENDING;
|
||||||
}
|
}
|
||||||
fdesc = open (filename, omode|oflags, oprot);
|
fdesc = __open (filename, omode|oflags, oprot);
|
||||||
if (fdesc < 0)
|
if (fdesc < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
fp->_fileno = fdesc;
|
fp->_fileno = fdesc;
|
||||||
@ -443,10 +423,8 @@ _IO_old_file_sync (_IO_FILE *fp)
|
|||||||
_IO_off_t new_pos = _IO_SYSSEEK (fp, delta, 1);
|
_IO_off_t new_pos = _IO_SYSSEEK (fp, delta, 1);
|
||||||
if (new_pos != (_IO_off_t) EOF)
|
if (new_pos != (_IO_off_t) EOF)
|
||||||
fp->_IO_read_end = fp->_IO_read_ptr;
|
fp->_IO_read_end = fp->_IO_read_ptr;
|
||||||
#ifdef ESPIPE
|
|
||||||
else if (errno == ESPIPE)
|
else if (errno == ESPIPE)
|
||||||
; /* Ignore error from unseekable devices. */
|
; /* Ignore error from unseekable devices. */
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
retval = EOF;
|
retval = EOF;
|
||||||
}
|
}
|
||||||
@ -647,7 +625,7 @@ _IO_old_file_write (_IO_FILE *f, const void *data, _IO_ssize_t n)
|
|||||||
_IO_ssize_t to_do = n;
|
_IO_ssize_t to_do = n;
|
||||||
while (to_do > 0)
|
while (to_do > 0)
|
||||||
{
|
{
|
||||||
_IO_ssize_t count = write (f->_fileno, data, to_do);
|
_IO_ssize_t count = __write (f->_fileno, data, to_do);
|
||||||
if (count == EOF)
|
if (count == EOF)
|
||||||
{
|
{
|
||||||
f->_flags |= _IO_ERR_SEEN;
|
f->_flags |= _IO_ERR_SEEN;
|
||||||
@ -705,12 +683,7 @@ _IO_old_file_xsputn (_IO_FILE *f, const void *data, _IO_size_t n)
|
|||||||
count = to_do;
|
count = to_do;
|
||||||
if (count > 20)
|
if (count > 20)
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
|
f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
|
||||||
#else
|
|
||||||
memcpy (f->_IO_write_ptr, s, count);
|
|
||||||
f->_IO_write_ptr += count;
|
|
||||||
#endif
|
|
||||||
s += count;
|
s += count;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -32,10 +32,6 @@
|
|||||||
#include "libioP.h"
|
#include "libioP.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#ifndef _IO_fcntl
|
|
||||||
# define _IO_fcntl __fcntl
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_IO_FILE *
|
_IO_FILE *
|
||||||
attribute_compat_text_section
|
attribute_compat_text_section
|
||||||
_IO_old_fdopen (int fd, const char *mode)
|
_IO_old_fdopen (int fd, const char *mode)
|
||||||
@ -69,11 +65,7 @@ _IO_old_fdopen (int fd, const char *mode)
|
|||||||
}
|
}
|
||||||
if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+'))
|
if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+'))
|
||||||
read_write &= _IO_IS_APPENDING;
|
read_write &= _IO_IS_APPENDING;
|
||||||
#ifdef F_GETFL
|
fd_flags = __fcntl (fd, F_GETFL);
|
||||||
fd_flags = _IO_fcntl (fd, F_GETFL);
|
|
||||||
#ifndef O_ACCMODE
|
|
||||||
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
|
|
||||||
#endif
|
|
||||||
if (fd_flags == -1
|
if (fd_flags == -1
|
||||||
|| ((fd_flags & O_ACCMODE) == O_RDONLY && !(read_write & _IO_NO_WRITES))
|
|| ((fd_flags & O_ACCMODE) == O_RDONLY && !(read_write & _IO_NO_WRITES))
|
||||||
|| ((fd_flags & O_ACCMODE) == O_WRONLY && !(read_write & _IO_NO_READS)))
|
|| ((fd_flags & O_ACCMODE) == O_WRONLY && !(read_write & _IO_NO_READS)))
|
||||||
@ -97,12 +89,9 @@ _IO_old_fdopen (int fd, const char *mode)
|
|||||||
*/
|
*/
|
||||||
if ((posix_mode & O_APPEND) && !(fd_flags & O_APPEND))
|
if ((posix_mode & O_APPEND) && !(fd_flags & O_APPEND))
|
||||||
{
|
{
|
||||||
#ifdef F_SETFL
|
if (__fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
|
||||||
if (_IO_fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
|
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
|
new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
|
||||||
if (new_f == NULL)
|
if (new_f == NULL)
|
||||||
|
@ -45,20 +45,16 @@ _IO_old_fgetpos (_IO_FILE *fp, _IO_fpos_t *posp)
|
|||||||
{
|
{
|
||||||
/* ANSI explicitly requires setting errno to a positive value on
|
/* ANSI explicitly requires setting errno to a positive value on
|
||||||
failure. */
|
failure. */
|
||||||
#ifdef EIO
|
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
__set_errno (EIO);
|
__set_errno (EIO);
|
||||||
#endif
|
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
posp->__pos = pos;
|
posp->__pos = pos;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
compat_symbol (libc, _IO_old_fgetpos, _IO_fgetpos, GLIBC_2_0);
|
compat_symbol (libc, _IO_old_fgetpos, _IO_fgetpos, GLIBC_2_0);
|
||||||
strong_alias (_IO_old_fgetpos, __old_fgetpos)
|
strong_alias (_IO_old_fgetpos, __old_fgetpos)
|
||||||
compat_symbol (libc, __old_fgetpos, fgetpos, GLIBC_2_0);
|
compat_symbol (libc, __old_fgetpos, fgetpos, GLIBC_2_0);
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,20 +45,16 @@ _IO_old_fgetpos64 (_IO_FILE *fp, _IO_fpos64_t *posp)
|
|||||||
{
|
{
|
||||||
/* ANSI explicitly requires setting errno to a positive value on
|
/* ANSI explicitly requires setting errno to a positive value on
|
||||||
failure. */
|
failure. */
|
||||||
#ifdef EIO
|
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
__set_errno (EIO);
|
__set_errno (EIO);
|
||||||
#endif
|
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
posp->__pos = pos;
|
posp->__pos = pos;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
compat_symbol (libc, _IO_old_fgetpos64, _IO_fgetpos64, GLIBC_2_1);
|
compat_symbol (libc, _IO_old_fgetpos64, _IO_fgetpos64, GLIBC_2_1);
|
||||||
strong_alias (_IO_old_fgetpos64, __old_fgetpos64)
|
strong_alias (_IO_old_fgetpos64, __old_fgetpos64)
|
||||||
compat_symbol (libc, __old_fgetpos64, fgetpos64, GLIBC_2_1);
|
compat_symbol (libc, __old_fgetpos64, fgetpos64, GLIBC_2_1);
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,10 +41,8 @@ _IO_old_fsetpos (_IO_FILE *fp, const _IO_fpos_t *posp)
|
|||||||
{
|
{
|
||||||
/* ANSI explicitly requires setting errno to a positive value on
|
/* ANSI explicitly requires setting errno to a positive value on
|
||||||
failure. */
|
failure. */
|
||||||
#ifdef EIO
|
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
__set_errno (EIO);
|
__set_errno (EIO);
|
||||||
#endif
|
|
||||||
result = EOF;
|
result = EOF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -53,10 +51,8 @@ _IO_old_fsetpos (_IO_FILE *fp, const _IO_fpos_t *posp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
compat_symbol (libc, _IO_old_fsetpos, _IO_fsetpos, GLIBC_2_0);
|
compat_symbol (libc, _IO_old_fsetpos, _IO_fsetpos, GLIBC_2_0);
|
||||||
strong_alias (_IO_old_fsetpos, __old_fsetpos)
|
strong_alias (_IO_old_fsetpos, __old_fsetpos)
|
||||||
compat_symbol (libc, __old_fsetpos, fsetpos, GLIBC_2_0);
|
compat_symbol (libc, __old_fsetpos, fsetpos, GLIBC_2_0);
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,10 +42,8 @@ _IO_old_fsetpos64 (_IO_FILE *fp, const _IO_fpos64_t *posp)
|
|||||||
{
|
{
|
||||||
/* ANSI explicitly requires setting errno to a positive value on
|
/* ANSI explicitly requires setting errno to a positive value on
|
||||||
failure. */
|
failure. */
|
||||||
#ifdef EIO
|
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
__set_errno (EIO);
|
__set_errno (EIO);
|
||||||
#endif
|
|
||||||
result = EOF;
|
result = EOF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -54,10 +52,8 @@ _IO_old_fsetpos64 (_IO_FILE *fp, const _IO_fpos64_t *posp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
compat_symbol (libc, _IO_old_fsetpos64, _IO_fsetpos64, GLIBC_2_1);
|
compat_symbol (libc, _IO_old_fsetpos64, _IO_fsetpos64, GLIBC_2_1);
|
||||||
strong_alias (_IO_old_fsetpos64, __old_fsetpos64)
|
strong_alias (_IO_old_fsetpos64, __old_fsetpos64)
|
||||||
compat_symbol (libc, __old_fsetpos64, fsetpos64, GLIBC_2_1);
|
compat_symbol (libc, __old_fsetpos64, fsetpos64, GLIBC_2_1);
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,72 +26,17 @@
|
|||||||
in files containing the exception. */
|
in files containing the exception. */
|
||||||
|
|
||||||
#define _IO_USE_OLD_IO_FILE
|
#define _IO_USE_OLD_IO_FILE
|
||||||
#ifndef _POSIX_SOURCE
|
|
||||||
# define _POSIX_SOURCE
|
|
||||||
#endif
|
|
||||||
#include "libioP.h"
|
#include "libioP.h"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifdef _LIBC
|
#include <unistd.h>
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#ifndef _IO_fork
|
|
||||||
#ifdef _LIBC
|
|
||||||
#define _IO_fork __fork
|
|
||||||
#else
|
|
||||||
#define _IO_fork fork /* defined in libiberty, if needed */
|
|
||||||
#endif
|
|
||||||
extern _IO_pid_t _IO_fork (void) __THROW;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <shlib-compat.h>
|
#include <shlib-compat.h>
|
||||||
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
|
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
|
||||||
|
|
||||||
#ifndef _IO_pipe
|
|
||||||
#ifdef _LIBC
|
|
||||||
#define _IO_pipe __pipe
|
|
||||||
#else
|
|
||||||
#define _IO_pipe pipe
|
|
||||||
#endif
|
|
||||||
extern int _IO_pipe (int des[2]) __THROW;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _IO_dup2
|
|
||||||
#ifdef _LIBC
|
|
||||||
#define _IO_dup2 __dup2
|
|
||||||
#else
|
|
||||||
#define _IO_dup2 dup2
|
|
||||||
#endif
|
|
||||||
extern int _IO_dup2 (int fd, int fd2) __THROW;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _IO_waitpid
|
|
||||||
#ifdef _LIBC
|
|
||||||
#define _IO_waitpid __waitpid
|
|
||||||
#else
|
|
||||||
#define _IO_waitpid waitpid
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _IO_execl
|
|
||||||
#define _IO_execl execl
|
|
||||||
#endif
|
|
||||||
#ifndef _IO__exit
|
|
||||||
#define _IO__exit _exit
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _IO_close
|
|
||||||
#ifdef _LIBC
|
|
||||||
#define _IO_close __close
|
|
||||||
#else
|
|
||||||
#define _IO_close close
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct _IO_proc_file
|
struct _IO_proc_file
|
||||||
{
|
{
|
||||||
struct _IO_FILE_complete_plus file;
|
struct _IO_FILE_complete_plus file;
|
||||||
@ -123,7 +68,7 @@ _IO_old_proc_open (_IO_FILE *fp, const char *command, const char *mode)
|
|||||||
_IO_pid_t child_pid;
|
_IO_pid_t child_pid;
|
||||||
if (_IO_file_is_open (fp))
|
if (_IO_file_is_open (fp))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (_IO_pipe (pipe_fds) < 0)
|
if (__pipe (pipe_fds) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (mode[0] == 'r' && mode[1] == '\0')
|
if (mode[0] == 'r' && mode[1] == '\0')
|
||||||
{
|
{
|
||||||
@ -139,36 +84,36 @@ _IO_old_proc_open (_IO_FILE *fp, const char *command, const char *mode)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_IO_close (pipe_fds[0]);
|
__close (pipe_fds[0]);
|
||||||
_IO_close (pipe_fds[1]);
|
__close (pipe_fds[1]);
|
||||||
__set_errno (EINVAL);
|
__set_errno (EINVAL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
((_IO_proc_file *) fp)->pid = child_pid = _IO_fork ();
|
((_IO_proc_file *) fp)->pid = child_pid = __fork ();
|
||||||
if (child_pid == 0)
|
if (child_pid == 0)
|
||||||
{
|
{
|
||||||
int child_std_end = mode[0] == 'r' ? 1 : 0;
|
int child_std_end = mode[0] == 'r' ? 1 : 0;
|
||||||
struct _IO_proc_file *p;
|
struct _IO_proc_file *p;
|
||||||
|
|
||||||
_IO_close (parent_end);
|
__close (parent_end);
|
||||||
if (child_end != child_std_end)
|
if (child_end != child_std_end)
|
||||||
{
|
{
|
||||||
_IO_dup2 (child_end, child_std_end);
|
__dup2 (child_end, child_std_end);
|
||||||
_IO_close (child_end);
|
__close (child_end);
|
||||||
}
|
}
|
||||||
/* POSIX.2: "popen() shall ensure that any streams from previous
|
/* POSIX.2: "popen() shall ensure that any streams from previous
|
||||||
popen() calls that remain open in the parent process are closed
|
popen() calls that remain open in the parent process are closed
|
||||||
in the new child process." */
|
in the new child process." */
|
||||||
for (p = old_proc_file_chain; p; p = p->next)
|
for (p = old_proc_file_chain; p; p = p->next)
|
||||||
_IO_close (_IO_fileno ((_IO_FILE *) p));
|
__close (_IO_fileno ((_IO_FILE *) p));
|
||||||
|
|
||||||
_IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0);
|
execl ("/bin/sh", "sh", "-c", command, (char *) 0);
|
||||||
_IO__exit (127);
|
_exit (127);
|
||||||
}
|
}
|
||||||
_IO_close (child_end);
|
__close (child_end);
|
||||||
if (child_pid < 0)
|
if (child_pid < 0)
|
||||||
{
|
{
|
||||||
_IO_close (parent_end);
|
__close (parent_end);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
_IO_fileno (fp) = parent_end;
|
_IO_fileno (fp) = parent_end;
|
||||||
@ -251,7 +196,7 @@ _IO_old_proc_close (_IO_FILE *fp)
|
|||||||
_IO_cleanup_region_end (0);
|
_IO_cleanup_region_end (0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (status < 0 || _IO_close (_IO_fileno(fp)) < 0)
|
if (status < 0 || __close (_IO_fileno(fp)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
/* POSIX.2 Rationale: "Some historical implementations either block
|
/* POSIX.2 Rationale: "Some historical implementations either block
|
||||||
or ignore the signals SIGINT, SIGQUIT, and SIGHUP while waiting
|
or ignore the signals SIGINT, SIGQUIT, and SIGHUP while waiting
|
||||||
@ -259,7 +204,7 @@ _IO_old_proc_close (_IO_FILE *fp)
|
|||||||
described in POSIX.2, such implementations are not conforming." */
|
described in POSIX.2, such implementations are not conforming." */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
wait_pid = _IO_waitpid (((_IO_proc_file *) fp)->pid, &wstatus, 0);
|
wait_pid = __waitpid (((_IO_proc_file *) fp)->pid, &wstatus, 0);
|
||||||
}
|
}
|
||||||
while (wait_pid == -1 && errno == EINTR);
|
while (wait_pid == -1 && errno == EINTR);
|
||||||
if (wait_pid == -1)
|
if (wait_pid == -1)
|
||||||
|
@ -36,11 +36,9 @@ libc_hidden_def (_IO_putc)
|
|||||||
|
|
||||||
#undef putc
|
#undef putc
|
||||||
|
|
||||||
#ifdef weak_alias
|
|
||||||
weak_alias (_IO_putc, putc)
|
weak_alias (_IO_putc, putc)
|
||||||
|
|
||||||
#ifndef _IO_MTSAFE_IO
|
#ifndef _IO_MTSAFE_IO
|
||||||
#undef putc_unlocked
|
#undef putc_unlocked
|
||||||
weak_alias (_IO_putc, putc_unlocked)
|
weak_alias (_IO_putc, putc_unlocked)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include "libioP.h"
|
#include "libioP.h"
|
||||||
|
|
||||||
#ifdef _IO_MTSAFE_IO
|
#ifdef _IO_MTSAFE_IO
|
||||||
# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
|
|
||||||
# define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
|
# define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
|
||||||
static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
|
static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
|
||||||
static struct _IO_wide_data _IO_wide_data_##FD \
|
static struct _IO_wide_data _IO_wide_data_##FD \
|
||||||
@ -42,27 +41,13 @@
|
|||||||
struct _IO_FILE_plus NAME \
|
struct _IO_FILE_plus NAME \
|
||||||
= {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \
|
= {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \
|
||||||
&_IO_file_jumps};
|
&_IO_file_jumps};
|
||||||
# else
|
|
||||||
# define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
|
|
||||||
static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
|
|
||||||
struct _IO_FILE_plus NAME \
|
|
||||||
= {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), \
|
|
||||||
&_IO_file_jumps};
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
|
|
||||||
# define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
|
# define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
|
||||||
static struct _IO_wide_data _IO_wide_data_##FD \
|
static struct _IO_wide_data _IO_wide_data_##FD \
|
||||||
= { ._wide_vtable = &_IO_wfile_jumps }; \
|
= { ._wide_vtable = &_IO_wfile_jumps }; \
|
||||||
struct _IO_FILE_plus NAME \
|
struct _IO_FILE_plus NAME \
|
||||||
= {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \
|
= {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \
|
||||||
&_IO_file_jumps};
|
&_IO_file_jumps};
|
||||||
# else
|
|
||||||
# define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
|
|
||||||
struct _IO_FILE_plus NAME \
|
|
||||||
= {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), \
|
|
||||||
&_IO_file_jumps};
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DEF_STDFILE(_IO_2_1_stdin_, 0, 0, _IO_NO_WRITES);
|
DEF_STDFILE(_IO_2_1_stdin_, 0, 0, _IO_NO_WRITES);
|
||||||
|
@ -37,12 +37,10 @@ _IO_FILE *stderr = (FILE *) &_IO_2_1_stderr_;
|
|||||||
#undef _IO_stdin
|
#undef _IO_stdin
|
||||||
#undef _IO_stdout
|
#undef _IO_stdout
|
||||||
#undef _IO_stderr
|
#undef _IO_stderr
|
||||||
#ifdef _LIBC
|
#define AL(name) AL2 (name, _IO_##name)
|
||||||
# define AL(name) AL2 (name, _IO_##name)
|
#define AL2(name, al) \
|
||||||
# define AL2(name, al) \
|
|
||||||
extern __typeof (name) al __attribute__ ((alias (#name), \
|
extern __typeof (name) al __attribute__ ((alias (#name), \
|
||||||
visibility ("hidden")))
|
visibility ("hidden")))
|
||||||
AL(stdin);
|
AL(stdin);
|
||||||
AL(stdout);
|
AL(stdout);
|
||||||
AL(stderr);
|
AL(stderr);
|
||||||
#endif
|
|
||||||
|
@ -33,24 +33,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef _LIBC
|
|
||||||
# define _IO_new_do_write _IO_do_write
|
|
||||||
# define _IO_new_file_attach _IO_file_attach
|
|
||||||
# define _IO_new_file_close_it _IO_file_close_it
|
|
||||||
# define _IO_new_file_finish _IO_file_finish
|
|
||||||
# define _IO_new_file_fopen _IO_file_fopen
|
|
||||||
# define _IO_new_file_init _IO_file_init
|
|
||||||
# define _IO_new_file_setbuf _IO_file_setbuf
|
|
||||||
# define _IO_new_file_sync _IO_file_sync
|
|
||||||
# define _IO_new_file_overflow _IO_file_overflow
|
|
||||||
# define _IO_new_file_seekoff _IO_file_seekoff
|
|
||||||
# define _IO_new_file_underflow _IO_file_underflow
|
|
||||||
# define _IO_new_file_write _IO_file_write
|
|
||||||
# define _IO_new_file_xsputn _IO_file_xsputn
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Convert TO_DO wide character from DATA to FP.
|
/* Convert TO_DO wide character from DATA to FP.
|
||||||
Then mark FP as having empty buffers. */
|
Then mark FP as having empty buffers. */
|
||||||
int
|
int
|
||||||
@ -541,10 +523,8 @@ _IO_wfile_sync (_IO_FILE *fp)
|
|||||||
fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
|
fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
|
||||||
fp->_IO_read_end = fp->_IO_read_ptr;
|
fp->_IO_read_end = fp->_IO_read_ptr;
|
||||||
}
|
}
|
||||||
#ifdef ESPIPE
|
|
||||||
else if (errno == ESPIPE)
|
else if (errno == ESPIPE)
|
||||||
; /* Ignore error from unseekable devices. */
|
; /* Ignore error from unseekable devices. */
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
retval = WEOF;
|
retval = WEOF;
|
||||||
}
|
}
|
||||||
@ -1010,13 +990,8 @@ _IO_wfile_xsputn (_IO_FILE *f, const void *data, _IO_size_t n)
|
|||||||
count = to_do;
|
count = to_do;
|
||||||
if (count > 20)
|
if (count > 20)
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
f->_wide_data->_IO_write_ptr =
|
f->_wide_data->_IO_write_ptr =
|
||||||
__wmempcpy (f->_wide_data->_IO_write_ptr, s, count);
|
__wmempcpy (f->_wide_data->_IO_write_ptr, s, count);
|
||||||
#else
|
|
||||||
wmemcpy (f->_wide_data->_IO_write_ptr, s, count);
|
|
||||||
f->_wide_data->_IO_write_ptr += count;
|
|
||||||
#endif
|
|
||||||
s += count;
|
s += count;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -34,16 +34,7 @@
|
|||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef _LIBC
|
static int save_for_wbackup (_IO_FILE *fp, wchar_t *end_p) __THROW;
|
||||||
# define __wmemcpy(dst, src, n) wmemcpy (dst, src, n)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static int save_for_wbackup (_IO_FILE *fp, wchar_t *end_p) __THROW
|
|
||||||
#ifdef _LIBC
|
|
||||||
internal_function
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
/* Return minimum _pos markers
|
/* Return minimum _pos markers
|
||||||
Assumes the current get area is the main get area. */
|
Assumes the current get area is the main get area. */
|
||||||
@ -307,13 +298,8 @@ _IO_wdefault_xsputn (_IO_FILE *f, const void *data, _IO_size_t n)
|
|||||||
count = more;
|
count = more;
|
||||||
if (count > 20)
|
if (count > 20)
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
f->_wide_data->_IO_write_ptr =
|
f->_wide_data->_IO_write_ptr =
|
||||||
__wmempcpy (f->_wide_data->_IO_write_ptr, s, count);
|
__wmempcpy (f->_wide_data->_IO_write_ptr, s, count);
|
||||||
#else
|
|
||||||
memcpy (f->_wide_data->_IO_write_ptr, s, count);
|
|
||||||
f->_wide_data->_IO_write_ptr += count;
|
|
||||||
#endif
|
|
||||||
s += count;
|
s += count;
|
||||||
}
|
}
|
||||||
else if (count <= 0)
|
else if (count <= 0)
|
||||||
@ -353,12 +339,7 @@ _IO_wdefault_xsgetn (_IO_FILE *fp, void *data, _IO_size_t n)
|
|||||||
count = more;
|
count = more;
|
||||||
if (count > 20)
|
if (count > 20)
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
s = __wmempcpy (s, fp->_wide_data->_IO_read_ptr, count);
|
s = __wmempcpy (s, fp->_wide_data->_IO_read_ptr, count);
|
||||||
#else
|
|
||||||
memcpy (s, fp->_wide_data->_IO_read_ptr, count);
|
|
||||||
s += count;
|
|
||||||
#endif
|
|
||||||
fp->_wide_data->_IO_read_ptr += count;
|
fp->_wide_data->_IO_read_ptr += count;
|
||||||
}
|
}
|
||||||
else if (count <= 0)
|
else if (count <= 0)
|
||||||
@ -466,9 +447,6 @@ _IO_switch_to_wput_mode (_IO_FILE *fp)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
#ifdef _LIBC
|
|
||||||
internal_function
|
|
||||||
#endif
|
|
||||||
save_for_wbackup (_IO_FILE *fp, wchar_t *end_p)
|
save_for_wbackup (_IO_FILE *fp, wchar_t *end_p)
|
||||||
{
|
{
|
||||||
/* Append [_IO_read_base..end_p] to backup area. */
|
/* Append [_IO_read_base..end_p] to backup area. */
|
||||||
@ -492,32 +470,17 @@ save_for_wbackup (_IO_FILE *fp, wchar_t *end_p)
|
|||||||
return EOF; /* FIXME */
|
return EOF; /* FIXME */
|
||||||
if (least_mark < 0)
|
if (least_mark < 0)
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
__wmempcpy (__wmempcpy (new_buffer + avail,
|
__wmempcpy (__wmempcpy (new_buffer + avail,
|
||||||
fp->_wide_data->_IO_save_end + least_mark,
|
fp->_wide_data->_IO_save_end + least_mark,
|
||||||
-least_mark),
|
-least_mark),
|
||||||
fp->_wide_data->_IO_read_base,
|
fp->_wide_data->_IO_read_base,
|
||||||
end_p - fp->_wide_data->_IO_read_base);
|
end_p - fp->_wide_data->_IO_read_base);
|
||||||
#else
|
|
||||||
memcpy (new_buffer + avail,
|
|
||||||
fp->_wide_data->_IO_save_end + least_mark,
|
|
||||||
-least_mark * sizeof (wchar_t));
|
|
||||||
memcpy (new_buffer + avail - least_mark,
|
|
||||||
fp->_wide_data->_IO_read_base,
|
|
||||||
(end_p - fp->_wide_data->_IO_read_base) * sizeof (wchar_t));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
__wmemcpy (new_buffer + avail,
|
__wmemcpy (new_buffer + avail,
|
||||||
fp->_wide_data->_IO_read_base + least_mark,
|
fp->_wide_data->_IO_read_base + least_mark,
|
||||||
needed_size);
|
needed_size);
|
||||||
#else
|
|
||||||
memcpy (new_buffer + avail,
|
|
||||||
fp->_wide_data->_IO_read_base + least_mark,
|
|
||||||
needed_size * sizeof (wchar_t));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
free (fp->_wide_data->_IO_save_base);
|
free (fp->_wide_data->_IO_save_base);
|
||||||
fp->_wide_data->_IO_save_base = new_buffer;
|
fp->_wide_data->_IO_save_base = new_buffer;
|
||||||
@ -528,32 +491,17 @@ save_for_wbackup (_IO_FILE *fp, wchar_t *end_p)
|
|||||||
avail = current_Bsize - needed_size;
|
avail = current_Bsize - needed_size;
|
||||||
if (least_mark < 0)
|
if (least_mark < 0)
|
||||||
{
|
{
|
||||||
#ifdef _LIBC
|
|
||||||
__wmemmove (fp->_wide_data->_IO_save_base + avail,
|
__wmemmove (fp->_wide_data->_IO_save_base + avail,
|
||||||
fp->_wide_data->_IO_save_end + least_mark,
|
fp->_wide_data->_IO_save_end + least_mark,
|
||||||
-least_mark);
|
-least_mark);
|
||||||
__wmemcpy (fp->_wide_data->_IO_save_base + avail - least_mark,
|
__wmemcpy (fp->_wide_data->_IO_save_base + avail - least_mark,
|
||||||
fp->_wide_data->_IO_read_base,
|
fp->_wide_data->_IO_read_base,
|
||||||
end_p - fp->_wide_data->_IO_read_base);
|
end_p - fp->_wide_data->_IO_read_base);
|
||||||
#else
|
|
||||||
memmove (fp->_wide_data->_IO_save_base + avail,
|
|
||||||
fp->_wide_data->_IO_save_end + least_mark,
|
|
||||||
-least_mark * sizeof (wchar_t));
|
|
||||||
memcpy (fp->_wide_data->_IO_save_base + avail - least_mark,
|
|
||||||
fp->_wide_data->_IO_read_base,
|
|
||||||
(end_p - fp->_wide_data->_IO_read_base) * sizeof (wchar_t));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (needed_size > 0)
|
else if (needed_size > 0)
|
||||||
#ifdef _LIBC
|
|
||||||
__wmemcpy (fp->_wide_data->_IO_save_base + avail,
|
__wmemcpy (fp->_wide_data->_IO_save_base + avail,
|
||||||
fp->_wide_data->_IO_read_base + least_mark,
|
fp->_wide_data->_IO_read_base + least_mark,
|
||||||
needed_size);
|
needed_size);
|
||||||
#else
|
|
||||||
memcpy (fp->_wide_data->_IO_save_base + avail,
|
|
||||||
fp->_wide_data->_IO_read_base + least_mark,
|
|
||||||
needed_size * sizeof (wchar_t));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
fp->_wide_data->_IO_backup_base = fp->_wide_data->_IO_save_base + avail;
|
fp->_wide_data->_IO_backup_base = fp->_wide_data->_IO_save_base + avail;
|
||||||
/* Adjust all the streammarkers. */
|
/* Adjust all the streammarkers. */
|
||||||
|
Reference in New Issue
Block a user