• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavcodec/ppc/check_altivec.c

Go to the documentation of this file.
00001 /*
00002  * This file is part of FFmpeg.
00003  *
00004  * FFmpeg is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * FFmpeg is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with FFmpeg; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00017  */
00018 
00019 
00025 #ifdef __APPLE__
00026 #undef _POSIX_C_SOURCE
00027 #include <sys/sysctl.h>
00028 #elif defined(__OpenBSD__)
00029 #include <sys/param.h>
00030 #include <sys/sysctl.h>
00031 #include <machine/cpu.h>
00032 #elif defined(__AMIGAOS4__)
00033 #include <exec/exec.h>
00034 #include <interfaces/exec.h>
00035 #include <proto/exec.h>
00036 #endif /* __APPLE__ */
00037 
00043 int has_altivec(void)
00044 {
00045 #ifdef __AMIGAOS4__
00046     ULONG result = 0;
00047     extern struct ExecIFace *IExec;
00048 
00049     IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE);
00050     if (result == VECTORTYPE_ALTIVEC) return 1;
00051     return 0;
00052 #elif defined(__APPLE__) || defined(__OpenBSD__)
00053 #ifdef __OpenBSD__
00054     int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC};
00055 #else
00056     int sels[2] = {CTL_HW, HW_VECTORUNIT};
00057 #endif
00058     int has_vu = 0;
00059     size_t len = sizeof(has_vu);
00060     int err;
00061 
00062     err = sysctl(sels, 2, &has_vu, &len, NULL, 0);
00063 
00064     if (err == 0) return has_vu != 0;
00065     return 0;
00066 #elif CONFIG_RUNTIME_CPUDETECT
00067     int proc_ver;
00068     // Support of mfspr PVR emulation added in Linux 2.6.17.
00069     __asm__ volatile("mfspr %0, 287" : "=r" (proc_ver));
00070     proc_ver >>= 16;
00071     if (proc_ver  & 0x8000 ||
00072         proc_ver == 0x000c ||
00073         proc_ver == 0x0039 || proc_ver == 0x003c ||
00074         proc_ver == 0x0044 || proc_ver == 0x0045 ||
00075         proc_ver == 0x0070)
00076         return 1;
00077     return 0;
00078 #else
00079     // Since we were compiled for AltiVec, just assume we have it
00080     // until someone comes up with a proper way (not involving signal hacks).
00081     return 1;
00082 #endif /* __AMIGAOS4__ */
00083 }
00084 

Generated on Tue Nov 4 2014 12:59:22 for ffmpeg by  doxygen 1.7.1