gfx/cairo/libpixman/src/pixman-mips.c

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /*
michael@0 2 * Copyright © 2000 SuSE, Inc.
michael@0 3 * Copyright © 2007 Red Hat, Inc.
michael@0 4 *
michael@0 5 * Permission to use, copy, modify, distribute, and sell this software and its
michael@0 6 * documentation for any purpose is hereby granted without fee, provided that
michael@0 7 * the above copyright notice appear in all copies and that both that
michael@0 8 * copyright notice and this permission notice appear in supporting
michael@0 9 * documentation, and that the name of SuSE not be used in advertising or
michael@0 10 * publicity pertaining to distribution of the software without specific,
michael@0 11 * written prior permission. SuSE makes no representations about the
michael@0 12 * suitability of this software for any purpose. It is provided "as is"
michael@0 13 * without express or implied warranty.
michael@0 14 *
michael@0 15 * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
michael@0 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
michael@0 17 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
michael@0 18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
michael@0 19 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
michael@0 20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
michael@0 21 */
michael@0 22 #ifdef HAVE_CONFIG_H
michael@0 23 #include <config.h>
michael@0 24 #endif
michael@0 25
michael@0 26 #include "pixman-private.h"
michael@0 27
michael@0 28 #if defined(USE_MIPS_DSPR2) || defined(USE_LOONGSON_MMI)
michael@0 29
michael@0 30 #include <string.h>
michael@0 31 #include <stdlib.h>
michael@0 32
michael@0 33 static pixman_bool_t
michael@0 34 have_feature (const char *search_string)
michael@0 35 {
michael@0 36 #if defined (__linux__) /* linux ELF */
michael@0 37 /* Simple detection of MIPS features at runtime for Linux.
michael@0 38 * It is based on /proc/cpuinfo, which reveals hardware configuration
michael@0 39 * to user-space applications. According to MIPS (early 2010), no similar
michael@0 40 * facility is universally available on the MIPS architectures, so it's up
michael@0 41 * to individual OSes to provide such.
michael@0 42 */
michael@0 43 const char *file_name = "/proc/cpuinfo";
michael@0 44 char cpuinfo_line[256];
michael@0 45 FILE *f = NULL;
michael@0 46
michael@0 47 if ((f = fopen (file_name, "r")) == NULL)
michael@0 48 return FALSE;
michael@0 49
michael@0 50 while (fgets (cpuinfo_line, sizeof (cpuinfo_line), f) != NULL)
michael@0 51 {
michael@0 52 if (strstr (cpuinfo_line, search_string) != NULL)
michael@0 53 {
michael@0 54 fclose (f);
michael@0 55 return TRUE;
michael@0 56 }
michael@0 57 }
michael@0 58
michael@0 59 fclose (f);
michael@0 60 #endif
michael@0 61
michael@0 62 /* Did not find string in the proc file, or not Linux ELF. */
michael@0 63 return FALSE;
michael@0 64 }
michael@0 65
michael@0 66 #endif
michael@0 67
michael@0 68 pixman_implementation_t *
michael@0 69 _pixman_mips_get_implementations (pixman_implementation_t *imp)
michael@0 70 {
michael@0 71 #ifdef USE_LOONGSON_MMI
michael@0 72 /* I really don't know if some Loongson CPUs don't have MMI. */
michael@0 73 if (!_pixman_disabled ("loongson-mmi") && have_feature ("Loongson"))
michael@0 74 imp = _pixman_implementation_create_mmx (imp);
michael@0 75 #endif
michael@0 76
michael@0 77 #ifdef USE_MIPS_DSPR2
michael@0 78 if (!_pixman_disabled ("mips-dspr2"))
michael@0 79 {
michael@0 80 int already_compiling_everything_for_dspr2 = 0;
michael@0 81 #if defined(__mips_dsp) && (__mips_dsp_rev >= 2)
michael@0 82 already_compiling_everything_for_dspr2 = 1;
michael@0 83 #endif
michael@0 84 if (already_compiling_everything_for_dspr2 ||
michael@0 85 /* Only currently available MIPS core that supports DSPr2 is 74K. */
michael@0 86 have_feature ("MIPS 74K"))
michael@0 87 {
michael@0 88 imp = _pixman_implementation_create_mips_dspr2 (imp);
michael@0 89 }
michael@0 90 }
michael@0 91 #endif
michael@0 92
michael@0 93 return imp;
michael@0 94 }

mercurial