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).
This commit is contained in:
Adam Jackson 2005-04-25 00:25:39 +00:00
parent 6c37648754
commit 07cc29cf69

View File

@ -204,13 +204,13 @@ LoaderSetPath(const char *path)
/* Standard set of module subdirectories to search, in order of preference */ /* Standard set of module subdirectories to search, in order of preference */
static const char *stdSubdirs[] = { static const char *stdSubdirs[] = {
"drivers/", "",
"fonts/",
"input/", "input/",
"drivers/",
"multimedia/", "multimedia/",
"extensions/", "extensions/",
"fonts/",
"internal/", "internal/",
"",
NULL NULL
}; };
@ -398,18 +398,19 @@ static char *
FindModule(const char *module, const char *dir, const char **subdirlist, FindModule(const char *module, const char *dir, const char **subdirlist,
PatternPtr patterns) PatternPtr patterns)
{ {
char buf[PATH_MAX + 1]; char buf[PATH_MAX + 1], tmpBuf[PATH_MAX + 1];
char *dirpath = NULL; char *dirpath = NULL;
char *name = NULL; char *name = NULL;
struct stat stat_buf; struct stat stat_buf;
int len, dirlen; int dirlen;
char *fp; char *fp;
DIR *d;
const char **subdirs = NULL; const char **subdirs = NULL;
PatternPtr p = NULL;
const char **s; const char **s;
struct dirent *dp; #ifdef DLOPEN_HACK
regmatch_t match[2]; const char suffix[3][3] = { "so", "a", "o" };
#else
const char suffix[3][3] = { "a", "o", "so" };
#endif
subdirs = InitSubdirs(subdirlist); subdirs = InitSubdirs(subdirlist);
if (!subdirs) if (!subdirs)
@ -431,36 +432,34 @@ FindModule(const char *module, const char *dir, const char **subdirlist,
strcpy(buf, dirpath); strcpy(buf, dirpath);
strcat(buf, *s); strcat(buf, *s);
/*xf86Msg(X_INFO,"OS2DIAG: FindModule: buf=%s\n",buf); */ /*xf86Msg(X_INFO,"OS2DIAG: FindModule: buf=%s\n",buf); */
fp = buf + dirlen; if ((stat(buf, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) {
if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) && int i;
(d = opendir(buf))) {
if (buf[dirlen - 1] != '/') { if (buf[dirlen - 1] != '/') {
buf[dirlen++] = '/'; buf[dirlen++] = '/';
fp++; fp++;
} }
while ((dp = readdir(d))) {
if (dirlen + strlen(dp->d_name) + 1 > PATH_MAX) for (i = 0; i < 3 && !name; i++) {
continue; snprintf(tmpBuf, PATH_MAX, "%slib%s.%s", buf, module,
strcpy(fp, dp->d_name); suffix[i]);
if (!(stat(buf, &stat_buf) == 0 && S_ISREG(stat_buf.st_mode))) if (stat(tmpBuf, &stat_buf) == 0) {
continue; name = tmpBuf;
for (p = patterns; p->pattern; p++) { break;
if (regexec(&p->rex, dp->d_name, 2, match, 0) == 0 && }
match[1].rm_so != -1) { snprintf(tmpBuf, PATH_MAX, "%s%s_drv.%s", buf, module,
len = match[1].rm_eo - match[1].rm_so; suffix[i]);
if (len == strlen(module) && if (stat(tmpBuf, &stat_buf) == 0) {
strncmp(module, dp->d_name + match[1].rm_so, name = tmpBuf;
len) == 0) { break;
/*xf86Msg(X_INFO,"OS2DIAG: matching %s\n",buf); */ }
name = buf; snprintf(tmpBuf, PATH_MAX, "%s%s.%s", buf, module,
suffix[i]);
if (stat(tmpBuf, &stat_buf) == 0) {
name = tmpBuf;
break; break;
} }
} }
}
if (name)
break;
}
closedir(d);
if (name) if (name)
break; break;
} }