1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 2001-2007 Sun Microsystems, Inc. All rights reserved.
3 * (Brian Cameron, Dmitriy Demin, James Cheng, Padraig O'Briain)
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * Modified by the GTK+ Team and others 1997-2007. See the AUTHORS
23 * file for a list of people on the GTK+ Team. See the ChangeLog
24 * files for a list of changes. These files are distributed with
25 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
41 #if defined(HAVE_SYS_SYSTEMINFO_H)
42 #include <sys/systeminfo.h>
43 #elif defined(HAVE_SYS_SYSINFO_H)
44 #include <sys/sysinfo.h>
47 #include "gdkmedialib.h"
49 typedef char * (*ml_version) (void);
51 static ml_version medialib_version = mlib_version;
54 _gdk_use_medialib (void)
56 char *mlib_version_string;
61 * Sun mediaLib(tm) support.
63 * http://www.sun.com/processors/vis/mlib.html
66 if (getenv ("GDK_DISABLE_MEDIALIB"))
70 * The imaging functions we want to use were added in mediaLib version 2.
71 * So turn off mediaLib support if the user has an older version.
72 * mlib_version returns a string in this format:
74 * mediaLib:0210:20011101:v8plusa
75 * ^^^^^^^^ ^^^^ ^^^^^^^^ ^^^^^^^
76 * libname vers build ISALIST identifier
77 * date (in this case sparcv8plus+vis)
79 * The first 2 digits of the version are the major version. The 3rd digit
80 * is the minor version, and the 4th digit is the micro version. So the
81 * above string corresponds to version 2.1.0.In the following test we only
82 * care about the major version.
84 mlib_version_string = medialib_version ();
86 count = sysinfo (SI_ARCHITECTURE, &sys_info[0], 257);
90 if (strcmp (sys_info, "i386") == 0)
92 char *mlib_target_isa = &mlib_version_string[23];
95 * For x86 processors mediaLib generic C implementation
96 * does not give any performance advantage so disable it.
98 if (strncmp (mlib_target_isa, "sse", 3) != 0)
104 * For x86 processors use of libumem conflicts with
105 * mediaLib, so avoid using it.
107 if ((dlsym (RTLD_DEFAULT, "umem_alloc") != NULL) ||
108 (dlsym (RTLD_PROBE, "umem_alloc") != NULL) ||
109 (dlsym (RTLD_NEXT, "umem_alloc") != NULL) ||
110 (dlsym (RTLD_SELF, "umem_alloc") != NULL))
118 /* Failed to get system architecture, disable mediaLib */