aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-08-31 14:07:23 +0200
committerFlorian Weimer <fweimer@redhat.com>2017-08-31 14:48:25 +0200
commit5f0704b66cea73cf2ab148ec4cff645cc301fd8c (patch)
tree13817263f75cf2e72b3bc0ce9abafa4b9b7398e8
parent5129873a8e913e207e5f7b4b521c72f41a1bbf6d (diff)
downloadglibc-5f0704b66cea73cf2ab148ec4cff645cc301fd8c.tar.xz
glibc-5f0704b66cea73cf2ab148ec4cff645cc301fd8c.zip
libio: Assume _LIBC, weak_alias, errno, (__set_)errno &c are defined
Do not define _POSIX_SOURCE.
-rw-r--r--ChangeLog93
-rw-r--r--libio/fcloseall.c2
-rw-r--r--libio/feof.c2
-rw-r--r--libio/ferror.c2
-rw-r--r--libio/fileno.c2
-rw-r--r--libio/fileops.c95
-rw-r--r--libio/ftello.c4
-rw-r--r--libio/ftello64.c2
-rw-r--r--libio/genops.c40
-rw-r--r--libio/getc.c2
-rw-r--r--libio/getwc.c2
-rw-r--r--libio/iofclose.c13
-rw-r--r--libio/iofdopen.c23
-rw-r--r--libio/iofflush.c2
-rw-r--r--libio/iofgetpos.c4
-rw-r--r--libio/iofgetpos64.c2
-rw-r--r--libio/iofgets.c2
-rw-r--r--libio/iofopen.c12
-rw-r--r--libio/iofopen64.c4
-rw-r--r--libio/iofputs.c2
-rw-r--r--libio/iofread.c2
-rw-r--r--libio/iofsetpos.c2
-rw-r--r--libio/iofsetpos64.c2
-rw-r--r--libio/ioftell.c6
-rw-r--r--libio/iofwide.c154
-rw-r--r--libio/iofwrite.c2
-rw-r--r--libio/iogetdelim.c2
-rw-r--r--libio/iogets.c4
-rw-r--r--libio/iogetwline.c10
-rw-r--r--libio/iopopen.c68
-rw-r--r--libio/ioputs.c2
-rw-r--r--libio/ioseekoff.c6
-rw-r--r--libio/iosetbuffer.c2
-rw-r--r--libio/iosetvbuf.c2
-rw-r--r--libio/ioungetc.c2
-rw-r--r--libio/libioP.h88
-rw-r--r--libio/oldfileops.c31
-rw-r--r--libio/oldiofdopen.c15
-rw-r--r--libio/oldiofgetpos.c4
-rw-r--r--libio/oldiofgetpos64.c4
-rw-r--r--libio/oldiofsetpos.c4
-rw-r--r--libio/oldiofsetpos64.c4
-rw-r--r--libio/oldiopopen.c85
-rw-r--r--libio/putc.c2
-rw-r--r--libio/stdfiles.c19
-rw-r--r--libio/stdio.c6
-rw-r--r--libio/wfileops.c25
-rw-r--r--libio/wgenops.c54
48 files changed, 166 insertions, 751 deletions
diff --git a/ChangeLog b/ChangeLog
index c94f4c1639..f9625dec80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,98 @@
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>
+
* malloc/malloc.c (top_check): Change return type to void. Remove
internal_function.
* malloc/hooks.c (top_check): Likewise.
diff --git a/libio/fcloseall.c b/libio/fcloseall.c
index 59c33ccf48..80e1ae01d7 100644
--- a/libio/fcloseall.c
+++ b/libio/fcloseall.c
@@ -34,6 +34,4 @@ __fcloseall (void)
return _IO_cleanup ();
}
-#ifdef weak_alias
weak_alias (__fcloseall, fcloseall)
-#endif
diff --git a/libio/feof.c b/libio/feof.c
index 8890a5f51f..72dde1f82d 100644
--- a/libio/feof.c
+++ b/libio/feof.c
@@ -40,11 +40,9 @@ _IO_feof (_IO_FILE *fp)
return result;
}
-#ifdef weak_alias
weak_alias (_IO_feof, feof)
#ifndef _IO_MTSAFE_IO
#undef feof_unlocked
weak_alias (_IO_feof, feof_unlocked)
#endif
-#endif
diff --git a/libio/ferror.c b/libio/ferror.c
index d10fcd9fff..ab6185bade 100644
--- a/libio/ferror.c
+++ b/libio/ferror.c
@@ -40,11 +40,9 @@ _IO_ferror (_IO_FILE *fp)
return result;
}
-#ifdef weak_alias
weak_alias (_IO_ferror, ferror)
#ifndef _IO_MTSAFE_IO
#undef ferror_unlocked
weak_alias (_IO_ferror, ferror_unlocked)
#endif
-#endif
diff --git a/libio/fileno.c b/libio/fileno.c
index b78d4a1461..d4d749d4d0 100644
--- a/libio/fileno.c
+++ b/libio/fileno.c
@@ -44,10 +44,8 @@ libc_hidden_def (__fileno)
weak_alias (__fileno, fileno)
libc_hidden_weak (fileno)
-#ifdef weak_alias
/* The fileno implementation for libio does not require locking because
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. */
weak_alias (__fileno, fileno_unlocked)
-#endif
diff --git a/libio/fileops.c b/libio/fileops.c
index b8b02ba261..a9e948f31e 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -26,9 +26,6 @@
in files containing the exception. */
-#ifndef _POSIX_SOURCE
-# define _POSIX_SOURCE
-#endif
#include "libioP.h"
#include <assert.h>
#include <fcntl.h>
@@ -40,48 +37,14 @@
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
-#if _LIBC
-# include "../wcsmbs/wcsmbsload.h"
-# include "../iconv/gconv_charset.h"
-# include "../iconv/gconv_int.h"
-# include <shlib-compat.h>
-# include <not-cancel.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
+#include "../wcsmbs/wcsmbsload.h"
+#include "../iconv/gconv_charset.h"
+#include "../iconv/gconv_int.h"
+#include <shlib-compat.h>
+#include <not-cancel.h>
+#include <kernel-features.h>
-
-#ifdef _LIBC
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.
Putback mode is a variant of get mode.
@@ -180,7 +143,6 @@ _IO_new_file_close_it (_IO_FILE *fp)
? _IO_SYSCLOSE (fp) : 0);
/* Free buffer. */
-#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
if (fp->_mode > 0)
{
if (_IO_have_wbackup (fp))
@@ -189,7 +151,6 @@ _IO_new_file_close_it (_IO_FILE *fp)
_IO_wsetg (fp, NULL, NULL, NULL);
_IO_wsetp (fp, NULL, NULL);
}
-#endif
_IO_setb (fp, NULL, NULL, 0);
_IO_setg (fp, NULL, 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 fdesc;
-#ifdef _LIBC
if (__glibc_unlikely (fp->_flags2 & _IO_FLAGS2_NOTCANCEL))
fdesc = __open_nocancel (filename,
posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
else
- fdesc = open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
-#else
- fdesc = open (filename, posix_mode, prot);
-#endif
+ fdesc = __open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
if (fdesc < 0)
return NULL;
fp->_fileno = fdesc;
@@ -260,10 +217,8 @@ _IO_new_file_fopen (_IO_FILE *fp, const char *filename, const char *mode,
int oprot = 0666;
int i;
_IO_FILE *result;
-#ifdef _LIBC
const char *cs;
const char *last_recognized;
-#endif
if (_IO_file_is_open (fp))
return 0;
@@ -287,9 +242,7 @@ _IO_new_file_fopen (_IO_FILE *fp, const char *filename, const char *mode,
__set_errno (EINVAL);
return NULL;
}
-#ifdef _LIBC
last_recognized = mode;
-#endif
for (i = 1; i < 7; ++i)
{
switch (*++mode)
@@ -299,20 +252,14 @@ _IO_new_file_fopen (_IO_FILE *fp, const char *filename, const char *mode,
case '+':
omode = O_RDWR;
read_write &= _IO_IS_APPENDING;
-#ifdef _LIBC
last_recognized = mode;
-#endif
continue;
case 'x':
oflags |= O_EXCL;
-#ifdef _LIBC
last_recognized = mode;
-#endif
continue;
case 'b':
-#ifdef _LIBC
last_recognized = mode;
-#endif
continue;
case 'm':
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);
if (new_pos != (_IO_off64_t) EOF)
fp->_IO_read_end = fp->_IO_read_ptr;
-#ifdef ESPIPE
else if (errno == ESPIPE)
; /* Ignore error from unseekable devices. */
-#endif
else
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)
? __read_nocancel (fp->_fileno, buf, size)
- : read (fp->_fileno, buf, size));
+ : __read (fp->_fileno, buf, size));
}
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_FLAGS2_NOTCANCEL, 0)
? __write_nocancel (f->_fileno, data, to_do)
- : write (f->_fileno, data, to_do));
+ : __write (f->_fileno, data, to_do));
if (count < 0)
{
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)
count = to_do;
-#ifdef _LIBC
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;
to_do -= count;
}
@@ -1380,12 +1320,7 @@ _IO_file_xsgetn (_IO_FILE *fp, void *data, _IO_size_t n)
{
if (have > 0)
{
-#ifdef _LIBC
s = __mempcpy (s, fp->_IO_read_ptr, have);
-#else
- memcpy (s, fp->_IO_read_ptr, have);
- s += have;
-#endif
want -= 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)))
{
-#ifdef _LIBC
s = __mempcpy (s, read_ptr, have);