incpath.c (get_added_cpp_dirs): New function.
authorTristan Gingold <gingold@adacore.com>
Tue, 15 Nov 2011 10:25:36 +0000 (10:25 +0000)
committerTristan Gingold <gingold@gcc.gnu.org>
Tue, 15 Nov 2011 10:25:36 +0000 (10:25 +0000)
2011-11-15  Tristan Gingold  <gingold@adacore.com>

* incpath.c (get_added_cpp_dirs): New function.
* incpath.h (get_added_cpp_dirs): Declare.
* config/vms/vms-c.c (vms_c_register_includes): New function.
(vms_std_modules): New variable.
* config/vms/vms.h (TARGET_EXTRA_INCLUDES): Define.
(vms_c_register_includes): Declare.

From-SVN: r181380

gcc/ChangeLog
gcc/config/vms/vms-c.c
gcc/config/vms/vms.h
gcc/incpath.c
gcc/incpath.h

index eab0ca46c8bbd23657f810103b54c25ee7b1b12a..31e6968c58ef05ebf116484445d5813884b6fb2a 100644 (file)
@@ -1,3 +1,12 @@
+2011-11-15  Tristan Gingold  <gingold@adacore.com>
+
+       * incpath.c (get_added_cpp_dirs): New function.
+       * incpath.h (get_added_cpp_dirs): Declare.
+       * config/vms/vms-c.c (vms_c_register_includes): New function.
+       (vms_std_modules): New variable.
+       * config/vms/vms.h (TARGET_EXTRA_INCLUDES): Define.
+       (vms_c_register_includes): Declare.
+
 2011-11-15  Tristan Gingold  <gingold@adacore.com>
 
        * c-family/c-pragma.h (pragma_extern_prefix): Declare.
index 19291b628777581b6c6b28e38c27e5c0d4db1e09..b3e0d955f197d86861fad4ced1c220785af1a026 100644 (file)
@@ -283,3 +283,50 @@ vms_c_register_pragma (void)
   c_register_pragma (NULL, "__message", vms_pragma_message);
   c_register_pragma (NULL, "__extern_prefix", vms_pragma_extern_prefix);
 }
+
+/* Standard modules list.  */
+static const char * const vms_std_modules[] = { "rtldef", "starlet_c", NULL };
+
+/* Find include modules in the include path.  */
+
+void
+vms_c_register_includes (const char *sysroot,
+                         const char *iprefix ATTRIBUTE_UNUSED, int stdinc)
+{
+  static const char dir_separator_str[] = { DIR_SEPARATOR, 0 };
+  struct cpp_dir *dir;
+
+  /* Add on standard include pathes.  */
+  if (!stdinc)
+    return;
+
+  for (dir = get_added_cpp_dirs (SYSTEM); dir != NULL; dir = dir->next)
+    {
+      const char * const *lib;
+      for (lib = vms_std_modules; *lib != NULL; lib++)
+        {
+          char *path;
+          struct stat st;
+
+          if (sysroot != NULL)
+            path = concat (sysroot, dir->name, dir_separator_str, *lib, NULL);
+          else
+            path = concat (dir->name, dir_separator_str, *lib, NULL);
+
+          if (stat (path, &st) == 0 && S_ISDIR (st.st_mode))
+            {
+              cpp_dir *p;
+
+              p = XNEW (cpp_dir);
+              p->next = NULL;
+              p->name = path;
+              p->sysp = 1;
+              p->construct = 0;
+              p->user_supplied_p = 0;
+              add_cpp_dir_path (p, SYSTEM);
+            }
+          else
+            free (path);
+        }
+    }
+}
index 0da9d85a89c5e888c874dc89a74ad8432c4e370b..62e8636cae4a91c4730a3100f006553975be2a91 100644 (file)
@@ -34,6 +34,9 @@ along with GCC; see the file COPYING3.  If not see
       }                                              \
   } while (0)
 
+extern void vms_c_register_includes (const char *, const char *, int);
+#define TARGET_EXTRA_INCLUDES vms_c_register_includes
+
 /* Tell compiler we want to support VMS pragmas */
 #define REGISTER_TARGET_PRAGMAS() vms_c_register_pragma ()
 
index 07a765f3fc07ec7ca25c7498ba0d10c857bc05d9..6b683a053dcc007363ae3bcb0034d9f4f3fe6786 100644 (file)
@@ -460,6 +460,15 @@ register_include_chains (cpp_reader *pfile, const char *sysroot,
   cpp_set_include_chains (pfile, heads[QUOTE], heads[BRACKET],
                          quote_ignores_source_dir);
 }
+
+/* Return the current chain of cpp dirs.  */
+
+struct cpp_dir *
+get_added_cpp_dirs (int chain)
+{
+  return heads[chain];
+}
+
 #if !(defined TARGET_EXTRA_INCLUDES) || !(defined TARGET_EXTRA_PRE_INCLUDES)
 static void hook_void_charptr_charptr_int (const char *sysroot ATTRIBUTE_UNUSED,
                                           const char *iprefix ATTRIBUTE_UNUSED,
index df5b6b1812942d5305f1fcee3942a5e158e0a1f2..4c647a39fe741efb851a575e5a14544eb72d8975 100644 (file)
@@ -22,6 +22,7 @@ extern void register_include_chains (cpp_reader *, const char *,
                                     const char *, const char *,
                                     int, int, int);
 extern void add_cpp_dir_path (struct cpp_dir *, int);
+extern struct cpp_dir *get_added_cpp_dirs (int);
 
 struct target_c_incpath_s {
   /* Do extra includes processing.  STDINC is false iff -nostdinc was given.  */