This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: Patches to libio
- To: "Martin v. Loewis" <martin@mira.isdn.cs.tu-berlin.de>
- Subject: Re: Patches to libio
- From: Chip Salzenberg <chip@perlsupport.com>
- Date: Thu, 15 Apr 1999 03:46:42 -0400
- Cc: libstdc++@sourceware.cygnus.com
- References: <199904150726.JAA13571@mira.isdn.cs.tu-berlin.de>
According to Martin v. Loewis:
> I just tried to compile libstdc++ v3 from CVS on i586-pc-linux-gnu.
> Compilation of libio failed, because the following patches are
> missing.
I think the below patch is a better approach: It simplifies the code,
making it smaller instead of bigger.
Index: libio/libioP.h
===================================================================
RCS file: /cvs/libstdc++/libstdc++/libio/libioP.h,v
retrieving revision 1.1
diff -d -c -r1.1 libioP.h
*** libioP.h 1999/01/22 17:14:16 1.1
--- libioP.h 1999/04/15 07:45:03
***************
*** 47,52 ****
--- 47,60 ----
#define _IO_seek_cur 1
#define _IO_seek_end 2
+ #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
+ typedef _IO_fpos64_t _IO_seek_fpos_t;
+ typedef _IO_off64_t _IO_seek_off_t;
+ #else
+ typedef _IO_fpos_t _IO_seek_fpos_t;
+ typedef _IO_off_t _IO_seek_off_t;
+ #endif
+
/* THE JUMPTABLE FUNCTIONS.
* The _IO_FILE type is used to implement the FILE type in GNU libc,
***************
*** 138,150 ****
(MODE==1), or the end of the file (MODE==2).
It matches the streambuf::seekoff virtual function.
It is also used for the ANSI fseek function. */
! #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
! typedef _IO_fpos64_t (*_IO_seekoff_t) __PMT ((_IO_FILE *FP, _IO_off64_t OFF,
! int DIR, int MODE));
! #else
! typedef _IO_fpos_t (*_IO_seekoff_t) __PMT ((_IO_FILE *FP, _IO_off_t OFF,
! int DIR, int MODE));
! #endif
#define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3 (__seekoff, FP, OFF, DIR, MODE)
/* The 'seekpos' hook also moves the stream position,
--- 146,154 ----
(MODE==1), or the end of the file (MODE==2).
It matches the streambuf::seekoff virtual function.
It is also used for the ANSI fseek function. */
! typedef _IO_seek_fpos_t (*_IO_seekoff_t) __PMT ((_IO_FILE *FP,
! _IO_seek_off_t OFF,
! int DIR, int MODE));
#define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3 (__seekoff, FP, OFF, DIR, MODE)
/* The 'seekpos' hook also moves the stream position,
***************
*** 152,162 ****
It matches the streambuf::seekpos virtual function.
It is also used for the ANSI fgetpos and fsetpos functions. */
/* The _IO_seek_cur and _IO_seek_end options are not allowed. */
! #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
! typedef _IO_fpos64_t (*_IO_seekpos_t) __PMT ((_IO_FILE *, _IO_fpos64_t, int));
! #else
! typedef _IO_fpos_t (*_IO_seekpos_t) __PMT ((_IO_FILE *, _IO_fpos_t, int));
! #endif
#define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2 (__seekpos, FP, POS, FLAGS)
/* The 'setbuf' hook gives a buffer to the file.
--- 156,163 ----
It matches the streambuf::seekpos virtual function.
It is also used for the ANSI fgetpos and fsetpos functions. */
/* The _IO_seek_cur and _IO_seek_end options are not allowed. */
! typedef _IO_seek_fpos_t (*_IO_seekpos_t) __PMT ((_IO_FILE *,
! _IO_seek_fpos_t, int));
#define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2 (__seekpos, FP, POS, FLAGS)
/* The 'setbuf' hook gives a buffer to the file.
***************
*** 205,215 ****
It generalizes the Unix lseek(2) function.
It matches the streambuf::sys_seek virtual function, which is
specific to this implementation. */
! #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
! typedef _IO_fpos64_t (*_IO_seek_t) __PMT ((_IO_FILE *, _IO_off64_t, int));
! #else
! typedef _IO_fpos_t (*_IO_seek_t) __PMT ((_IO_FILE *, _IO_off_t, int));
! #endif
#define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2 (__seek, FP, OFFSET, MODE)
/* The 'sysclose' hook is used to finalize (close, finish up) an
--- 206,213 ----
It generalizes the Unix lseek(2) function.
It matches the streambuf::sys_seek virtual function, which is
specific to this implementation. */
! typedef _IO_seek_fpos_t (*_IO_seek_t) __PMT ((_IO_FILE *,
! _IO_seek_off_t, int));
#define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2 (__seek, FP, OFFSET, MODE)
/* The 'sysclose' hook is used to finalize (close, finish up) an
***************
*** 290,302 ****
/* Generic functions */
! #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
! extern _IO_fpos64_t _IO_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
! extern _IO_fpos64_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos64_t, int));
! #else
! extern _IO_fpos_t _IO_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
! extern _IO_fpos_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos_t, int));
! #endif
extern void _IO_switch_to_main_get_area __P ((_IO_FILE *));
extern void _IO_switch_to_backup_area __P ((_IO_FILE *));
--- 288,297 ----
/* Generic functions */
! extern _IO_seek_fpos_t _IO_seekoff __P ((_IO_FILE *,
! _IO_seek_off_t, int, int));
! extern _IO_seek_fpos_t _IO_seekpos __P ((_IO_FILE *,
! _IO_seek_fpos_t, int));
extern void _IO_switch_to_main_get_area __P ((_IO_FILE *));
extern void _IO_switch_to_backup_area __P ((_IO_FILE *));
***************
*** 332,355 ****
extern _IO_size_t _IO_default_xsputn __P ((_IO_FILE *, const void *,
_IO_size_t));
extern _IO_size_t _IO_default_xsgetn __P ((_IO_FILE *, void *, _IO_size_t));
! #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
! extern _IO_fpos64_t _IO_default_seekoff __P ((_IO_FILE *,
! _IO_off64_t, int, int));
! extern _IO_fpos64_t _IO_default_seekpos __P ((_IO_FILE *,
! _IO_fpos64_t, int));
! #else
! extern _IO_fpos_t _IO_default_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
! extern _IO_fpos_t _IO_default_seekpos __P ((_IO_FILE *, _IO_fpos_t, int));
! #endif
extern _IO_ssize_t _IO_default_write __P ((_IO_FILE *, const void *,
_IO_ssize_t));
extern _IO_ssize_t _IO_default_read __P ((_IO_FILE *, void *, _IO_ssize_t));
extern int _IO_default_stat __P ((_IO_FILE *, void *));
! #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
! extern _IO_fpos64_t _IO_default_seek __P ((_IO_FILE *, _IO_off64_t, int));
! #else
! extern _IO_fpos_t _IO_default_seek __P ((_IO_FILE *, _IO_off_t, int));
! #endif
extern int _IO_default_sync __P ((_IO_FILE *));
#define _IO_default_close ((_IO_close_t) _IO_default_sync)
--- 327,342 ----
extern _IO_size_t _IO_default_xsputn __P ((_IO_FILE *, const void *,
_IO_size_t));
extern _IO_size_t _IO_default_xsgetn __P ((_IO_FILE *, void *, _IO_size_t));
! extern _IO_seek_fpos_t _IO_default_seekoff __P ((_IO_FILE *,
! _IO_seek_off_t, int, int));
! extern _IO_seek_fpos_t _IO_default_seekpos __P ((_IO_FILE *,
! _IO_seek_fpos_t, int));
extern _IO_ssize_t _IO_default_write __P ((_IO_FILE *, const void *,
_IO_ssize_t));
extern _IO_ssize_t _IO_default_read __P ((_IO_FILE *, void *, _IO_ssize_t));
extern int _IO_default_stat __P ((_IO_FILE *, void *));
! extern _IO_seek_fpos_t _IO_default_seek __P ((_IO_FILE *,
! _IO_seek_off_t, int));
extern int _IO_default_sync __P ((_IO_FILE *));
#define _IO_default_close ((_IO_close_t) _IO_default_sync)
***************
*** 381,393 ****
extern int _IO_file_doallocate __P ((_IO_FILE *));
extern _IO_FILE* _IO_file_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));
! #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
! extern _IO_fpos64_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
! extern _IO_fpos64_t _IO_file_seek __P ((_IO_FILE *, _IO_off64_t, int));
! #else
! extern _IO_fpos_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
! extern _IO_fpos_t _IO_file_seek __P ((_IO_FILE *, _IO_off_t, int));
! #endif
extern _IO_size_t _IO_file_xsputn __P ((_IO_FILE *, const void *, _IO_size_t));
extern int _IO_file_stat __P ((_IO_FILE *, void *));
extern int _IO_file_close __P ((_IO_FILE *));
--- 368,377 ----
extern int _IO_file_doallocate __P ((_IO_FILE *));
extern _IO_FILE* _IO_file_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));
! extern _IO_seek_fpos_t _IO_file_seekoff __P ((_IO_FILE *,
! _IO_seek_off_t, int, int));
! extern _IO_seek_fpos_t _IO_file_seek __P ((_IO_FILE *,
! _IO_seek_off_t, int));
extern _IO_size_t _IO_file_xsputn __P ((_IO_FILE *, const void *, _IO_size_t));
extern int _IO_file_stat __P ((_IO_FILE *, void *));
extern int _IO_file_close __P ((_IO_FILE *));
***************
*** 398,404 ****
extern _IO_FILE* _IO_file_attach __P ((_IO_FILE *, int));
extern _IO_FILE* _IO_file_open __P ((_IO_FILE *, const char *, int, int,
int, int));
! #if _G_IO_IO_FILE_VERSION == 0x20001
extern _IO_FILE* _IO_file_fopen __P ((_IO_FILE *, const char *, const char *,
int));
#else
--- 382,388 ----
extern _IO_FILE* _IO_file_attach __P ((_IO_FILE *, int));
extern _IO_FILE* _IO_file_open __P ((_IO_FILE *, const char *, int, int,
int, int));
! #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
extern _IO_FILE* _IO_file_fopen __P ((_IO_FILE *, const char *, const char *,
int));
#else
***************
*** 419,429 ****
extern int _IO_str_underflow __P ((_IO_FILE *));
extern int _IO_str_overflow __P ((_IO_FILE *, int));
extern int _IO_str_pbackfail __P ((_IO_FILE *, int));
! #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
! extern _IO_fpos64_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
! #else
! extern _IO_fpos_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
! #endif
extern void _IO_str_finish __P ((_IO_FILE *, int));
/* Other strfile functions */
--- 403,410 ----
extern int _IO_str_underflow __P ((_IO_FILE *));
extern int _IO_str_overflow __P ((_IO_FILE *, int));
extern int _IO_str_pbackfail __P ((_IO_FILE *, int));
! extern _IO_seek_fpos_t _IO_str_seekoff __P ((_IO_FILE *,
! _IO_seek_off_t, int, int));
extern void _IO_str_finish __P ((_IO_FILE *, int));
/* Other strfile functions */
***************
*** 539,557 ****
/* _IO_pos_BAD is an _IO_fpos_t value indicating error, unknown, or EOF. */
#ifndef _IO_pos_BAD
! # if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
! # define _IO_pos_BAD ((_IO_fpos64_t) -1)
! # else
! # define _IO_pos_BAD ((_IO_fpos_t) -1)
! # endif
#endif
/* _IO_pos_as_off converts an _IO_fpos_t value to an _IO_off_t value. */
#ifndef _IO_pos_as_off
! # if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
! # define _IO_pos_as_off(__pos) ((_IO_off64_t) (__pos))
! # else
! # define _IO_pos_as_off(__pos) ((_IO_off_t) (__pos))
! # endif
#endif
/* _IO_pos_adjust adjust an _IO_fpos_t by some number of bytes. */
#ifndef _IO_pos_adjust
--- 520,530 ----
/* _IO_pos_BAD is an _IO_fpos_t value indicating error, unknown, or EOF. */
#ifndef _IO_pos_BAD
! # define _IO_pos_BAD ((_IO_seek_fpos_t) -1)
#endif
/* _IO_pos_as_off converts an _IO_fpos_t value to an _IO_off_t value. */
#ifndef _IO_pos_as_off
! # define _IO_pos_as_off(__pos) ((_IO_seek_off_t) (__pos))
#endif
/* _IO_pos_adjust adjust an _IO_fpos_t by some number of bytes. */
#ifndef _IO_pos_adjust
***************
*** 559,569 ****
#endif
/* _IO_pos_0 is an _IO_fpos_t value indicating beginning of file. */
#ifndef _IO_pos_0
! # if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
! # define _IO_pos_0 ((_IO_fpos64_t) 0)
! # else
! # define _IO_pos_0 ((_IO_fpos_t) 0)
! # endif
#endif
#ifdef __cplusplus
--- 532,538 ----
#endif
/* _IO_pos_0 is an _IO_fpos_t value indicating beginning of file. */
#ifndef _IO_pos_0
! # define _IO_pos_0 ((_IO_seek_fpos_t) 0)
#endif
#ifdef __cplusplus
Index: libio/fileops.c
===================================================================
RCS file: /cvs/libstdc++/libstdc++/libio/fileops.c,v
retrieving revision 1.1
diff -d -c -r1.1 fileops.c
*** fileops.c 1999/01/22 17:14:14 1.1
--- fileops.c 1999/04/15 07:44:54
***************
*** 159,172 ****
}
_IO_FILE *
! _IO_file_fopen (fp, filename, mode)
_IO_FILE *fp;
const char *filename;
const char *mode;
{
int oflags = 0, omode;
int read_write, fdesc;
int oprot = 0666;
if (_IO_file_is_open (fp))
return 0;
switch (*mode++)
--- 159,182 ----
}
_IO_FILE *
! _IO_file_fopen (fp, filename, mode
! #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
! , oprot
! #endif
! )
_IO_FILE *fp;
const char *filename;
const char *mode;
+ #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
+ int oprot;
+ #endif
{
int oflags = 0, omode;
int read_write, fdesc;
+ #if !(defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001)
int oprot = 0666;
+ #endif
+
if (_IO_file_is_open (fp))
return 0;
switch (*mode++)
***************
*** 422,436 ****
return retval;
}
! _IO_pos_t
_IO_file_seekoff (fp, offset, dir, mode)
_IO_FILE *fp;
! _IO_off_t offset;
int dir;
int mode;
{
! _IO_pos_t result;
! _IO_off_t delta, new_offset;
long count;
/* POSIX.1 8.2.3.7 says that after a call the fflush() the file
offset of the underlying file must be exact. */
--- 432,446 ----
return retval;
}
! _IO_seek_fpos_t
_IO_file_seekoff (fp, offset, dir, mode)
_IO_FILE *fp;
! _IO_seek_off_t offset;
int dir;
int mode;
{
! _IO_seek_fpos_t result;
! _IO_seek_off_t delta, new_offset;
long count;
/* POSIX.1 8.2.3.7 says that after a call the fflush() the file
offset of the underlying file must be exact. */
***************
*** 590,599 ****
return read (fp->_fileno, buf, size);
}
! _IO_pos_t
_IO_file_seek (fp, offset, dir)
_IO_FILE *fp;
! _IO_off_t offset;
int dir;
{
return lseek (fp->_fileno, offset, dir);
--- 600,609 ----
return read (fp->_fileno, buf, size);
}
! _IO_seek_fpos_t
_IO_file_seek (fp, offset, dir)
_IO_FILE *fp;
! _IO_seek_off_t offset;
int dir;
{
return lseek (fp->_fileno, offset, dir);
Index: libio/genops.c
===================================================================
RCS file: /cvs/libstdc++/libstdc++/libio/genops.c,v
retrieving revision 1.1
diff -d -c -r1.1 genops.c
*** genops.c 1999/01/22 17:14:15 1.1
--- genops.c 1999/04/15 07:45:02
***************
*** 467,476 ****
return fp;
}
! _IO_pos_t
_IO_default_seekpos (fp, pos, mode)
_IO_FILE *fp;
! _IO_pos_t pos;
int mode;
{
return _IO_SEEKOFF (fp, _IO_pos_as_off (pos), 0, mode);
--- 467,476 ----
return fp;
}
! _IO_seek_fpos_t
_IO_default_seekpos (fp, pos, mode)
_IO_FILE *fp;
! _IO_seek_fpos_t pos;
int mode;
{
return _IO_SEEKOFF (fp, _IO_pos_as_off (pos), 0, mode);
***************
*** 551,560 ****
_IO_un_link (fp);
}
! _IO_pos_t
_IO_default_seekoff (fp, offset, dir, mode)
_IO_FILE *fp;
! _IO_off_t offset;
int dir;
int mode;
{
--- 551,560 ----
_IO_un_link (fp);
}
! _IO_seek_fpos_t
_IO_default_seekoff (fp, offset, dir, mode)
_IO_FILE *fp;
! _IO_seek_off_t offset;
int dir;
int mode;
{
***************
*** 882,891 ****
return (unsigned char) *fp->_IO_read_ptr;
}
! _IO_pos_t
_IO_default_seek (fp, offset, dir)
_IO_FILE *fp;
! _IO_off_t offset;
int dir;
{
return _IO_pos_BAD;
--- 882,891 ----
return (unsigned char) *fp->_IO_read_ptr;
}
! _IO_seek_fpos_t
_IO_default_seek (fp, offset, dir)
_IO_FILE *fp;
! _IO_seek_off_t offset;
int dir;
{
return _IO_pos_BAD;
Index: libio/ioseekoff.c
===================================================================
RCS file: /cvs/libstdc++/libstdc++/libio/ioseekoff.c,v
retrieving revision 1.1
diff -d -c -r1.1 ioseekoff.c
*** ioseekoff.c 1999/01/22 17:14:15 1.1
--- ioseekoff.c 1999/04/15 07:45:03
***************
*** 25,38 ****
#include <libioP.h>
! _IO_pos_t
_IO_seekoff (fp, offset, dir, mode)
_IO_FILE *fp;
! _IO_off_t offset;
int dir;
int mode;
{
! _IO_pos_t retval;
/* If we have a backup buffer, get rid of it, since the __seekoff
callback may not know to do the right thing about it.
--- 25,38 ----
#include <libioP.h>
! _IO_seek_fpos_t
_IO_seekoff (fp, offset, dir, mode)
_IO_FILE *fp;
! _IO_seek_off_t offset;
int dir;
int mode;
{
! _IO_seek_fpos_t retval;
/* If we have a backup buffer, get rid of it, since the __seekoff
callback may not know to do the right thing about it.
Index: libio/ioseekpos.c
===================================================================
RCS file: /cvs/libstdc++/libstdc++/libio/ioseekpos.c,v
retrieving revision 1.1
diff -d -c -r1.1 ioseekpos.c
*** ioseekpos.c 1999/01/22 17:14:16 1.1
--- ioseekpos.c 1999/04/15 07:45:03
***************
*** 25,37 ****
#include <libioP.h>
! _IO_pos_t
_IO_seekpos (fp, pos, mode)
_IO_FILE *fp;
! _IO_pos_t pos;
int mode;
{
! _IO_pos_t retval;
/* If we have a backup buffer, get rid of it, since the __seekoff
callback may not know to do the right thing about it.
--- 25,37 ----
#include <libioP.h>
! _IO_seek_fpos_t
_IO_seekpos (fp, pos, mode)
_IO_FILE *fp;
! _IO_seek_fpos_t pos;
int mode;
{
! _IO_seek_fpos_t retval;
/* If we have a backup buffer, get rid of it, since the __seekoff
callback may not know to do the right thing about it.
Index: libio/strops.c
===================================================================
RCS file: /cvs/libstdc++/libstdc++/libio/strops.c,v
retrieving revision 1.1
diff -d -c -r1.1 strops.c
*** strops.c 1999/01/22 17:14:17 1.1
--- strops.c 1999/04/15 07:45:03
***************
*** 205,219 ****
- fp->_IO_read_base);
}
! _IO_pos_t
_IO_str_seekoff (fp, offset, dir, mode)
_IO_FILE *fp;
! _IO_off_t offset;
int dir;
int mode;
{
_IO_ssize_t cur_size = _IO_str_count (fp);
! _IO_pos_t new_pos = EOF;
/* Move the get pointer, if requested. */
if (mode & _IOS_INPUT)
--- 205,219 ----
- fp->_IO_read_base);
}
! _IO_seek_fpos_t
_IO_str_seekoff (fp, offset, dir, mode)
_IO_FILE *fp;
! _IO_seek_off_t offset;
int dir;
int mode;
{
_IO_ssize_t cur_size = _IO_str_count (fp);
! _IO_seek_fpos_t new_pos = EOF;
/* Move the get pointer, if requested. */
if (mode & _IOS_INPUT)
--
Chip Salzenberg - a.k.a. - <chip@perlsupport.com>
"When do you work?" "Whenever I'm not busy."