|
Packit |
030a23 |
/*
|
|
Packit |
030a23 |
* Copyright © 2000 SuSE, Inc.
|
|
Packit |
030a23 |
* Copyright © 2007 Red Hat, Inc.
|
|
Packit |
030a23 |
*
|
|
Packit |
030a23 |
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
Packit |
030a23 |
* documentation for any purpose is hereby granted without fee, provided that
|
|
Packit |
030a23 |
* the above copyright notice appear in all copies and that both that
|
|
Packit |
030a23 |
* copyright notice and this permission notice appear in supporting
|
|
Packit |
030a23 |
* documentation, and that the name of SuSE not be used in advertising or
|
|
Packit |
030a23 |
* publicity pertaining to distribution of the software without specific,
|
|
Packit |
030a23 |
* written prior permission. SuSE makes no representations about the
|
|
Packit |
030a23 |
* suitability of this software for any purpose. It is provided "as is"
|
|
Packit |
030a23 |
* without express or implied warranty.
|
|
Packit |
030a23 |
*
|
|
Packit |
030a23 |
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
|
Packit |
030a23 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
|
|
Packit |
030a23 |
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
Packit |
030a23 |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
Packit |
030a23 |
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
Packit |
030a23 |
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
Packit |
030a23 |
*/
|
|
Packit |
030a23 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
030a23 |
#include <config.h>
|
|
Packit |
030a23 |
#endif
|
|
Packit |
030a23 |
|
|
Packit |
030a23 |
#include "pixman-private.h"
|
|
Packit |
030a23 |
|
|
Packit |
030a23 |
#if defined(USE_MIPS_DSPR2) || defined(USE_LOONGSON_MMI)
|
|
Packit |
030a23 |
|
|
Packit |
030a23 |
#include <string.h>
|
|
Packit |
030a23 |
#include <stdlib.h>
|
|
Packit |
030a23 |
|
|
Packit |
030a23 |
static pixman_bool_t
|
|
Packit |
030a23 |
have_feature (const char *search_string)
|
|
Packit |
030a23 |
{
|
|
Packit |
030a23 |
#if defined (__linux__) /* linux ELF */
|
|
Packit |
030a23 |
/* Simple detection of MIPS features at runtime for Linux.
|
|
Packit |
030a23 |
* It is based on /proc/cpuinfo, which reveals hardware configuration
|
|
Packit |
030a23 |
* to user-space applications. According to MIPS (early 2010), no similar
|
|
Packit |
030a23 |
* facility is universally available on the MIPS architectures, so it's up
|
|
Packit |
030a23 |
* to individual OSes to provide such.
|
|
Packit |
030a23 |
*/
|
|
Packit |
030a23 |
const char *file_name = "/proc/cpuinfo";
|
|
Packit |
030a23 |
char cpuinfo_line[256];
|
|
Packit |
030a23 |
FILE *f = NULL;
|
|
Packit |
030a23 |
|
|
Packit |
030a23 |
if ((f = fopen (file_name, "r")) == NULL)
|
|
Packit |
030a23 |
return FALSE;
|
|
Packit |
030a23 |
|
|
Packit |
030a23 |
while (fgets (cpuinfo_line, sizeof (cpuinfo_line), f) != NULL)
|
|
Packit |
030a23 |
{
|
|
Packit |
030a23 |
if (strstr (cpuinfo_line, search_string) != NULL)
|
|
Packit |
030a23 |
{
|
|
Packit |
030a23 |
fclose (f);
|
|
Packit |
030a23 |
return TRUE;
|
|
Packit |
030a23 |
}
|
|
Packit |
030a23 |
}
|
|
Packit |
030a23 |
|
|
Packit |
030a23 |
fclose (f);
|
|
Packit |
030a23 |
#endif
|
|
Packit |
030a23 |
|
|
Packit |
030a23 |
/* Did not find string in the proc file, or not Linux ELF. */
|
|
Packit |
030a23 |
return FALSE;
|
|
Packit |
030a23 |
}
|
|
Packit |
030a23 |
|
|
Packit |
030a23 |
#endif
|
|
Packit |
030a23 |
|
|
Packit |
030a23 |
pixman_implementation_t *
|
|
Packit |
030a23 |
_pixman_mips_get_implementations (pixman_implementation_t *imp)
|
|
Packit |
030a23 |
{
|
|
Packit |
030a23 |
#ifdef USE_LOONGSON_MMI
|
|
Packit |
030a23 |
/* I really don't know if some Loongson CPUs don't have MMI. */
|
|
Packit |
030a23 |
if (!_pixman_disabled ("loongson-mmi") && have_feature ("Loongson"))
|
|
Packit |
030a23 |
imp = _pixman_implementation_create_mmx (imp);
|
|
Packit |
030a23 |
#endif
|
|
Packit |
030a23 |
|
|
Packit |
030a23 |
#ifdef USE_MIPS_DSPR2
|
|
Packit |
030a23 |
if (!_pixman_disabled ("mips-dspr2"))
|
|
Packit |
030a23 |
{
|
|
Packit |
030a23 |
int already_compiling_everything_for_dspr2 = 0;
|
|
Packit |
030a23 |
#if defined(__mips_dsp) && (__mips_dsp_rev >= 2)
|
|
Packit |
030a23 |
already_compiling_everything_for_dspr2 = 1;
|
|
Packit |
030a23 |
#endif
|
|
Packit |
030a23 |
if (already_compiling_everything_for_dspr2 ||
|
|
Packit |
030a23 |
/* Only currently available MIPS core that supports DSPr2 is 74K. */
|
|
Packit |
030a23 |
have_feature ("MIPS 74K"))
|
|
Packit |
030a23 |
{
|
|
Packit |
030a23 |
imp = _pixman_implementation_create_mips_dspr2 (imp);
|
|
Packit |
030a23 |
}
|
|
Packit |
030a23 |
}
|
|
Packit |
030a23 |
#endif
|
|
Packit |
030a23 |
|
|
Packit |
030a23 |
return imp;
|
|
Packit |
030a23 |
}
|