aboutsummaryrefslogtreecommitdiff
path: root/libio
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1996-12-12 03:24:48 +0000
committerUlrich Drepper <drepper@redhat.com>1996-12-12 03:24:48 +0000
commitf8b87ef0d47ea0db7304a9c59d5479aebdaea347 (patch)
treeba0101df45ef63d6dc7321d4bdb91ee761c915da /libio
parent6259ec0d78fd301572fcb616fdfa0500b828a824 (diff)
downloadglibc-f8b87ef0d47ea0db7304a9c59d5479aebdaea347.zip
glibc-f8b87ef0d47ea0db7304a9c59d5479aebdaea347.tar.gz
glibc-f8b87ef0d47ea0db7304a9c59d5479aebdaea347.tar.bz2
update from main archive 961211cvs/libc-961214cvs/libc-961213cvs/libc-961212
Thu Dec 12 03:32:21 1996 Ulrich Drepper <drepper@cygnus.com> * libio/_G_config.h: Add definition of _G_int16_t, _G_int32_t, _G_uint16_t, _G_uin32_t, _G_HAVE_BOOL, _G_HAVE_MMAP, and _G_ARGS. Change libio buffer handling to allocate internal buffers using mmap if possible. * libio/filedoalloc.c (_IO_file_doallocate): Change call to ALLOC_BUF. * libio/genops.c (_IO_setb, _IO_default_finish): Change call to FREE_BUF. (_IO_default_doallocate): Change call to ALLOC_BUF. * libio/libioP.h: Change definition of ALLOC_BUF and FREE_BUF to use mmap/munmap when possible. * libio/memstream.c: Don't use ALLOC_BUF, but directly malloc. * libio/vasprintf.c: Likewise. Patch by HJ Lu. * libio/libio.h: Define NULL as __null only for gcc-2.8 and up. * libio/libioP.h: Likewise. * libio/fileops.c (_IO_file_read, _IO_file_write): Don't restart syscall when EINTR was returned. Necessary for POSIX.1. * libio/strops.c (_IO_str_overflow): Add cast to prevent warning. * new-malloc/malloc.c (heap_trim): Correctly place parentheses to prevent warnings. * nis/Makefile: Remove rules for bsd-tools which are not part of glibc. Patch by Thorsten Kukuk. * nis/ypclnt.c: Add prototype for xdr_free. Add const to first parameter for __yp_bind. * nis/nss_compat/compat-pwd.c (getpwent_next_netgr, getpwent_next_nis, getpwent_next_file): Variable `p2len' must have type size_t. * nis/nss_nis/nis-alias.c: Add casts to prevent warnings. * nis/nss_nis/nis-ethers.c: Likewise. * nis/nss_nis/nis-grp.c: Likewise. * nis/nss_nis/nis-hosts.c: Likewise. * nis/nss_nis/nis-network.c: Likewise. * nis/nss_nis/nis-proto.c: Likewise. * nis/nss_nis/nis-pwd.c: Likewise. * nis/nss_nis/nis-rpc.c: Likewise. * nis/nss_nis/nis-service.c: Likewise. * nis/nss_nis/nis-spwd.c: Likewise. * nis/rpcsvc/yp_prot.h (ypreq_key): Change type of members to `const char *'. (ypmaplist): Change member names to `map' and `next' and provide #defines for old names. Patch by Thorsten Kukuk. * nss/nss_files/files-parse.c (parse_line, parse_list): Change type for `datalen' parameter to size_t. * shsdow/lckpwdf.c: Use fcntl forlocking, not flock. * stdio-common/printf.c [USE_IN_LIBIO]: Provide alias _IO_printf for printf. * stdio-common/sscanf.c [USE_IN_LIBIO]: Provide alias _IO_sscanf for sscanf. Patch by HJ Lu. * stdio-common/tmpfile.c: Update copyright. * stdio-common/vfscanf.c: Correctly handle EINTR error from fgetc function. Don't eat white space for `C' format. * stdlib/tst-strtol.c [~0UL != 0xffffffff]: Fix typo in test data. * sysdeps/generic/abort.c: Update copyright. De-ANSI-declfy. * sysdeps/i386/abort.c: Removed. This version does not use signal SIGABRT. * sysdeps/i386/fpu/__math.h: Define __NO_MATH_INLINES if not using gcc-2.8 or up. Patch by HJ Lu. * sysdeps/posix/tempname.c: Test for error but EEXIST after open call. If EMFILE, ENFILE, or EINTR return with error. Wed Dec 11 14:43:52 1996 Ulrich Drepper <drepper@cygnus.com> * gnu-versions.h: Set _GNU_OBSTACK_INTERFACE_VERSION back to 1. We are compatible again. * new-malloc/obstack.h (struct obstack): Add back alloc_failed bit even though it is not used. * malloc/obstack.h: Likewise. * new-malloc/obstack.c (_obstack_begin, _obstack_begin_1): Initialize alloc_failed bit to 0. * time/strftime.c: Extend for Emacs' needs. Recognize field width, %P format and `0' modifier. Tue Dec 10 21:20:44 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makerules (make-link): Don't discard exit codes of intermediate commands. Always use rellns-sh if symbolic links are available. Tue Dec 10 20:09:51 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/netinet/in.h: Enclose #include <linux/in.h> in __BEGIN_DECLS/__END_DECLS to avoid linkage conflict of ntohs etc. in <asm/byteorder.h>.
Diffstat (limited to 'libio')
-rw-r--r--libio/_G_config.h14
-rw-r--r--libio/filedoalloc.c4
-rw-r--r--libio/fileops.c4
-rw-r--r--libio/genops.c10
-rw-r--r--libio/libio.h3
-rw-r--r--libio/libioP.h51
-rw-r--r--libio/memstream.c4
-rw-r--r--libio/strops.c2
-rw-r--r--libio/vasprintf.c11
9 files changed, 82 insertions, 21 deletions
diff --git a/libio/_G_config.h b/libio/_G_config.h
index 34d77e2..5fa7300 100644
--- a/libio/_G_config.h
+++ b/libio/_G_config.h
@@ -16,6 +16,13 @@
#define _G_pid_t __pid_t
#define _G_uid_t __uid_t
+typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
+typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
+typedef unsigned int _G_uint16_t __attribute__ ((__mode__ (__HI__)));
+typedef unsigned int _G_uint32_t __attribute__ ((__mode__ (__SI__)));
+
+#define _G_HAVE_BOOL 1
+
/* These library features are always available in the GNU C library. */
#define _G_HAVE_ATEXIT 1
@@ -25,6 +32,7 @@
#define _G_va_list __gnuc_va_list
#define _G_HAVE_PRINTF_FP 1
+#define _G_HAVE_MMAP 1
/* This is defined by <statbuf.h> if `st_blksize' exists. */
#define _G_HAVE_ST_BLKSIZE defined (_STATBUF_ST_BLKSIZE)
@@ -37,4 +45,10 @@
#define _G_VTABLE_LABEL_HAS_LENGTH 1
+#if defined (__cplusplus) || defined (__STDC__)
+#define _G_ARGS(ARGLIST) ARGLIST
+#else
+#define _G_ARGS(ARGLIST) ()
+#endif
+
#endif /* _G_config.h */
diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c
index eee489b..f36bfb3 100644
--- a/libio/filedoalloc.c
+++ b/libio/filedoalloc.c
@@ -98,9 +98,7 @@ DEFUN(_IO_file_doallocate, (fp),
size = _IO_BUFSIZ;
#endif
}
- p = ALLOC_BUF(size);
- if (p == NULL)
- return EOF;
+ ALLOC_BUF(p, size, EOF);
_IO_setb(fp, p, p+size, 1);
if (couldbetty && __isatty (fp->_fileno))
fp->_flags |= _IO_LINE_BUF;
diff --git a/libio/fileops.c b/libio/fileops.c
index b5026e1..3294bef 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -547,7 +547,7 @@ DEFUN(_IO_file_read, (fp, buf, size),
for (;;)
{
_IO_ssize_t count = _IO_read(fp->_fileno, buf, size);
-#ifdef EINTR
+#if 0 && defined EINTR
if (count == -1 && errno == EINTR)
continue;
#endif
@@ -586,7 +586,7 @@ DEFUN(_IO_file_write, (f, data, n),
_IO_ssize_t count = _IO_write(f->_fileno, data, to_do);
if (count == EOF)
{
-#ifdef EINTR
+#if 0 && defined EINTR
if (errno == EINTR)
continue;
else
diff --git a/libio/genops.c b/libio/genops.c
index 3a58cd2..52b8fc3 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -278,7 +278,7 @@ DEFUN(_IO_setb, (f, b, eb, a),
_IO_FILE *f AND char *b AND char *eb AND int a)
{
if (f->_IO_buf_base && !(f->_flags & _IO_USER_BUF))
- FREE_BUF(f->_IO_buf_base);
+ FREE_BUF(f->_IO_buf_base, _IO_blen (f));
f->_IO_buf_base = b;
f->_IO_buf_end = eb;
if (a)
@@ -438,9 +438,9 @@ int
DEFUN(_IO_default_doallocate, (fp),
_IO_FILE *fp)
{
- char *buf = ALLOC_BUF(_IO_BUFSIZ);
- if (buf == NULL)
- return EOF;
+ char *buf;
+
+ ALLOC_BUF(buf, _IO_BUFSIZ, EOF);
_IO_setb(fp, buf, buf+_IO_BUFSIZ, 1);
return 1;
}
@@ -487,7 +487,7 @@ DEFUN(_IO_default_finish, (fp),
struct _IO_marker *mark;
if (fp->_IO_buf_base && !(fp->_flags & _IO_USER_BUF))
{
- FREE_BUF(fp->_IO_buf_base);
+ FREE_BUF(fp->_IO_buf_base, _IO_blen (fp));
fp->_IO_buf_base = fp->_IO_buf_end = NULL;
}
diff --git a/libio/libio.h b/libio/libio.h
index acc34c0..49f1d8c 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -83,7 +83,8 @@ the executable file might be covered by the GNU General Public License. */
#define EOF (-1)
#endif
#ifndef NULL
-#ifdef __GNUG__
+#if defined __GNUG__ && \
+ (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
#define NULL (__null)
#else
#if !defined(__cplusplus)
diff --git a/libio/libioP.h b/libio/libioP.h
index 008f9b7..c9a639a 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -396,7 +396,8 @@ extern void (*_IO_cleanup_registration_needed) __P ((void));
#define EOF (-1)
#endif
#ifndef NULL
-#ifdef __GNUG__
+#if defined __GNUG__ && \
+ (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
#define NULL (__null)
#else
#if !defined(__cplusplus)
@@ -407,8 +408,52 @@ extern void (*_IO_cleanup_registration_needed) __P ((void));
#endif
#endif
-#define FREE_BUF(_B) free(_B)
-#define ALLOC_BUF(_S) (char*)malloc(_S)
+#if _G_HAVE_MMAP
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/param.h>
+
+#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
+#if !defined(MAP_ANONYMOUS) || !defined(EXEC_PAGESIZE)
+#undef _G_HAVE_MMAP
+#define _G_HAVE_MMAP 0
+#endif
+
+#endif /* _G_HAVE_MMAP */
+
+#if _G_HAVE_MMAP
+
+#define ROUND_TO_PAGE(_S) \
+ (((_S) + EXEC_PAGESIZE - 1) & ~(EXEC_PAGESIZE - 1))
+
+#define FREE_BUF(_B, _S) \
+ munmap ((_B), ROUND_TO_PAGE (_S))
+#define ALLOC_BUF(_B, _S, _R) \
+ do { \
+ (_B) = (char *) mmap (0, ROUND_TO_PAGE (_S), \
+ PROT_READ | PROT_WRITE, \
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
+ if ((_B) == (char *) -1) \
+ return (_R); \
+ } while (0)
+
+#else /* _G_HAVE_MMAP */
+
+#define FREE_BUF(_B, _S) \
+ free(_B)
+#define ALLOC_BUF(_B, _S, _R) \
+ do { \
+ (_B) = (char*)malloc(_S); \
+ if ((_B) == NULL) \
+ return (_R); \
+ } while (0)
+
+#endif /* _G_HAVE_MMAP */
#ifndef OS_FSTAT
#define OS_FSTAT fstat
diff --git a/libio/memstream.c b/libio/memstream.c
index ddcce67..e3c34d0 100644
--- a/libio/memstream.c
+++ b/libio/memstream.c
@@ -80,7 +80,9 @@ open_memstream (bufloc, sizeloc)
new_f->fp._sf._sbf._f._lock = &new_f->lock;
#endif
- buf = ALLOC_BUF (_IO_BUFSIZ);
+ buf = malloc (_IO_BUFSIZ);
+ if (buf == NULL)
+ return NULL;
_IO_init (&new_f->fp._sf._sbf._f, 0);
_IO_JUMPS (&new_f->fp._sf._sbf._f) = &_IO_mem_jumps;
_IO_str_init_static (&new_f->fp._sf._sbf._f, buf, _IO_BUFSIZ, buf);
diff --git a/libio/strops.c b/libio/strops.c
index 8a6c56d..281141e 100644
--- a/libio/strops.c
+++ b/libio/strops.c
@@ -124,7 +124,7 @@ DEFUN(_IO_str_overflow, (fp, c),
fp->_IO_read_ptr = fp->_IO_read_end;
}
pos = fp->_IO_write_ptr - fp->_IO_write_base;
- if (pos >= _IO_blen(fp) + flush_only)
+ if (pos >= (_IO_size_t) (_IO_blen(fp) + flush_only))
{
if (fp->_flags & _IO_USER_BUF) /* not allowed to enlarge */
return EOF;
diff --git a/libio/vasprintf.c b/libio/vasprintf.c
index f8dba80..0228940 100644
--- a/libio/vasprintf.c
+++ b/libio/vasprintf.c
@@ -42,7 +42,7 @@ _IO_vasprintf (result_ptr, format, args)
_IO_lock_t lock;
#endif
int ret;
- string = ALLOC_BUF(init_string_size);
+ string = malloc (init_string_size);
if (string == NULL)
return -1;
#ifdef _IO_MTSAFE_IO
@@ -52,13 +52,14 @@ _IO_vasprintf (result_ptr, format, args)
_IO_JUMPS((_IO_FILE*)&sf) = &_IO_str_jumps;
_IO_str_init_static ((_IO_FILE*)&sf, string, init_string_size, string);
sf._sbf._f._flags &= ~_IO_USER_BUF;
- sf._s._allocate_buffer = (_IO_alloc_type)malloc;
- sf._s._free_buffer = (_IO_free_type)free;
+ sf._s._allocate_buffer = (_IO_alloc_type) malloc;
+ sf._s._free_buffer = (_IO_free_type) free;
ret = _IO_vfprintf((_IO_FILE*)&sf, format, args);
if (ret < 0)
return ret;
- *result_ptr = (char*)realloc(sf._sbf._f._IO_buf_base,
- (sf._sbf._f._IO_write_ptr - sf._sbf._f._IO_write_base) +1);
+ *result_ptr = (char *) realloc (sf._sbf._f._IO_buf_base,
+ (sf._sbf._f._IO_write_ptr
+ - sf._sbf._f._IO_write_base) +1);
if (*result_ptr == NULL)
*result_ptr = sf._sbf._f._IO_buf_base;
(*result_ptr)[sf._sbf._f._IO_write_ptr-sf._sbf._f._IO_write_base] = '\0';