LCOV - code coverage report
Current view: top level - gfx/cairo/libpixman/src - pixman-mips.c (source / functions) Hit Total Coverage
Test: output.info Lines: 2 2 100.0 %
Date: 2017-07-14 16:53:18 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13