aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/config/io/basic_file_stdio.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/config/io/basic_file_stdio.cc')
-rw-r--r--libstdc++-v3/config/io/basic_file_stdio.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/libstdc++-v3/config/io/basic_file_stdio.cc b/libstdc++-v3/config/io/basic_file_stdio.cc
index ff23d983ae8..961523b0dcd 100644
--- a/libstdc++-v3/config/io/basic_file_stdio.cc
+++ b/libstdc++-v3/config/io/basic_file_stdio.cc
@@ -74,7 +74,11 @@ namespace std
if (__testi && !__testo && !__testt && !__testa)
{
strcpy(__c_mode, "r");
+#if defined (O_NONBLOCK)
__p_mode |= O_RDONLY | O_NONBLOCK;
+#else
+ __p_mode |= O_RDONLY;
+#endif
}
if (__testi && __testo && !__testt && !__testa)
{
@@ -151,9 +155,11 @@ namespace std
{
_M_cfile_created = true;
+#if defined (F_SETFL) && defined (O_NONBLOCK)
// Set input to nonblocking for fifos.
if (__mode & ios_base::in)
fcntl(this->fd(), F_SETFL, O_NONBLOCK);
+#endif
__ret = this;
}
@@ -197,15 +203,21 @@ namespace std
__basic_file<char>::seekoff(streamoff __off, ios_base::seekdir __way,
ios_base::openmode /*__mode*/)
{
- fseek(_M_cfile, __off, __way);
- return ftell(_M_cfile);
+ if (!fseek(_M_cfile, __off, __way))
+ return ftell(_M_cfile);
+ else
+ // Fseek failed.
+ return -1L;
}
streamoff
__basic_file<char>::seekpos(streamoff __pos, ios_base::openmode /*__mode*/)
{
- fseek(_M_cfile, __pos, ios_base::beg);
- return ftell(_M_cfile);
+ if (!fseek(_M_cfile, __pos, ios_base::beg))
+ return ftell(_M_cfile);
+ else
+ // Fseek failed.
+ return -1L;
}
int