aboutsummaryrefslogtreecommitdiff
path: root/libio
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 /libio
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.
Diffstat (limited to 'libio')
-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
47 files changed, 73 insertions, 751 deletions
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);
-#else
- memcpy (s, read_ptr, have);
- s += have;
-#endif
n -= have;
_IO_switch_to_main_get_area (fp);
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)
{
have = MIN (have, n);
-#ifdef _LIBC
s = __mempcpy (s, read_ptr, have);
-#else
- memcpy (s, read_ptr, have);
- s += have;
-#endif
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);
}
-#ifdef _LIBC
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_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_write, _IO_file_write, 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 =
{
diff --git a/libio/ftello.c b/libio/ftello.c
index 38863e16c3..9791e835c6 100644
--- a/libio/ftello.c
+++ b/libio/ftello.c
@@ -45,17 +45,13 @@ __ftello (_IO_FILE *fp)
_IO_release_lock (fp);
if (pos == _IO_pos_BAD)
{
-#ifdef EIO
if (errno == 0)
__set_errno (EIO);
-#endif
return -1L;
}
if ((_IO_off64_t) (off_t) pos != pos)
{
-#ifdef EOVERFLOW
__set_errno (EOVERFLOW);
-#endif
return -1L;
}
return pos;
diff --git a/libio/ftello64.c b/libio/ftello64.c
index edb10e0880..15518af7a6 100644
--- a/libio/ftello64.c
+++ b/libio/ftello64.c
@@ -46,10 +46,8 @@ ftello64 (_IO_FILE *fp)
_IO_release_lock (fp);
if (pos == _IO_pos_BAD)
{
-#ifdef EIO
if (errno == 0)
__set_errno (EIO);
-#endif
return -1L;
}
return pos;
diff --git a/libio/genops.c b/libio/genops.c
index 6ad7346cae..e3f372520a 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -30,9 +30,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
-#ifdef _LIBC
#include <sched.h>
-#endif
#ifdef _IO_MTSAFE_IO
static _IO_lock_t list_all_lock = _IO_lock_initializer;
@@ -233,16 +231,7 @@ __overflow (_IO_FILE *f, int ch)
}
libc_hidden_def (__overflow)
-static int save_for_backup (_IO_FILE *fp, char *end_p)
-#ifdef _LIBC
- internal_function
-#endif
- ;
-
static int
-#ifdef _LIBC
-internal_function
-#endif
save_for_backup (_IO_FILE *fp, char *end_p)
{
/* 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 */
if (least_mark < 0)
{
-#ifdef _LIBC
__mempcpy (__mempcpy (new_buffer + avail,
fp->_IO_save_end + least_mark,
-least_mark),
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
memcpy (new_buffer + avail,
@@ -314,10 +294,8 @@ save_for_backup (_IO_FILE *fp, char *end_p)
int
__underflow (_IO_FILE *fp)
{
-#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
return EOF;
-#endif
if (fp->_mode == 0)
_IO_fwide (fp, -1)