diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-06-27 14:14:54 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-07-07 01:09:23 -0400 |
commit | 8b795a9c17aa25328b9c76b949d319bb578d5f1e (patch) | |
tree | 6e6793aeff992a2154a3f6a3dd59a39d72db9857 | |
parent | 16502dd3ae3bf1d49faf1de533bd58013e168e64 (diff) | |
download | pixman-8b795a9c17aa25328b9c76b949d319bb578d5f1e.tar.gz |
Simplify MIPS CPU detection
There is no reason to have pixman_have_<feature> functions when all
they do is call pixman_have_mips_feature().
Instead rename pixman_have_mips_feature() to have_feature() and call
it directly from _pixman_mips_get_implementations(). Also on
non-Linux, just make have_feature() return FALSE.
-rw-r--r-- | pixman/pixman-mips.c | 44 |
1 files changed, 9 insertions, 35 deletions
diff --git a/pixman/pixman-mips.c b/pixman/pixman-mips.c index 9d3ee59..2b280c6 100644 --- a/pixman/pixman-mips.c +++ b/pixman/pixman-mips.c @@ -30,21 +30,18 @@ #include <string.h> #include <stdlib.h> -#if defined (__linux__) /* linux ELF */ - static pixman_bool_t -pixman_have_mips_feature (const char *search_string) +have_feature (const char *search_string) { - const char *file_name = "/proc/cpuinfo"; +#if defined (__linux__) /* linux ELF */ /* Simple detection of MIPS features at runtime for Linux. * It is based on /proc/cpuinfo, which reveals hardware configuration * to user-space applications. According to MIPS (early 2010), no similar * facility is universally available on the MIPS architectures, so it's up * to individual OSes to provide such. */ - + const char *file_name = "/proc/cpuinfo"; char cpuinfo_line[256]; - FILE *f = NULL; if ((f = fopen (file_name, "r")) == NULL) @@ -60,51 +57,28 @@ pixman_have_mips_feature (const char *search_string) } fclose (f); +#endif - /* Did not find string in the proc file. */ + /* Did not find string in the proc file, or not Linux ELF. */ return FALSE; } -#if defined(USE_MIPS_DSPR2) -pixman_bool_t -pixman_have_mips_dspr2 (void) -{ - /* Only currently available MIPS core that supports DSPr2 is 74K. */ - return pixman_have_mips_feature ("MIPS 74K"); -} #endif -#if defined(USE_LOONGSON_MMI) -pixman_bool_t -pixman_have_loongson_mmi (void) -{ - /* I really don't know if some Loongson CPUs don't have MMI. */ - return pixman_have_mips_feature ("Loongson"); -} -#endif - -#else /* linux ELF */ - -#define pixman_have_mips_dspr2() FALSE -#define pixman_have_loongson_mmi() FALSE - -#endif /* linux ELF */ - -#endif /* USE_MIPS_DSPR2 || USE_LOONGSON_MMI */ - pixman_implementation_t * _pixman_mips_get_implementations (pixman_implementation_t *imp) { #ifdef USE_LOONGSON_MMI - if (!_pixman_disabled ("loongson-mmi") && pixman_have_loongson_mmi ()) + /* I really don't know if some Loongson CPUs don't have MMI. */ + if (!_pixman_disabled ("loongson-mmi") && have_feature ("Loongson")) imp = _pixman_implementation_create_mmx (imp); #endif #ifdef USE_MIPS_DSPR2 - if (!_pixman_disabled ("mips-dspr2") && pixman_have_mips_dspr2 ()) + /* Only currently available MIPS core that supports DSPr2 is 74K. */ + if (!_pixman_disabled ("mips-dspr2") && have_feature ("MIPS 74K")) imp = _pixman_implementation_create_mips_dspr2 (imp); #endif return imp; } - |