1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/cairo/libpixman/src/pixman-mips.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,94 @@ 1.4 +/* 1.5 + * Copyright © 2000 SuSE, Inc. 1.6 + * Copyright © 2007 Red Hat, Inc. 1.7 + * 1.8 + * Permission to use, copy, modify, distribute, and sell this software and its 1.9 + * documentation for any purpose is hereby granted without fee, provided that 1.10 + * the above copyright notice appear in all copies and that both that 1.11 + * copyright notice and this permission notice appear in supporting 1.12 + * documentation, and that the name of SuSE not be used in advertising or 1.13 + * publicity pertaining to distribution of the software without specific, 1.14 + * written prior permission. SuSE makes no representations about the 1.15 + * suitability of this software for any purpose. It is provided "as is" 1.16 + * without express or implied warranty. 1.17 + * 1.18 + * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL 1.19 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE 1.20 + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1.21 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 1.22 + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 1.23 + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1.24 + */ 1.25 +#ifdef HAVE_CONFIG_H 1.26 +#include <config.h> 1.27 +#endif 1.28 + 1.29 +#include "pixman-private.h" 1.30 + 1.31 +#if defined(USE_MIPS_DSPR2) || defined(USE_LOONGSON_MMI) 1.32 + 1.33 +#include <string.h> 1.34 +#include <stdlib.h> 1.35 + 1.36 +static pixman_bool_t 1.37 +have_feature (const char *search_string) 1.38 +{ 1.39 +#if defined (__linux__) /* linux ELF */ 1.40 + /* Simple detection of MIPS features at runtime for Linux. 1.41 + * It is based on /proc/cpuinfo, which reveals hardware configuration 1.42 + * to user-space applications. According to MIPS (early 2010), no similar 1.43 + * facility is universally available on the MIPS architectures, so it's up 1.44 + * to individual OSes to provide such. 1.45 + */ 1.46 + const char *file_name = "/proc/cpuinfo"; 1.47 + char cpuinfo_line[256]; 1.48 + FILE *f = NULL; 1.49 + 1.50 + if ((f = fopen (file_name, "r")) == NULL) 1.51 + return FALSE; 1.52 + 1.53 + while (fgets (cpuinfo_line, sizeof (cpuinfo_line), f) != NULL) 1.54 + { 1.55 + if (strstr (cpuinfo_line, search_string) != NULL) 1.56 + { 1.57 + fclose (f); 1.58 + return TRUE; 1.59 + } 1.60 + } 1.61 + 1.62 + fclose (f); 1.63 +#endif 1.64 + 1.65 + /* Did not find string in the proc file, or not Linux ELF. */ 1.66 + return FALSE; 1.67 +} 1.68 + 1.69 +#endif 1.70 + 1.71 +pixman_implementation_t * 1.72 +_pixman_mips_get_implementations (pixman_implementation_t *imp) 1.73 +{ 1.74 +#ifdef USE_LOONGSON_MMI 1.75 + /* I really don't know if some Loongson CPUs don't have MMI. */ 1.76 + if (!_pixman_disabled ("loongson-mmi") && have_feature ("Loongson")) 1.77 + imp = _pixman_implementation_create_mmx (imp); 1.78 +#endif 1.79 + 1.80 +#ifdef USE_MIPS_DSPR2 1.81 + if (!_pixman_disabled ("mips-dspr2")) 1.82 + { 1.83 + int already_compiling_everything_for_dspr2 = 0; 1.84 +#if defined(__mips_dsp) && (__mips_dsp_rev >= 2) 1.85 + already_compiling_everything_for_dspr2 = 1; 1.86 +#endif 1.87 + if (already_compiling_everything_for_dspr2 || 1.88 + /* Only currently available MIPS core that supports DSPr2 is 74K. */ 1.89 + have_feature ("MIPS 74K")) 1.90 + { 1.91 + imp = _pixman_implementation_create_mips_dspr2 (imp); 1.92 + } 1.93 + } 1.94 +#endif 1.95 + 1.96 + return imp; 1.97 +}