fixes #120345 add disable-cpu-opt

Original commit message from CVS:
fixes #120345
add disable-cpu-opt
This commit is contained in:
Thomas Vander Stichele 2003-09-28 14:39:52 +00:00
parent 46534a11bb
commit fda9e21f43
6 changed files with 65 additions and 40 deletions

2
common

@ -1 +1 @@
Subproject commit b4a839c99c0bf2d4903824426ef3cc0d4b0ad992 Subproject commit b7abb510aa14e8692df39ea8c2c758e37d8a8d8a

View file

@ -229,6 +229,16 @@ AC_HELP_STRING([--enable-atomic],[use atomic reference counting header]),
esac], esac],
[USE_ATOMIC_H=$HAVE_ATOMIC_H]) dnl Default value [USE_ATOMIC_H=$HAVE_ATOMIC_H]) dnl Default value
AC_ARG_ENABLE(fast-stack-trash,
AC_HELP_STRING([--enable-fast-stack-trash],[use fast memory allocator (i586 or above)]),
[case "${enableval}" in
yes) USE_FAST_STACK_TRASH=yes;;
noset) USE_FAST_STACK_TRASH=no;;
no) USE_FAST_STACK_TRASH=no;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-atomic) ;;
esac],
[USE_FAST_STACK_TRASH=yes]) dnl Default value
AC_ARG_ENABLE(plugin-builddir, AC_ARG_ENABLE(plugin-builddir,
AC_HELP_STRING([--enable-plugin-builddir],[allow tests/demos to use non-installed plugins]), AC_HELP_STRING([--enable-plugin-builddir],[allow tests/demos to use non-installed plugins]),
[case "${enableval}" in [case "${enableval}" in
@ -340,6 +350,10 @@ if test "x$USE_ATOMIC_H" = xyes; then
AC_DEFINE(HAVE_ATOMIC_H, 1, [Define if atomic.h header file is available]) AC_DEFINE(HAVE_ATOMIC_H, 1, [Define if atomic.h header file is available])
fi fi
if test "x$USE_FAST_STACK_TRASH" = xyes; then
AC_DEFINE(USE_FAST_STACK_TRASH, 1, [Define if we should use i586 optimized stack functions])
fi
dnl test if we have pthread_attr_setstack; if not use the older calls dnl test if we have pthread_attr_setstack; if not use the older calls
AC_CHECK_LIB(pthread, pthread_attr_setstack, AC_CHECK_LIB(pthread, pthread_attr_setstack,
AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACK, 1, AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACK, 1,

View file

@ -43,6 +43,8 @@ static GstRegistry *_user_registry;
static gboolean _gst_registry_fixed = FALSE; static gboolean _gst_registry_fixed = FALSE;
static gboolean _gst_use_threads = TRUE; static gboolean _gst_use_threads = TRUE;
static gboolean _gst_enable_cpu_opt = TRUE;
static gboolean gst_initialized = FALSE; static gboolean gst_initialized = FALSE;
/* this will be set in popt callbacks when a problem has been encountered */ /* this will be set in popt callbacks when a problem has been encountered */
static gboolean _gst_initialization_failure = FALSE; static gboolean _gst_initialization_failure = FALSE;
@ -82,6 +84,7 @@ enum {
ARG_DEBUG_MASK, ARG_DEBUG_MASK,
ARG_MASK, ARG_MASK,
ARG_MASK_HELP, ARG_MASK_HELP,
ARG_DISABLE_CPU_OPT,
ARG_PLUGIN_SPEW, ARG_PLUGIN_SPEW,
ARG_PLUGIN_PATH, ARG_PLUGIN_PATH,
ARG_PLUGIN_LOAD, ARG_PLUGIN_LOAD,
@ -105,6 +108,7 @@ static const struct poptOption options[] = {
{"gst-debug-mask", NUL, POPT_ARG_INT|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_MASK, "debugging bitmask", "MASK"}, {"gst-debug-mask", NUL, POPT_ARG_INT|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_MASK, "debugging bitmask", "MASK"},
{"gst-mask", NUL, POPT_ARG_INT|POPT_ARGFLAG_STRIP, NULL, ARG_MASK, "bitmask for both info and debugging", "MASK"}, {"gst-mask", NUL, POPT_ARG_INT|POPT_ARGFLAG_STRIP, NULL, ARG_MASK, "bitmask for both info and debugging", "MASK"},
{"gst-mask-help", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_MASK_HELP, "how to set the level of diagnostic output (-mask values)", NULL}, {"gst-mask-help", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_MASK_HELP, "how to set the level of diagnostic output (-mask values)", NULL},
{"gst-disable-cpu-opt",NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_DISABLE_CPU_OPT,"Disable accelerated CPU instructions", NULL},
{"gst-plugin-spew", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_SPEW, "enable verbose plugin loading diagnostics", NULL}, {"gst-plugin-spew", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_SPEW, "enable verbose plugin loading diagnostics", NULL},
{"gst-plugin-path", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_PATH, "'" G_SEARCHPATH_SEPARATOR_S "'--separated path list for loading plugins", "PATHS"}, {"gst-plugin-path", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_PATH, "'" G_SEARCHPATH_SEPARATOR_S "'--separated path list for loading plugins", "PATHS"},
{"gst-plugin-load", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_LOAD, "comma-separated list of plugins to preload in addition to the list stored in env variable GST_PLUGIN_PATH", "PLUGINS"}, {"gst-plugin-load", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_LOAD, "comma-separated list of plugins to preload in addition to the list stored in env variable GST_PLUGIN_PATH", "PLUGINS"},
@ -497,7 +501,7 @@ init_post (void)
/* register core plugins */ /* register core plugins */
_gst_plugin_register_static (&plugin_desc); _gst_plugin_register_static (&plugin_desc);
_gst_cpu_initialize (); _gst_cpu_initialize (_gst_enable_cpu_opt);
_gst_props_initialize (); _gst_props_initialize ();
_gst_caps_initialize (); _gst_caps_initialize ();
_gst_plugin_initialize (); _gst_plugin_initialize ();
@ -610,6 +614,9 @@ init_popt_callback (poptContext context, enum poptCallbackReason reason,
case ARG_MASK_HELP: case ARG_MASK_HELP:
gst_mask_help (); gst_mask_help ();
exit (0); exit (0);
case ARG_DISABLE_CPU_OPT:
_gst_enable_cpu_opt = FALSE;
break;
case ARG_PLUGIN_SPEW: case ARG_PLUGIN_SPEW:
break; break;
case ARG_PLUGIN_PATH: case ARG_PLUGIN_PATH:

View file

@ -1,6 +1,7 @@
/* GStreamer /* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be> * 2000 Wim Taymans <wtay@chello.be>
* 2003 Colin Walters <walters@verbum.org>
* *
* gstcpu.c: CPU detection and architecture-specific routines * gstcpu.c: CPU detection and architecture-specific routines
* *
@ -25,78 +26,81 @@
#include "gst_private.h" #include "gst_private.h"
#include "gstcpu.h" #include "gstcpu.h"
static guint32 _gst_cpu_flags; static guint32 _gst_cpu_flags = 0;
#ifdef HAVE_CPU_I386 #ifdef HAVE_CPU_I386
#define _gst_cpu_initialize_arch _gst_cpu_initialize_i386
void gst_cpuid_i386 (int, unsigned long *, unsigned long *, unsigned long *, unsigned long *); void gst_cpuid_i386 (int, unsigned long *, unsigned long *, unsigned long *, unsigned long *);
#define gst_cpuid gst_cpuid_i386
#else #else
#define gst_cpuid(o,a,b,c,d) (void)(a);(void)(b);(void)(c); #define _gst_cpu_initialize_arch _gst_cpu_initialize_none
#endif #endif
static gchar * gboolean _gst_cpu_initialize_i386 (gulong *flags, GString *featurelist);
stringcat (gchar * a, gchar * b)
{
gchar *c;
if (a) {
c = g_strconcat (a, b, NULL);
g_free (a);
}
else {
c = g_strdup (b);
}
return c;
}
void void
_gst_cpu_initialize (void) _gst_cpu_initialize (gboolean opt)
{ {
gchar *featurelist = NULL; GString *featurelist = g_string_new ("");
gboolean AMD; gulong flags = 0;
if (opt) {
if (!_gst_cpu_initialize_arch (&flags, featurelist))
g_string_append (featurelist, "NONE");
} else
g_string_append (featurelist, "(DISABLED)");
GST_INFO (GST_CAT_GST_INIT, "CPU features: (%08lx) %s", flags, featurelist->str);
g_string_free (featurelist, TRUE);
}
gboolean
_gst_cpu_initialize_none (gulong *flags, GString *featurelist)
{
return FALSE;
}
gboolean
_gst_cpu_initialize_i386 (gulong *flags, GString *featurelist)
{
gboolean AMD;
gulong eax = 0, ebx = 0, ecx = 0, edx = 0; gulong eax = 0, ebx = 0, ecx = 0, edx = 0;
gst_cpuid (0, &eax, &ebx, &ecx, &edx); gst_cpuid_i386 (0, &eax, &ebx, &ecx, &edx);
AMD = (ebx == 0x68747541) && (ecx == 0x444d4163) && (edx == 0x69746e65); AMD = (ebx == 0x68747541) && (ecx == 0x444d4163) && (edx == 0x69746e65);
gst_cpuid (1, &eax, &ebx, &ecx, &edx); gst_cpuid_i386 (1, &eax, &ebx, &ecx, &edx);
if (edx & (1 << 23)) { if (edx & (1 << 23)) {
_gst_cpu_flags |= GST_CPU_FLAG_MMX; _gst_cpu_flags |= GST_CPU_FLAG_MMX;
featurelist = stringcat (featurelist, "MMX "); g_string_append (featurelist, "MMX ");
if (edx & (1 << 25)) { if (edx & (1 << 25)) {
_gst_cpu_flags |= GST_CPU_FLAG_SSE; _gst_cpu_flags |= GST_CPU_FLAG_SSE;
_gst_cpu_flags |= GST_CPU_FLAG_MMXEXT; _gst_cpu_flags |= GST_CPU_FLAG_MMXEXT;
featurelist = stringcat (featurelist, "SSE "); g_string_append (featurelist, "SSE ");
} }
gst_cpuid (0x80000000, &eax, &ebx, &ecx, &edx); gst_cpuid_i386 (0x80000000, &eax, &ebx, &ecx, &edx);
if (eax >= 0x80000001) { if (eax >= 0x80000001) {
gst_cpuid (0x80000001, &eax, &ebx, &ecx, &edx); gst_cpuid_i386 (0x80000001, &eax, &ebx, &ecx, &edx);
if (edx & (1 << 31)) { if (edx & (1 << 31)) {
_gst_cpu_flags |= GST_CPU_FLAG_3DNOW; _gst_cpu_flags |= GST_CPU_FLAG_3DNOW;
featurelist = stringcat (featurelist, "3DNOW "); g_string_append (featurelist, "3DNOW ");
} }
if (AMD && (edx & (1 << 22))) { if (AMD && (edx & (1 << 22))) {
_gst_cpu_flags |= GST_CPU_FLAG_MMXEXT; _gst_cpu_flags |= GST_CPU_FLAG_MMXEXT;
featurelist = stringcat (featurelist, "MMXEXT "); g_string_append (featurelist, "MMXEXT ");
} }
} }
} }
*flags = eax;
if (!_gst_cpu_flags) { if (_gst_cpu_flags)
featurelist = stringcat (featurelist, "NONE"); return TRUE;
} return FALSE;
GST_INFO (GST_CAT_GST_INIT, "CPU features: (%08lx) %s", edx, featurelist);
g_free (featurelist);
} }
GstCPUFlags GstCPUFlags

View file

@ -31,7 +31,7 @@ typedef enum {
GST_CPU_FLAG_3DNOW = (1<<3) GST_CPU_FLAG_3DNOW = (1<<3)
} GstCPUFlags; } GstCPUFlags;
void _gst_cpu_initialize (void); void _gst_cpu_initialize (gboolean useopt);
GstCPUFlags gst_cpu_get_flags (void); GstCPUFlags gst_cpu_get_flags (void);

View file

@ -51,7 +51,7 @@ GST_INLINE_FUNC gpointer gst_trash_stack_pop (GstTrashStack *stack);
#if defined (GST_CAN_INLINE) || defined (__GST_TRASH_STACK_C__) #if defined (GST_CAN_INLINE) || defined (__GST_TRASH_STACK_C__)
#if defined (__i386__) && defined (__GNUC__) && __GNUC__ >= 2 #if defined (USE_FAST_STACK_TRASH) && defined (__i386__) && defined (__GNUC__) && __GNUC__ >= 2
#ifdef GST_CONFIG_NO_SMP #ifdef GST_CONFIG_NO_SMP
#define SMP_LOCK "" #define SMP_LOCK ""