IA MCU psABI support: changes to libraries
[gcc.git] / gcc / file-find.c
index fcc25612008243a733bf9a702601025da56298a1..9b1dfba0f2e071698167b412b26e59297e17dc3c 100644 (file)
@@ -1,6 +1,5 @@
 /* Utility functions for finding files relative to GCC binaries.
-   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012
+   Copyright (C) 1992-2015 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -26,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;
@@ -51,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);
 
@@ -67,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
 
@@ -84,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
@@ -94,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
       }
@@ -106,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)
        ;
@@ -139,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.  */