--- xvid.c 2008/12/01 15:06:48 1.80 +++ xvid.c 2009/06/05 07:58:41 1.82 @@ -19,7 +19,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: xvid.c,v 1.80 2008/12/01 15:06:48 Isibaar Exp $ + * $Id: xvid.c,v 1.82 2009/06/05 07:58:41 Isibaar Exp $ * ****************************************************************************/ @@ -32,6 +32,22 @@ #include #endif +#if defined(__APPLE__) && defined(__MACH__) && !defined(_SC_NPROCESSORS_CONF) +#include +#include +#ifdef MAX +#undef MAX +#endif +#ifdef MIN +#undef MIN +#endif +#endif + +#if defined(__amigaos4__) +#include +#include +#endif + #include "xvid.h" #include "decoder.h" #include "encoder.h" @@ -58,7 +74,7 @@ #if (defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)) && defined(_MSC_VER) # include -#elif defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) || defined(ARCH_IS_PPC) +#elif defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) || (defined(ARCH_IS_PPC) && !defined(__amigaos4__)) # include # include @@ -71,7 +87,6 @@ } #endif - /* * Calls the funcptr, and returns whether SIGILL (illegal instruction) was * signalled @@ -94,7 +109,7 @@ } return(0); } -#elif defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) || defined(ARCH_IS_PPC) +#elif defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64) || (defined(ARCH_IS_PPC) && !defined(__amigaos4__)) static int sigill_check(void (*func)()) { @@ -146,9 +161,19 @@ #endif #if defined(ARCH_IS_PPC) +#if defined(__amigaos4__) + { + uint32_t vector_unit = VECTORTYPE_NONE; + IExec->GetCPUInfoTags(GCIT_VectorUnit, &vector_unit, TAG_END); + if (vector_unit == VECTORTYPE_ALTIVEC) { + cpu_flags |= XVID_CPU_ALTIVEC; + } + } +#else if (!sigill_check(altivec_trigger)) cpu_flags |= XVID_CPU_ALTIVEC; #endif +#endif return cpu_flags; } @@ -667,7 +692,7 @@ info->actual_version = XVID_VERSION; info->build = "xvid-1.3.0-dev"; info->cpu_flags = detect_cpu_flags(); - info->num_threads = 0; + info->num_threads = 0; /* single-thread */ #if defined(_WIN32) @@ -677,10 +702,33 @@ info->num_threads = siSysInfo.dwNumberOfProcessors; /* number of _logical_ cores */ } -#else +#elif defined(_SC_NPROCESSORS_CONF) /* should be available on Apple too actually */ info->num_threads = sysconf(_SC_NPROCESSORS_CONF); +#elif defined(__APPLE__) && defined(__MACH__) + + { + size_t len; + int mib[2], ncpu; + + mib[0] = CTL_HW; + mib[1] = HW_NCPU; + len = sizeof(ncpu); + if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == 0) + info -> num_threads = ncpu; + else + info -> num_threads = 1; + } + +#elif defined(__amigaos4__) + + { + uint32_t num_threads = 1; + IExec->GetCPUInfoTags(GCIT_NumberOfCPUs, &num_threads, TAG_END); + info->num_threads = num_threads; + } + #endif return 0;