Bryan Levin reported a problem of the FreeBSD flac port dumping
core on FreeBSD 4.x:
http://sourceforge.net/tracker/index.php?func=detail&aid=1099004&group_id=13478&atid=113478
It turns out that the port enabled SSE support, but FreeBSD 4.x
does not support SSE by default. (FreeBSD 5.x and later do.) I
have added a small patch to the port to check at runtime whether
the system handles SSE.
(The semantics of hw.instruction_sse are that a value of 1 means
that the kernel includes SSE handling *and* the CPU supports SSE.
A value of 0 means that the kernel will not handle SSE so it can't
be used, although the system CPU may or may not support it.)
--- src/libFLAC/cpu.c.orig
+++ src/libFLAC/cpu.c
@@ -25,6 +25,11 @@
#include <config.h>
#endif
+#ifdef __FreeBSD__
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
+
const unsigned FLAC__CPUINFO_IA32_CPUID_CMOV = 0x00008000;
const unsigned FLAC__CPUINFO_IA32_CPUID_MMX = 0x00800000;
const unsigned FLAC__CPUINFO_IA32_CPUID_FXSR = 0x01000000;
@@ -52,6 +57,15 @@
#ifndef FLAC__SSE_OS
info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 =
false;
+#else
+#if defined(__FreeBSD__)
+ {
+ int sse;
+ size_t len = sizeof(sse);
+ if (sysctlbyname("hw.instruction_sse", &sse, &len, NULL,
0) || !sse)
+ info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2
= false;
+ }
+#endif
#endif
#ifdef FLAC__USE_3DNOW
--
Christian "naddy" Weisgerber
naddy@mips.inka.de