This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libio partial fix : sys_open


Hi,

I cleaned the libio stuff a bit up but i could not find out what the 

__basic_file<_CharT>*
__basic_file<_CharT>::sys_open(int __fd, ios_base::openmode __mode,                            		
	bool __del);

function is supposed to do, so currently it does nothing... I did not solve or 
introduce new bugs, just made sure it all compiled again.

If anyone can provide the implementation of this sys_open call, I (and others) 
could test it some further.

Apply this patch in the libstdc++ directory.

Peter

-- 
Peter Soetens
The Orocos Project  : http://www.orocos.org
KU Leuven - Belgium
--
diff -u -r ./config/io/basic_file_libio.h ../../../gcc-3.2.1/libstdc++-v3/config/io/basic_file_libio.h
--- ./config/io/basic_file_libio.h	2002-02-12 05:35:54.000000000 +0100
+++ ../../../gcc-3.2.1/libstdc++-v3/config/io/basic_file_libio.h	2003-01-24 14:35:14.000000000 +0100
@@ -54,7 +54,7 @@
   // and detailed description of the whole object-layout,
   // vtable-swapping, sordid history of this hack.
   template<typename _CharT>
-    struct __basic_file_base: public __c_file_type
+    struct __basic_file_base: public __c_file
     {
       virtual 
       ~__basic_file_base() { };
@@ -123,7 +123,7 @@
     class __basic_file: public __basic_file_base<_CharT>
     {
 # ifdef _GLIBCPP_USE_WCHAR_T
-      __c_wfile_type	_M_wfile;
+      __c_wfile	_M_wfile;
 # endif
 
     public:
@@ -140,11 +140,14 @@
       // Used for opening the standard streams, cin, cout, cerr, clog,
       // and their wide-stream equivalents. Instead of calling open, it
       // just sets
-      //  - for libio:  __c_file_type->_fileno and the respective _flags bits
+      //  - for libio:  __c_file->_fileno and the respective _flags bits
       //  - for stdio:  _M_cfile = __file and some internal flags
       // and returns.
       __basic_file*
-      sys_open(__c_file_type* __file, ios_base::openmode __mode);
+      sys_open(__c_file* __file, ios_base::openmode __mode);
+
+      __basic_file*
+      sys_open(int __fd, ios_base::openmode __mode, bool __del);
 
       _CharT
       sys_getc();
@@ -156,7 +159,7 @@
       close(); 
 
       bool 
-      is_open();
+      is_open() const;
 
       int 
       fd();
@@ -180,26 +183,26 @@
       virtual int 
       pbackfail(int __c);
 
-      // A complex "write" function that sets all of __c_file_type's
+      // A complex "write" function that sets all of __c_file's
       // pointers and associated data members correctly and manages its
       // relation to the external byte sequence.
       virtual streamsize 
       xsputn(const _CharT* __s, streamsize __n);
 
-      // A complex "read" function that sets all of __c_file_type's
+      // A complex "read" function that sets all of __c_file's
       // pointers and associated data members correctly and manages its
       // relation to the external byte sequence.
       virtual streamsize 
       xsgetn(_CharT* __s, streamsize __n);
 
-      // A complex "seekoff" function that sets all of __c_file_type's
+      // A complex "seekoff" function that sets all of __c_file's
       // pointers and associated data members correctly and manages its
       // relation to the external byte sequence.
       virtual streamoff
       seekoff(streamoff __off, ios_base::seekdir __way,
 	      ios_base::openmode __mode = ios_base::in | ios_base::out);
 
-      // A complex "seekpos" function that sets all of __c_file_type's
+      // A complex "seekpos" function that sets all of __c_file's
       // pointers and associated data members correctly and manages its
       // relation to the external byte sequence.
       virtual streamoff
@@ -217,19 +220,19 @@
 
       // A simple read function for the external byte sequence, that
       // does no mucking around with or setting of the pointers or flags
-      // in __c_file_type.
+      // in __c_file.
       virtual streamsize 
       sys_read(_CharT* __s, streamsize __n);
 
       // A simple write function for the external byte sequence, that
       // does no mucking around with or setting of the pointers or flags
-      // in __c_file_type.
+      // in __c_file.
       virtual streamsize 
       sys_write(const _CharT* __s, streamsize __n);
 
       // A simple seek function for the external byte sequence, that
       // does no mucking around with or setting of the pointers or flags
-      // in __c_file_type.
+      // in __c_file.
       virtual streamoff
       sys_seek(streamoff __off, ios_base::seekdir __way);
 
@@ -394,7 +397,7 @@
   
   template<typename _CharT>
     __basic_file<_CharT>*
-    __basic_file<_CharT>::sys_open(__c_file_type* __f, 
+    __basic_file<_CharT>::sys_open(__c_file* __f, 
 				   ios_base::openmode __mode) 
     {
       __basic_file* __ret = NULL;
@@ -419,6 +422,33 @@
     }
   
   template<typename _CharT>
+  __basic_file<_CharT>*
+  __basic_file<_CharT>::sys_open(int __fd, ios_base::openmode __mode, 
+			       bool __del) 
+  {
+    __basic_file* __ret = NULL;
+    int __p_mode = 0;
+    int __rw_mode = 0;
+    char __c_mode[4];
+
+#if 0    
+#error copy from basic_file_stdio.h will make no sense
+    _M_open_mode(__mode, __p_mode, __rw_mode, __c_mode);
+    if (!this->is_open() && (_M_cfile = fdopen(__fd, __c_mode)))
+      {
+	// Iff __del is true, then close will fclose the fd.
+	_M_cfile_created = __del;
+
+	if (__fd == 0)
+	  setvbuf(_M_cfile, reinterpret_cast<char*>(NULL), _IONBF, 0);
+
+	__ret = this;
+      }
+#endif
+    return __ret;
+  }
+
+  template<typename _CharT>
     __basic_file<_CharT>* 
     __basic_file<_CharT>::open(const char* __name, ios_base::openmode __mode, 
 			       int __prot)
@@ -431,7 +461,7 @@
       _M_open_mode(__mode, __p_mode, __rw_mode, __c_mode);
       if (!_IO_file_is_open(this))
 	{
-	  __c_file_type* __f;
+	  __c_file* __f;
 	  __f = _IO_file_open(this, __name, __p_mode, __prot, __rw_mode, 0);
 	  __ret = __f ? this: NULL;
 	}
@@ -440,7 +470,7 @@
   
   template<typename _CharT>
     bool 
-    __basic_file<_CharT>::is_open() { return _fileno >= 0; }
+    __basic_file<_CharT>::is_open() const { return _fileno >= 0; }
   
   template<typename _CharT>
     __basic_file<_CharT>* 
diff -u -r ./config/io/c_io_libio.h ../../../gcc-3.2.1/libstdc++-v3/config/io/c_io_libio.h
--- ./config/io/c_io_libio.h	2002-02-12 05:35:54.000000000 +0100
+++ ../../../gcc-3.2.1/libstdc++-v3/config/io/c_io_libio.h	2003-01-23 15:18:29.000000000 +0100
@@ -55,8 +55,8 @@
 #endif
 
 // from basic_file.h
-  typedef _IO_FILE 	__c_file_type;
-  typedef _IO_wide_data __c_wfile_type;
+  typedef _IO_FILE 	__c_file;
+  typedef _IO_wide_data __c_wfile;
 
 #ifdef _GLIBCPP_USE_WCHAR_T
   extern "C" _IO_codecvt __c_libio_codecvt;
diff -u -r ./libio/Makefile.am ../../../gcc-3.2.1/libstdc++-v3/libio/Makefile.am
--- ./libio/Makefile.am	2001-07-13 18:47:55.000000000 +0200
+++ ../../../gcc-3.2.1/libstdc++-v3/libio/Makefile.am	2003-01-23 14:38:19.000000000 +0100
@@ -45,7 +45,7 @@
 
 if GLIBCPP_NEED_LIBIO
 LIBIO_SRCS = \
-	filedoalloc.c genops.c fileops.c stdfiles.c c_codecvt.c \
+	filedoalloc.c genops.c fileops.c stdfiles.c \
 	iofclose.c iofopen.c 
 else
 LIBIO_SRCS =

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]