open-src/xserver/xorg/amd64-loader-path.patch
author Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
Mon, 09 May 2011 14:58:28 -0700
changeset 1124 7bc7e624f965
parent 1097 243d7ed7a10c
child 1265 0b5cc5c013e4
permissions -rw-r--r--
7042476 Xorg 1.10 & associated module updates [PSARC/2011/214] PSARC/2011/213 X Synchronization Extension version 3.1 PSARC/2011/214 Xorg server 1.10

# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index eaa99e8..0c8b21c 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -166,6 +166,13 @@ InitPathList(const char *path)
 		list[n][len - 1] = '/';
 		list[n][len] = '\0';
 	    }
+
+#ifdef SUNSOFT /* strip amd64/ off loader path if it's there */
+	    if (strcmp(list[n] + (len - 6), "amd64/") == 0) {
+		    list[n][len - 6] = '\0';
+	    }
+#endif
+	    
 	    n++;
 	}
 	elem = strtok(NULL, ",");
@@ -387,6 +394,24 @@ FindModuleInSubdir(const char *dirpath, const char *module)
     char *ret = NULL, tmpBuf[PATH_MAX];
     struct stat stat_buf;
 
+#if defined(SUNSOFT) && defined(__x86)
+    Bool in_64_dir = FALSE;
+
+    if (strstr(dirpath, "/amd64") != NULL) {
+# if !(defined(__amd64) || defined(__amd64__))
+       return NULL;
+# else
+       in_64_dir = TRUE;
+# endif
+    }
+    /* After the 32-bit EOF, all modules under /usr/lib/xorg are 64-bit,
+       but legacy modules under /usr/X11/lib are still split into 32-bit
+       and 64-bit versions */
+    if (strncmp(dirpath, "/usr/X11/lib/modules/", 21) != 0) {
+	in_64_dir = TRUE;
+    }
+#endif
+
     dir = opendir(dirpath);
     if (!dir)
         return NULL;
@@ -394,6 +419,13 @@ FindModuleInSubdir(const char *dirpath, const char *module)
     while ((direntry = readdir(dir))) {
         if (direntry->d_name[0] == '.')
             continue;
+
+#if defined(SUNSOFT) && (defined(__i386) || defined(__i386__))
+        /* skip 64-bit subdirectories when running 32-bit server */
+        if (strcmp(direntry->d_name, "amd64") == 0)
+            continue;
+#endif
+
         snprintf(tmpBuf, PATH_MAX, "%s%s/", dirpath, direntry->d_name);
 	/* the stat with the appended / fails for normal files,
 	   and works for sub dirs fine, looks a bit strange in strace
@@ -403,6 +435,12 @@ FindModuleInSubdir(const char *dirpath, const char *module)
                 break;
             continue;
         }
+
+#if defined(SUNSOFT) && (defined(__amd64) || defined(__amd64__))
+        /* Don't match files in non-amd64 directories */
+        if (!in_64_dir)
+            continue;
+#endif	
  
         snprintf(tmpBuf, PATH_MAX, "lib%s.so", module);
         if (strcmp(direntry->d_name, tmpBuf) == 0) {