summaryrefslogtreecommitdiff
path: root/libc/libio
diff options
context:
space:
mode:
Diffstat (limited to 'libc/libio')
-rw-r--r--libc/libio/Makefile19
-rw-r--r--libc/libio/fileops.c6
-rw-r--r--libc/libio/iogetdelim.c3
-rw-r--r--libc/libio/iogetline.c4
-rw-r--r--libc/libio/iogetwline.c4
-rw-r--r--libc/libio/iopopen.c11
-rw-r--r--libc/libio/libio.h30
-rw-r--r--libc/libio/libioP.h70
-rw-r--r--libc/libio/oldfileops.c6
-rw-r--r--libc/libio/oldiopopen.c11
-rwxr-xr-xlibc/libio/test-freopen.sh5
-rw-r--r--libc/libio/wfileops.c2
12 files changed, 52 insertions, 119 deletions
diff --git a/libc/libio/Makefile b/libc/libio/Makefile
index ba2466076..d66e090e6 100644
--- a/libc/libio/Makefile
+++ b/libc/libio/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1995-2004,2006-2009,2011,2012 Free Software Foundation, Inc.
+# Copyright (C) 1995-2012 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -59,6 +59,8 @@ routines-$(OPTION_POSIX_WIDE_CHAR_DEVICE_IO) += \
wprintf wscanf fwscanf vwscanf \
fwide
+include ../Makeconfig
+
tests = test-fmemopen tst-ext tst-ext2 \
tst-mmap-setvbuf tst-atime tst-eof \
tst-freopen bug-ungetc bug-fseek \
@@ -68,7 +70,7 @@ tests = test-fmemopen tst-ext tst-ext2 \
tst-memstream1 tst-memstream2 \
bug-memstream1 tst-popen1 bug-fclose1
tests-$(OPTION_EGLIBC_LOCALE_CODE) \
- += tst-swscanf tst-fgetws tst-fopenloc tst-setvbuf1 \
+ += tst-swscanf tst-fgetws tst-setvbuf1 \
tst-ungetwc1 tst-ungetwc2 bug-ftell bug-ungetwc2 \
tst-widetext
tests-$(OPTION_POSIX_WIDE_CHAR_DEVICE_IO) \
@@ -80,12 +82,15 @@ tests-$(OPTION_POSIX_C_LANG_WIDE_CHAR) \
+= tst_swprintf tst_swscanf \
tst-sscanf \
tst-wmemstream1 tst-wmemstream2
+ifeq (yes,$(build-shared))
+# Add test-fopenloc only if shared library is enabled since it depends on
+# shared localedata objects.
+tests-$(OPTION_EGLIBC_LOCALE_CODE) += tst-fopenloc
+endif
test-srcs = test-freopen
all: # Make this the default target; it will be defined in Rules.
-include ../Makeconfig
-
ifeq ($(versioning),yes)
routines += oldiofopen oldiofdopen oldiofclose oldiopopen oldpclose \
oldtmpfile oldiofgetpos oldiofgetpos64 oldiofsetpos \
@@ -194,12 +199,16 @@ include ../Rules
ifeq (y,$(OPTION_POSIX_WIDE_CHAR_DEVICE_IO))
tests: $(objpfx)test-freopen.out
$(objpfx)test-freopen.out: test-freopen.sh $(objpfx)test-freopen
- $(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' \
+ $(SHELL) $< $(common-objpfx) '$(run-program-prefix)' \
$(common-objpfx)libio/
endif
ifeq (y,$(OPTION_EGLIBC_LOCALE_CODE))
+ifeq (yes,$(build-shared))
+# Run tst-fopenloc.check only if shared library is enabled since it
+# depends on tst-fopenloc.out.
tests: $(objpfx)tst-fopenloc.check
+endif
$(objpfx)tst-fopenloc.check: $(objpfx)tst-fopenloc.out
cmp ../iconvdata/testdata/ISO-8859-1..UTF8 $(objpfx)tst-fopenloc.out \
> $@
diff --git a/libc/libio/fileops.c b/libc/libio/fileops.c
index 9a6e51885..a65f0afbc 100644
--- a/libc/libio/fileops.c
+++ b/libc/libio/fileops.c
@@ -102,7 +102,7 @@ extern struct __gconv_trans_data __libio_translit attribute_hidden;
to _IO_buf_base, though not necessarily if we have switched from
get mode to put mode. (The reason is to maintain the invariant
that _IO_read_end corresponds to the external file position.)
- _IO_write_base is non-NULL and usually equal to _IO_base_base.
+ _IO_write_base is non-NULL and usually equal to _IO_buf_base.
We also have _IO_write_end == _IO_buf_end, but only in fully buffered mode.
The un-flushed character are those between _IO_write_base and _IO_write_ptr.
@@ -992,10 +992,10 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
/* Flush unwritten characters.
(This may do an unneeded write if we seek within the buffer.
But to be able to switch to reading, we would need to set
- egptr to ptr. That can't be done in the current design,
+ egptr to pptr. That can't be done in the current design,
which assumes file_ptr() is eGptr. Anyway, since we probably
end up flushing when we close(), it doesn't make much difference.)
- FIXME: simulate mem-papped files. */
+ FIXME: simulate mem-mapped files. */
if (fp->_IO_write_ptr > fp->_IO_write_base || _IO_in_put_mode (fp))
if (_IO_switch_to_get_mode (fp))
diff --git a/libc/libio/iogetdelim.c b/libc/libio/iogetdelim.c
index 405b65f1e..bf4b0f776 100644
--- a/libc/libio/iogetdelim.c
+++ b/libc/libio/iogetdelim.c
@@ -29,6 +29,7 @@
#include "libioP.h"
#include <string.h>
#include <errno.h>
+#include <limits.h>
/* Read up to (and including) a TERMINATOR from FP into *LINEPTR
(and null-terminate it). *LINEPTR is a pointer returned from malloc (or
@@ -89,7 +90,7 @@ _IO_getdelim (lineptr, n, delimiter, fp)
t = (char *) memchr ((void *) fp->_IO_read_ptr, delimiter, len);
if (t != NULL)
len = (t - fp->_IO_read_ptr) + 1;
- if (__builtin_expect (cur_len + len + 1 < 0, 0))
+ if (__builtin_expect (len >= SSIZE_MAX - cur_len, 0))
{
__set_errno (EOVERFLOW);
result = -1;
diff --git a/libc/libio/iogetline.c b/libc/libio/iogetline.c
index f097f8002..bdb35b30f 100644
--- a/libc/libio/iogetline.c
+++ b/libc/libio/iogetline.c
@@ -27,8 +27,6 @@
#include "libioP.h"
#include <string.h>
-#if defined _LIBC || !_G_HAVE_IO_GETLINE_INFO
-
_IO_size_t
_IO_getline (fp, buf, n, delim, extract_delim)
_IO_FILE *fp;
@@ -117,5 +115,3 @@ _IO_getline_info (fp, buf, n, delim, extract_delim, eof)
return ptr - buf;
}
libc_hidden_def (_IO_getline_info)
-
-#endif /* Defined _LIBC || !_G_HAVE_IO_GETLINE_INFO */
diff --git a/libc/libio/iogetwline.c b/libc/libio/iogetwline.c
index 598ece173..63b7da672 100644
--- a/libc/libio/iogetwline.c
+++ b/libc/libio/iogetwline.c
@@ -32,8 +32,6 @@
# define wmemcpy __wmemcpy
#endif
-#if defined _LIBC || !_G_HAVE_IO_GETLINE_INFO
-
_IO_size_t
_IO_getwline (fp, buf, n, delim, extract_delim)
_IO_FILE *fp;
@@ -122,5 +120,3 @@ _IO_getwline_info (fp, buf, n, delim, extract_delim, eof)
}
return ptr - buf;
}
-
-#endif /* Defined _LIBC || !_G_HAVE_IO_GETLINE_INFO */
diff --git a/libc/libio/iopopen.c b/libc/libio/iopopen.c
index 4f67e8cca..716395804 100644
--- a/libc/libio/iopopen.c
+++ b/libc/libio/iopopen.c
@@ -29,7 +29,6 @@
# define _POSIX_SOURCE
#endif
#include "libioP.h"
-#if _IO_HAVE_SYS_WAIT
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
@@ -51,8 +50,6 @@
extern _IO_pid_t _IO_fork (void) __THROW;
#endif
-#endif /* _IO_HAVE_SYS_WAIT */
-
#ifndef _IO_dup2
#ifdef _LIBC
#define _IO_dup2 __dup2
@@ -114,7 +111,6 @@ _IO_new_proc_open (fp, command, mode)
const char *command;
const char *mode;
{
-#if _IO_HAVE_SYS_WAIT
int read_or_write;
int parent_end, child_end;
int pipe_fds[2];
@@ -273,9 +269,6 @@ _IO_new_proc_open (fp, command, mode)
_IO_mask_flags (fp, read_or_write, _IO_NO_READS|_IO_NO_WRITES);
return fp;
-#else /* !_IO_HAVE_SYS_WAIT */
- return NULL;
-#endif
}
_IO_FILE *
@@ -317,7 +310,6 @@ _IO_new_proc_close (fp)
_IO_FILE *fp;
{
/* This is not name-space clean. FIXME! */
-#if _IO_HAVE_SYS_WAIT
int wstatus;
_IO_proc_file **ptr = &proc_file_chain;
_IO_pid_t wait_pid;
@@ -356,9 +348,6 @@ _IO_new_proc_close (fp)
if (wait_pid == -1)
return -1;
return wstatus;
-#else /* !_IO_HAVE_SYS_WAIT */
- return -1;
-#endif
}
static const struct _IO_jump_t _IO_proc_jumps = {
diff --git a/libc/libio/libio.h b/libc/libio/libio.h
index bbfdd9d32..f093a93e9 100644
--- a/libc/libio/libio.h
+++ b/libc/libio/libio.h
@@ -34,37 +34,31 @@
#define _IO_pos_t _G_fpos_t /* obsolete */
#define _IO_fpos_t _G_fpos_t
#define _IO_fpos64_t _G_fpos64_t
-#define _IO_size_t _G_size_t
-#define _IO_ssize_t _G_ssize_t
-#define _IO_off_t _G_off_t
+#define _IO_size_t size_t
+#define _IO_ssize_t __ssize_t
+#define _IO_off_t __off_t
#define _IO_off64_t _G_off64_t
-#define _IO_pid_t _G_pid_t
-#define _IO_uid_t _G_uid_t
+#define _IO_pid_t __pid_t
+#define _IO_uid_t __uid_t
#define _IO_iconv_t _G_iconv_t
-#define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT
#define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE
#define _IO_BUFSIZ _G_BUFSIZ
#define _IO_va_list _G_va_list
-#define _IO_wint_t _G_wint_t
+#define _IO_wint_t wint_t
-#ifdef _G_NEED_STDARG_H
/* This define avoids name pollution if we're using GNU stdarg.h */
-# define __need___va_list
-# include <stdarg.h>
-# ifdef __GNUC_VA_LIST
-# undef _IO_va_list
-# define _IO_va_list __gnuc_va_list
-# endif /* __GNUC_VA_LIST */
-#endif
+#define __need___va_list
+#include <stdarg.h>
+#ifdef __GNUC_VA_LIST
+# undef _IO_va_list
+# define _IO_va_list __gnuc_va_list
+#endif /* __GNUC_VA_LIST */
#ifndef __P
# include <sys/cdefs.h>
#endif /*!__P*/
#define _IO_UNIFIED_JUMPTABLES 1
-#ifndef _G_HAVE_PRINTF_FP
-# define _IO_USE_DTOA 1
-#endif
#ifndef EOF
# define EOF (-1)
diff --git a/libc/libio/libioP.h b/libc/libio/libioP.h
index f55a84ba2..9bbf2a741 100644
--- a/libc/libio/libioP.h
+++ b/libc/libio/libioP.h
@@ -113,34 +113,18 @@ extern "C" {
# define _IO_vtable_offset(THIS) 0
#endif
#define _IO_WIDE_JUMPS_FUNC(THIS) _IO_WIDE_JUMPS(THIS)
-#ifdef _G_USING_THUNKS
-# define JUMP_FIELD(TYPE, NAME) TYPE NAME
-# define JUMP0(FUNC, THIS) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS)
-# define JUMP1(FUNC, THIS, X1) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
-# define JUMP2(FUNC, THIS, X1, X2) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
-# define JUMP3(FUNC, THIS, X1,X2,X3) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
-# define JUMP_INIT(NAME, VALUE) VALUE
-# define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT (dummy2, 0)
-
-# define WJUMP0(FUNC, THIS) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS)
-# define WJUMP1(FUNC, THIS, X1) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
-# define WJUMP2(FUNC, THIS, X1, X2) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
-# define WJUMP3(FUNC, THIS, X1,X2,X3) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
-#else
-/* These macros will change when we re-implement vtables to use "thunks"! */
-# define JUMP_FIELD(TYPE, NAME) struct { short delta1, delta2; TYPE pfn; } NAME
-# define JUMP0(FUNC, THIS) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS)
-# define JUMP1(FUNC, THIS, X1) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1)
-# define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1, X2)
-# define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1,X2,X3)
-# define JUMP_INIT(NAME, VALUE) {0, 0, VALUE}
-# define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0)
-
-# define WJUMP0(FUNC, THIS) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS)
-# define WJUMP1(FUNC, THIS, X1) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1)
-# define WJUMP2(FUNC, THIS, X1, X2) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1, X2)
-# define WJUMP3(FUNC, THIS, X1,X2,X3) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1,X2,X3)
-#endif
+#define JUMP_FIELD(TYPE, NAME) TYPE NAME
+#define JUMP0(FUNC, THIS) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS)
+#define JUMP1(FUNC, THIS, X1) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
+#define JUMP2(FUNC, THIS, X1, X2) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
+#define JUMP3(FUNC, THIS, X1,X2,X3) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
+#define JUMP_INIT(NAME, VALUE) VALUE
+#define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT (dummy2, 0)
+
+#define WJUMP0(FUNC, THIS) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS)
+#define WJUMP1(FUNC, THIS, X1) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
+#define WJUMP2(FUNC, THIS, X1, X2) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
+#define WJUMP3(FUNC, THIS, X1,X2,X3) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
/* The 'finish' function does any final cleaning up of an _IO_FILE object.
It does not delete (free) it, but does everything else to finalize it.
@@ -302,10 +286,8 @@ typedef void (*_IO_imbue_t) (_IO_FILE *, void *);
struct _IO_jump_t
{
- JUMP_FIELD(_G_size_t, __dummy);
-#ifdef _G_USING_THUNKS
- JUMP_FIELD(_G_size_t, __dummy2);
-#endif
+ JUMP_FIELD(size_t, __dummy);
+ JUMP_FIELD(size_t, __dummy2);
JUMP_FIELD(_IO_finish_t, __finish);
JUMP_FIELD(_IO_overflow_t, __overflow);
JUMP_FIELD(_IO_underflow_t, __underflow);
@@ -878,30 +860,6 @@ extern int _IO_vscanf (const char *, _IO_va_list) __THROW;
# endif
#endif
-/* VTABLE_LABEL defines NAME as of the CLASS class.
- CNLENGTH is strlen(#CLASS). */
-#ifdef __GNUC__
-# if _G_VTABLE_LABEL_HAS_LENGTH
-# define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
- extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CNLENGTH #CLASS);
-# else
-# define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
- extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CLASS);
-# endif
-#endif /* __GNUC__ */
-
-#if !defined(builtinbuf_vtable) && defined(__cplusplus)
-# ifdef __GNUC__
-VTABLE_LABEL(builtinbuf_vtable, builtinbuf, 10)
-# else
-# if _G_VTABLE_LABEL_HAS_LENGTH
-# define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##10builtinbuf
-# else
-# define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##builtinbuf
-# endif
-# endif
-#endif /* !defined(builtinbuf_vtable) && defined(__cplusplus) */
-
#define _IO_va_start(args, last) va_start(args, last)
extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf;
diff --git a/libc/libio/oldfileops.c b/libc/libio/oldfileops.c
index c68ca6a76..8fda0484a 100644
--- a/libc/libio/oldfileops.c
+++ b/libc/libio/oldfileops.c
@@ -76,7 +76,7 @@ extern int errno;
to _IO_buf_base, though not necessarily if we have switched from
get mode to put mode. (The reason is to maintain the invariant
that _IO_read_end corresponds to the external file position.)
- _IO_write_base is non-NULL and usually equal to _IO_base_base.
+ _IO_write_base is non-NULL and usually equal to _IO_buf_base.
We also have _IO_write_end == _IO_buf_end, but only in fully buffered mode.
The un-flushed character are those between _IO_write_base and _IO_write_ptr.
@@ -492,10 +492,10 @@ _IO_old_file_seekoff (fp, offset, dir, mode)
/* Flush unwritten characters.
(This may do an unneeded write if we seek within the buffer.
But to be able to switch to reading, we would need to set
- egptr to ptr. That can't be done in the current design,
+ egptr to pptr. That can't be done in the current design,
which assumes file_ptr() is eGptr. Anyway, since we probably
end up flushing when we close(), it doesn't make much difference.)
- FIXME: simulate mem-papped files. */
+ FIXME: simulate mem-mapped files. */
if (fp->_IO_write_ptr > fp->_IO_write_base || _IO_in_put_mode (fp))
if (_IO_switch_to_get_mode (fp))
diff --git a/libc/libio/oldiopopen.c b/libc/libio/oldiopopen.c
index e14961ad8..4965a732b 100644
--- a/libc/libio/oldiopopen.c
+++ b/libc/libio/oldiopopen.c
@@ -30,7 +30,6 @@
# define _POSIX_SOURCE
#endif
#include "libioP.h"
-#if _IO_HAVE_SYS_WAIT
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
@@ -49,8 +48,6 @@
extern _IO_pid_t _IO_fork (void) __THROW;
#endif
-#endif /* _IO_HAVE_SYS_WAIT */
-
#include <shlib-compat.h>
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
@@ -123,7 +120,6 @@ _IO_old_proc_open (fp, command, mode)
const char *command;
const char *mode;
{
-#if _IO_HAVE_SYS_WAIT
volatile int read_or_write;
volatile int parent_end, child_end;
int pipe_fds[2];
@@ -194,9 +190,6 @@ _IO_old_proc_open (fp, command, mode)
_IO_mask_flags (fp, read_or_write, _IO_NO_READS|_IO_NO_WRITES);
return fp;
-#else /* !_IO_HAVE_SYS_WAIT */
- return NULL;
-#endif
}
_IO_FILE *
@@ -240,7 +233,6 @@ _IO_old_proc_close (fp)
_IO_FILE *fp;
{
/* This is not name-space clean. FIXME! */
-#if _IO_HAVE_SYS_WAIT
int wstatus;
_IO_proc_file **ptr = &old_proc_file_chain;
_IO_pid_t wait_pid;
@@ -279,9 +271,6 @@ _IO_old_proc_close (fp)
if (wait_pid == -1)
return -1;
return wstatus;
-#else /* !_IO_HAVE_SYS_WAIT */
- return -1;
-#endif
}
const struct _IO_jump_t _IO_old_proc_jumps = {
diff --git a/libc/libio/test-freopen.sh b/libc/libio/test-freopen.sh
index 07b4cf68d..9ee453087 100755
--- a/libc/libio/test-freopen.sh
+++ b/libc/libio/test-freopen.sh
@@ -1,8 +1,7 @@
#! /bin/sh
# Test of freopen.
-# Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+# Copyright (C) 2000-2012 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
-#
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -18,6 +17,8 @@
# License along with the GNU C Library; if not, see
# <http://www.gnu.org/licenses/>.
+set -e
+
common_objpfx=$1
run_program_prefix=$2
objpfx=$3
diff --git a/libc/libio/wfileops.c b/libc/libio/wfileops.c
index 3f628bfd1..b790029ff 100644
--- a/libc/libio/wfileops.c
+++ b/libc/libio/wfileops.c
@@ -589,7 +589,7 @@ _IO_wfile_seekoff (fp, offset, dir, mode)
/* Flush unwritten characters.
(This may do an unneeded write if we seek within the buffer.
But to be able to switch to reading, we would need to set
- egptr to ptr. That can't be done in the current design,
+ egptr to pptr. That can't be done in the current design,
which assumes file_ptr() is eGptr. Anyway, since we probably
end up flushing when we close(), it doesn't make much difference.)
FIXME: simulate mem-mapped files. */