summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@nwnk.net>2005-04-25 00:25:39 +0000
committerAdam Jackson <ajax@nwnk.net>2005-04-25 00:25:39 +0000
commit07cc29cf69ff1e079efe3c9bfc55e8ac0f9bac93 (patch)
tree2851a2007df0dde0c7497efe626674b019dc27d8
parent6c37648754c9bd901adecf8d38f9bb46db65efad (diff)
Bug #2138: When the server is built with MakeDllModules YES, prefer
dlloader modules to elfloader modules, and vice versa when MakeDllModules is NO. Based on 028_loader_speed_hack.diff from Ubuntu (Daniel Stone).
-rw-r--r--hw/xfree86/loader/loadmod.c79
1 files changed, 39 insertions, 40 deletions
diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index 5047bbf03..148073cf9 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -204,13 +204,13 @@ LoaderSetPath(const char *path)
/* Standard set of module subdirectories to search, in order of preference */
static const char *stdSubdirs[] = {
- "drivers/",
+ "",
+ "fonts/",
"input/",
+ "drivers/",
"multimedia/",
"extensions/",
- "fonts/",
"internal/",
- "",
NULL
};
@@ -398,19 +398,20 @@ static char *
FindModule(const char *module, const char *dir, const char **subdirlist,
PatternPtr patterns)
{
- char buf[PATH_MAX + 1];
+ char buf[PATH_MAX + 1], tmpBuf[PATH_MAX + 1];
char *dirpath = NULL;
char *name = NULL;
struct stat stat_buf;
- int len, dirlen;
+ int dirlen;
char *fp;
- DIR *d;
const char **subdirs = NULL;
- PatternPtr p = NULL;
const char **s;
- struct dirent *dp;
- regmatch_t match[2];
-
+#ifdef DLOPEN_HACK
+ const char suffix[3][3] = { "so", "a", "o" };
+#else
+ const char suffix[3][3] = { "a", "o", "so" };
+#endif
+
subdirs = InitSubdirs(subdirlist);
if (!subdirs)
return NULL;
@@ -431,39 +432,37 @@ FindModule(const char *module, const char *dir, const char **subdirlist,
strcpy(buf, dirpath);
strcat(buf, *s);
/*xf86Msg(X_INFO,"OS2DIAG: FindModule: buf=%s\n",buf); */
- fp = buf + dirlen;
- if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) &&
- (d = opendir(buf))) {
- if (buf[dirlen - 1] != '/') {
- buf[dirlen++] = '/';
- fp++;
- }
- while ((dp = readdir(d))) {
- if (dirlen + strlen(dp->d_name) + 1 > PATH_MAX)
- continue;
- strcpy(fp, dp->d_name);
- if (!(stat(buf, &stat_buf) == 0 && S_ISREG(stat_buf.st_mode)))
- continue;
- for (p = patterns; p->pattern; p++) {
- if (regexec(&p->rex, dp->d_name, 2, match, 0) == 0 &&
- match[1].rm_so != -1) {
- len = match[1].rm_eo - match[1].rm_so;
- if (len == strlen(module) &&
- strncmp(module, dp->d_name + match[1].rm_so,
- len) == 0) {
- /*xf86Msg(X_INFO,"OS2DIAG: matching %s\n",buf); */
- name = buf;
- break;
- }
- }
- }
- if (name)
- break;
+ if ((stat(buf, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) {
+ int i;
+
+ if (buf[dirlen - 1] != '/') {
+ buf[dirlen++] = '/';
+ fp++;
+ }
+
+ for (i = 0; i < 3 && !name; i++) {
+ snprintf(tmpBuf, PATH_MAX, "%slib%s.%s", buf, module,
+ suffix[i]);
+ if (stat(tmpBuf, &stat_buf) == 0) {
+ name = tmpBuf;
+ break;
+ }
+ snprintf(tmpBuf, PATH_MAX, "%s%s_drv.%s", buf, module,
+ suffix[i]);
+ if (stat(tmpBuf, &stat_buf) == 0) {
+ name = tmpBuf;
+ break;
+ }
+ snprintf(tmpBuf, PATH_MAX, "%s%s.%s", buf, module,
+ suffix[i]);
+ if (stat(tmpBuf, &stat_buf) == 0) {
+ name = tmpBuf;
+ break;
+ }
}
- closedir(d);
if (name)
break;
- }
+ }
}
FreeSubdirs(subdirs);
if (dirpath != dir)