[x264-devel] [PATCH] OpenBSD support
Brad
brad at comstyle.com
Tue Sep 2 03:47:28 CEST 2008
Here are a handful of patches to fix x264 on OpenBSD.
Correct pthreads detection.
$OpenBSD: patch-configure,v 1.4 2008/07/22 20:24:04 brad Exp $
--- configure.orig Mon Sep 1 16:45:08 2008
+++ configure Mon Sep 1 21:21:31 2008
@@ -353,6 +353,9 @@ if test "$pthread" = "auto" ; then
CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
fi
;;
+ OPENBSD)
+ cc_check pthread.h -pthread && pthread="yes" && libpthread="-pthread"
+ ;;
*)
cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
;;
Switch from using the signals method of AltiVec detection to using
the machdep.altivec sysctl and add support for detecting the number
of CPUs in the system using the hw.ncpu sysctl.
$OpenBSD: patch-common_cpu_c,v 1.3 2008/08/28 15:23:31 brad Exp $
--- common/cpu.c.orig Sun Jul 13 16:45:06 2008
+++ common/cpu.c Thu Aug 14 20:58:30 2008
@@ -32,6 +32,10 @@
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
+#ifdef SYS_OPENBSD
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
#include "common.h"
#include "cpu.h"
@@ -182,17 +186,28 @@ uint32_t x264_cpu_detect( void )
#elif defined( ARCH_PPC )
-#ifdef SYS_MACOSX
+#if defined(SYS_MACOSX) || defined(SYS_OPENBSD)
#include <sys/sysctl.h>
+#ifdef SYS_OPENBSD
+#include <machine/cpu.h>
+#endif
uint32_t x264_cpu_detect( void )
{
/* Thank you VLC */
uint32_t cpu = 0;
- int selectors[2] = { CTL_HW, HW_VECTORUNIT };
- int has_altivec = 0;
+ int selectors[2];
+ int has_altivec = 0, error;
size_t length = sizeof( has_altivec );
- int error = sysctl( selectors, 2, &has_altivec, &length, NULL, 0 );
+#ifdef SYS_OPENBSD
+ selectors[0] = CTL_MACHDEP;
+ selectors[1] = CPU_ALTIVEC;
+#else
+ selectors[0] = CTL_HW;
+ selectors[1] = HW_VECTORUNIT;
+#endif
+
+ error = sysctl( selectors, 2, &has_altivec, &length, NULL, 0 );
if( error == 0 && has_altivec != 0 )
{
cpu |= X264_CPU_ALTIVEC;
@@ -286,6 +301,19 @@ int x264_cpu_num_processors( void )
int numberOfCPUs;
size_t length = sizeof( numberOfCPUs );
if( sysctlbyname("hw.ncpu", &numberOfCPUs, &length, NULL, 0) )
+ {
+ numberOfCPUs = 1;
+ }
+ return numberOfCPUs;
+
+#elif defined(SYS_OPENBSD)
+ int mib[2], numberOfCPUs;
+ size_t length = sizeof( numberOfCPUs );
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_NCPU;
+
+ if( sysctl(mib, 2, &numberOfCPUs, &length, NULL, 0) )
{
numberOfCPUs = 1;
}
OpenBSD 4.4 now has the C99 macro isfinite().
$OpenBSD: patch-common_osdep_h,v 1.1 2008/08/20 01:44:44 jakemsr Exp $
--- common/osdep.h.orig Mon Sep 1 16:45:08 2008
+++ common/osdep.h Mon Sep 1 21:08:50 2008
@@ -51,7 +51,7 @@
#define X264_VERSION "" // no configure script for msvc
#endif
-#if defined(SYS_OPENBSD) || defined(SYS_SunOS)
+#if defined(SYS_OPENBSD) && !defined(isfinite) || defined(SYS_SunOS)
#define isfinite finite
#endif
#if defined(_MSC_VER) || defined(SYS_SunOS) || defined(SYS_MACOSX)
Fix compilation on OpenBSD PowerPC architectures when using
AltiVec.
FYI, I really think a test should be added to the configure script
to look for altivec.h and define a symbol name like HAVE_ALTIVEC_H
instead of maintaining a list of OS's.
$OpenBSD: patch-common_ppc_dct_c,v 1.2 2008/07/22 20:24:04 brad Exp $
--- common/ppc/dct.c.orig Fri Jul 4 16:45:05 2008
+++ common/ppc/dct.c Tue Jul 8 23:59:12 2008
@@ -21,7 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*****************************************************************************/
-#ifdef SYS_LINUX
+#if defined SYS_LINUX || defined SYS_OPENBSD
#include <altivec.h>
#endif
$OpenBSD: patch-common_ppc_deblock_c,v 1.1 2008/08/20 01:44:44 jakemsr Exp $
--- common/ppc/deblock.c.orig Tue Aug 19 16:00:18 2008
+++ common/ppc/deblock.c Tue Aug 19 16:00:45 2008
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*****************************************************************************/
-#if defined SYS_LINUX
+#if defined SYS_LINUX || defined SYS_OPENBSD
#include <altivec.h>
#endif
$OpenBSD: patch-common_ppc_mc_c,v 1.1.1.1 2007/04/08 17:31:01 ajacoutot Exp $
--- common/ppc/mc.c.orig Mon Sep 1 16:45:08 2008
+++ common/ppc/mc.c Mon Sep 1 21:15:35 2008
@@ -27,7 +27,7 @@
#include <stdint.h>
#include <stdarg.h>
-#ifdef SYS_LINUX
+#if defined SYS_LINUX || defined SYS_OPENBSD
#include <altivec.h>
#endif
$OpenBSD: patch-common_ppc_pixel_c,v 1.2 2008/07/22 20:24:04 brad Exp $
--- common/ppc/pixel.c.orig Fri Jul 4 16:45:05 2008
+++ common/ppc/pixel.c Tue Jul 8 23:59:12 2008
@@ -21,7 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*****************************************************************************/
-#ifdef SYS_LINUX
+#if defined SYS_LINUX || defined SYS_OPENBSD
#include <altivec.h>
#endif
$OpenBSD: patch-common_ppc_predict_c,v 1.1 2008/08/20 01:44:44 jakemsr Exp $
--- common/ppc/predict.c.orig Tue Aug 19 16:02:22 2008
+++ common/ppc/predict.c Tue Aug 19 17:13:49 2008
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*****************************************************************************/
-#ifdef SYS_LINUX
+#if defined SYS_LINUX || defined SYS_OPENBSD
#include <altivec.h>
#endif
$OpenBSD: patch-common_ppc_quant_c,v 1.2 2008/07/22 20:24:04 brad Exp $
--- common/ppc/quant.c.orig Fri Jul 4 16:45:05 2008
+++ common/ppc/quant.c Tue Jul 8 23:59:12 2008
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*****************************************************************************/
-#if defined SYS_LINUX
+#if defined SYS_LINUX || defined SYS_OPENBSD
#include <altivec.h>
#endif
This fixed an issue found on amd64 where there were unresolved
symbols.
$OpenBSD: patch-common_x86_mc-a_asm,v 1.1 2008/07/22 20:24:04 brad Exp $
--- common/x86/mc-a.asm.orig Mon Sep 1 16:45:08 2008
+++ common/x86/mc-a.asm Mon Sep 1 21:07:49 2008
@@ -365,12 +365,12 @@ AVG_CACHELINE_CHECK 8, 32, mmxext
AVG_CACHELINE_CHECK 12, 32, mmxext
AVG_CACHELINE_CHECK 16, 32, mmxext
AVG_CACHELINE_CHECK 20, 32, mmxext
-AVG_CACHELINE_CHECK 16, 64, mmxext
-AVG_CACHELINE_CHECK 20, 64, mmxext
%endif
AVG_CACHELINE_CHECK 8, 64, mmxext
AVG_CACHELINE_CHECK 12, 64, mmxext
+AVG_CACHELINE_CHECK 16, 64, mmxext
+AVG_CACHELINE_CHECK 20, 64, mmxext
AVG_CACHELINE_CHECK 16, 64, sse2
AVG_CACHELINE_CHECK 20, 64, sse2
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the x264-devel
mailing list