aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/cstreams.c
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2016-04-18 14:27:10 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2016-04-18 14:27:10 +0200
commit4afcf3a5a0391b309520cbcf5d4836d611bd7fd9 (patch)
treeffe4f91e0d909b0d393db9ce84a1203f8c331576 /gcc/ada/cstreams.c
parent58ba2415917ccf9f4556394786a76470284a8d5f (diff)
downloadgcc-4afcf3a5a0391b309520cbcf5d4836d611bd7fd9.zip
gcc-4afcf3a5a0391b309520cbcf5d4836d611bd7fd9.tar.gz
gcc-4afcf3a5a0391b309520cbcf5d4836d611bd7fd9.tar.bz2
[multiple changes]
2016-04-18 Gary Dismukes <dismukes@adacore.com> * lib-xref-spark_specific.adb, par-ch2.adb, errout.ads, exp_intr.adb: Minor reformatting and typo corrections. 2016-04-18 Ed Schonberg <schonberg@adacore.com> * sem_ch6.adb: Code cleanup. 2016-04-18 Thomas Quinot <quinot@adacore.com> * sem_ch13.adb: Minor reformatting and error message tweaking (remove extraneous spaces). 2016-04-18 Johannes Kanig <kanig@adacore.com> * gnat1drv.adb (Gnat1drv): Force loading of System unit for SPARK. 2016-04-18 Bob Duff <duff@adacore.com> * s-fileio.adb (Fopen_Mode): If Mode = Out_File, and the file exists, and it's a fifo, we use "w" as the open string instead of "r+". This is necessary to make a write to the fifo block until a reader is ready. 2016-04-18 Hristian Kirtchev <kirtchev@adacore.com> * sem_attr.adb (Denote_Same_Function): Account for a special case where a primitive of a tagged type inherits a class-wide postcondition from a parent type. From-SVN: r235135
Diffstat (limited to 'gcc/ada/cstreams.c')
-rw-r--r--gcc/ada/cstreams.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/ada/cstreams.c b/gcc/ada/cstreams.c
index 915e4a3..f0f8266 100644
--- a/gcc/ada/cstreams.c
+++ b/gcc/ada/cstreams.c
@@ -39,6 +39,8 @@
#include <stdio.h>
#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#ifdef _AIX
/* needed to avoid conflicting declarations */
@@ -320,6 +322,24 @@ __gnat_fseek64 (FILE *stream, __int64 offset, int origin)
}
#endif
+/* Returns true if the path names a fifo (i.e. a named pipe). */
+int
+__gnat_is_fifo (const char* path)
+{
+/* Posix defines S_ISFIFO as a macro. If the macro doesn't exist, we return
+ false. */
+#ifdef S_ISFIFO
+ struct stat buf;
+ const int status = stat(path, &buf);
+ if (status == 0)
+ return S_ISFIFO(buf.st_mode);
+#endif
+
+ /* S_ISFIFO is not available, or stat got an error (probably
+ file not found). */
+ return 0;
+}
+
#ifdef __cplusplus
}
#endif