[Pixman] [PATCH 05/12] MIPS: MIPS32r2: Added support for run-time detection
Nemanja Lukic
nemanja.lukic at rt-rk.com
Sun Sep 8 15:52:44 PDT 2013
---
pixman/pixman-mips.c | 38 +++++++++++++++++++++++++++++---------
1 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/pixman/pixman-mips.c b/pixman/pixman-mips.c
index 1a0a8c0..e9cf2e9 100644
--- a/pixman/pixman-mips.c
+++ b/pixman/pixman-mips.c
@@ -27,12 +27,27 @@
#include <string.h>
#include <stdlib.h>
+#ifdef USE_MIPS_DSPR2
+static const char *mips_dspr2_cores[] = {"MIPS 74K", NULL};
+#endif
+
+#ifdef USE_MIPS32R2
+static const char *mips32r2_cores[] = {"MIPS 1004K", "MIPS 74K", "MIPS 34K",
+ "MIPS 24K", "MIPS 4Kc", "MIPS 4Km",
+ "MIPS 4Kp", "MIPS 4KEc", "MIPS 4KEm",
+ "MIPS 4KEp", "MIPS 4KSc", "MIPS 4KSd",
+ NULL};
+#endif
+
+#ifdef USE_LOONGSON_MMI
+static const char *mips_loongson_cores[] = {"Loongson", NULL};
+#endif
#if defined(USE_MIPS_DSPR2) || defined(USE_MIPS32R2) || \
defined(USE_LOONGSON_MMI)
static pixman_bool_t
-have_feature (const char *search_string)
+have_feature (const char **cores)
{
#if defined (__linux__) /* linux ELF */
/* Simple detection of MIPS features at runtime for Linux.
@@ -48,13 +63,18 @@ have_feature (const char *search_string)
if ((f = fopen (file_name, "r")) == NULL)
return FALSE;
- while (fgets (cpuinfo_line, sizeof (cpuinfo_line), f) != NULL)
+ while (*cores)
{
- if (strstr (cpuinfo_line, search_string) != NULL)
+ while (fgets (cpuinfo_line, sizeof (cpuinfo_line), f) != NULL)
{
- fclose (f);
- return TRUE;
+ if (strstr (cpuinfo_line, *cores) != NULL)
+ {
+ fclose (f);
+ return TRUE;
+ }
}
+ rewind (f);
+ cores++;
}
fclose (f);
@@ -71,7 +91,8 @@ _pixman_mips_get_implementations (pixman_implementation_t *imp)
{
#ifdef USE_LOONGSON_MMI
/* I really don't know if some Loongson CPUs don't have MMI. */
- if (!_pixman_disabled ("loongson-mmi") && have_feature ("Loongson"))
+ if (!_pixman_disabled ("loongson-mmi") &&
+ have_feature (mips_loongson_cores))
imp = _pixman_implementation_create_mmx (imp);
#endif
@@ -83,7 +104,7 @@ _pixman_mips_get_implementations (pixman_implementation_t *imp)
already_compiling_everything_for_mips32r2 = 1;
#endif
if (already_compiling_everything_for_mips32r2 ||
- have_feature ("MIPS 74K"))
+ have_feature (mips32r2_cores))
{
imp = _pixman_implementation_create_mips32r2 (imp);
}
@@ -98,8 +119,7 @@ _pixman_mips_get_implementations (pixman_implementation_t *imp)
already_compiling_everything_for_dspr2 = 1;
#endif
if (already_compiling_everything_for_dspr2 ||
- /* Only currently available MIPS core that supports DSPr2 is 74K. */
- have_feature ("MIPS 74K"))
+ have_feature (mips_dspr2_cores))
{
imp = _pixman_implementation_create_mips_dspr2 (imp);
}
--
1.7.3
More information about the Pixman
mailing list