[x264-devel] [PATCH] OpenBSD support... again.
Brad
brad at comstyle.com
Sun Sep 21 04:34:18 CEST 2008
On Sat, Sep 20, 2008 at 07:00:06PM +0200, Dominik 'Rathann' Mierzejewski wrote:
> I see code duplication.
Technically there could be a perception of some level
of code duplication, but that is not always bad. Some
small amounts of code duplication IMO is better than
having ugly code with lots of #ifdef's all over the
place.
Take your pick... the previous diff or this one. If
it was my code I'd take the former.
$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 Sat Sep 20 15:18:21 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,13 +186,20 @@ 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;
+#ifdef SYS_OPENBSD
+ int selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC };
+#else
int selectors[2] = { CTL_HW, HW_VECTORUNIT };
+#endif
int has_altivec = 0;
size_t length = sizeof( has_altivec );
int error = sysctl( selectors, 2, &has_altivec, &length, NULL, 0 );
@@ -282,10 +293,17 @@ int x264_cpu_num_processors( void )
get_system_info( &info );
return info.cpu_count;
-#elif defined(SYS_MACOSX) || defined(SYS_FREEBSD)
+#elif defined(SYS_MACOSX) || defined(SYS_FREEBSD) || defined(SYS_OPENBSD)
int numberOfCPUs;
+#ifdef SYS_OPENBSD
+ int mib[2] = { CTL_HW, HW_NCPU };
+#endif
size_t length = sizeof( numberOfCPUs );
+#ifdef SYS_OPENBSD
+ if( sysctl(mib, 2, &numberOfCPUs, &length, NULL, 0) )
+#else
if( sysctlbyname("hw.ncpu", &numberOfCPUs, &length, NULL, 0) )
+#endif
{
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)
>
> This is ugly. You should just test for isfinite presence and use
> #ifndef HAVE_ISFINITE
> #define isfinite finite
> #endif
> instead.
Ya, there are a lot of little ugly bits of code in x264 as
it is already.
> > 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.
>
> Exactly. I'm sure a patch that does that would be welcome.
If someone else wants to do it go ahead.
> [...]
> > 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
>
> What was the *exact* error message?
The library has unresolved symbols when linking it into any
binary.
libx264.a(mc-c.o)(.rodata+0x960): undefined reference to `x264_pixel_avg2_w16_cache64_mmxext'
libx264.a(mc-c.o)(.rodata+0x968): undefined reference to `x264_pixel_avg2_w20_cache64_mmxext'
--
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