IA MCU psABI support: changes to libraries
[gcc.git] / gcc / file-find.c
index 45af9380d0364c1a766f2dd7344f653f8e5f77ff..9b1dfba0f2e071698167b412b26e59297e17dc3c 100644 (file)
@@ -1,5 +1,5 @@
 /* Utility functions for finding files relative to GCC binaries.
-   Copyright (C) 1992-2013 Free Software Foundation, Inc.
+   Copyright (C) 1992-2015 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -25,13 +25,13 @@ along with GCC; see the file COPYING3.  If not see
 static bool debug = false;
 
 void
-find_file_set_debug(bool debug_state)
+find_file_set_debug (bool debug_state)
 {
   debug = debug_state;
 }
 
 char *
-find_a_file (struct path_prefix *pprefix, const char *name)
+find_a_file (struct path_prefix *pprefix, const char *name, int mode)
 {
   char *temp;
   struct prefix_list *pl;
@@ -50,7 +50,7 @@ find_a_file (struct path_prefix *pprefix, const char *name)
 
   if (IS_ABSOLUTE_PATH (name))
     {
-      if (access (name, X_OK) == 0)
+      if (access (name, mode) == 0)
        {
          strcpy (temp, name);
 
@@ -66,7 +66,7 @@ find_a_file (struct path_prefix *pprefix, const char *name)
       strcpy (temp, name);
        strcat (temp, HOST_EXECUTABLE_SUFFIX);
 
-       if (access (temp, X_OK) == 0)
+       if (access (temp, mode) == 0)
          return temp;
 #endif
 
@@ -83,7 +83,7 @@ find_a_file (struct path_prefix *pprefix, const char *name)
 
        if (stat (temp, &st) >= 0
            && ! S_ISDIR (st.st_mode)
-           && access (temp, X_OK) == 0)
+           && access (temp, mode) == 0)
          return temp;
 
 #ifdef HOST_EXECUTABLE_SUFFIX
@@ -93,7 +93,7 @@ find_a_file (struct path_prefix *pprefix, const char *name)
 
        if (stat (temp, &st) >= 0
            && ! S_ISDIR (st.st_mode)
-           && access (temp, X_OK) == 0)
+           && access (temp, mode) == 0)
          return temp;
 #endif
       }
@@ -105,15 +105,16 @@ find_a_file (struct path_prefix *pprefix, const char *name)
   return 0;
 }
 
-/* Add an entry for PREFIX to prefix list PPREFIX.  */
+/* Add an entry for PREFIX to prefix list PREFIX.
+   Add at beginning if FIRST is true.  */
 
 void
-add_prefix (struct path_prefix *pprefix, const char *prefix)
+do_add_prefix (struct path_prefix *pprefix, const char *prefix, bool first)
 {
   struct prefix_list *pl, **prev;
   int len;
 
-  if (pprefix->plist)
+  if (pprefix->plist && !first)
     {
       for (pl = pprefix->plist; pl->next; pl = pl->next)
        ;
@@ -138,6 +139,22 @@ add_prefix (struct path_prefix *pprefix, const char *prefix)
   *prev = pl;
 }
 
+/* Add an entry for PREFIX at the end of prefix list PREFIX.  */
+
+void
+add_prefix (struct path_prefix *pprefix, const char *prefix)
+{
+  do_add_prefix (pprefix, prefix, false);
+}
+
+/* Add an entry for PREFIX at the begin of prefix list PREFIX.  */
+
+void
+add_prefix_begin (struct path_prefix *pprefix, const char *prefix)
+{
+  do_add_prefix (pprefix, prefix, true);
+}
+
 /* Take the value of the environment variable ENV, break it into a path, and
    add of the entries to PPREFIX.  */