This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

[VxWorks 04/20] New general purpose routines in utils.c


These are some general-purpose routines that were added for the VxWorks
port...  Hopefully other parts of the GDB code will make use of them.

gdb/ChangeLog:

        * utils.c (have_dos_based_filesystem, is_regular_file):
        New functions.
        * source.c (is_regular_file): Delete.  Moved to utils.c.
        * defs.h (have_dos_based_filesystem, is_regular_file):
        Add declaration.
---
 gdb/defs.h   |    4 ++++
 gdb/source.c |   18 ------------------
 gdb/utils.c  |   31 +++++++++++++++++++++++++++++++
 3 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/gdb/defs.h b/gdb/defs.h
index 9409dde..11178f8 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -421,6 +421,10 @@ extern const char *gdb_bfd_errmsg (bfd_error_type error_tag, char **matching);
 
 extern int parse_pid_to_attach (char *args);
 
+extern int have_dos_based_filesystem (void);
+
+extern int is_regular_file (const char *name);
+
 /* From demangle.c */
 
 extern void set_demangling_style (char *);
diff --git a/gdb/source.c b/gdb/source.c
index a14a802..9e35dd9 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -657,24 +657,6 @@ source_info (char *ignore, int from_tty)
 }
 
 
-/* Return True if the file NAME exists and is a regular file.  */
-static int
-is_regular_file (const char *name)
-{
-  struct stat st;
-  const int status = stat (name, &st);
-
-  /* Stat should never fail except when the file does not exist.
-     If stat fails, analyze the source of error and return True
-     unless the file does not exist, to avoid returning false results
-     on obscure systems where stat does not work as expected.  */
-
-  if (status != 0)
-    return (errno != ENOENT);
-
-  return S_ISREG (st.st_mode);
-}
-
 /* Open a file named STRING, searching path PATH (dir names sep by some char)
    using mode MODE in the calls to open.  You cannot use this function to
    create files (O_CREAT).
diff --git a/gdb/utils.c b/gdb/utils.c
index 91e6af4..042ced1 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -74,6 +74,7 @@
 #include "gdb_usleep.h"
 #include "interps.h"
 #include "gdb_regex.h"
+#include "gdb_stat.h"
 
 #if !HAVE_DECL_MALLOC
 extern PTR malloc ();		/* ARI: PTR */
@@ -3987,6 +3988,36 @@ parse_pid_to_attach (char *args)
   return pid;
 }
 
+/* Return non-zero if the host has a dos-based file system.  */
+
+int
+have_dos_based_filesystem (void)
+{
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+  return 1;
+#else
+  return 0;
+#endif
+}
+
+/* Return True if the file NAME exists and is a regular file.  */
+
+int
+is_regular_file (const char *name)
+{
+  struct stat st;
+  const int status = stat (name, &st);
+
+  /* Stat should never fail except when the file does not exist.
+     If stat fails, analyze the source of error and return True
+     unless the file does not exist, to avoid returning false results
+     on obscure systems where stat does not work as expected.  */
+  if (status != 0)
+    return (errno != ENOENT);
+
+  return S_ISREG (st.st_mode);
+}
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 extern initialize_file_ftype _initialize_utils;
 
-- 
1.7.0.4


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